Respect SkPictureRecorder::kPlaybackDrawPicture_RecordFlag for SkDrawables
authordjsollen <djsollen@google.com>
Tue, 17 Nov 2015 14:18:31 +0000 (06:18 -0800)
committerCommit bot <commit-bot@chromium.org>
Tue, 17 Nov 2015 14:18:31 +0000 (06:18 -0800)
Review URL: https://codereview.chromium.org/1452193002

include/core/SkPictureRecorder.h
src/core/SkRecorder.cpp

index a1ec7a7..6f95860 100644 (file)
@@ -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,
     };
 
index 0605d17..a3c9513 100644 (file)
@@ -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) {