2013-10-16 17:02:15 +04:00
|
|
|
#include "DMReplayTask.h"
|
2013-10-21 22:40:25 +04:00
|
|
|
#include "DMWriteTask.h"
|
2013-10-16 17:02:15 +04:00
|
|
|
#include "DMUtil.h"
|
|
|
|
|
2013-10-21 22:40:25 +04:00
|
|
|
#include "SkCommandLineFlags.h"
|
2013-10-16 17:02:15 +04:00
|
|
|
#include "SkPicture.h"
|
|
|
|
|
2013-12-02 17:36:22 +04:00
|
|
|
DEFINE_bool(replay, false, "If true, run picture replay tests.");
|
|
|
|
DEFINE_bool(rtree, false, "If true, run picture replay tests with an rtree.");
|
2013-10-21 22:40:25 +04:00
|
|
|
|
2013-10-16 17:02:15 +04:00
|
|
|
namespace DM {
|
|
|
|
|
2013-10-21 22:40:25 +04:00
|
|
|
ReplayTask::ReplayTask(const Task& parent,
|
2013-10-16 17:02:15 +04:00
|
|
|
skiagm::GM* gm,
|
2013-10-31 00:45:28 +04:00
|
|
|
SkBitmap reference,
|
|
|
|
bool useRTree)
|
2013-10-16 17:02:15 +04:00
|
|
|
: Task(parent)
|
2013-10-31 00:45:28 +04:00
|
|
|
, fName(UnderJoin(parent.name().c_str(), useRTree ? "rtree" : "replay"))
|
2013-10-16 17:02:15 +04:00
|
|
|
, fGM(gm)
|
|
|
|
, fReference(reference)
|
2013-10-31 00:45:28 +04:00
|
|
|
, fUseRTree(useRTree)
|
2013-10-16 17:02:15 +04:00
|
|
|
{}
|
|
|
|
|
|
|
|
void ReplayTask::draw() {
|
2013-10-21 22:40:25 +04:00
|
|
|
SkPicture recorded;
|
2013-10-31 00:45:28 +04:00
|
|
|
const uint32_t flags = fUseRTree ? SkPicture::kOptimizeForClippedPlayback_RecordingFlag : 0;
|
|
|
|
RecordPicture(fGM.get(), &recorded, flags);
|
2013-10-16 17:02:15 +04:00
|
|
|
|
|
|
|
SkBitmap bitmap;
|
2013-10-21 22:40:25 +04:00
|
|
|
SetupBitmap(fReference.config(), fGM.get(), &bitmap);
|
|
|
|
DrawPicture(&recorded, &bitmap);
|
|
|
|
if (!BitmapsEqual(bitmap, fReference)) {
|
2013-10-16 17:02:15 +04:00
|
|
|
this->fail();
|
2013-10-21 22:40:25 +04:00
|
|
|
this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
|
2013-10-16 17:02:15 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ReplayTask::shouldSkip() const {
|
2013-10-31 00:45:28 +04:00
|
|
|
if (fGM->getFlags() & skiagm::GM::kSkipPicture_Flag) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FLAGS_rtree && fUseRTree) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (FLAGS_replay && !fUseRTree) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2013-10-16 17:02:15 +04:00
|
|
|
}
|
|
|
|
|
2013-10-19 00:52:44 +04:00
|
|
|
} // namespace DM
|