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

Unified Diff: src/core/SkPicturePlayback.cpp

Issue 2187613002: Deserialize pictures with custom image-deserializer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix legacy case, remove null-check Created 4 years, 4 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 | « src/core/SkPictureData.cpp ('k') | src/core/SkPictureRecord.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPicturePlayback.cpp
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index 307e9468717352ca5e2c2bb6c107381805fd7f57..dec72e10ac6dddfa60d916162af1d76576367568 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -80,11 +80,6 @@ void get_text(SkReadBuffer* reader, TextContainer* text) {
text->fText = (const char*)reader->skip(length);
}
-// FIXME: SkBitmaps are stateful, so we need to copy them to play back in multiple threads.
-static SkBitmap shallow_copy(const SkBitmap& bitmap) {
- return bitmap;
-}
-
void SkPicturePlayback::draw(SkCanvas* canvas,
SkPicture::AbortCallback* callback,
const SkReadBuffer* buffer) {
@@ -214,39 +209,43 @@ void SkPicturePlayback::handleOp(SkReadBuffer* reader,
} break;
case DRAW_BITMAP: {
const SkPaint* paint = fPictureData->getPaint(reader);
- const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader));
+ const SkImage* image = fPictureData->getBitmapAsImage(reader);
SkPoint loc;
reader->readPoint(&loc);
- canvas->drawBitmap(bitmap, loc.fX, loc.fY, paint);
+ canvas->drawImage(image, loc.fX, loc.fY, paint);
} break;
case DRAW_BITMAP_RECT: {
const SkPaint* paint = fPictureData->getPaint(reader);
- const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader));
+ const SkImage* image = fPictureData->getBitmapAsImage(reader);
SkRect storage;
const SkRect* src = get_rect_ptr(reader, &storage); // may be null
SkRect dst;
reader->readRect(&dst); // required
SkCanvas::SrcRectConstraint constraint = (SkCanvas::SrcRectConstraint)reader->readInt();
- canvas->legacy_drawBitmapRect(bitmap, src, dst, paint, constraint);
+ if (src) {
+ canvas->drawImageRect(image, *src, dst, paint, constraint);
+ } else {
+ canvas->drawImageRect(image, dst, paint, constraint);
+ }
} break;
case DRAW_BITMAP_MATRIX: {
const SkPaint* paint = fPictureData->getPaint(reader);
- const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader));
+ const SkImage* image = fPictureData->getBitmapAsImage(reader);
SkMatrix matrix;
reader->readMatrix(&matrix);
SkAutoCanvasRestore acr(canvas, true);
canvas->concat(matrix);
- canvas->drawBitmap(bitmap, 0, 0, paint);
+ canvas->drawImage(image, 0, 0, paint);
} break;
case DRAW_BITMAP_NINE: {
const SkPaint* paint = fPictureData->getPaint(reader);
- const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader));
+ const SkImage* image = fPictureData->getBitmapAsImage(reader);
SkIRect src;
reader->readIRect(&src);
SkRect dst;
reader->readRect(&dst);
- canvas->drawBitmapNine(bitmap, src, dst, paint);
+ canvas->drawImageNine(image, src, dst, paint);
} break;
case DRAW_CLEAR:
canvas->clear(reader->readInt());
@@ -465,7 +464,7 @@ void SkPicturePlayback::handleOp(SkReadBuffer* reader,
} break;
case DRAW_SPRITE: {
/* const SkPaint* paint = */ fPictureData->getPaint(reader);
- /* const SkBitmap bitmap = */ shallow_copy(fPictureData->getBitmap(reader));
+ /* const SkImage* image = */ fPictureData->getBitmapAsImage(reader);
/* int left = */ reader->readInt();
/* int top = */ reader->readInt();
// drawSprite removed dec-2015
« no previous file with comments | « src/core/SkPictureData.cpp ('k') | src/core/SkPictureRecord.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698