Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Unified Diff: src/core/SkPictureRecorder.cpp

Issue 324293004: Remove picture pre-allocation from SkPictureRecorder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix initializer list order Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkPictureRecord.cpp ('k') | tests/CanvasTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPictureRecorder.cpp
diff --git a/src/core/SkPictureRecorder.cpp b/src/core/SkPictureRecorder.cpp
index 863dbcda90b9af2a0a4e19661e1f8ac03a92d76f..3abd08e1b027cbc789b8f145fecd427c1d20b5a2 100644
--- a/src/core/SkPictureRecorder.cpp
+++ b/src/core/SkPictureRecorder.cpp
@@ -18,20 +18,19 @@ SkPictureRecorder::~SkPictureRecorder() {
SkCanvas* SkPictureRecorder::beginRecording(int width, int height,
SkBBHFactory* bbhFactory /* = NULL */,
uint32_t recordFlags /* = 0 */) {
- SkSafeSetNull(fCanvas);
- fPicture.reset(SkNEW(SkPicture));
+ SkSafeSetNull(fCanvas); // terminate any prior recording(s)
- fPicture->fWidth = width;
- fPicture->fHeight = height;
+ fWidth = width;
+ fHeight = height;
const SkISize size = SkISize::Make(width, height);
if (NULL != bbhFactory) {
SkAutoTUnref<SkBBoxHierarchy> tree((*bbhFactory)(width, height));
SkASSERT(NULL != tree);
- fCanvas = SkNEW_ARGS(SkBBoxHierarchyRecord, (fPicture, size, recordFlags, tree.get()));
+ fCanvas = SkNEW_ARGS(SkBBoxHierarchyRecord, (size, recordFlags, tree.get()));
} else {
- fCanvas = SkNEW_ARGS(SkPictureRecord, (fPicture, size, recordFlags));
+ fCanvas = SkNEW_ARGS(SkPictureRecord, (size, recordFlags));
}
fCanvas->beginRecording();
@@ -44,23 +43,18 @@ SkCanvas* SkPictureRecorder::getRecordingCanvas() {
}
SkPicture* SkPictureRecorder::endRecording() {
- if (NULL == fPicture.get()) {
+ if (NULL == fCanvas) {
return NULL;
}
- SkASSERT(NULL == fPicture->fPlayback);
- SkASSERT(NULL != fCanvas);
-
fCanvas->endRecording();
- SkPictInfo info;
- fPicture->createHeader(&info);
const bool deepCopyOps = false;
- fPicture->fPlayback = SkNEW_ARGS(SkPicturePlayback, (fPicture, *fCanvas, info, deepCopyOps));
-
+ SkAutoTUnref<SkPicture> picture(SkNEW_ARGS(SkPicture, (fWidth, fHeight,
+ *fCanvas, deepCopyOps)));
SkSafeSetNull(fCanvas);
- return fPicture.detach();
+ return picture.detach();
}
void SkPictureRecorder::internalOnly_EnableOpts(bool enableOpts) {
@@ -70,14 +64,13 @@ void SkPictureRecorder::internalOnly_EnableOpts(bool enableOpts) {
}
void SkPictureRecorder::partialReplay(SkCanvas* canvas) const {
- if (NULL == fPicture.get() || NULL == canvas) {
+ if (NULL == fCanvas || NULL == canvas) {
// Not recording or nothing to replay into
return;
}
- SkASSERT(NULL != fCanvas);
-
- SkAutoTDelete<SkPicturePlayback> playback(SkPicture::FakeEndRecording(fPicture.get(),
- *fCanvas));
- playback->draw(*canvas, NULL);
+ const bool deepCopyOps = true;
+ SkAutoTUnref<SkPicture> picture(SkNEW_ARGS(SkPicture, (fWidth, fHeight,
+ *fCanvas, deepCopyOps)));
+ picture->draw(canvas);
}
« no previous file with comments | « src/core/SkPictureRecord.cpp ('k') | tests/CanvasTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698