diff options
author | crupest <crupest@outlook.com> | 2021-10-26 16:07:53 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-10-26 16:07:53 +0800 |
commit | 397843cda9e4161d3e92d8797f8012f478ce64f0 (patch) | |
tree | c04b1600fb60e5aca9e19ab21c2a52efedbc2bad /src | |
parent | a4dafa3e2918f2cc28657145e6b0afe7bcf1ca7b (diff) | |
download | cru-397843cda9e4161d3e92d8797f8012f478ce64f0.tar.gz cru-397843cda9e4161d3e92d8797f8012f478ce64f0.tar.bz2 cru-397843cda9e4161d3e92d8797f8012f478ce64f0.zip |
...
Diffstat (limited to 'src')
-rw-r--r-- | src/osx/graphics/quartz/Brush.cpp | 4 | ||||
-rw-r--r-- | src/osx/graphics/quartz/Painter.cpp | 33 |
2 files changed, 30 insertions, 7 deletions
diff --git a/src/osx/graphics/quartz/Brush.cpp b/src/osx/graphics/quartz/Brush.cpp index 41e9d2c5..9daa8e13 100644 --- a/src/osx/graphics/quartz/Brush.cpp +++ b/src/osx/graphics/quartz/Brush.cpp @@ -20,11 +20,7 @@ void QuartzSolidColorBrush::SetColor(const Color& color) { } void QuartzSolidColorBrush::Select(CGContextRef context) { - CGContextSaveGState(context); - CGContextSetStrokeColorWithColor(context, cg_color_); CGContextSetFillColorWithColor(context, cg_color_); - - CGContextRestoreGState(context); } } // namespace cru::platform::graphics::osx::quartz diff --git a/src/osx/graphics/quartz/Painter.cpp b/src/osx/graphics/quartz/Painter.cpp index eee175ac..ec951e6c 100644 --- a/src/osx/graphics/quartz/Painter.cpp +++ b/src/osx/graphics/quartz/Painter.cpp @@ -8,7 +8,6 @@ #include "cru/platform/Check.hpp" #include "cru/platform/Color.hpp" #include "cru/platform/Exception.hpp" -#include "cru/platform/graphics/util/Painter.hpp" namespace cru::platform::graphics::osx::quartz { QuartzCGContextPainter::QuartzCGContextPainter( @@ -75,7 +74,8 @@ void QuartzCGContextPainter::DrawLine(const Point& start, const Point& end, QuartzBrush* b = CheckPlatform<QuartzBrush>(brush, GetPlatformId()); b->Select(cg_context_); - CGContextSetLineWidth(cg_context_, width); + SetLineWidth(width); + CGContextStrokePath(cg_context_); } @@ -97,6 +97,26 @@ void QuartzCGContextPainter::FillRectangle(const Rect& rectangle, CGContextFillRect(cg_context_, Convert(rectangle)); } +void QuartzCGContextPainter::StrokeEllipse(const Rect& outline_rect, + IBrush* brush, float width) { + Validate(); + + QuartzBrush* b = CheckPlatform<QuartzBrush>(brush, GetPlatformId()); + b->Select(cg_context_); + SetLineWidth(width); + + CGContextStrokeEllipseInRect(cg_context_, Convert(outline_rect)); +} + +void QuartzCGContextPainter::FillEllipse(const Rect& outline_rect, + IBrush* brush, float width) { + Validate(); + + QuartzBrush* b = CheckPlatform<QuartzBrush>(brush, GetPlatformId()); + b->Select(cg_context_); + CGContextFillEllipseInRect(cg_context_, Convert(outline_rect)); +} + void QuartzCGContextPainter::StrokeGeometry(IGeometry* geometry, IBrush* brush, float width) { Validate(); @@ -105,7 +125,8 @@ void QuartzCGContextPainter::StrokeGeometry(IGeometry* geometry, IBrush* brush, QuartzBrush* b = CheckPlatform<QuartzBrush>(brush, GetPlatformId()); b->Select(cg_context_); - CGContextSetLineWidth(cg_context_, width); + SetLineWidth(width); + CGContextBeginPath(cg_context_); CGContextAddPath(cg_context_, g->GetCGPath()); CGContextStrokePath(cg_context_); @@ -189,6 +210,12 @@ void QuartzCGContextPainter::PopState() { void QuartzCGContextPainter::EndDraw() { DoEndDraw(); } +void QuartzCGContextPainter::SetLineWidth(float width) { + if (cg_context_) { + CGContextSetLineWidth(cg_context_, width); + } +} + void QuartzCGContextPainter::DoEndDraw() { if (cg_context_) { CGContextFlush(cg_context_); |