aboutsummaryrefslogtreecommitdiffhomepage
path: root/dm/DMReplayTask.cpp
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-21 18:40:25 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-21 18:40:25 +0000
commit192cbf67b281b20477320134962d554ed823c691 (patch)
tree33778f1bb896b7dd9656cc4d19f916beb2b1e517 /dm/DMReplayTask.cpp
parentad6d35bbf94119108f8e2176fecfeb17f108bd50 (diff)
DM: add --serialize
Plus: - minor ReplayTask refactoring to share code with SerializeTask - move --replay to ReplayTask and --serialize to SerializeTask like WriteTask - when --writePath is given, write failures for Replay and Serialize tasks - function names have fewer blatant Skia style violations BUG= R=bsalomon@google.com Author: mtklein@google.com Review URL: https://codereview.chromium.org/32613003 git-svn-id: http://skia.googlecode.com/svn/trunk@11890 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'dm/DMReplayTask.cpp')
-rw-r--r--dm/DMReplayTask.cpp42
1 files changed, 13 insertions, 29 deletions
diff --git a/dm/DMReplayTask.cpp b/dm/DMReplayTask.cpp
index 0d6780ef42..a0ecf5fadf 100644
--- a/dm/DMReplayTask.cpp
+++ b/dm/DMReplayTask.cpp
@@ -1,54 +1,38 @@
#include "DMReplayTask.h"
+#include "DMWriteTask.h"
#include "DMUtil.h"
+#include "SkCommandLineFlags.h"
#include "SkPicture.h"
+DEFINE_bool(replay, false, "If true, run picture replay tests.");
+
namespace DM {
-ReplayTask::ReplayTask(const char* suffix,
- const Task& parent,
+ReplayTask::ReplayTask(const Task& parent,
skiagm::GM* gm,
SkBitmap reference)
: Task(parent)
- , fName(underJoin(parent.name().c_str(), suffix))
+ , fName(UnderJoin(parent.name().c_str(), "replay"))
, fGM(gm)
, fReference(reference)
{}
void ReplayTask::draw() {
- SkPicture picture;
- SkCanvas* canvas = picture.beginRecording(SkScalarCeilToInt(fGM->width()),
- SkScalarCeilToInt(fGM->height()),
- 0 /*flags*/);
-
- canvas->concat(fGM->getInitialTransform());
- fGM->draw(canvas);
- canvas->flush();
-
- picture.endRecording();
+ SkPicture recorded;
+ RecordPicture(fGM.get(), &recorded);
SkBitmap bitmap;
- bitmap.setConfig(fReference.config(),
- SkScalarCeilToInt(fGM->width()),
- SkScalarCeilToInt(fGM->height()));
- bitmap.allocPixels();
- bitmap.eraseColor(0x00000000);
-
- SkCanvas replay(bitmap);
- replay.drawPicture(picture);
- replay.flush();
-
- const SkAutoLockPixels mine(bitmap), theirs(fReference);
- if (bitmap.getSize() != fReference.getSize() ||
- 0 != memcmp(bitmap.getPixels(), fReference.getPixels(), bitmap.getSize()))
- {
+ SetupBitmap(fReference.config(), fGM.get(), &bitmap);
+ DrawPicture(&recorded, &bitmap);
+ if (!BitmapsEqual(bitmap, fReference)) {
this->fail();
+ this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
}
}
bool ReplayTask::shouldSkip() const {
- return fGM->getFlags() & skiagm::GM::kGPUOnly_Flag ||
- fGM->getFlags() & skiagm::GM::kSkipPicture_Flag;
+ return !FLAGS_replay || fGM->getFlags() & skiagm::GM::kSkipPicture_Flag;
}
} // namespace DM