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

Unified Diff: src/pipe/SkGPipeRead.cpp

Issue 1126273002: Revert of Revert of Make drawImage a virtual on SkDevice (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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 | « src/pipe/SkGPipePriv.h ('k') | src/pipe/SkGPipeWrite.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pipe/SkGPipeRead.cpp
diff --git a/src/pipe/SkGPipeRead.cpp b/src/pipe/SkGPipeRead.cpp
index f8411f5aeaeae2758d39d3270be01b2bbcc2c8a1..917bb50976197c31ad3a6e32bd081edf11613166 100644
--- a/src/pipe/SkGPipeRead.cpp
+++ b/src/pipe/SkGPipeRead.cpp
@@ -178,6 +178,10 @@
this->updateReader();
}
+ void setImageHeap(SkImageHeap* heap) {
+ fImageHeap.reset(SkRef(heap));
+ }
+
/**
* Access the shared heap. Only used in the case when bitmaps are not
* flattened.
@@ -196,6 +200,10 @@
SkTypeface* getTypeface(unsigned id) const {
return id ? fTypefaces[id - 1] : NULL;
+ }
+
+ const SkImage* getImage(int32_t slot) const {
+ return fImageHeap->get(slot);
}
private:
@@ -227,6 +235,7 @@
bool fSilent;
// Only used when sharing bitmaps with the writer.
SkBitmapHeap* fSharedHeap;
+ SkAutoTUnref<SkImageHeap> fImageHeap;
unsigned fFlags;
};
@@ -629,6 +638,35 @@
}
}
+static void drawImage_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, SkGPipeState* state) {
+ unsigned slot = DrawOp_unpackData(op32);
+ unsigned flags = DrawOp_unpackFlags(op32);
+ bool hasPaint = SkToBool(flags & kDrawBitmap_HasPaint_DrawOpFlag);
+ SkScalar x = reader->readScalar();
+ SkScalar y = reader->readScalar();
+ const SkImage* image = state->getImage(slot);
+ if (state->shouldDraw()) {
+ canvas->drawImage(image, x, y, hasPaint ? &state->paint() : NULL);
+ }
+}
+
+static void drawImageRect_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32,
+ SkGPipeState* state) {
+ unsigned slot = DrawOp_unpackData(op32);
+ unsigned flags = DrawOp_unpackFlags(op32);
+ bool hasPaint = SkToBool(flags & kDrawBitmap_HasPaint_DrawOpFlag);
+ bool hasSrc = SkToBool(flags & kDrawBitmap_HasSrcRect_DrawOpFlag);
+ const SkRect* src = NULL;
+ if (hasSrc) {
+ src = skip<SkRect>(reader);
+ }
+ const SkRect* dst = skip<SkRect>(reader);
+ const SkImage* image = state->getImage(slot);
+ if (state->shouldDraw()) {
+ canvas->drawImageRect(image, src, *dst, hasPaint ? &state->paint() : NULL);
+ }
+}
+
///////////////////////////////////////////////////////////////////////////////
static void drawPicture_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32,
@@ -774,8 +812,12 @@
}
static void shareBitmapHeap_rp(SkCanvas*, SkReader32* reader, uint32_t,
- SkGPipeState* state) {
+ SkGPipeState* state) {
state->setSharedHeap(static_cast<SkBitmapHeap*>(reader->readPtr()));
+}
+
+static void shareImageHeap_rp(SkCanvas*, SkReader32* reader, uint32_t, SkGPipeState* state) {
+ state->setImageHeap(static_cast<SkImageHeap*>(reader->readPtr()));
}
static void done_rp(SkCanvas*, SkReader32*, uint32_t, SkGPipeState*) {}
@@ -793,6 +835,8 @@
drawBitmapNine_rp,
drawBitmapRect_rp,
drawDRRect_rp,
+ drawImage_rp,
+ drawImageRect_rp,
drawOval_rp,
drawPaint_rp,
drawPatch_rp,
@@ -828,6 +872,7 @@
reportFlags_rp,
shareBitmapHeap_rp,
+ shareImageHeap_rp,
done_rp
};
« no previous file with comments | « src/pipe/SkGPipePriv.h ('k') | src/pipe/SkGPipeWrite.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698