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

Unified Diff: dm/DMRecordTask.cpp

Issue 206313003: SkRecord strawman (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: IsSmall -> IsLarge: pithier Created 6 years, 9 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/DMRecordTask.h ('k') | gyp/dm.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DMRecordTask.cpp
diff --git a/dm/DMRecordTask.cpp b/dm/DMRecordTask.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0109a41d8fb1b5eb4fc0d70a8f9adbb697aac047
--- /dev/null
+++ b/dm/DMRecordTask.cpp
@@ -0,0 +1,42 @@
+#include "DMRecordTask.h"
+#include "DMUtil.h"
+#include "DMWriteTask.h"
+#include "SkCommandLineFlags.h"
+#include "SkRecordDraw.h"
+#include "SkRecorder.h"
+
+DEFINE_bool(skr, false, "If true, run SKR tests.");
+
+namespace DM {
+
+RecordTask::RecordTask(const Task& parent, skiagm::GM* gm, SkBitmap reference)
+ : CpuTask(parent)
+ , fName(UnderJoin(parent.name().c_str(), "skr"))
+ , fGM(gm)
+ , fReference(reference)
+ {}
+
+void RecordTask::draw() {
+ // Record the GM into an SkRecord.
+ SkRecord record;
+ SkRecorder canvas(&record, fReference.width(), fReference.height());
+ canvas.concat(fGM->getInitialTransform());
+ fGM->draw(&canvas);
+
+ // Draw the SkRecord back into a bitmap.
+ SkBitmap bitmap;
+ SetupBitmap(fReference.colorType(), fGM.get(), &bitmap);
+ SkCanvas target(bitmap);
+ record.visit(SkRecordDraw(&target));
+
+ if (!BitmapsEqual(bitmap, fReference)) {
+ this->fail();
+ this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
+ }
+}
+
+bool RecordTask::shouldSkip() const {
+ return !FLAGS_skr;
+}
+
+} // namespace DM
« no previous file with comments | « dm/DMRecordTask.h ('k') | gyp/dm.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698