2013-10-16 13:02:15 +00:00
|
|
|
#include "DMReplayTask.h"
|
2013-10-21 18:40:25 +00:00
|
|
|
#include "DMWriteTask.h"
|
2013-10-16 13:02:15 +00:00
|
|
|
#include "DMUtil.h"
|
|
|
|
|
2013-10-21 18:40:25 +00:00
|
|
|
#include "SkCommandLineFlags.h"
|
2013-10-16 13:02:15 +00:00
|
|
|
#include "SkPicture.h"
|
|
|
|
|
2013-10-21 18:40:25 +00:00
|
|
|
DEFINE_bool(replay, false, "If true, run picture replay tests.");
|
|
|
|
|
2013-10-16 13:02:15 +00:00
|
|
|
namespace DM {
|
|
|
|
|
2013-10-21 18:40:25 +00:00
|
|
|
ReplayTask::ReplayTask(const Task& parent,
|
2013-10-16 13:02:15 +00:00
|
|
|
skiagm::GM* gm,
|
2013-10-16 19:13:38 +00:00
|
|
|
SkBitmap reference)
|
2013-10-16 13:02:15 +00:00
|
|
|
: Task(parent)
|
2013-10-21 18:40:25 +00:00
|
|
|
, fName(UnderJoin(parent.name().c_str(), "replay"))
|
2013-10-16 13:02:15 +00:00
|
|
|
, fGM(gm)
|
|
|
|
, fReference(reference)
|
|
|
|
{}
|
|
|
|
|
|
|
|
void ReplayTask::draw() {
|
2013-10-21 18:40:25 +00:00
|
|
|
SkPicture recorded;
|
|
|
|
RecordPicture(fGM.get(), &recorded);
|
2013-10-16 13:02:15 +00:00
|
|
|
|
|
|
|
SkBitmap bitmap;
|
2013-10-21 18:40:25 +00:00
|
|
|
SetupBitmap(fReference.config(), fGM.get(), &bitmap);
|
|
|
|
DrawPicture(&recorded, &bitmap);
|
|
|
|
if (!BitmapsEqual(bitmap, fReference)) {
|
2013-10-16 13:02:15 +00:00
|
|
|
this->fail();
|
2013-10-21 18:40:25 +00:00
|
|
|
this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
|
2013-10-16 13:02:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ReplayTask::shouldSkip() const {
|
2013-10-21 18:40:25 +00:00
|
|
|
return !FLAGS_replay || fGM->getFlags() & skiagm::GM::kSkipPicture_Flag;
|
2013-10-16 13:02:15 +00:00
|
|
|
}
|
|
|
|
|
2013-10-18 20:52:44 +00:00
|
|
|
} // namespace DM
|