Chromium Code Reviews| 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 |
| 13 static const char* kReplay = "replay"; | |
| 14 static const char* kRTree = "rtree"; | |
| 15 | |
| 16 static const char* flags_name(uint32_t flags) { | |
| 17 switch (flags) { | |
| 18 case 0: return kRepla y; | |
| 19 case SkPicture::kOptimizeForClippedPlayback_RecordingFlag: return kRTree ; | |
| 20 default: return "hey-g ive-me-a-name"; | |
|
epoger
2013/10/30 19:37:01
maybe SkASSERT failure in this case?
| |
| 21 } | |
| 22 } | |
| 23 | |
| 12 ReplayTask::ReplayTask(const Task& parent, | 24 ReplayTask::ReplayTask(const Task& parent, |
| 13 skiagm::GM* gm, | 25 skiagm::GM* gm, |
| 14 SkBitmap reference) | 26 SkBitmap reference, |
| 27 uint32_t recordFlags) | |
| 15 : Task(parent) | 28 : Task(parent) |
| 16 , fName(UnderJoin(parent.name().c_str(), "replay")) | 29 , fName(UnderJoin(parent.name().c_str(), flags_name(recordFlags))) |
| 17 , fGM(gm) | 30 , fGM(gm) |
| 18 , fReference(reference) | 31 , fReference(reference) |
| 32 , fRecordFlags(recordFlags) | |
| 19 {} | 33 {} |
| 20 | 34 |
| 21 void ReplayTask::draw() { | 35 void ReplayTask::draw() { |
| 22 SkPicture recorded; | 36 SkPicture recorded; |
| 23 RecordPicture(fGM.get(), &recorded); | 37 RecordPicture(fGM.get(), &recorded, fRecordFlags); |
| 24 | 38 |
| 25 SkBitmap bitmap; | 39 SkBitmap bitmap; |
| 26 SetupBitmap(fReference.config(), fGM.get(), &bitmap); | 40 SetupBitmap(fReference.config(), fGM.get(), &bitmap); |
| 27 DrawPicture(&recorded, &bitmap); | 41 DrawPicture(&recorded, &bitmap); |
| 28 if (!BitmapsEqual(bitmap, fReference)) { | 42 if (!BitmapsEqual(bitmap, fReference)) { |
| 29 this->fail(); | 43 this->fail(); |
| 30 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); | 44 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); |
| 31 } | 45 } |
| 32 } | 46 } |
| 33 | 47 |
| 34 bool ReplayTask::shouldSkip() const { | 48 bool ReplayTask::shouldSkip() const { |
| 35 return !FLAGS_replay || fGM->getFlags() & skiagm::GM::kSkipPicture_Flag; | 49 if (fGM->getFlags() & skiagm::GM::kSkipPicture_Flag) { |
| 50 return true; | |
| 51 } | |
| 52 | |
| 53 if (FLAGS_rtree && flags_name(fRecordFlags) == kRTree) { | |
|
epoger
2013/10/30 19:37:01
It seems very strange to me that we change code pa
| |
| 54 return false; | |
|
epoger
2013/10/30 19:37:01
Maybe it's just me, but I would find it easier to
| |
| 55 } | |
| 56 if (FLAGS_replay && flags_name(fRecordFlags) == kReplay) { | |
|
epoger
2013/10/30 19:37:01
Here and above, please put in more parentheses. N
| |
| 57 return false; | |
| 58 } | |
| 59 return true; | |
| 36 } | 60 } |
| 37 | 61 |
| 38 } // namespace DM | 62 } // namespace DM |
| OLD | NEW |