More stuff, should be almost feature complete (but bugged as hell, probably), I should start real testing tomorrow, hopefully

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15350 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2005-12-05 20:12:18 +00:00
parent 9743fe8729
commit 9bd3f620bc
2 changed files with 60 additions and 38 deletions

View File

@ -7,7 +7,9 @@
#include <Debug.h> #include <Debug.h>
const static int32 kMaxPoints = 1024; using namespace std;
const static int32 kMaxPoints = 512;
const static int32 kMaxVerticalExtent = 0x10000000; const static int32 kMaxVerticalExtent = 0x10000000;
const static int32 kMaxPositive = 0x7ffffffd; const static int32 kMaxPositive = 0x7ffffffd;
const static int32 kMaxNegative = 0x80000003; const static int32 kMaxNegative = 0x80000003;
@ -308,7 +310,21 @@ ClipRegion::WriteToLink(BPrivate::ServerLink &link)
} }
#endif #endif
// private methods // private methods
static int
leftComparator(const void *a, const void *b)
{
return ((clipping_rect *)(a))->left > ((clipping_rect *)(b))->left;
}
static int
topComparator(const void *a, const void *b)
{
return ((clipping_rect *)(a))->top > ((clipping_rect *)(b))->top;
}
void void
ClipRegion::_IntersectWithComplex(const ClipRegion &region) ClipRegion::_IntersectWithComplex(const ClipRegion &region)
{ {
@ -323,8 +339,8 @@ ClipRegion::_IntersectWithComplex(const ClipRegion &region)
} }
if (dest.fCount > 1) if (dest.fCount > 1)
dest._SortRects(); qsort(dest.fData, sizeof(clipping_rect), dest.fCount, topComparator);
_Adopt(dest); _Adopt(dest);
} }
@ -386,6 +402,7 @@ ClipRegion::_IncludeNoIntersection(const ClipRegion &region)
} }
void void
ClipRegion::_IncludeComplex(const ClipRegion &region) ClipRegion::_IncludeComplex(const ClipRegion &region)
{ {
@ -407,8 +424,8 @@ ClipRegion::_IncludeComplex(const ClipRegion &region)
+ region._ExtractStripRects(top, bottom, &rects[rectsCount], &b); + region._ExtractStripRects(top, bottom, &rects[rectsCount], &b);
if (rectsCount > 0) { if (rectsCount > 0) {
//if (rectsCount > 1) if (rectsCount > 1)
// SortTrans(lefts, rights, foundCount); qsort(rects, sizeof(clipping_rect), rectsCount, leftComparator);
dest._MergeAndInclude(rects, rectsCount); dest._MergeAndInclude(rects, rectsCount);
} }
} }
@ -422,39 +439,41 @@ ClipRegion::_IncludeComplex(const ClipRegion &region)
void void
ClipRegion::_ExcludeComplex(const ClipRegion &region) ClipRegion::_ExcludeComplex(const ClipRegion &region)
{ {
} /*
int32 bottom = min_c(fBound.top, region.fBound.top) - 1;
int32 a = 0, b = 0;
// Helper method to swap two rects ClipRegion dest;
static inline void while (true) {
SwapRects(clipping_rect &rect, clipping_rect &anotherRect) int32 top = bottom + 1;
{ bottom = region._FindSmallestBottom(_FindSmallestBottom(top, a), b);
clipping_rect tmpRect = rect;
rect = anotherRect; if (bottom == kMaxVerticalExtent)
anotherRect = tmpRect; break;
}
clipping_rect rectsA[kMaxPoints];
rectsA[0].top = top;
void rectsA[0].bottom = bottom;
ClipRegion::_SortRects()
{ clipping_rect rectsB[kMaxPoints];
bool again; rectsB[0].top = top;
rectsB[0].bottom = bottom;
if (fCount == 2) {
if (fData[0].top > fData[1].top) int32 foundA = _ExtractStripRects(top, bottom, rectsA, &a);
SwapRects(fData[0], fData[1]); int32 foundB = region._ExtractStripRects(top, bottom, rectsB, &b);
if (foundA > 1)
qsort(rectsA, sizeof(clipping_rect), foundA, leftComparator);
if (foundB > 1)
qsort(rectsB, sizeof(clipping_rect), foundB, leftComparator);
// TODO: Do the actual exclusion
} else if (fCount > 2) {
do {
again = false;
for (int32 c = 1; c < fCount; c++) {
if (fData[c - 1].top > fData[c].top) {
SwapRects(fData[c - 1], fData[c]);
again = true;
}
}
} while (again);
} }
dest._Coalesce();
_Adopt(dest);
*/
} }
@ -562,6 +581,9 @@ ClipRegion::_ExtractStripRects(const int32 &top, const int32 &bottom, clipping_r
break; break;
} }
if (*inOutIndex == -1)
*inOutIndex = currentIndex;
return foundCount; return foundCount;
} }

View File

@ -7,6 +7,7 @@ namespace BPrivate {
class ServerLink; class ServerLink;
}; };
class ClipRegion { class ClipRegion {
public: public:
ClipRegion(); ClipRegion();
@ -68,7 +69,6 @@ private:
void _IncludeComplex(const ClipRegion &region); void _IncludeComplex(const ClipRegion &region);
void _ExcludeComplex(const ClipRegion &region); void _ExcludeComplex(const ClipRegion &region);
void _SortRects();
void _AddRect(const clipping_rect &rect); void _AddRect(const clipping_rect &rect);
void _RecalculateBounds(const clipping_rect &newRect); void _RecalculateBounds(const clipping_rect &newRect);