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-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,
|
|
|
|
bool useRTree)
|
2014-02-28 20:31:31 +00:00
|
|
|
: CpuTask(parent)
|
2013-10-30 20:45:28 +00:00
|
|
|
, fName(UnderJoin(parent.name().c_str(), useRTree ? "rtree" : "replay"))
|
2013-10-16 13:02:15 +00:00
|
|
|
, fGM(gm)
|
|
|
|
, fReference(reference)
|
2013-10-30 20:45:28 +00:00
|
|
|
, fUseRTree(useRTree)
|
2013-10-16 13:02:15 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
void ReplayTask::draw() {
|
2013-10-30 20:45:28 +00:00
|
|
|
const uint32_t flags = fUseRTree ? SkPicture::kOptimizeForClippedPlayback_RecordingFlag : 0;
|
2014-04-13 19:09:42 +00:00
|
|
|
SkAutoTUnref<SkPicture> recorded(RecordPicture(fGM.get(), flags));
|
2013-10-16 13:02:15 +00:00
|
|
|
|
|
|
|
SkBitmap bitmap;
|
2014-02-16 00:59:25 +00:00
|
|
|
SetupBitmap(fReference.colorType(), fGM.get(), &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-02-21 19:19:47 +00:00
|
|
|
return (fGM->getFlags() & skiagm::GM::kSkipTiled_Flag) != 0;
|
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
|