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

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: 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..4637a7f8be8239412284fe94c80acc926d879787 100644
--- a/src/core/SkPictureRecorder.cpp
+++ b/src/core/SkPictureRecorder.cpp
@@ -5,18 +5,64 @@
* 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"
SkCanvas* SkPictureRecorder::beginRecording(int width, int height,
SkBBHFactory* bbhFactory /* = NULL */,
uint32_t recordFlags /* = 0 */) {
+ fCanvas.reset(NULL);
mtklein 2014/06/04 22:22:17 You can probably drop this? Either way, you're go
robertphillips 2014/06/05 20:29:44 This will eventually go away when SkPictureRecord
fPicture.reset(SkNEW(SkPicture));
- return fPicture->beginRecording(width, height, bbhFactory, recordFlags);
+
+ fPicture->fWidth = width;
+ fPicture->fHeight = height;
+
+ const SkISize size = SkISize::Make(width, height);
+
+ SkPictureRecord* record = NULL;
mtklein 2014/06/04 22:22:17 Might skip this and just call fCanvas.reset inside
robertphillips 2014/06/05 20:29:44 All this goofiness was b.c. SkPictureRecord.h is p
+
+ if (NULL != bbhFactory) {
+ SkAutoTUnref<SkBBoxHierarchy> tree((*bbhFactory)(width, height));
+ SkASSERT(NULL != tree);
+ record = SkNEW_ARGS(SkBBoxHierarchyRecord, (fPicture, size, recordFlags, tree.get()));
+ } else {
+ record = SkNEW_ARGS(SkPictureRecord, (fPicture, size, recordFlags));
+ }
+ fCanvas.reset(record);
+ record->beginRecording();
+
+ return fCanvas;
+}
+
+SkPicture* SkPictureRecorder::endRecording() {
+ if (NULL != fPicture.get()) {
mtklein 2014/06/04 22:22:17 I'd probably invert this so the normal case is out
robertphillips 2014/06/05 20:29:44 Done.
+ SkASSERT(NULL == fPicture->fPlayback);
+ SkASSERT(NULL != fCanvas);
+
+ SkPictureRecord* record = static_cast<SkPictureRecord*>(fCanvas.get());
mtklein 2014/06/04 22:22:17 Store fCanvas as SkAutoTUnref<SkPictureRecord>?
robertphillips 2014/06/05 20:29:44 SkPictureRecord.h is private.
+ record->endRecording();
+
+ SkPictInfo info;
+ fPicture->createHeader(&info);
+ fPicture->fPlayback = SkNEW_ARGS(SkPicturePlayback, (fPicture, *record, info));
mtklein 2014/06/04 22:22:17 In the future this goes away too right? Sort of s
robertphillips 2014/06/05 20:29:44 Right. At this point SkPictureRecorder should just
+
+ fCanvas.reset(NULL);
+
+ return fPicture.detach();
+ }
+ return NULL;
+}
+
+void SkPictureRecorder::internalOnly_EnableOpts(bool enableOpts) {
+ if (NULL == fCanvas) {
+ return;
+ }
+
+ SkPictureRecord* record = static_cast<SkPictureRecord*>(fCanvas.get());
+ record->internalOnly_EnableOpts(enableOpts);
}
#ifdef SK_BUILD_FOR_ANDROID
@@ -26,10 +72,11 @@ void SkPictureRecorder::partialReplay(SkCanvas* canvas) const {
return;
}
- SkASSERT(NULL != fPicture->fRecord);
+ SkASSERT(NULL != fCanvas.get());
+ SkPictureRecord* record = static_cast<SkPictureRecord*>(fCanvas.get());
SkAutoTDelete<SkPicturePlayback> playback(SkPicture::FakeEndRecording(fPicture.get(),
- *fPicture->fRecord,
+ *record,
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