From: robertphillips@google.com Date: Thu, 2 Aug 2012 12:42:43 +0000 (+0000) Subject: Fixed oversized SkRegion bound problem for complexclip_aa GM X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~15331 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=768fee8b6e9ae0a849ed45ab377fc9079b5db11e;p=platform%2Fupstream%2FlibSkiaSharp.git 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 --- diff --git a/src/core/SkAAClip.cpp b/src/core/SkAAClip.cpp index 8936297..e0fcf7a 100644 --- a/src/core/SkAAClip.cpp +++ b/src/core/SkAAClip.cpp @@ -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(); } diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 27d3724..9ed1ccb 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -384,7 +384,7 @@ static void check_bounds(const GrClipData& clipData, } } -// GrAssert(devBound.contains(clipRegion.getBounds())); + GrAssert(devBound.contains(clipRegion.getBounds())); } #endif