aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-16 19:13:38 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-16 19:13:38 +0000
commit66bb3d1f5e451f8501f5c28d1dc28fcef6e908e1 (patch)
tree74f5b572abe176fdc61abae703fa1747437d9587
parent4cc18156c2f998135eaff6eea7a8a0696dc98ec9 (diff)
DM: duh, don't calculate digests unless we're going to look at them.
This doesn't cut the runtime significantly (~6s either way) but it does cut the CPU time down from ~10s to ~6s. BUG= R=bungeman@google.com Author: mtklein@google.com Review URL: https://codereview.chromium.org/27476007 git-svn-id: http://skia.googlecode.com/svn/trunk@11826 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--dm/DMComparisonTask.cpp3
-rw-r--r--dm/DMCpuTask.cpp5
-rw-r--r--dm/DMReplayTask.cpp14
-rw-r--r--dm/DMReplayTask.h8
-rw-r--r--dm/DMUtil.cpp11
-rw-r--r--dm/DMUtil.h6
6 files changed, 23 insertions, 24 deletions
diff --git a/dm/DMComparisonTask.cpp b/dm/DMComparisonTask.cpp
index f4f742c921..24976f011d 100644
--- a/dm/DMComparisonTask.cpp
+++ b/dm/DMComparisonTask.cpp
@@ -13,8 +13,7 @@ ComparisonTask::ComparisonTask(const Task& parent,
{}
void ComparisonTask::draw() {
- const skiagm::GmResultDigest digest(fBitmap);
- if (!meetsExpectations(fExpectations, digest)) {
+ if (!meetsExpectations(fExpectations, fBitmap)) {
this->fail();
}
}
diff --git a/dm/DMCpuTask.cpp b/dm/DMCpuTask.cpp
index 544f73c4c1..14f661ac38 100644
--- a/dm/DMCpuTask.cpp
+++ b/dm/DMCpuTask.cpp
@@ -33,14 +33,13 @@ void CpuTask::draw() {
fGM->draw(&canvas);
canvas.flush();
- const skiagm::GmResultDigest digest(bitmap);
- if (!meetsExpectations(fExpectations, digest)) {
+ if (!meetsExpectations(fExpectations, bitmap)) {
this->fail();
}
if (FLAGS_replay) {
this->spawnChild(SkNEW_ARGS(ReplayTask,
- ("replay", *this, fGMFactory(NULL), digest, fConfig)));
+ ("replay", *this, fGMFactory(NULL), bitmap)));
}
}
diff --git a/dm/DMReplayTask.cpp b/dm/DMReplayTask.cpp
index 7e183f6cbd..e5f392cee4 100644
--- a/dm/DMReplayTask.cpp
+++ b/dm/DMReplayTask.cpp
@@ -8,13 +8,11 @@ namespace DM {
ReplayTask::ReplayTask(const char* suffix,
const Task& parent,
skiagm::GM* gm,
- skiagm::GmResultDigest reference,
- SkBitmap::Config config)
+ SkBitmap reference)
: Task(parent)
, fName(underJoin(parent.name().c_str(), suffix))
, fGM(gm)
, fReference(reference)
- , fConfig(config)
{}
void ReplayTask::draw() {
@@ -30,7 +28,9 @@ void ReplayTask::draw() {
picture.endRecording();
SkBitmap bitmap;
- bitmap.setConfig(fConfig, SkScalarCeilToInt(fGM->width()), SkScalarCeilToInt(fGM->height()));
+ bitmap.setConfig(fReference.config(),
+ SkScalarCeilToInt(fGM->width()),
+ SkScalarCeilToInt(fGM->height()));
bitmap.allocPixels();
bitmap.eraseColor(0x00000000);
@@ -38,8 +38,10 @@ void ReplayTask::draw() {
replay.drawPicture(picture);
replay.flush();
- const skiagm::GmResultDigest replayDigest(bitmap);
- if (!replayDigest.equals(fReference)) {
+ const SkAutoLockPixels mine(bitmap), theirs(fReference);
+ if (bitmap.getSize() != fReference.getSize() ||
+ 0 != memcmp(bitmap.getPixels(), fReference.getPixels(), bitmap.getSize()))
+ {
this->fail();
}
}
diff --git a/dm/DMReplayTask.h b/dm/DMReplayTask.h
index 0ed9351c13..6a96373f72 100644
--- a/dm/DMReplayTask.h
+++ b/dm/DMReplayTask.h
@@ -10,7 +10,7 @@
#include "gm.h"
#include "gm_expectations.h"
-// Records a GM through an SkPicture, draws it, and compares against the reference checksum.
+// Records a GM through an SkPicture, draws it, and compares against the reference bitmap.
namespace DM {
@@ -20,8 +20,7 @@ public:
ReplayTask(const char* name,
const Task& parent,
skiagm::GM*,
- skiagm::GmResultDigest reference,
- SkBitmap::Config);
+ SkBitmap reference);
virtual void draw() SK_OVERRIDE;
virtual bool usesGpu() const SK_OVERRIDE { return false; }
@@ -31,8 +30,7 @@ public:
private:
const SkString fName;
SkAutoTDelete<skiagm::GM> fGM;
- const skiagm::GmResultDigest fReference;
- const SkBitmap::Config fConfig;
+ const SkBitmap fReference;
};
} // namespace DM
diff --git a/dm/DMUtil.cpp b/dm/DMUtil.cpp
index 803c338adc..dc652ebdbe 100644
--- a/dm/DMUtil.cpp
+++ b/dm/DMUtil.cpp
@@ -13,11 +13,12 @@ SkString png(SkString s) {
return s;
}
-bool meetsExpectations(const skiagm::Expectations& expectations,
- const skiagm::GmResultDigest& digest) {
- return expectations.ignoreFailure()
- || expectations.empty()
- || expectations.match(digest);
+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);
}
} // namespace DM
diff --git a/dm/DMUtil.h b/dm/DMUtil.h
index e808ca0f8f..c95f93346a 100644
--- a/dm/DMUtil.h
+++ b/dm/DMUtil.h
@@ -1,6 +1,7 @@
#ifndef DMUtil_DEFINED
#define DMUtil_DEFINED
+#include "SkBitmap.h"
#include "SkString.h"
#include "gm_expectations.h"
@@ -14,9 +15,8 @@ SkString underJoin(const char* a, const char* b);
// png("a") -> "a.png"
SkString png(SkString s);
-// Roughly, expectations.match(digest), but only does it if we're not ignoring the result.
-bool meetsExpectations(const skiagm::Expectations& expectations,
- const skiagm::GmResultDigest& digest);
+// Roughly, expectations.match(GmResultDigest(bitmap)), but calculates the digest lazily.
+bool meetsExpectations(const skiagm::Expectations& expectations, const SkBitmap bitmap);
} // namespace DM