aboutsummaryrefslogtreecommitdiffhomepage
path: root/dm
diff options
context:
space:
mode:
authorGravatar mtklein@google.com <mtklein@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-11-26 18:52:31 +0000
committerGravatar mtklein@google.com <mtklein@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-11-26 18:52:31 +0000
commitee21a3e395298021ca70e0d72bf2d983b2fc9225 (patch)
tree68d216f1101e0cf43e45f1f43eac9519856e932e /dm
parentd7255b6ae43f1931d5ec086fe4e92a664e28ab6f (diff)
DM: some refactoring
- rename ComparisonTask to ChecksumTask - have ChecksumTask handle all the checksum-checking - turn on all extra modes by default - simplify progress output to a countdown BUG= R=bsalomon@google.com Review URL: https://codereview.chromium.org/88543002 git-svn-id: http://skia.googlecode.com/svn/trunk@12398 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'dm')
-rw-r--r--dm/DMChecksumTask.cpp26
-rw-r--r--dm/DMChecksumTask.h (renamed from dm/DMComparisonTask.h)15
-rw-r--r--dm/DMComparisonTask.cpp21
-rw-r--r--dm/DMCpuTask.cpp22
-rw-r--r--dm/DMGpuTask.cpp6
-rw-r--r--dm/DMPipeTask.cpp2
-rw-r--r--dm/DMReplayTask.cpp4
-rw-r--r--dm/DMReporter.cpp2
-rw-r--r--dm/DMSerializeTask.cpp2
-rw-r--r--dm/DMUtil.cpp16
-rw-r--r--dm/DMUtil.h3
11 files changed, 56 insertions, 63 deletions
diff --git a/dm/DMChecksumTask.cpp b/dm/DMChecksumTask.cpp
new file mode 100644
index 0000000000..0d9dce7fd1
--- /dev/null
+++ b/dm/DMChecksumTask.cpp
@@ -0,0 +1,26 @@
+#include "DMChecksumTask.h"
+#include "DMUtil.h"
+
+namespace DM {
+
+ChecksumTask::ChecksumTask(const Task& parent,
+ skiagm::Expectations expectations,
+ SkBitmap bitmap)
+ : Task(parent)
+ , fName(parent.name()) // Masquerade as parent so failures are attributed to it.
+ , fExpectations(expectations)
+ , fBitmap(bitmap)
+ {}
+
+void ChecksumTask::draw() {
+ if (fExpectations.ignoreFailure() || fExpectations.empty()) {
+ return;
+ }
+
+ const skiagm::GmResultDigest digest(fBitmap);
+ if (!fExpectations.match(digest)) {
+ this->fail();
+ }
+}
+
+} // namespace DM
diff --git a/dm/DMComparisonTask.h b/dm/DMChecksumTask.h
index 265a58ce32..b0afac9467 100644
--- a/dm/DMComparisonTask.h
+++ b/dm/DMChecksumTask.h
@@ -1,5 +1,5 @@
-#ifndef DMComparisonTask_DEFINED
-#define DMComparisonTask_DEFINED
+#ifndef DMChecksumTask_DEFINED
+#define DMChecksumTask_DEFINED
#include "DMTask.h"
#include "SkBitmap.h"
@@ -8,12 +8,11 @@
namespace DM {
-// We use ComparisonTask to move CPU-bound comparison work of GpuTasks back to
-// the main thread pool, where we probably have more threads available.
-
-class ComparisonTask : public Task {
+// ChecksumTask compares an SkBitmap against some Expectations.
+// Moving this off the GPU threadpool is a nice (~30%) runtime win.
+class ChecksumTask : public Task {
public:
- ComparisonTask(const Task& parent, skiagm::Expectations, SkBitmap);
+ ChecksumTask(const Task& parent, skiagm::Expectations, SkBitmap);
virtual void draw() SK_OVERRIDE;
virtual bool usesGpu() const SK_OVERRIDE { return false; }
@@ -28,4 +27,4 @@ private:
} // namespace DM
-#endif // DMComparisonTask_DEFINED
+#endif // DMChecksumTask_DEFINED
diff --git a/dm/DMComparisonTask.cpp b/dm/DMComparisonTask.cpp
deleted file mode 100644
index bb4e656754..0000000000
--- a/dm/DMComparisonTask.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-#include "DMComparisonTask.h"
-#include "DMUtil.h"
-
-namespace DM {
-
-ComparisonTask::ComparisonTask(const Task& parent,
- skiagm::Expectations expectations,
- SkBitmap bitmap)
- : Task(parent)
- , fName(parent.name()) // Masquerade as parent so failures are attributed to it.
- , fExpectations(expectations)
- , fBitmap(bitmap)
- {}
-
-void ComparisonTask::draw() {
- if (!MeetsExpectations(fExpectations, fBitmap)) {
- this->fail();
- }
-}
-
-} // namespace DM
diff --git a/dm/DMCpuTask.cpp b/dm/DMCpuTask.cpp
index 1d1d4010f7..263e55667e 100644
--- a/dm/DMCpuTask.cpp
+++ b/dm/DMCpuTask.cpp
@@ -1,4 +1,5 @@
#include "DMCpuTask.h"
+#include "DMChecksumTask.h"
#include "DMPipeTask.h"
#include "DMReplayTask.h"
#include "DMSerializeTask.h"
@@ -30,19 +31,20 @@ void CpuTask::draw() {
fGM->draw(&canvas);
canvas.flush();
- if (!MeetsExpectations(fExpectations, bitmap)) {
- this->fail();
- }
+#define SPAWN(ChildTask, ...) this->spawnChild(SkNEW_ARGS(ChildTask, (*this, __VA_ARGS__)))
+ SPAWN(ChecksumTask, fExpectations, bitmap);
+
+ SPAWN(PipeTask, fGMFactory(NULL), bitmap, false, false);
+ SPAWN(PipeTask, fGMFactory(NULL), bitmap, true, false);
+ SPAWN(PipeTask, fGMFactory(NULL), bitmap, true, true);
- this->spawnChild(SkNEW_ARGS(PipeTask, (*this, fGMFactory(NULL), bitmap, false, false)));
- this->spawnChild(SkNEW_ARGS(PipeTask, (*this, fGMFactory(NULL), bitmap, true, false)));
- this->spawnChild(SkNEW_ARGS(PipeTask, (*this, fGMFactory(NULL), bitmap, true, true)));
+ SPAWN(ReplayTask, fGMFactory(NULL), bitmap, false);
+ SPAWN(ReplayTask, fGMFactory(NULL), bitmap, true);
- this->spawnChild(SkNEW_ARGS(ReplayTask, (*this, fGMFactory(NULL), bitmap, true)));
- this->spawnChild(SkNEW_ARGS(ReplayTask, (*this, fGMFactory(NULL), bitmap, false)));
+ SPAWN(SerializeTask, fGMFactory(NULL), bitmap);
- this->spawnChild(SkNEW_ARGS(SerializeTask, (*this, fGMFactory(NULL), bitmap)));
- this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
+ SPAWN(WriteTask, bitmap);
+#undef SPAWN
}
bool CpuTask::shouldSkip() const {
diff --git a/dm/DMGpuTask.cpp b/dm/DMGpuTask.cpp
index 4d99356237..d4c4254c62 100644
--- a/dm/DMGpuTask.cpp
+++ b/dm/DMGpuTask.cpp
@@ -1,6 +1,6 @@
#include "DMGpuTask.h"
-#include "DMComparisonTask.h"
+#include "DMChecksumTask.h"
#include "DMUtil.h"
#include "DMWriteTask.h"
#include "SkCommandLineFlags.h"
@@ -60,9 +60,7 @@ void GpuTask::draw() {
gr->printCacheStats();
#endif
- // We offload checksum comparison to the main CPU threadpool.
- // This cuts run time by about 30%.
- this->spawnChild(SkNEW_ARGS(ComparisonTask, (*this, fExpectations, bitmap)));
+ this->spawnChild(SkNEW_ARGS(ChecksumTask, (*this, fExpectations, bitmap)));
this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
}
diff --git a/dm/DMPipeTask.cpp b/dm/DMPipeTask.cpp
index 8a8fe62000..de3897a898 100644
--- a/dm/DMPipeTask.cpp
+++ b/dm/DMPipeTask.cpp
@@ -6,7 +6,7 @@
#include "SkCommandLineFlags.h"
#include "SkGPipe.h"
-DEFINE_bool(pipe, false, "If true, check several pipe variants against the reference bitmap.");
+DEFINE_bool(pipe, true, "If true, check several pipe variants against the reference bitmap.");
namespace DM {
diff --git a/dm/DMReplayTask.cpp b/dm/DMReplayTask.cpp
index 0ec9e250d9..af8669b7d1 100644
--- a/dm/DMReplayTask.cpp
+++ b/dm/DMReplayTask.cpp
@@ -5,8 +5,8 @@
#include "SkCommandLineFlags.h"
#include "SkPicture.h"
-DEFINE_bool(replay, false, "If true, run picture replay tests.");
-DEFINE_bool(rtree, false, "If true, run picture replay tests with an rtree.");
+DEFINE_bool(replay, true, "If true, run picture replay tests.");
+DEFINE_bool(rtree, true, "If true, run picture replay tests with an rtree.");
namespace DM {
diff --git a/dm/DMReporter.cpp b/dm/DMReporter.cpp
index 0e01d71f20..31310d1cd9 100644
--- a/dm/DMReporter.cpp
+++ b/dm/DMReporter.cpp
@@ -12,7 +12,7 @@ void Reporter::updateStatusLine() const {
}
SkString status;
- status.printf("\r\033[K%d / %d", this->finished(), this->started());
+ status.printf("\r\033[K%d tasks left", this->started() - this->finished());
const int failed = this->failed();
if (failed > 0) {
status.appendf(", %d failed", failed);
diff --git a/dm/DMSerializeTask.cpp b/dm/DMSerializeTask.cpp
index d71dfdccfa..8bc8c8ef98 100644
--- a/dm/DMSerializeTask.cpp
+++ b/dm/DMSerializeTask.cpp
@@ -6,7 +6,7 @@
#include "SkPicture.h"
#include "SkPixelRef.h"
-DEFINE_bool(serialize, false, "If true, run picture serialization tests.");
+DEFINE_bool(serialize, true, "If true, run picture serialization tests.");
namespace DM {
diff --git a/dm/DMUtil.cpp b/dm/DMUtil.cpp
index d5214849e6..6cf6c22e2a 100644
--- a/dm/DMUtil.cpp
+++ b/dm/DMUtil.cpp
@@ -15,18 +15,9 @@ SkString Png(SkString s) {
return s;
}
-bool MeetsExpectations(const skiagm::Expectations& expectations, const SkBitmap bitmap) {
- if (expectations.ignoreFailure() || expectations.empty()) {
- return true;
- }
- const skiagm::GmResultDigest digest(bitmap);
- return expectations.match(digest);
-}
-
void RecordPicture(skiagm::GM* gm, SkPicture* picture, uint32_t recordFlags) {
- SkCanvas* canvas = picture->beginRecording(SkScalarCeilToInt(gm->width()),
- SkScalarCeilToInt(gm->height()),
- recordFlags);
+ const SkISize size = gm->getISize();
+ SkCanvas* canvas = picture->beginRecording(size.width(), size.height(), recordFlags);
canvas->concat(gm->getInitialTransform());
gm->draw(canvas);
canvas->flush();
@@ -34,7 +25,8 @@ void RecordPicture(skiagm::GM* gm, SkPicture* picture, uint32_t recordFlags) {
}
void SetupBitmap(const SkBitmap::Config config, skiagm::GM* gm, SkBitmap* bitmap) {
- bitmap->setConfig(config, SkScalarCeilToInt(gm->width()), SkScalarCeilToInt(gm->height()));
+ const SkISize size = gm->getISize();
+ bitmap->setConfig(config, size.width(), size.height());
bitmap->allocPixels();
bitmap->eraseColor(0x00000000);
}
diff --git a/dm/DMUtil.h b/dm/DMUtil.h
index 512ad64eb6..5f22df0878 100644
--- a/dm/DMUtil.h
+++ b/dm/DMUtil.h
@@ -15,9 +15,6 @@ SkString UnderJoin(const char* a, const char* b);
// Png("a") -> "a.png"
SkString Png(SkString s);
-// Roughly, expectations.match(GmResultDigest(bitmap)), but calculates the digest lazily.
-bool MeetsExpectations(const skiagm::Expectations& expectations, const SkBitmap bitmap);
-
// Draw gm to picture. Passes recordFlags to SkPicture::beginRecording().
void RecordPicture(skiagm::GM* gm, SkPicture* picture, uint32_t recordFlags = 0);