aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrRecordReplaceDraw.cpp
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2015-05-19 11:11:26 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-05-19 11:11:26 -0700
commit9db912c2ac2ab53bc24f2d50a3e5a80162051dcc (patch)
tree053a0e9ec711d0ccb95625219dd83022e7b6ece2 /src/gpu/GrRecordReplaceDraw.cpp
parent612f70d5fa2d4bf7a393c791966bbce933407017 (diff)
Sketch splitting SkPicture into an interface and SkBigPicture.
Adds small pictures for drawRect(), drawTextBlob(), and drawPath(). These cover about 89% of draw calls from Blink SKPs, and about 25% of draw calls from our GMs. SkPicture handles: - serialization and deserialization - unique IDs Everything else is left to the subclasses: - playback(), cullRect() - hasBitmap(), hasText(), suitableForGPU(), etc. - LayerInfo / AccelData if applicable. The time to record a 1-op picture improves a good chunk (2 mallocs to 1), and the time to record a 0-op picture greatly improves (2 mallocs to none): picture_overhead_draw: 450ns -> 350ns picture_overhead_nodraw: 300ns -> 90ns BUG=skia: Committed: https://skia.googlesource.com/skia/+/c92c129ff85b05a714bd1bf921c02d5e14651f8b Latest blink_linux_rel: http://build.chromium.org/p/tryserver.blink/builders/linux_blink_rel/builds/61248 Committed: https://skia.googlesource.com/skia/+/15877b6eae33a9282458bdb904a6d00440eca0ec http://build.chromium.org/p/tryserver.blink/builders/linux_blink_rel/builds/62015 Review URL: https://codereview.chromium.org/1112523006
Diffstat (limited to 'src/gpu/GrRecordReplaceDraw.cpp')
-rw-r--r--src/gpu/GrRecordReplaceDraw.cpp47
1 files changed, 29 insertions, 18 deletions
diff --git a/src/gpu/GrRecordReplaceDraw.cpp b/src/gpu/GrRecordReplaceDraw.cpp
index dacc939e62..6f05206dcc 100644
--- a/src/gpu/GrRecordReplaceDraw.cpp
+++ b/src/gpu/GrRecordReplaceDraw.cpp
@@ -8,6 +8,7 @@
#include "GrContext.h"
#include "GrLayerCache.h"
#include "GrRecordReplaceDraw.h"
+#include "SkBigPicture.h"
#include "SkCanvasPriv.h"
#include "SkGrPixelRef.h"
#include "SkImage.h"
@@ -45,7 +46,7 @@ static inline void draw_replacement_bitmap(GrCachedLayer* layer, SkCanvas* canva
canvas->drawBitmapRectToRect(bm, &src, dst, layer->paint());
canvas->restore();
} else {
- canvas->drawSprite(bm,
+ canvas->drawSprite(bm,
layer->srcIR().fLeft + layer->offset().fX,
layer->srcIR().fTop + layer->offset().fY,
layer->paint());
@@ -59,7 +60,7 @@ public:
ReplaceDraw(SkCanvas* canvas, GrLayerCache* layerCache,
SkPicture const* const drawablePicts[], int drawableCount,
const SkPicture* topLevelPicture,
- const SkPicture* picture,
+ const SkBigPicture* picture,
const SkMatrix& initialMatrix,
SkPicture::AbortCallback* callback,
const unsigned* opIndices, int numIndices)
@@ -76,8 +77,8 @@ public:
}
int draw() {
- const SkBBoxHierarchy* bbh = fPicture->fBBH.get();
- const SkRecord* record = fPicture->fRecord.get();
+ const SkBBoxHierarchy* bbh = fPicture->bbh();
+ const SkRecord* record = fPicture->record();
if (NULL == record) {
return 0;
}
@@ -135,13 +136,17 @@ public:
SkAutoCanvasMatrixPaint acmp(fCanvas, &dp.matrix, dp.paint, dp.picture->cullRect());
- // Draw sub-pictures with the same replacement list but a different picture
- ReplaceDraw draw(fCanvas, fLayerCache,
- this->drawablePicts(), this->drawableCount(),
- fTopLevelPicture, dp.picture, fInitialMatrix, fCallback,
- fOpIndexStack.begin(), fOpIndexStack.count());
-
- fNumReplaced += draw.draw();
+ if (const SkBigPicture* bp = dp.picture->asSkBigPicture()) {
+ // Draw sub-pictures with the same replacement list but a different picture
+ ReplaceDraw draw(fCanvas, fLayerCache,
+ this->drawablePicts(), this->drawableCount(),
+ fTopLevelPicture, bp, fInitialMatrix, fCallback,
+ fOpIndexStack.begin(), fOpIndexStack.count());
+ fNumReplaced += draw.draw();
+ } else {
+ // TODO: can we assume / assert this doesn't happen?
+ dp.picture->playback(fCanvas, fCallback);
+ }
fOpIndexStack.pop();
}
@@ -168,7 +173,7 @@ public:
draw_replacement_bitmap(layer, fCanvas);
- if (fPicture->fBBH.get()) {
+ if (fPicture->bbh()) {
while (fOps[fIndex] < layer->stop()) {
++fIndex;
}
@@ -190,7 +195,7 @@ private:
SkCanvas* fCanvas;
GrLayerCache* fLayerCache;
const SkPicture* fTopLevelPicture;
- const SkPicture* fPicture;
+ const SkBigPicture* fPicture;
const SkMatrix fInitialMatrix;
SkPicture::AbortCallback* fCallback;
@@ -211,9 +216,15 @@ int GrRecordReplaceDraw(const SkPicture* picture,
SkPicture::AbortCallback* callback) {
SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/);
- // TODO: drawablePicts?
- ReplaceDraw draw(canvas, layerCache, NULL, 0,
- picture, picture,
- initialMatrix, callback, NULL, 0);
- return draw.draw();
+ if (const SkBigPicture* bp = picture->asSkBigPicture()) {
+ // TODO: drawablePicts?
+ ReplaceDraw draw(canvas, layerCache, NULL, 0,
+ bp, bp,
+ initialMatrix, callback, NULL, 0);
+ return draw.draw();
+ } else {
+ // TODO: can we assume / assert this doesn't happen?
+ picture->playback(canvas, callback);
+ return 0;
+ }
}