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