aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-16 19:35:39 +0000
committerGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-16 19:35:39 +0000
commit719a3733ae8873d015e92605b747ef2850766817 (patch)
tree72335ca05b86eeb38d877ebc89175f892407e2ab /src
parent9401deeb1046ff763d38d5354bb54648b3bab234 (diff)
Band-aid for subsetted bitmaps in SKPs.
Partial fix for https://code.google.com/p/skia/issues/detail?id=1301. Instead of firing an assert when the recorded width and height do not match the encoded data's width and height, take a subset of the bitmap of the correct size. The bitmap may be drawn incorrectly, since it will not necessarily be the correct subset (though it will be the correct size). The complete fix will be to record the offset to the stream. Holding off on that since it will change the PICTURE_VERSION. There is still more work to do on read/writeBitmap, and I would like to change PICTURE_VERSION as few times as possible. BUG=https://code.google.com/p/skia/issues/detail?id=1301 R=djsollen@google.com Review URL: https://codereview.chromium.org/15159004 git-svn-id: http://skia.googlecode.com/svn/trunk@9169 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/core/SkOrderedReadBuffer.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/core/SkOrderedReadBuffer.cpp b/src/core/SkOrderedReadBuffer.cpp
index 85491c5607..4af64706a1 100644
--- a/src/core/SkOrderedReadBuffer.cpp
+++ b/src/core/SkOrderedReadBuffer.cpp
@@ -197,8 +197,23 @@ void SkOrderedReadBuffer::readBitmap(SkBitmap* bitmap) {
// A non-zero size means the SkBitmap was encoded.
const void* data = this->skip(length);
if (fBitmapDecoder != NULL && fBitmapDecoder(data, length, bitmap)) {
- SkASSERT(bitmap->width() == width && bitmap->height() == height);
- return;
+ if (bitmap->width() == width && bitmap->height() == height) {
+ return;
+ }
+
+ // This case can only be reached if extractSubset was called, so
+ // the recorded width and height must be smaller than (or equal to
+ // the encoded width and height.
+ SkASSERT(width <= bitmap->width() && height <= bitmap->height());
+
+ // FIXME: Once the writer is changed to record the (x,y) offset,
+ // they will be used to store the correct portion of the picture.
+ SkBitmap subsetBm;
+ SkIRect subset = SkIRect::MakeWH(width, height);
+ if (bitmap->extractSubset(&subsetBm, subset)) {
+ bitmap->swap(subsetBm);
+ return;
+ }
}
// This bitmap was encoded when written, but we are unable to decode, possibly due to
// not having a decoder.