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

Unified Diff: src/core/SkPictureRecorder.cpp

Issue 318763004: First pass at splitting out SkPictureRecord from SkPicture (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Make dtor non-virtual 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/SkPicture.cpp ('k') | no next file » | 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 1589ec0536a0cb64e07690c0db419fe815046957..31302d0cbc00e0c289cf015d2ccf3d4849d4301c 100644
--- a/src/core/SkPictureRecorder.cpp
+++ b/src/core/SkPictureRecorder.cpp
@@ -5,18 +5,67 @@
* found in the LICENSE file.
*/
-// Need to include SkTypes first, so that SK_BUILD_FOR_ANDROID is defined.
-#include "SkTypes.h"
-#ifdef SK_BUILD_FOR_ANDROID
+#include "SkBBoxHierarchyRecord.h"
#include "SkPicturePlayback.h"
-#endif
+#include "SkPictureRecord.h"
#include "SkPictureRecorder.h"
+#include "SkTypes.h"
+
+SkPictureRecorder::~SkPictureRecorder() {
+ SkSafeSetNull(fCanvas);
+}
SkCanvas* SkPictureRecorder::beginRecording(int width, int height,
SkBBHFactory* bbhFactory /* = NULL */,
uint32_t recordFlags /* = 0 */) {
+ SkSafeSetNull(fCanvas);
fPicture.reset(SkNEW(SkPicture));
- return fPicture->beginRecording(width, height, bbhFactory, recordFlags);
+
+ fPicture->fWidth = width;
+ fPicture->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()));
+ } else {
+ fCanvas = SkNEW_ARGS(SkPictureRecord, (fPicture, size, recordFlags));
+ }
+
+ fCanvas->beginRecording();
+
+ return fCanvas;
+}
+
+SkCanvas* SkPictureRecorder::getRecordingCanvas() {
+ return fCanvas;
+}
+
+SkPicture* SkPictureRecorder::endRecording() {
+ if (NULL == fPicture.get()) {
+ return NULL;
+ }
+
+ SkASSERT(NULL == fPicture->fPlayback);
+ SkASSERT(NULL != fCanvas);
+
+ fCanvas->endRecording();
+
+ SkPictInfo info;
+ fPicture->createHeader(&info);
+ fPicture->fPlayback = SkNEW_ARGS(SkPicturePlayback, (fPicture, *fCanvas, info));
+
+ SkSafeSetNull(fCanvas);
+
+ return fPicture.detach();
+}
+
+void SkPictureRecorder::internalOnly_EnableOpts(bool enableOpts) {
+ if (NULL != fCanvas) {
+ fCanvas->internalOnly_EnableOpts(enableOpts);
+ }
}
#ifdef SK_BUILD_FOR_ANDROID
@@ -26,10 +75,10 @@ void SkPictureRecorder::partialReplay(SkCanvas* canvas) const {
return;
}
- SkASSERT(NULL != fPicture->fRecord);
+ SkASSERT(NULL != fCanvas);
SkAutoTDelete<SkPicturePlayback> playback(SkPicture::FakeEndRecording(fPicture.get(),
- *fPicture->fRecord,
+ *fCanvas,
false));
playback->draw(*canvas, NULL);
}
« no previous file with comments | « src/core/SkPicture.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698