Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Unified Diff: src/core/SkOrderedReadBuffer.cpp

Issue 15159004: Band-aid for subsetted bitmaps in SKPs. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Extra comment for clarity Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkOrderedReadBuffer.cpp
diff --git a/src/core/SkOrderedReadBuffer.cpp b/src/core/SkOrderedReadBuffer.cpp
index 85491c5607545b04f8c48652399a611b3524cd21..4af64706a1db70e9246863a75f1ef9d183982c11 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.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698