Fixed oversized SkRegion bound problem for complexclip_aa GM
http://codereview.appspot.com/6447076/ git-svn-id: http://skia.googlecode.com/svn/trunk@4906 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
ab5ec7e3a5
commit
768fee8b6e
@ -221,6 +221,8 @@ void SkAAClip::validate() const {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Count the number of zeros on the left and right edges of the passed in
|
||||
// RLE row. If 'row' is all zeros return 'width' in both variables.
|
||||
static void count_left_right_zeros(const uint8_t* row, int width,
|
||||
int* leftZ, int* riteZ) {
|
||||
int zeros = 0;
|
||||
@ -237,6 +239,12 @@ static void count_left_right_zeros(const uint8_t* row, int width,
|
||||
} while (width > 0);
|
||||
*leftZ = zeros;
|
||||
|
||||
if (0 == width) {
|
||||
// this line is completely empty return 'width' in both variables
|
||||
*riteZ = *leftZ;
|
||||
return;
|
||||
}
|
||||
|
||||
zeros = 0;
|
||||
while (width > 0) {
|
||||
int n = row[0];
|
||||
@ -265,7 +273,7 @@ static void test_count_left_right_zeros() {
|
||||
const uint8_t data2[] = { 7, 0, 5, 0, 2, 0, 3, 0xFF };
|
||||
const uint8_t data3[] = { 0, 5, 5, 0xFF, 2, 0, 3, 0 };
|
||||
const uint8_t data4[] = { 2, 3, 2, 0, 5, 0xFF, 3, 0 };
|
||||
const uint8_t data5[] = { 10, 0, 10, 0 };
|
||||
const uint8_t data5[] = { 10, 10, 10, 0 };
|
||||
const uint8_t data6[] = { 2, 2, 2, 0, 2, 0xFF, 2, 0, 2, 0xFF, 2, 0 };
|
||||
|
||||
const uint8_t* array[] = {
|
||||
@ -398,11 +406,15 @@ bool SkAAClip::trimLeftRight() {
|
||||
YOffset* stop = yoff + head->fRowCount;
|
||||
uint8_t* base = head->data();
|
||||
|
||||
// After this loop, 'leftZeros' & 'rightZeros' will contain the minimum
|
||||
// number of zeros on the left and right of the clip. This information
|
||||
// can be used to shrink the bounding box.
|
||||
int leftZeros = width;
|
||||
int riteZeros = width;
|
||||
while (yoff < stop) {
|
||||
int L, R;
|
||||
count_left_right_zeros(base + yoff->fOffset, width, &L, &R);
|
||||
SkASSERT(L + R < width || (L == width && R == width));
|
||||
if (L < leftZeros) {
|
||||
leftZeros = L;
|
||||
}
|
||||
@ -417,7 +429,8 @@ bool SkAAClip::trimLeftRight() {
|
||||
}
|
||||
|
||||
SkASSERT(leftZeros || riteZeros);
|
||||
if (width == (leftZeros + riteZeros)) {
|
||||
if (width == leftZeros) {
|
||||
SkASSERT(width == riteZeros);
|
||||
return this->setEmpty();
|
||||
}
|
||||
|
||||
|
@ -384,7 +384,7 @@ static void check_bounds(const GrClipData& clipData,
|
||||
}
|
||||
}
|
||||
|
||||
// GrAssert(devBound.contains(clipRegion.getBounds()));
|
||||
GrAssert(devBound.contains(clipRegion.getBounds()));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user