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

Unified Diff: src/core/SkRecorder.cpp

Issue 732653004: option to return drawable from recording (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month 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/SkRecorder.h ('k') | src/gpu/GrRecordReplaceDraw.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkRecorder.cpp
diff --git a/src/core/SkRecorder.cpp b/src/core/SkRecorder.cpp
index 22d742f3e78f12407a63db76857db2fbab084fe4..3548851a72ca6d5aa121189aa122dd252229c667 100644
--- a/src/core/SkRecorder.cpp
+++ b/src/core/SkRecorder.cpp
@@ -9,6 +9,28 @@
#include "SkPatchUtils.h"
#include "SkPicture.h"
+SkCanvasDrawableList::~SkCanvasDrawableList() {
+ fArray.unrefAll();
+}
+
+SkPicture::SnapshotArray* SkCanvasDrawableList::newDrawableSnapshot() {
+ const int count = fArray.count();
+ if (0 == count) {
+ return NULL;
+ }
+ SkAutoTMalloc<const SkPicture*> pics(count);
+ for (int i = 0; i < count; ++i) {
+ pics[i] = fArray[i]->newPictureSnapshot();
+ }
+ return SkNEW_ARGS(SkPicture::SnapshotArray, (pics.detach(), count));
+}
+
+void SkCanvasDrawableList::append(SkCanvasDrawable* drawable) {
+ *fArray.append() = SkRef(drawable);
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////
+
SkRecorder::SkRecorder(SkRecord* record, int width, int height)
: SkCanvas(SkIRect::MakeWH(width, height), SkCanvas::kConservativeRasterClip_InitFlag)
, fRecord(record)
@@ -19,29 +41,11 @@ SkRecorder::SkRecorder(SkRecord* record, const SkRect& bounds)
, fRecord(record)
, fSaveLayerCount(0) {}
-SkRecorder::~SkRecorder() {
- fDrawableList.unrefAll();
-}
-
void SkRecorder::forgetRecord() {
- fDrawableList.unrefAll();
- fDrawableList.reset();
+ fDrawableList.reset(NULL);
fRecord = NULL;
}
-SkPicture::SnapshotArray* SkRecorder::newDrawableSnapshot(SkBBHFactory* factory,
- uint32_t recordFlags) {
- const int count = fDrawableList.count();
- if (0 == count) {
- return NULL;
- }
- SkAutoTMalloc<const SkPicture*> pics(count);
- for (int i = 0; i < count; ++i) {
- pics[i] = fDrawableList[i]->newPictureSnapshot(factory, recordFlags);
- }
- return SkNEW_ARGS(SkPicture::SnapshotArray, (pics.detach(), count));
-}
-
// To make appending to fRecord a little less verbose.
#define APPEND(T, ...) \
SkNEW_PLACEMENT_ARGS(fRecord->append<SkRecords::T>(), SkRecords::T, (__VA_ARGS__))
@@ -146,8 +150,11 @@ void SkRecorder::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, const
}
void SkRecorder::onDrawDrawable(SkCanvasDrawable* drawable) {
- *fDrawableList.append() = SkRef(drawable);
- APPEND(DrawDrawable, drawable->getBounds(), fDrawableList.count() - 1);
+ if (!fDrawableList) {
+ fDrawableList.reset(SkNEW(SkCanvasDrawableList));
+ }
+ fDrawableList->append(drawable);
+ APPEND(DrawDrawable, drawable->getBounds(), fDrawableList->count() - 1);
}
void SkRecorder::drawPath(const SkPath& path, const SkPaint& paint) {
« no previous file with comments | « src/core/SkRecorder.h ('k') | src/gpu/GrRecordReplaceDraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698