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