blob: a0ecf5fadf7812e282b1a8a7b745a698204fda77 [file] [log] [blame]
mtklein@google.comd36522d2013-10-16 13:02:15 +00001#include "DMReplayTask.h"
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +00002#include "DMWriteTask.h"
mtklein@google.comd36522d2013-10-16 13:02:15 +00003#include "DMUtil.h"
4
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +00005#include "SkCommandLineFlags.h"
mtklein@google.comd36522d2013-10-16 13:02:15 +00006#include "SkPicture.h"
7
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +00008DEFINE_bool(replay, false, "If true, run picture replay tests.");
9
mtklein@google.comd36522d2013-10-16 13:02:15 +000010namespace DM {
11
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +000012ReplayTask::ReplayTask(const Task& parent,
mtklein@google.comd36522d2013-10-16 13:02:15 +000013 skiagm::GM* gm,
commit-bot@chromium.org66bb3d12013-10-16 19:13:38 +000014 SkBitmap reference)
mtklein@google.comd36522d2013-10-16 13:02:15 +000015 : Task(parent)
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +000016 , fName(UnderJoin(parent.name().c_str(), "replay"))
mtklein@google.comd36522d2013-10-16 13:02:15 +000017 , fGM(gm)
18 , fReference(reference)
mtklein@google.comd36522d2013-10-16 13:02:15 +000019 {}
20
21void ReplayTask::draw() {
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +000022 SkPicture recorded;
23 RecordPicture(fGM.get(), &recorded);
mtklein@google.comd36522d2013-10-16 13:02:15 +000024
25 SkBitmap bitmap;
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +000026 SetupBitmap(fReference.config(), fGM.get(), &bitmap);
27 DrawPicture(&recorded, &bitmap);
28 if (!BitmapsEqual(bitmap, fReference)) {
mtklein@google.comd36522d2013-10-16 13:02:15 +000029 this->fail();
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +000030 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
mtklein@google.comd36522d2013-10-16 13:02:15 +000031 }
32}
33
34bool ReplayTask::shouldSkip() const {
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +000035 return !FLAGS_replay || fGM->getFlags() & skiagm::GM::kSkipPicture_Flag;
mtklein@google.comd36522d2013-10-16 13:02:15 +000036}
37
mtklein@google.coma7a9f372013-10-18 20:52:44 +000038} // namespace DM