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

Unified Diff: src/core/SkPicture.cpp

Issue 349973008: Tick off some TODOs: (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: robert 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 | « include/core/SkPicture.h ('k') | src/core/SkPicturePlayback.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPicture.cpp
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp
index c4e4204bf839d669218d9efb96f3785d19f226ad..2d054c607a5160a9fecf7d4082b280d68b30b827 100644
--- a/src/core/SkPicture.cpp
+++ b/src/core/SkPicture.cpp
@@ -15,6 +15,7 @@
#include "SkBitmapDevice.h"
#include "SkCanvas.h"
#include "SkChunkAlloc.h"
+#include "SkDrawPictureCallback.h"
#include "SkPaintPriv.h"
#include "SkPicture.h"
#include "SkRegion.h"
@@ -34,6 +35,7 @@
#include "SkRecord.h"
#include "SkRecordDraw.h"
+#include "SkRecorder.h"
template <typename T> int SafeCount(const T* obj) {
return obj ? obj->count() : 0;
@@ -146,29 +148,42 @@ SkPicture::SkPicture(int width, int height,
fPlayback.reset(SkNEW_ARGS(SkPicturePlayback, (record, info, deepCopyOps)));
}
-// fRecord TODO
+// The simplest / safest way to copy an SkRecord is to replay it into a new one.
+static SkRecord* copy(const SkRecord& src, int width, int height) {
+ SkRecord* dst = SkNEW(SkRecord);
+ SkRecorder recorder(dst, width, height);
+ SkRecordDraw(src, &recorder);
+ return dst;
+}
+
+// fRecord OK
SkPicture::SkPicture(const SkPicture& src) : INHERITED() {
this->needsNewGenID();
fWidth = src.fWidth;
fHeight = src.fHeight;
- if (src.fPlayback.get()) {
+ if (NULL != src.fPlayback.get()) {
fPlayback.reset(SkNEW_ARGS(SkPicturePlayback, (*src.fPlayback)));
- fUniqueID = src.uniqueID(); // need to call method to ensure != 0
+ fUniqueID = src.uniqueID(); // need to call method to ensure != 0
+ }
+
+ if (NULL != src.fRecord.get()) {
+ fRecord.reset(copy(*src.fRecord, fWidth, fHeight));
+ fUniqueID = src.uniqueID(); // need to call method to ensure != 0
}
}
// fRecord OK
SkPicture::~SkPicture() {}
-// fRecord TODO
+// fRecord TODO, fix by deleting this method
SkPicture* SkPicture::clone() const {
SkPicture* clonedPicture = SkNEW(SkPicture);
this->clone(clonedPicture, 1);
return clonedPicture;
}
-// fRecord TODO
+// fRecord TODO, fix by deleting this method
void SkPicture::clone(SkPicture* pictures, int count) const {
SkPictCopyInfo copyInfo;
@@ -293,8 +308,7 @@ void SkPicture::draw(SkCanvas* canvas, SkDrawPictureCallback* callback) const {
fPlayback->draw(*canvas, callback);
}
if (NULL != fRecord.get()) {
- // TODO: support SkDrawPictureCallback
- SkRecordDraw(*fRecord, canvas);
+ SkRecordDraw(*fRecord, canvas, callback);
}
}
@@ -495,7 +509,7 @@ bool SkPicture::willPlayBackBitmaps() const {
}
#ifdef SK_BUILD_FOR_ANDROID
-// fRecord TODO
+// fRecord TODO, fix by switching Android to SkDrawPictureCallback, then deleting this method
void SkPicture::abortPlayback() {
if (NULL == fPlayback.get()) {
return;
« no previous file with comments | « include/core/SkPicture.h ('k') | src/core/SkPicturePlayback.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698