aboutsummaryrefslogtreecommitdiff
path: root/src/platform/graphics/cairo/CairoGeometry.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/platform/graphics/cairo/CairoGeometry.cpp')
-rw-r--r--src/platform/graphics/cairo/CairoGeometry.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/platform/graphics/cairo/CairoGeometry.cpp b/src/platform/graphics/cairo/CairoGeometry.cpp
new file mode 100644
index 00000000..7abe273c
--- /dev/null
+++ b/src/platform/graphics/cairo/CairoGeometry.cpp
@@ -0,0 +1,48 @@
+#include "cru/platform/graphics/cairo/CairoGeometry.h"
+#include "cru/platform/graphics/cairo/CairoGraphicsFactory.h"
+
+namespace cru::platform::graphics::cairo {
+CairoGeometry::CairoGeometry(CairoGraphicsFactory* factory,
+ cairo_path_t* cairo_path, bool auto_destroy)
+ : CairoResource(factory),
+ cairo_path_(cairo_path),
+ auto_destroy_(auto_destroy) {
+ Expects(cairo_path);
+}
+
+CairoGeometry::~CairoGeometry() {
+ if (auto_destroy_) {
+ cairo_path_destroy(cairo_path_);
+ cairo_path_ = nullptr;
+ }
+}
+
+bool CairoGeometry::FillContains(const Point& point) {
+ auto cairo = GetCairoGraphicsFactory()->GetDefaultCairo();
+ cairo_save(cairo);
+ cairo_new_path(cairo);
+ cairo_append_path(cairo, cairo_path_);
+ auto result = cairo_in_fill(cairo, point.x, point.y);
+ cairo_restore(cairo);
+ return result;
+}
+
+Rect CairoGeometry::GetBounds() {
+ auto cairo = GetCairoGraphicsFactory()->GetDefaultCairo();
+ cairo_save(cairo);
+ cairo_new_path(cairo);
+ cairo_append_path(cairo, cairo_path_);
+ double l, t, r, b;
+ cairo_path_extents(cairo, &l, &t, &r, &b);
+ cairo_restore(cairo);
+ return Rect::FromVertices(l, t, r, b);
+}
+
+std::unique_ptr<IGeometry> CairoGeometry::Transform(const Matrix& matrix) {
+ throw Exception(u"Not implemented");
+}
+
+std::unique_ptr<IGeometry> CairoGeometry::CreateStrokeGeometry(float width) {
+ throw Exception(u"Not implemented");
+}
+} // namespace cru::platform::graphics::cairo