From aa6f739c999fc2cdd64ba7a2332d333770722d06 Mon Sep 17 00:00:00 2001 From: djsollen Date: Tue, 17 Nov 2015 06:18:31 -0800 Subject: [PATCH] Respect SkPictureRecorder::kPlaybackDrawPicture_RecordFlag for SkDrawables Review URL: https://codereview.chromium.org/1452193002 --- include/core/SkPictureRecorder.h | 4 ++-- src/core/SkRecorder.cpp | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/include/core/SkPictureRecorder.h b/include/core/SkPictureRecorder.h index a1ec7a70a3..6f95860b70 100644 --- a/include/core/SkPictureRecorder.h +++ b/include/core/SkPictureRecorder.h @@ -35,8 +35,8 @@ public: // information should also be extracted at the same time. kComputeSaveLayerInfo_RecordFlag = 0x01, - // If you call drawPicture() on the recording canvas, this flag forces - // that to use SkPicture::playback() immediately rather than (e.g.) reffing the picture. + // If you call drawPicture() or drawDrawable() on the recording canvas, this flag forces + // that object to playback its contents immediately rather than reffing the object. kPlaybackDrawPicture_RecordFlag = 0x02, }; diff --git a/src/core/SkRecorder.cpp b/src/core/SkRecorder.cpp index 0605d17fc3..a3c9513168 100644 --- a/src/core/SkRecorder.cpp +++ b/src/core/SkRecorder.cpp @@ -158,11 +158,16 @@ void SkRecorder::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, const } void SkRecorder::onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) { - if (!fDrawableList) { - fDrawableList.reset(new SkDrawableList); + if (fDrawPictureMode == Record_DrawPictureMode) { + if (!fDrawableList) { + fDrawableList.reset(new SkDrawableList); + } + fDrawableList->append(drawable); + APPEND(DrawDrawable, this->copy(matrix), drawable->getBounds(), fDrawableList->count() - 1); + } else { + SkASSERT(fDrawPictureMode == Playback_DrawPictureMode); + drawable->draw(this, matrix); } - fDrawableList->append(drawable); - APPEND(DrawDrawable, this->copy(matrix), drawable->getBounds(), fDrawableList->count() - 1); } void SkRecorder::onDrawPath(const SkPath& path, const SkPaint& paint) {