Fixed warnings, some cleanups
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7129 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Copyright (c) 2003, OpenBeOS
|
// Copyright (c) 2003-2004, OpenBeOS
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -46,17 +46,17 @@ const int32 kMaxVerticalExtent = 0x10000000;
|
|||||||
|
|
||||||
|
|
||||||
#define TRACE_REGION 0
|
#define TRACE_REGION 0
|
||||||
|
#define ARGS (const char *, ...)
|
||||||
#if TRACE_REGION
|
#if TRACE_REGION
|
||||||
#define RTRACE printf
|
#define RTRACE(ARGS) printf ARGS
|
||||||
#define CALLED() RTRACE("%s\n", __PRETTY_FUNCTION__)
|
#define CALLED() printf("%s\n", __PRETTY_FUNCTION__)
|
||||||
#else
|
#else
|
||||||
#define RTRACE (void)
|
#define RTRACE(ARGS) ;
|
||||||
#define CALLED()
|
#define CALLED()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
/*! \brief zeroes the given region, setting its rect count to 0,
|
/*! \brief zeroes the given region, setting its rect count to 0,
|
||||||
and invalidating its bound rectangle.
|
and invalidating its bound rectangle.
|
||||||
\param region The region to be zeroed.
|
\param region The region to be zeroed.
|
||||||
@@ -84,7 +84,7 @@ BRegion::Support::ClearRegion(BRegion *region)
|
|||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
// XXX: What is it used for ?
|
// XXX: What is it used for ?
|
||||||
// Can be that a cleared region represents an infinite one ?
|
// Could be that a cleared region represents an infinite one ?
|
||||||
|
|
||||||
region->count = 0;
|
region->count = 0;
|
||||||
region->bound.left = 0xfffffff;
|
region->bound.left = 0xfffffff;
|
||||||
@@ -265,11 +265,11 @@ BRegion::Support::CleanupRegionVertical(BRegion *region)
|
|||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
clipping_rect testRect = { 1, 1, -1, -2 };
|
clipping_rect testRect = { 1, 1, -1, -2 };
|
||||||
long newCount = -1;
|
long newCount = -1;
|
||||||
|
|
||||||
for (long x = 0; x < region->count; x++) {
|
for (long x = 0; x < region->count; x++) {
|
||||||
clipping_rect rect = region->data[x];
|
clipping_rect &rect = region->data[x];
|
||||||
|
|
||||||
if (rect.left == testRect.left && rect.right == testRect.right
|
if (rect.left == testRect.left && rect.right == testRect.right
|
||||||
&& rect.top == testRect.bottom + 1) {
|
&& rect.top == testRect.bottom + 1) {
|
||||||
@@ -299,7 +299,8 @@ BRegion::Support::CleanupRegionHorizontal(BRegion *region)
|
|||||||
long newCount = -1;
|
long newCount = -1;
|
||||||
|
|
||||||
for (long x = 0; x < region->count; x++) {
|
for (long x = 0; x < region->count; x++) {
|
||||||
clipping_rect rect = region->data[x];
|
clipping_rect &rect = region->data[x];
|
||||||
|
|
||||||
if (rect.top == testRect.top && rect.bottom == testRect.bottom
|
if (rect.top == testRect.top && rect.bottom == testRect.bottom
|
||||||
&& rect.left == testRect.right + 1) {
|
&& rect.left == testRect.right + 1) {
|
||||||
|
|
||||||
@@ -316,6 +317,17 @@ BRegion::Support::CleanupRegionHorizontal(BRegion *region)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Helper method to swap two rects
|
||||||
|
static inline void
|
||||||
|
SwapRects(clipping_rect &rect, clipping_rect &anotherRect)
|
||||||
|
{
|
||||||
|
clipping_rect tmpRect;
|
||||||
|
tmpRect = rect;
|
||||||
|
rect = anotherRect;
|
||||||
|
anotherRect = tmpRect;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Sorts the given rects by their top value.
|
/*! \brief Sorts the given rects by their top value.
|
||||||
\param rects A pointer to an array of clipping_rects.
|
\param rects A pointer to an array of clipping_rects.
|
||||||
\param count The number of rectangles in the array.
|
\param count The number of rectangles in the array.
|
||||||
@@ -328,19 +340,15 @@ BRegion::Support::SortRects(clipping_rect *rects, long count)
|
|||||||
bool again; //flag that tells we changed rects positions
|
bool again; //flag that tells we changed rects positions
|
||||||
|
|
||||||
if (count == 2) {
|
if (count == 2) {
|
||||||
if (rects[0].top > rects[1].top) {
|
if (rects[0].top > rects[1].top)
|
||||||
clipping_rect tmp = rects[0];
|
SwapRects(rects[0], rects[1]);
|
||||||
rects[0] = rects[1];
|
|
||||||
rects[1] = tmp;
|
|
||||||
}
|
|
||||||
} else if (count > 2) {
|
} else if (count > 2) {
|
||||||
do {
|
do {
|
||||||
again = false;
|
again = false;
|
||||||
for (long c = 1; c < count; c++) {
|
for (long c = 1; c < count; c++) {
|
||||||
if (rects[c - 1].top > rects[c].top) {
|
if (rects[c - 1].top > rects[c].top) {
|
||||||
clipping_rect tmp = rects[c - 1];
|
SwapRects(rects[c - 1], rects[c]);
|
||||||
rects[c - 1] = rects[c];
|
|
||||||
rects[c] = tmp;
|
|
||||||
again = true;
|
again = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -349,6 +357,22 @@ BRegion::Support::SortRects(clipping_rect *rects, long count)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Helper methods to swap transition points in two given arrays
|
||||||
|
static inline void
|
||||||
|
SwapTrans(long *leftPoints, long *rightPoints, long index1, long index2)
|
||||||
|
{
|
||||||
|
// First, swap the left points
|
||||||
|
long tmp = leftPoints[index1];
|
||||||
|
leftPoints[index1] = leftPoints[index2];
|
||||||
|
leftPoints[index2] = tmp;
|
||||||
|
|
||||||
|
// then the right points
|
||||||
|
tmp = rightPoints[index1];
|
||||||
|
rightPoints[index1] = rightPoints[index2];
|
||||||
|
rightPoints[index2] = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BRegion::Support::SortTrans(long *lptr1, long *lptr2, long count)
|
BRegion::Support::SortTrans(long *lptr1, long *lptr2, long count)
|
||||||
{
|
{
|
||||||
@@ -357,31 +381,19 @@ BRegion::Support::SortTrans(long *lptr1, long *lptr2, long count)
|
|||||||
bool again; //flag that tells we changed trans positions
|
bool again; //flag that tells we changed trans positions
|
||||||
|
|
||||||
if (count == 2) {
|
if (count == 2) {
|
||||||
if (lptr1[0] > lptr1[1]) {
|
if (lptr1[0] > lptr1[1])
|
||||||
int32 tmp = lptr1[0];
|
SwapTrans(lptr1, lptr2, 0, 1);
|
||||||
lptr1[0] = lptr1[1];
|
|
||||||
lptr1[1] = tmp;
|
|
||||||
|
|
||||||
tmp = lptr2[0];
|
|
||||||
lptr2[0] = lptr2[1];
|
|
||||||
lptr2[1] = tmp;
|
|
||||||
}
|
|
||||||
} else if (count > 2) {
|
} else if (count > 2) {
|
||||||
do {
|
do {
|
||||||
again = false;
|
again = false;
|
||||||
for (long c = 1; c < count; c++) {
|
for (long c = 1; c < count; c++) {
|
||||||
if (lptr1[c - 1] > lptr1[c]) {
|
if (lptr1[c - 1] > lptr1[c]) {
|
||||||
int32 tmp = lptr1[c - 1];
|
SwapTrans(lptr1, lptr2, c - 1, c);
|
||||||
lptr1[c - 1] = lptr1[c];
|
|
||||||
lptr1[c] = tmp;
|
|
||||||
|
|
||||||
tmp = lptr2[c - 1];
|
|
||||||
lptr2[c - 1] = lptr2[c];
|
|
||||||
lptr2[c] = tmp;
|
|
||||||
again = true;
|
again = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (again);
|
} while (again);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -529,8 +541,8 @@ BRegion::Support::ROr(long top, long bottom, BRegion *first, BRegion *second, BR
|
|||||||
int32 maxCount = first->count - i1 + second->count - i2;
|
int32 maxCount = first->count - i1 + second->count - i2;
|
||||||
|
|
||||||
if (maxCount > kMaxPoints) {
|
if (maxCount > kMaxPoints) {
|
||||||
RTRACE("Stack space isn't sufficient. Allocating %d bytes on the heap...\n",
|
RTRACE(("Stack space isn't sufficient. Allocating %ld bytes on the heap...\n",
|
||||||
2 * maxCount);
|
2 * maxCount));
|
||||||
lefts = allocatedBuffer = new(nothrow) int32[2 * maxCount];
|
lefts = allocatedBuffer = new(nothrow) int32[2 * maxCount];
|
||||||
if (!allocatedBuffer)
|
if (!allocatedBuffer)
|
||||||
return;
|
return;
|
||||||
@@ -600,7 +612,7 @@ BRegion::Support::ROr(long top, long bottom, BRegion *first, BRegion *second, BR
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (allocatedBuffer) {
|
if (allocatedBuffer) {
|
||||||
RTRACE("Freeing heap...\n");
|
RTRACE(("Freeing heap...\n"));
|
||||||
delete[] allocatedBuffer;
|
delete[] allocatedBuffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -813,8 +825,8 @@ BRegion::Support::RSub(long top, long bottom, BRegion *first, BRegion *second, B
|
|||||||
int32 maxCountB = second->count - i2;
|
int32 maxCountB = second->count - i2;
|
||||||
|
|
||||||
if (maxCountA + maxCountB > kMaxPoints) {
|
if (maxCountA + maxCountB > kMaxPoints) {
|
||||||
RTRACE("Stack space isn't sufficient. Allocating %d bytes on the heap...\n",
|
RTRACE(("Stack space isn't sufficient. Allocating %ld bytes on the heap...\n",
|
||||||
2 * (maxCountA + maxCountB));
|
2 * (maxCountA + maxCountB)));
|
||||||
leftsA = allocatedBuffer = new(nothrow) int32[2 * (maxCountA + maxCountB)];
|
leftsA = allocatedBuffer = new(nothrow) int32[2 * (maxCountA + maxCountB)];
|
||||||
if (!allocatedBuffer)
|
if (!allocatedBuffer)
|
||||||
return;
|
return;
|
||||||
@@ -937,7 +949,7 @@ BRegion::Support::RSub(long top, long bottom, BRegion *first, BRegion *second, B
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (allocatedBuffer) {
|
if (allocatedBuffer) {
|
||||||
RTRACE("Freeing heap...\n");
|
RTRACE(("Freeing heap...\n"));
|
||||||
delete[] allocatedBuffer;
|
delete[] allocatedBuffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user