X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/d6f6602d7cea3a7899990fe79216af7d98d05917..06578d6778bff8aa2bd6a2387651dd0ba55aa27c:/lib/gdi/region.cpp diff --git a/lib/gdi/region.cpp b/lib/gdi/region.cpp index f341e79a..d75221fe 100644 --- a/lib/gdi/region.cpp +++ b/lib/gdi/region.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #undef max #define max(a,b) ((a) > (b) ? (a) : (b)) @@ -25,10 +26,11 @@ gRegion::gRegion(const eRect &rect) : extends(rect) { - rects.push_back(rect); + if (rect.valid() && !rect.empty()) + rects.push_back(rect); } -gRegion::gRegion() +gRegion::gRegion() : extends(eRect::emptyRect()) { } @@ -87,7 +89,7 @@ void gRegion::appendNonO(std::vector::const_iterator r, rects.reserve(rects.size() + newRects); do { assert(r->x1 < r->x2); - rects.push_back(eRect(r->x1, y1, r->x2, y2)); + rects.push_back(eRect(r->x1, y1, r->x2 - r->x1, y2 - y1)); r++; } while (r != rEnd); } @@ -110,7 +112,7 @@ void gRegion::intersectO( x2 = min(r1->x2, r2->x2); if (x1 < x2) - rects.push_back(eRect(x1, y1, x2, y2)); + rects.push_back(eRect(x1, y1, x2 - x1, y2 - y1)); if (r1->x2 == x2) r1++; if (r2->x2 == x2) @@ -145,7 +147,7 @@ void gRegion::subtractO( ++r2; } else if (r2->x1 < r1->x2) { assert(x1x1); - rects.push_back(eRect(x1, y1, r2->x1, y2)); + rects.push_back(eRect(x1, y1, r2->x1 - x1, y2 - y1)); x1 = r2->x2; if (x1 >= r1->x2) { ++r1; @@ -156,7 +158,7 @@ void gRegion::subtractO( } else { if (r1->x2 > x1) - rects.push_back(eRect(x1, y1, r1->x2, y2)); + rects.push_back(eRect(x1, y1, r1->x2 - x1, y2 - y1)); ++r1; if (r1 != r1End) x1 = r1->x1; @@ -165,7 +167,7 @@ void gRegion::subtractO( while (r1 != r1End) { assert(x1x2); - rects.push_back(eRect(x1, y1, r1->x2, y2)); + rects.push_back(eRect(x1, y1, r1->x2 - x1, y2 - y1)); ++r1; if (r1 != r1End) x1 = r1->x1; @@ -180,7 +182,7 @@ void gRegion::subtractO( if (x2 < r->x2) x2 = r->x2; \ } else { \ /* Add current rectangle, start new one */ \ - rects.push_back(eRect(x1, y1, x2, y2)); \ + rects.push_back(eRect(x1, y1, x2 - x1, y2 - y1)); \ x1 = r->x1; \ x2 = r->x2; \ } \ @@ -225,7 +227,7 @@ void gRegion::mergeO( MERGERECT(r2); } while (r2 != r2End); } - rects.push_back(eRect(x1, y1, x2, y2)); + rects.push_back(eRect(x1, y1, x2 - x1, y2 - y1)); } void gRegion::regionOp(const gRegion ®1, const gRegion ®2, int opcode, int &overlap) @@ -264,8 +266,8 @@ void gRegion::regionOp(const gRegion ®1, const gRegion ®2, int opcode, int bot = min(r1->y2, r2y1); if (top != bot) { curBand = rects.size(); - appendNonO(r1, r1BandEnd, top, bot); - coalesce(prevBand, curBand); + appendNonO(r1, r1BandEnd, top, bot); + coalesce(prevBand, curBand); } } ytop = r2y1; @@ -318,10 +320,28 @@ void gRegion::regionOp(const gRegion ®1, const gRegion ®2, int opcode, int coalesce(prevBand, curBand); AppendRegions(r2BandEnd, r2End); } + + extends = eRect(); + + for (unsigned int a = 0; a