aboutsummaryrefslogtreecommitdiff
path: root/src/osx/graphics/quartz
diff options
context:
space:
mode:
Diffstat (limited to 'src/osx/graphics/quartz')
-rw-r--r--src/osx/graphics/quartz/CMakeLists.txt2
-rw-r--r--src/osx/graphics/quartz/Convert.cpp11
-rw-r--r--src/osx/graphics/quartz/Painter.cpp15
-rw-r--r--src/osx/graphics/quartz/Resource.cpp1
4 files changed, 29 insertions, 0 deletions
diff --git a/src/osx/graphics/quartz/CMakeLists.txt b/src/osx/graphics/quartz/CMakeLists.txt
index 41577ad7..2d66c3e7 100644
--- a/src/osx/graphics/quartz/CMakeLists.txt
+++ b/src/osx/graphics/quartz/CMakeLists.txt
@@ -1,11 +1,13 @@
set(CRU_OSX_GRAPHICS_NATIVE_INCLUDE_DIR ${CRU_INCLUDE_DIR}/cru/osx/graphics/quartz)
add_library(cru_osx_graphics_quartz SHARED
+ Convert.cpp
Factory.cpp
Painter.cpp
Resource.cpp
)
target_sources(cru_osx_graphics_quartz PUBLIC
+ ${CRU_OSX_GRAPHICS_NATIVE_INCLUDE_DIR}/Convert.hpp
${CRU_OSX_GRAPHICS_NATIVE_INCLUDE_DIR}/Factory.hpp
${CRU_OSX_GRAPHICS_NATIVE_INCLUDE_DIR}/Painter.hpp
${CRU_OSX_GRAPHICS_NATIVE_INCLUDE_DIR}/Resource.hpp
diff --git a/src/osx/graphics/quartz/Convert.cpp b/src/osx/graphics/quartz/Convert.cpp
new file mode 100644
index 00000000..95923083
--- /dev/null
+++ b/src/osx/graphics/quartz/Convert.cpp
@@ -0,0 +1,11 @@
+#include "cru/osx/graphics/quartz/Convert.hpp"
+
+namespace cru::platform::graphics::osx::quartz {
+CGAffineTransform Convert(const Matrix& matrix) {
+ return CGAffineTransformMake(matrix.m11, matrix.m12, matrix.m21, matrix.m22, matrix.m31, matrix.m32);
+}
+
+Matrix Convert(const CGAffineTransform& matrix) {
+ return Matrix(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty);
+}
+} // namespace cru::platform::graphics::osx::quartz
diff --git a/src/osx/graphics/quartz/Painter.cpp b/src/osx/graphics/quartz/Painter.cpp
index b3006a97..65cf9154 100644
--- a/src/osx/graphics/quartz/Painter.cpp
+++ b/src/osx/graphics/quartz/Painter.cpp
@@ -1 +1,16 @@
#include "cru/osx/graphics/quartz/Painter.hpp"
+
+#include "cru/osx/graphics/quartz/Convert.hpp"
+
+namespace cru::platform::graphics::osx::quartz {
+ Matrix QuartzCGContextPainter::GetTransform() {
+ return Convert(CGContextGetCTM(cg_context_));
+ }
+
+ void QuartzCGContextPainter::SetTransform(const Matrix& matrix) {
+ auto old = CGContextGetCTM(cg_context_);
+ old = CGAffineTransformInvert(old);
+ CGContextConcatCTM(cg_context_, old);
+ CGContextConcatCTM(cg_context_, Convert(matrix));
+ }
+}
diff --git a/src/osx/graphics/quartz/Resource.cpp b/src/osx/graphics/quartz/Resource.cpp
index e69de29b..3ee09cdd 100644
--- a/src/osx/graphics/quartz/Resource.cpp
+++ b/src/osx/graphics/quartz/Resource.cpp
@@ -0,0 +1 @@
+#include "cru/osx/graphics/quartz/Resource.hpp"