diff options
author | reed <reed@google.com> | 2015-04-30 13:09:24 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-30 13:09:25 -0700 |
commit | 1c2c441fede0ae9573afc098017011e3439624a9 (patch) | |
tree | 088df00ee48e5e6f6d0763c2962f25e61b25a80f /src/core/SkCanvas.cpp | |
parent | 4f7ec55f7128e971318adc11f07fc485c4d50bc5 (diff) |
add heuristic to pour small pictures into recordings, rather than ref'ing
BUG=skia:
Review URL: https://codereview.chromium.org/1118693003
Diffstat (limited to 'src/core/SkCanvas.cpp')
-rw-r--r-- | src/core/SkCanvas.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index 95f9560f1f..c87c6c5f7c 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -2508,20 +2508,28 @@ void SkCanvas::drawTextOnPathHV(const void* text, size_t byteLength, } /////////////////////////////////////////////////////////////////////////////// -void SkCanvas::drawPicture(const SkPicture* picture) { - TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawPicture()"); - if (picture) { - this->onDrawPicture(picture, NULL, NULL); - } -} + +/** + * This constant is trying to balance the speed of ref'ing a subpicture into a parent picture, + * against the playback cost of recursing into the subpicture to get at its actual ops. + * + * For now we pick a conservatively small value, though measurement (and other heuristics like + * the type of ops contained) may justify changing this value. + */ +#define kMaxPictureOpsToUnrollInsteadOfRef 1 void SkCanvas::drawPicture(const SkPicture* picture, const SkMatrix* matrix, const SkPaint* paint) { - TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawPicture(SkMatrix, SkPaint)"); + TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawPicture()"); if (picture) { if (matrix && matrix->isIdentity()) { matrix = NULL; } - this->onDrawPicture(picture, matrix, paint); + if (picture->approximateOpCount() <= kMaxPictureOpsToUnrollInsteadOfRef) { + SkAutoCanvasMatrixPaint acmp(this, matrix, paint, picture->cullRect()); + picture->playback(this); + } else { + this->onDrawPicture(picture, matrix, paint); + } } } @@ -2537,7 +2545,6 @@ void SkCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* matrix, } SkAutoCanvasMatrixPaint acmp(this, matrix, paint, picture->cullRect()); - picture->playback(this); } |