Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: dm/DMReplayTask.cpp

Issue 345553003: Support serialization in SkRecord-backed SkPictures. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: robert Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « dm/DMReplayTask.h ('k') | dm/DMSKPTask.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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" };
14 static const bool* kEnabled[] = { &FLAGS_replay, &FLAGS_rtree, &FLAGS_skr };
11 15
12 namespace DM { 16 namespace DM {
13 17
14 ReplayTask::ReplayTask(const Task& parent, 18 ReplayTask::ReplayTask(const Task& parent,
15 skiagm::GM* gm, 19 skiagm::GM* gm,
16 SkBitmap reference, 20 SkBitmap reference,
17 Mode mode) 21 Mode mode)
18 : CpuTask(parent) 22 : CpuTask(parent)
19 , fUseRTree(mode == kRTree_Mode) 23 , fMode(mode)
20 , fName(UnderJoin(parent.name().c_str(), fUseRTree ? "rtree" : "replay")) 24 , fName(UnderJoin(parent.name().c_str(), kSuffixes[mode]))
21 , fGM(gm) 25 , fGM(gm)
22 , fReference(reference) 26 , fReference(reference)
23 {} 27 {}
24 28
25 void ReplayTask::draw() { 29 void ReplayTask::draw() {
26 SkAutoTDelete<SkBBHFactory> factory; 30 SkAutoTDelete<SkBBHFactory> factory;
27 if (fUseRTree) { 31 if (kRTree_Mode == fMode) {
28 factory.reset(SkNEW(SkRTreeFactory)); 32 factory.reset(SkNEW(SkRTreeFactory));
29 } 33 }
30 SkAutoTUnref<SkPicture> recorded(RecordPicture(fGM.get(), 0, factory.get())) ; 34 SkAutoTUnref<SkPicture> recorded(
35 RecordPicture(fGM.get(), factory.get(), kSkRecord_Mode == fMode));
31 36
32 SkBitmap bitmap; 37 SkBitmap bitmap;
33 AllocatePixels(fReference, &bitmap); 38 AllocatePixels(fReference, &bitmap);
34 DrawPicture(recorded, &bitmap); 39 DrawPicture(*recorded, &bitmap);
35 if (!BitmapsEqual(bitmap, fReference)) { 40 if (!BitmapsEqual(bitmap, fReference)) {
36 this->fail(); 41 this->fail();
37 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); 42 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
38 } 43 }
39 } 44 }
40 45
41 bool ReplayTask::shouldSkip() const { 46 bool ReplayTask::shouldSkip() const {
42 if (fGM->getFlags() & skiagm::GM::kSkipPicture_Flag) { 47 if (fGM->getFlags() & skiagm::GM::kSkipPicture_Flag) {
43 return true; 48 return true;
44 } 49 }
45 50 return !*kEnabled[fMode];
46 if (FLAGS_rtree && fUseRTree) {
47 return false;
48 }
49 if (FLAGS_replay && !fUseRTree) {
50 return false;
51 }
52 return true;
53 } 51 }
54 52
55 } // namespace DM 53 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DMReplayTask.h ('k') | dm/DMSKPTask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698