| OLD | NEW |
| 1 #include "DMReplayTask.h" | 1 #include "DMReplayTask.h" |
| 2 #include "DMWriteTask.h" | 2 #include "DMWriteTask.h" |
| 3 #include "DMUtil.h" | 3 #include "DMUtil.h" |
| 4 | 4 |
| 5 #include "SkCommandLineFlags.h" | 5 #include "SkCommandLineFlags.h" |
| 6 #include "SkPicture.h" | 6 #include "SkPicture.h" |
| 7 | 7 |
| 8 DEFINE_bool(replay, false, "If true, run picture replay tests."); | 8 DEFINE_bool(replay, false, "If true, run picture replay tests."); |
| 9 DEFINE_bool(rtree, false, "If true, run picture replay tests with an rtree."); |
| 9 | 10 |
| 10 namespace DM { | 11 namespace DM { |
| 11 | 12 |
| 12 ReplayTask::ReplayTask(const Task& parent, | 13 ReplayTask::ReplayTask(const Task& parent, |
| 13 skiagm::GM* gm, | 14 skiagm::GM* gm, |
| 14 SkBitmap reference) | 15 SkBitmap reference, |
| 16 bool useRTree) |
| 15 : Task(parent) | 17 : Task(parent) |
| 16 , fName(UnderJoin(parent.name().c_str(), "replay")) | 18 , fName(UnderJoin(parent.name().c_str(), useRTree ? "rtree" : "replay")) |
| 17 , fGM(gm) | 19 , fGM(gm) |
| 18 , fReference(reference) | 20 , fReference(reference) |
| 21 , fUseRTree(useRTree) |
| 19 {} | 22 {} |
| 20 | 23 |
| 21 void ReplayTask::draw() { | 24 void ReplayTask::draw() { |
| 22 SkPicture recorded; | 25 SkPicture recorded; |
| 23 RecordPicture(fGM.get(), &recorded); | 26 const uint32_t flags = fUseRTree ? SkPicture::kOptimizeForClippedPlayback_Re
cordingFlag : 0; |
| 27 RecordPicture(fGM.get(), &recorded, flags); |
| 24 | 28 |
| 25 SkBitmap bitmap; | 29 SkBitmap bitmap; |
| 26 SetupBitmap(fReference.config(), fGM.get(), &bitmap); | 30 SetupBitmap(fReference.config(), fGM.get(), &bitmap); |
| 27 DrawPicture(&recorded, &bitmap); | 31 DrawPicture(&recorded, &bitmap); |
| 28 if (!BitmapsEqual(bitmap, fReference)) { | 32 if (!BitmapsEqual(bitmap, fReference)) { |
| 29 this->fail(); | 33 this->fail(); |
| 30 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); | 34 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); |
| 31 } | 35 } |
| 32 } | 36 } |
| 33 | 37 |
| 34 bool ReplayTask::shouldSkip() const { | 38 bool ReplayTask::shouldSkip() const { |
| 35 return !FLAGS_replay || fGM->getFlags() & skiagm::GM::kSkipPicture_Flag; | 39 if (fGM->getFlags() & skiagm::GM::kSkipPicture_Flag) { |
| 40 return true; |
| 41 } |
| 42 |
| 43 if (FLAGS_rtree && fUseRTree) { |
| 44 return false; |
| 45 } |
| 46 if (FLAGS_replay && !fUseRTree) { |
| 47 return false; |
| 48 } |
| 49 return true; |
| 36 } | 50 } |
| 37 | 51 |
| 38 } // namespace DM | 52 } // namespace DM |
| OLD | NEW |