Another fix for drawing bitmaps through an SkGPipe that share pixelrefs.
In addition to checking the offset, also check to ensure that the width
and height match, so that a subset which includes the upper left corner
will be handled properly as well.
Review URL: https://codereview.appspot.com/6352066
git-svn-id: http://skia.googlecode.com/svn/trunk@4448 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/pipe/SkGPipeWrite.cpp b/src/pipe/SkGPipeWrite.cpp
index 066159f..5734a27 100644
--- a/src/pipe/SkGPipeWrite.cpp
+++ b/src/pipe/SkGPipeWrite.cpp
@@ -85,16 +85,19 @@
const uint32_t genID = orig.getGenerationID();
SkPixelRef* sharedPixelRef = NULL;
for (int i = fBitmaps.count() - 1; i >= 0; i--) {
+ SkBitmap* storedBitmap = fBitmaps[i].fBitmap;
if (genID == fBitmaps[i].fGenID) {
- if (orig.pixelRefOffset() != fBitmaps[i].fBitmap->pixelRefOffset()) {
+ if (orig.pixelRefOffset() != storedBitmap->pixelRefOffset()
+ || orig.width() != storedBitmap->width()
+ || orig.height() != storedBitmap->height()) {
// In this case, the bitmaps share a pixelRef, but have
- // different offsets. Keep track of the other bitmap so that
- // instead of making another copy of the pixelRef we can use
- // the copy we already made.
- sharedPixelRef = fBitmaps[i].fBitmap->pixelRef();
+ // different offsets or sizes. Keep track of the other
+ // bitmap so that instead of making another copy of the
+ // pixelRef we can use the copy we already made.
+ sharedPixelRef = storedBitmap->pixelRef();
break;
}
- return fBitmaps[i].fBitmap;
+ return storedBitmap;
}
}
SkBitmap* copy;