summaryrefslogtreecommitdiff
path: root/src/drivers/Android/Fl_Android_Graphics_Driver.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2018-03-15 21:17:16 +0000
committerMatthias Melcher <fltk@matthiasm.com>2018-03-15 21:17:16 +0000
commit6a145ed63aa48944b8dced0d5a6fbcaffda507e7 (patch)
tree1f0fd0c2b40f7441d4f8f38f53e7cf8abf5524f5 /src/drivers/Android/Fl_Android_Graphics_Driver.cxx
parent726cb77717e00de9cd6d9accad0a69f4ae7a6859 (diff)
Android: window clipping working fl_rectf.
This code is not very beautiful, but the resulting class should be easy to use. A range-based loop can be used to find all relevant clipping rectangles for a drawing call. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12754 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers/Android/Fl_Android_Graphics_Driver.cxx')
-rw-r--r--src/drivers/Android/Fl_Android_Graphics_Driver.cxx73
1 files changed, 38 insertions, 35 deletions
diff --git a/src/drivers/Android/Fl_Android_Graphics_Driver.cxx b/src/drivers/Android/Fl_Android_Graphics_Driver.cxx
index 554d72e84..aa2bcd937 100644
--- a/src/drivers/Android/Fl_Android_Graphics_Driver.cxx
+++ b/src/drivers/Android/Fl_Android_Graphics_Driver.cxx
@@ -97,15 +97,46 @@ static uint16_t make565(Fl_Color crgba)
void Fl_Android_Graphics_Driver::rectf_unscaled(float x, float y, float w, float h)
{
- // FIXME: r must be a complex region, like pClippingRegion.
+#if 1
Fl_Rect_Region r(x, y, w, h);
-#if 0
- if (r.intersect_with(pClippingRegion)) {
- rectf_unclipped(r.x(), r.y(), r.w(), r.h());
+ for (const auto &it: pClippingRegion.overlapping(r)) {
+#if 1
+ Fl_Rect_Region s(it->clipped_rect());
+ rectf_unclipped(s.x(), s.y(), s.w(), s.h());
+#else
+ if (it->is_simple()) {
+ Fl_Rect_Region r(x, y, w, h);
+ if (r.intersect_with(*it)) {
+ rectf_unclipped(r.x(), r.y(), r.w(), r.h());
+ }
+ }
+#endif
+ }
+
+#elif 0
+
+ // This is elegant code, but it is not efficient. It walks the entire tree
+ // and checks for intersetion, even if the parent region indicated that there
+ // is no intersection.
+ //
+ // Maybe we can add a parameter somewhere so that the iterator runs the tree
+ // based on a give rectangle.
+
+ for (const auto &it: pClippingRegion) {
+ // TODO: if region is complex, but doesn't intersect, can we somehow manipulate the iterator?
+ if (it->is_simple()) {
+ Fl_Rect_Region r(x, y, w, h);
+ if (r.intersect_with(*it)) {
+ rectf_unclipped(r.x(), r.y(), r.w(), r.h());
+ }
+ }
}
-#else // proof of concept
- // FIXME: write iterator over tree
+
+#else
+
+ // This code is massiv and ugly and has the same problem in that it does not
+ // optimize the number of tests for intersections.
r.print("---- fl_rectf");
pClippingRegion.print("clip to");
@@ -134,36 +165,8 @@ void Fl_Android_Graphics_Driver::rectf_unscaled(float x, float y, float w, float
}
}
}
-#endif
-
-
-
-
- // TODO: create a complex region by intersecting r with the pClippingRegion
- // TODO: walk the region and draw all rectangles
-
- /*
- * rectf(x, y, w, h) {
- * rectf(complex_window_region, drawing_rect(x, y, w, h))
- * }
- *
- * rectf( complexRgn, drawRgn) {
- * // B: start of iterator
- * if (intersect(rect_of_complexRgn, drawRgn) {
- * if (complexRgn->is_complex() {
- * rectf(complexRgn->subregion, drawRect);
- * } else {
- * rawRect = intersection(rect_of_complexRgn, drawRgn);
- * rawDrawRect(rawRect);
- * }
- * }
- * // A: recursion
- * if (complexRgn->next)
- * rectf(complexRgn->next, drawRgn);
- * // B: end of iterator
- * }
- */
+#endif
}
void Fl_Android_Graphics_Driver::rectf_unclipped(float x, float y, float w, float h)