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

Unified Diff: dm/DMReplayTask.cpp

Issue 22839016: Skeleton of DM (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: one last sync Created 7 years, 2 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/DMReplayTask.h ('k') | dm/DMReporter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DMReplayTask.cpp
diff --git a/dm/DMReplayTask.cpp b/dm/DMReplayTask.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..bc94f73cb1791230a5362d6d299fd7ff6544be3a
--- /dev/null
+++ b/dm/DMReplayTask.cpp
@@ -0,0 +1,50 @@
+#include "DMReplayTask.h"
+#include "DMUtil.h"
+
+#include "SkPicture.h"
+
+namespace DM {
+
+ReplayTask::ReplayTask(const char* suffix,
+ const Task& parent,
+ skiagm::GM* gm,
+ skiagm::GmResultDigest reference,
+ SkBitmap::Config config)
+ : Task(parent)
+ , fName(underJoin(parent.name().c_str(), suffix))
+ , fGM(gm)
+ , fReference(reference)
+ , fConfig(config)
+ {}
+
+void ReplayTask::draw() {
+ SkPicture picture;
+ SkCanvas* canvas = picture.beginRecording(fGM->width(), fGM->height(), 0 /*flags*/);
+
+ canvas->concat(fGM->getInitialTransform());
+ fGM->draw(canvas);
+ canvas->flush();
+
+ picture.endRecording();
+
+ SkBitmap bitmap;
+ bitmap.setConfig(fConfig, fGM->width(), fGM->height());
+ bitmap.allocPixels();
+ bitmap.eraseColor(0x00000000);
+
+ SkCanvas replay(bitmap);
+ replay.drawPicture(picture);
+ replay.flush();
+
+ const skiagm::GmResultDigest replayDigest(bitmap);
+ if (!replayDigest.equals(fReference)) {
+ this->fail();
+ }
+}
+
+bool ReplayTask::shouldSkip() const {
+ return fGM->getFlags() & skiagm::GM::kGPUOnly_Flag ||
+ fGM->getFlags() & skiagm::GM::kSkipPicture_Flag;
+}
+
+} // namespace
« no previous file with comments | « dm/DMReplayTask.h ('k') | dm/DMReporter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698