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 "SkBBHFactory.h" | 5 #include "SkBBHFactory.h" |
| 6 #include "SkCommandLineFlags.h" | 6 #include "SkCommandLineFlags.h" |
| 7 #include "SkPicture.h" | 7 #include "SkPicture.h" |
| 8 | 8 |
| 9 DEFINE_bool(replay, true, "If true, run picture replay tests."); | 9 DEFINE_bool(replay, true, "If true, run picture replay tests."); |
| 10 DEFINE_bool(rtree, true, "If true, run picture replay tests with an rtree."); | 10 DEFINE_bool(rtree, true, "If true, run picture replay tests with an rtree."); |
| 11 DEFINE_bool(skr, true, "If true, run picture replay tests with SkRecord backe nd."); | |
| 12 | |
| 13 static const char* kSuffixes[] = { "replay", "rtree", "skr" }; | |
| 11 | 14 |
| 12 namespace DM { | 15 namespace DM { |
| 13 | 16 |
| 14 ReplayTask::ReplayTask(const Task& parent, | 17 ReplayTask::ReplayTask(const Task& parent, |
| 15 skiagm::GM* gm, | 18 skiagm::GM* gm, |
| 16 SkBitmap reference, | 19 SkBitmap reference, |
| 17 Mode mode) | 20 Mode mode) |
| 18 : CpuTask(parent) | 21 : CpuTask(parent) |
| 19 , fUseRTree(mode == kRTree_Mode) | 22 , fMode(mode) |
| 20 , fName(UnderJoin(parent.name().c_str(), fUseRTree ? "rtree" : "replay")) | 23 , fName(UnderJoin(parent.name().c_str(), kSuffixes[mode])) |
| 21 , fGM(gm) | 24 , fGM(gm) |
| 22 , fReference(reference) | 25 , fReference(reference) |
| 23 {} | 26 {} |
| 24 | 27 |
| 25 void ReplayTask::draw() { | 28 void ReplayTask::draw() { |
| 26 SkAutoTDelete<SkBBHFactory> factory; | 29 SkAutoTDelete<SkBBHFactory> factory; |
| 27 if (fUseRTree) { | 30 if (kRTree_Mode == fMode) { |
| 28 factory.reset(SkNEW(SkRTreeFactory)); | 31 factory.reset(SkNEW(SkRTreeFactory)); |
| 29 } | 32 } |
| 30 SkAutoTUnref<SkPicture> recorded(RecordPicture(fGM.get(), 0, factory.get())) ; | 33 SkAutoTUnref<SkPicture> recorded( |
| 34 RecordPicture(fGM.get(), factory.get(), kSkRecord_Mode == fMode)); | |
| 31 | 35 |
| 32 SkBitmap bitmap; | 36 SkBitmap bitmap; |
| 33 AllocatePixels(fReference, &bitmap); | 37 AllocatePixels(fReference, &bitmap); |
| 34 DrawPicture(recorded, &bitmap); | 38 DrawPicture(*recorded, &bitmap); |
| 35 if (!BitmapsEqual(bitmap, fReference)) { | 39 if (!BitmapsEqual(bitmap, fReference)) { |
| 36 this->fail(); | 40 this->fail(); |
| 37 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); | 41 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); |
| 38 } | 42 } |
| 39 } | 43 } |
| 40 | 44 |
| 41 bool ReplayTask::shouldSkip() const { | 45 bool ReplayTask::shouldSkip() const { |
| 42 if (fGM->getFlags() & skiagm::GM::kSkipPicture_Flag) { | 46 if (fGM->getFlags() & skiagm::GM::kSkipPicture_Flag) { |
| 43 return true; | 47 return true; |
| 44 } | 48 } |
| 45 | 49 switch (fMode) { |
|
robertphillips
2014/06/24 18:34:46
if (!*) {
return true;
}
break;
?
mtklein
2014/06/24 19:17:03
Got rid of the switch entirely.
| |
| 46 if (FLAGS_rtree && fUseRTree) { | 50 case kNormal_Mode: if (!FLAGS_replay) return true; break; |
| 47 return false; | 51 case kRTree_Mode: if (!FLAGS_rtree) return true; break; |
| 52 case kSkRecord_Mode: if (!FLAGS_skr) return true; break; | |
| 48 } | 53 } |
| 49 if (FLAGS_replay && !fUseRTree) { | 54 return false; |
| 50 return false; | |
| 51 } | |
| 52 return true; | |
| 53 } | 55 } |
| 54 | 56 |
| 55 } // namespace DM | 57 } // namespace DM |
| OLD | NEW |