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 @@ public: |
this->updateReader(); |
} |
+ void setImageHeap(SkImageHeap* heap) { |
+ fImageHeap.reset(SkRef(heap)); |
+ } |
+ |
/** |
* Access the shared heap. Only used in the case when bitmaps are not |
* flattened. |
@@ -198,6 +202,10 @@ public: |
return id ? fTypefaces[id - 1] : NULL; |
} |
+ const SkImage* getImage(int32_t slot) const { |
+ return fImageHeap->get(slot); |
+ } |
+ |
private: |
void updateReader() { |
if (NULL == fReader) { |
@@ -227,6 +235,7 @@ private: |
bool fSilent; |
// Only used when sharing bitmaps with the writer. |
SkBitmapHeap* fSharedHeap; |
+ SkAutoTUnref<SkImageHeap> fImageHeap; |
unsigned fFlags; |
}; |
@@ -629,6 +638,35 @@ static void drawSprite_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, |
} |
} |
+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,10 +812,14 @@ static void reportFlags_rp(SkCanvas*, SkReader32*, uint32_t op32, |
} |
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*) {} |
typedef void (*ReadProc)(SkCanvas*, SkReader32*, uint32_t op32, SkGPipeState*); |
@@ -793,6 +835,8 @@ static const ReadProc gReadTable[] = { |
drawBitmapNine_rp, |
drawBitmapRect_rp, |
drawDRRect_rp, |
+ drawImage_rp, |
+ drawImageRect_rp, |
drawOval_rp, |
drawPaint_rp, |
drawPatch_rp, |
@@ -828,6 +872,7 @@ static const ReadProc gReadTable[] = { |
reportFlags_rp, |
shareBitmapHeap_rp, |
+ shareImageHeap_rp, |
done_rp |
}; |