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

Unified Diff: dm/DMSKPTask.cpp

Issue 345553003: Support serialization in SkRecord-backed SkPictures. (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 | « dm/DMSKPTask.h ('k') | dm/DMSerializeTask.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DMSKPTask.cpp
diff --git a/dm/DMSKPTask.cpp b/dm/DMSKPTask.cpp
index 760138f7c98a96d4b52ac5d5a424fcd6cdbfe3fc..68fbb60717fc8e94c72b321ba4835c0de78db160 100644
--- a/dm/DMSKPTask.cpp
+++ b/dm/DMSKPTask.cpp
@@ -1,23 +1,59 @@
-#include "DMRecordTask.h"
#include "DMSKPTask.h"
#include "DMUtil.h"
#include "DMWriteTask.h"
+#include "SkCommandLineFlags.h"
+#include "SkPictureRecorder.h"
+
+DECLARE_bool(skr); // in DMReplayTask.cpp
+
namespace DM {
-SKPTask::SKPTask(Reporter* r, TaskRunner* tr, SkPicture* pic, SkString filename)
+// Test that an SkPicture plays back the same when re-recorded into an
+// SkPicture backed by SkRecord.
+class SkrComparisonTask : public CpuTask {
+public:
+ SkrComparisonTask(const Task& parent, const SkPicture* picture, SkBitmap reference)
+ : CpuTask(parent)
+ , fPicture(picture)
+ , fReference(reference)
+ , fName(UnderJoin(parent.name().c_str(), "skr")) {}
+
+ virtual bool shouldSkip() const SK_OVERRIDE { return !FLAGS_skr; }
+ virtual SkString name() const SK_OVERRIDE { return fName; }
+
+ virtual void draw() SK_OVERRIDE {
+ SkPictureRecorder recorder;
+ fPicture->draw(recorder.EXPERIMENTAL_beginRecording(fPicture->width(), fPicture->height()));
+ SkAutoTDelete<const SkPicture> skrPicture(recorder.endRecording());
+
+ SkBitmap bitmap;
+ AllocatePixels(kN32_SkColorType, fPicture->width(), fPicture->height(), &bitmap);
+ DrawPicture(*skrPicture, &bitmap);
+
+ if (!BitmapsEqual(fReference, bitmap)) {
+ this->fail();
+ this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
+ }
+ }
+
+private:
+ SkAutoTUnref<const SkPicture> fPicture;
+ const SkBitmap fReference;
+ const SkString fName;
+};
+
+
+SKPTask::SKPTask(Reporter* r, TaskRunner* tr, const SkPicture* pic, SkString filename)
: CpuTask(r, tr), fPicture(SkRef(pic)), fName(FileToTaskName(filename)) {}
void SKPTask::draw() {
SkBitmap bitmap;
AllocatePixels(kN32_SkColorType, fPicture->width(), fPicture->height(), &bitmap);
- DrawPicture(fPicture, &bitmap);
+ DrawPicture(*fPicture, &bitmap);
- this->spawnChild(SkNEW_ARGS(RecordTask,
- (*this, fPicture, bitmap, RecordTask::kNoOptimize_Mode)));
- this->spawnChild(SkNEW_ARGS(RecordTask,
- (*this, fPicture, bitmap, RecordTask::kOptimize_Mode)));
this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
+ this->spawnChild(SkNEW_ARGS(SkrComparisonTask, (*this, fPicture.get(), bitmap)));
}
} // namespace DM
« no previous file with comments | « dm/DMSKPTask.h ('k') | dm/DMSerializeTask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698