diff options
author | mtklein <mtklein@chromium.org> | 2015-04-08 11:25:48 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-08 11:25:48 -0700 |
commit | feaadee1c38e1d4e1ec0069a3509ef6fbc5fbeff (patch) | |
tree | 6daa3fb967c439b8d2adb4a3ddf9a21957951b8f /src/core/SkPictureRecorder.cpp | |
parent | 3f324321cdd8fde7976d958e2888a1ec4e657e35 (diff) |
SkCanvas::resetForNextPicture()
No diffs against head for DM --config 8888 gpu 2ndpic-8888 2ndpic-gpu.
picture_overhead_draw 1.62us -> 1.6us 0.99x
picture_overhead_nodraw 792ns -> 342ns 0.43x
tiles and serialization modes will also test this a bit.
BUG=chromium:470553
Committed: https://skia.googlesource.com/skia/+/f920e468ac66a36c9653d1b11181480295044c7d
Review URL: https://codereview.chromium.org/1067893002
Diffstat (limited to 'src/core/SkPictureRecorder.cpp')
-rw-r--r-- | src/core/SkPictureRecorder.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/core/SkPictureRecorder.cpp b/src/core/SkPictureRecorder.cpp index 850be27530..f622e66c84 100644 --- a/src/core/SkPictureRecorder.cpp +++ b/src/core/SkPictureRecorder.cpp @@ -15,7 +15,10 @@ #include "SkRecordOpts.h" #include "SkTypes.h" -SkPictureRecorder::SkPictureRecorder() {} +SkPictureRecorder::SkPictureRecorder() { + fActivelyRecording = false; + fRecorder.reset(SkNEW_ARGS(SkRecorder, (nullptr, SkRect::MakeWH(0,0)))); +} SkPictureRecorder::~SkPictureRecorder() {} @@ -31,15 +34,18 @@ SkCanvas* SkPictureRecorder::beginRecording(const SkRect& cullRect, } fRecord.reset(SkNEW(SkRecord)); - fRecorder.reset(SkNEW_ARGS(SkRecorder, (fRecord.get(), cullRect))); + fRecorder->reset(fRecord.get(), cullRect); + fActivelyRecording = true; return this->getRecordingCanvas(); } SkCanvas* SkPictureRecorder::getRecordingCanvas() { - return fRecorder.get(); + return fActivelyRecording ? fRecorder.get() : nullptr; } SkPicture* SkPictureRecorder::endRecordingAsPicture() { + fActivelyRecording = false; + fRecorder->restoreToCount(1); // If we were missing any restores, add them now. // TODO: delay as much of this work until just before first playback? SkRecordOptimize(fRecord); @@ -73,7 +79,6 @@ SkPicture* SkPictureRecorder::endRecordingAsPicture() { } // release our refs now, so only the picture will be the owner. - fRecorder.reset(NULL); fRecord.reset(NULL); fBBH.reset(NULL); @@ -158,6 +163,8 @@ protected: }; SkDrawable* SkPictureRecorder::endRecordingAsDrawable() { + fActivelyRecording = false; + fRecorder->restoreToCount(1); // If we were missing any restores, add them now. // TODO: delay as much of this work until just before first playback? SkRecordOptimize(fRecord); @@ -171,7 +178,6 @@ SkDrawable* SkPictureRecorder::endRecordingAsDrawable() { SkToBool(fFlags & kComputeSaveLayerInfo_RecordFlag))); // release our refs now, so only the drawable will be the owner. - fRecorder.reset(NULL); fRecord.reset(NULL); fBBH.reset(NULL); |