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

Unified Diff: dm/DMReplayTask.cpp

Issue 32613003: DM: add --serialize (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: no-find-copies 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/DMSerializeTask.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
index 0d6780ef4200b13e119efb7539b45ef2ffdec60c..a0ecf5fadf7812e282b1a8a7b745a698204fda77 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
« no previous file with comments | « dm/DMReplayTask.h ('k') | dm/DMSerializeTask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698