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

Unified Diff: dm/DMCpuTask.cpp

Issue 22839016: Skeleton of DM (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: missed one 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
Index: dm/DMCpuTask.cpp
diff --git a/dm/DMCpuTask.cpp b/dm/DMCpuTask.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8aa40ea150df9a083a6f0981c8838f7df66153bc
--- /dev/null
+++ b/dm/DMCpuTask.cpp
@@ -0,0 +1,54 @@
+#include "DMCpuTask.h"
+#include "DMReplayTask.h"
+#include "DMUtil.h"
+#include "SkCommandLineFlags.h"
+
+DEFINE_bool(replay, false, "If true, run replay tests for each CpuTask.");
+// TODO(mtklein): add the other various options
+
+namespace DM {
+
+CpuTask::CpuTask(const char* name,
+ Reporter* reporter,
+ TaskRunner* taskRunner,
+ const skiagm::ExpectationsSource& expectations,
+ skiagm::GMRegistry::Factory gmFactory,
+ SkBitmap::Config config)
+ : Task(reporter, taskRunner)
+ , fGMFactory(gmFactory)
+ , fGM(fGMFactory(NULL))
+ , fName(underJoin(fGM->shortName(), name))
+ , fExpectations(expectations.get(png(fName).c_str()))
+ , fConfig(config)
+ {}
+
+void CpuTask::draw() {
+ SkBitmap bitmap;
+ bitmap.setConfig(fConfig, fGM->width(), fGM->height());
+ bitmap.allocPixels();
+ bitmap.eraseColor(0x00000000);
+ SkCanvas canvas(bitmap);
+
+ canvas.concat(fGM->getInitialTransform());
+ fGM->draw(&canvas);
+ canvas.flush();
+
+ const skiagm::GmResultDigest digest(bitmap);
+ if (!meetsExpectations(fExpectations, digest)) {
+ this->fail();
epoger 2013/10/11 21:13:13 So, are different types of failures (no_comparison
mtklein 2013/10/15 18:30:53 Ah, good catch. I intended to count failures but
+ }
+
+ if (FLAGS_replay) {
+ this->spawnChild(SkNEW_ARGS(ReplayTask,
+ ("replay", *this, fGMFactory(NULL), digest, fConfig)));
+ }
+}
+
+bool CpuTask::shouldSkip() const {
+ if (SkBitmap::kRGB_565_Config == fConfig && (fGM->getFlags() & skiagm::GM::kSkip565_Flag)) {
epoger 2013/10/11 21:13:13 Why is this the only config we check whether to sk
mtklein 2013/10/15 18:30:53 Hmm. Looks like I was being a little cute here.
epoger 2013/10/15 18:52:37 Easier to follow now, thanks.
+ return true;
+ }
+ return fGM->getFlags() & skiagm::GM::kGPUOnly_Flag;
+}
+
+} // namespace DM

Powered by Google App Engine
This is Rietveld 408576698