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

Unified Diff: src/core/SkRecorder.cpp

Issue 727363003: wip for drawables (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: works, but I took a few short-cuts 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
Index: src/core/SkRecorder.cpp
diff --git a/src/core/SkRecorder.cpp b/src/core/SkRecorder.cpp
index 8dfce7e7ddd93fe44a4057f4eb0ff33f024b215e..f15aec3ba2502fd519a92c1f60dae1aa0a39006b 100644
--- a/src/core/SkRecorder.cpp
+++ b/src/core/SkRecorder.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "SkData.h"
#include "SkRecorder.h"
#include "SkPatchUtils.h"
#include "SkPicture.h"
@@ -15,10 +16,29 @@ SkRecorder::SkRecorder(SkRecord* record, int width, int height)
, fRecord(record)
, fSaveLayerCount(0) {}
+SkRecorder::~SkRecorder() {
+ fDrawableList.unrefAll();
+}
+
void SkRecorder::forgetRecord() {
+ fDrawableList.unrefAll();
+ fDrawableList.reset();
fRecord = NULL;
}
+SkData* SkRecorder::newDrawableSnapshot(SkBBHFactory* factory, uint32_t recordFlags) {
+ const int count = fDrawableList.count();
+ if (0 == count) {
+ return NULL;
+ }
+ SkData* data = SkData::NewUninitialized(count * sizeof(SkPicture*));
+ SkPicture** pics = reinterpret_cast<SkPicture**>(data->writable_data());
+ for (int i = 0; i < count; ++i) {
+ pics[i] = fDrawableList[i]->newPictureSnapshot(factory, recordFlags);
+ }
+ return data;
+}
+
// To make appending to fRecord a little less verbose.
#define APPEND(T, ...) \
SkNEW_PLACEMENT_ARGS(fRecord->append<SkRecords::T>(), SkRecords::T, (__VA_ARGS__))
@@ -122,6 +142,11 @@ void SkRecorder::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, const
APPEND(DrawDRRect, delay_copy(paint), outer, inner);
}
+void SkRecorder::onDrawDrawable(SkCanvasDrawable* drawable) {
+ *fDrawableList.append() = SkRef(drawable);
+ APPEND(DrawDrawable, drawable->getBounds(), fDrawableList.count() - 1);
+}
+
void SkRecorder::drawPath(const SkPath& path, const SkPaint& paint) {
APPEND(DrawPath, delay_copy(paint), delay_copy(path));
}

Powered by Google App Engine
This is Rietveld 408576698