skia2/dm/DMReplayTask.cpp
commit-bot@chromium.org 96eb6243ca DM's rtree picture replay mode can ignore kSkippedTiled_Flag safely.
tested: out/Debug/dm && out/Release/dm

BUG=skia:2477
R=reed@google.com, mtklein@google.com

Author: mtklein@chromium.org

Review URL: https://codereview.chromium.org/253733006

git-svn-id: http://skia.googlecode.com/svn/trunk@14438 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-29 16:44:00 +00:00

56 lines
1.4 KiB
C++

#include "DMReplayTask.h"
#include "DMWriteTask.h"
#include "DMUtil.h"
#include "SkBBHFactory.h"
#include "SkCommandLineFlags.h"
#include "SkPicture.h"
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 {
ReplayTask::ReplayTask(const Task& parent,
skiagm::GM* gm,
SkBitmap reference,
bool useRTree)
: CpuTask(parent)
, fName(UnderJoin(parent.name().c_str(), useRTree ? "rtree" : "replay"))
, fGM(gm)
, fReference(reference)
, fUseRTree(useRTree)
{}
void ReplayTask::draw() {
SkAutoTDelete<SkBBHFactory> factory;
if (fUseRTree) {
factory.reset(SkNEW(SkRTreeFactory));
}
SkAutoTUnref<SkPicture> recorded(RecordPicture(fGM.get(), 0, factory.get()));
SkBitmap bitmap;
SetupBitmap(fReference.colorType(), fGM.get(), &bitmap);
DrawPicture(recorded, &bitmap);
if (!BitmapsEqual(bitmap, fReference)) {
this->fail();
this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
}
}
bool ReplayTask::shouldSkip() const {
if (fGM->getFlags() & skiagm::GM::kSkipPicture_Flag) {
return true;
}
if (FLAGS_rtree && fUseRTree) {
return false;
}
if (FLAGS_replay && !fUseRTree) {
return false;
}
return true;
}
} // namespace DM