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
This commit is contained in:
Matthias Melcher
2018-03-17 21:54:09 +00:00
parent 0c8ae29b79
commit 7ff40388cb
@@ -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) int Fl_Complex_Region::intersect_with(const Fl_Rect_Region &r)
{ {
set(r); if (pSubregion) {
return LESS; pSubregion->intersect_with(r);
delete pSubregion; pSubregion = 0; } else {
// FIXME: handle complex regions! int intersects = Fl_Rect_Region::intersect_with(r);
int ret = Fl_Rect_Region::intersect_with(r); switch (intersects) {
return ret; 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; if (!pSubregion) return;
// remove all empty regions, because the really don't add anything (literally) // remove all empty regions, because the really don't add anything (literally)
Fl_Complex_Region *rgn = pSubregion, **rgnPtr = &pSubregion; Fl_Complex_Region *rgn = pSubregion;
while (rgn) { #if 0
if (rgn->is_empty()) { // FIXME: remove emty rectangles and lift single rectangles
*rgnPtr = rgn->pNext; // TODO: merging rectangles may take much too much time with little benefit
print("compress");
while (rgn && rgn->is_empty()) {
pSubregion = rgn->next();
delete rgn; delete rgn;
rgn = pSubregion;
} }
rgnPtr = &rgn->pNext; if (!pSubregion) return;
rgn = *rgnPtr; rgn = pSubregion;
while (rgn) {
Fl_Complex_Region *nextRgn = rgn->next();
if (nextRgn && nextRgn->is_empty()) {
rgn->pNext = nextRgn->next();
delete nextRgn;
nextRgn = rgn->pNext;
}
rgn = rgn->next();
} }
if (!pSubregion) return; if (!pSubregion) return;
@@ -354,6 +384,7 @@ void Fl_Complex_Region::compress()
set((Fl_Rect_Region&)*pSubregion); // deletes subregion for us set((Fl_Rect_Region&)*pSubregion); // deletes subregion for us
} }
if (!pSubregion) return; if (!pSubregion) return;
#endif
// finally, update the boudning box // finally, update the boudning box
Fl_Rect_Region::set((Fl_Rect_Region&)*pSubregion); Fl_Rect_Region::set((Fl_Rect_Region&)*pSubregion);