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"
|
|
|
|
|
2014-04-18 18:04:41 +00:00
|
|
|
#include "SkBBHFactory.h"
|
2013-10-21 18:40:25 +00:00
|
|
|
#include "SkCommandLineFlags.h"
|
2013-10-16 13:02:15 +00:00
|
|
|
#include "SkPicture.h"
|
|
|
|
|
2013-12-02 13:50:38 +00:00
|
|
|
DEFINE_bool(replay, true, "If true, run picture replay tests.");
|
|
|
|
DEFINE_bool(rtree, true, "If true, run picture replay tests with an rtree.");
|
2013-10-21 18:40:25 +00:00
|
|
|
|
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-30 20:45:28 +00:00
|
|
|
SkBitmap reference,
|
2014-05-14 17:55:32 +00:00
|
|
|
Mode mode)
|
2014-02-28 20:31:31 +00:00
|
|
|
: CpuTask(parent)
|
2014-05-14 17:55:32 +00:00
|
|
|
, fUseRTree(mode == kRTree_Mode)
|
|
|
|
, fName(UnderJoin(parent.name().c_str(), fUseRTree ? "rtree" : "replay"))
|
2013-10-16 13:02:15 +00:00
|
|
|
, fGM(gm)
|
|
|
|
, fReference(reference)
|
|
|
|
{}
|
|
|
|
|
|
|
|
void ReplayTask::draw() {
|
2014-04-17 23:35:06 +00:00
|
|
|
SkAutoTDelete<SkBBHFactory> factory;
|
2014-04-16 16:02:10 +00:00
|
|
|
if (fUseRTree) {
|
2014-04-17 23:35:06 +00:00
|
|
|
factory.reset(SkNEW(SkRTreeFactory));
|
2014-04-16 16:02:10 +00:00
|
|
|
}
|
2014-04-17 23:35:06 +00:00
|
|
|
SkAutoTUnref<SkPicture> recorded(RecordPicture(fGM.get(), 0, factory.get()));
|
2013-10-16 13:02:15 +00:00
|
|
|
|
|
|
|
SkBitmap bitmap;
|
2014-05-15 17:33:31 +00:00
|
|
|
AllocatePixels(fReference, &bitmap);
|
2014-04-13 19:09:42 +00:00
|
|
|
DrawPicture(recorded, &bitmap);
|
2013-10-21 18:40:25 +00:00
|
|
|
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-30 20:45:28 +00:00
|
|
|
if (fGM->getFlags() & skiagm::GM::kSkipPicture_Flag) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FLAGS_rtree && fUseRTree) {
|
2014-04-29 16:44:00 +00:00
|
|
|
return false;
|
2013-10-30 20:45:28 +00:00
|
|
|
}
|
|
|
|
if (FLAGS_replay && !fUseRTree) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2013-10-16 13:02:15 +00:00
|
|
|
}
|
|
|
|
|
2013-10-18 20:52:44 +00:00
|
|
|
} // namespace DM
|