diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2018-03-17 21:54:09 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2018-03-17 21:54:09 +0000 |
| commit | 7ff40388cbf2b4f1441efbc3b30f35017cab9304 (patch) | |
| tree | 1cc30d47917035785596927ca4bf409e99aacf10 | |
| parent | 0c8ae29b79c0391c9ff6ac806231e2dde890e55a (diff) | |
Android: intersetcing a complex clipping region with a rectangle
However I did disable the complex region optimizer - too tired to get
the pointers right... .
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12770 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | src/drivers/Android/Fl_Android_Graphics_Clipping.cxx | 55 |
1 files changed, 43 insertions, 12 deletions
diff --git a/src/drivers/Android/Fl_Android_Graphics_Clipping.cxx b/src/drivers/Android/Fl_Android_Graphics_Clipping.cxx index 2b7b1120d..5050a5082 100644 --- a/src/drivers/Android/Fl_Android_Graphics_Clipping.cxx +++ b/src/drivers/Android/Fl_Android_Graphics_Clipping.cxx @@ -280,12 +280,30 @@ void Fl_Complex_Region::set(const Fl_Complex_Region &r) */ int Fl_Complex_Region::intersect_with(const Fl_Rect_Region &r) { - set(r); - return LESS; - delete pSubregion; pSubregion = 0; - // FIXME: handle complex regions! - int ret = Fl_Rect_Region::intersect_with(r); - return ret; + if (pSubregion) { + pSubregion->intersect_with(r); + } else { + int intersects = Fl_Rect_Region::intersect_with(r); + switch (intersects) { + case EMPTY: + // Will be deleted by compress() + break; + case SAME: + // nothing to do + break; + case LESS: + // nothing to do + break; + default: + Fl_Android_Application::log_e("Invalid case in %s:%d", __FUNCTION__, __LINE__); + break; + } + if (pNext) { + pNext->intersect_with(r); + } + } + compress(); + return 0; } /** @@ -336,14 +354,26 @@ void Fl_Complex_Region::compress() if (!pSubregion) return; // remove all empty regions, because the really don't add anything (literally) - Fl_Complex_Region *rgn = pSubregion, **rgnPtr = &pSubregion; + Fl_Complex_Region *rgn = pSubregion; +#if 0 + // FIXME: remove emty rectangles and lift single rectangles + // TODO: merging rectangles may take much too much time with little benefit + print("compress"); + while (rgn && rgn->is_empty()) { + pSubregion = rgn->next(); + delete rgn; + rgn = pSubregion; + } + if (!pSubregion) return; + rgn = pSubregion; while (rgn) { - if (rgn->is_empty()) { - *rgnPtr = rgn->pNext; - delete rgn; + Fl_Complex_Region *nextRgn = rgn->next(); + if (nextRgn && nextRgn->is_empty()) { + rgn->pNext = nextRgn->next(); + delete nextRgn; + nextRgn = rgn->pNext; } - rgnPtr = &rgn->pNext; - rgn = *rgnPtr; + rgn = rgn->next(); } if (!pSubregion) return; @@ -354,6 +384,7 @@ void Fl_Complex_Region::compress() set((Fl_Rect_Region&)*pSubregion); // deletes subregion for us } if (!pSubregion) return; +#endif // finally, update the boudning box Fl_Rect_Region::set((Fl_Rect_Region&)*pSubregion); |
