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

Side by Side Diff: dm/DMQuiltTask.cpp

Issue 454123003: Plumbing for using a BBH in SkRecordDraw. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: clang says asserts are always true Created 6 years, 4 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/DMQuiltTask.h ('k') | include/core/SkPicture.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 "DMQuiltTask.h" 1 #include "DMQuiltTask.h"
2 #include "DMUtil.h" 2 #include "DMUtil.h"
3 #include "DMWriteTask.h" 3 #include "DMWriteTask.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 #include "SkThreadPool.h" 8 #include "SkThreadPool.h"
9 9
10 DEFINE_bool(quilt, true, "If true, draw GM via a picture into a quilt of small t iles and compare."); 10 DEFINE_bool(quilt, true, "If true, draw GM via a picture into a quilt of small t iles and compare.");
11 DEFINE_int32(quiltTile, 256, "Dimension of (square) quilt tile."); 11 DEFINE_int32(quiltTile, 256, "Dimension of (square) quilt tile.");
12 12
13 static const char* kSuffixes[] = { "nobbh", "rtree", "quadtree", "tilegrid", "sk r" };
14
15 namespace DM { 13 namespace DM {
16 14
17 QuiltTask::QuiltTask(const Task& parent, skiagm::GM* gm, SkBitmap reference, Qui ltTask::Mode mode) 15 static SkString suffix(QuiltTask::Backend backend, QuiltTask::BBH bbh) {
16 static const char* kBackends[] = { "default", "skrecord" };
17 static const char* kBBHs[] = { "nobbh", "rtree", "quadtree", "tilegrid" };
18 return SkStringPrintf("%s-%s", kBackends[backend], kBBHs[bbh]);
19 }
20
21 QuiltTask::QuiltTask(const Task& parent, skiagm::GM* gm, SkBitmap reference,
22 QuiltTask::BBH bbh, QuiltTask::Backend backend)
18 : CpuTask(parent) 23 : CpuTask(parent)
19 , fMode(mode) 24 , fBBH(bbh)
20 , fName(UnderJoin(parent.name().c_str(), kSuffixes[mode])) 25 , fBackend(backend)
26 , fName(UnderJoin(parent.name().c_str(), suffix(backend, bbh).c_str()))
21 , fGM(gm) 27 , fGM(gm)
22 , fReference(reference) 28 , fReference(reference)
23 {} 29 {}
24 30
25 static int tiles_needed(int fullDimension, int tileDimension) { 31 static int tiles_needed(int fullDimension, int tileDimension) {
26 return (fullDimension + tileDimension - 1) / tileDimension; 32 return (fullDimension + tileDimension - 1) / tileDimension;
27 } 33 }
28 34
29 class Tile : public SkRunnable { 35 class Tile : public SkRunnable {
30 public: 36 public:
(...skipping 16 matching lines...) Expand all
47 } 53 }
48 54
49 private: 55 private:
50 const int fX, fY; 56 const int fX, fY;
51 const SkPicture& fPicture; 57 const SkPicture& fPicture;
52 SkBitmap* fQuilt; 58 SkBitmap* fQuilt;
53 }; 59 };
54 60
55 void QuiltTask::draw() { 61 void QuiltTask::draw() {
56 SkAutoTDelete<SkBBHFactory> factory; 62 SkAutoTDelete<SkBBHFactory> factory;
57 switch (fMode) { 63 switch (fBBH) {
58 case kRTree_Mode: 64 case kNone_BBH: break;
65 case kRTree_BBH:
59 factory.reset(SkNEW(SkRTreeFactory)); 66 factory.reset(SkNEW(SkRTreeFactory));
60 break; 67 break;
61 case kQuadTree_Mode: 68 case kQuadTree_BBH:
62 factory.reset(SkNEW(SkQuadTreeFactory)); 69 factory.reset(SkNEW(SkQuadTreeFactory));
63 break; 70 break;
64 case kTileGrid_Mode: { 71 case kTileGrid_BBH: {
65 const SkTileGridFactory::TileGridInfo tiles = { 72 const SkTileGridFactory::TileGridInfo tiles = {
66 { FLAGS_quiltTile, FLAGS_quiltTile }, 73 { FLAGS_quiltTile, FLAGS_quiltTile },
67 /*overlap: */{0, 0}, 74 /*overlap: */{0, 0},
68 /*offset: */{0, 0}, 75 /*offset: */{0, 0},
69 }; 76 };
70 factory.reset(SkNEW_ARGS(SkTileGridFactory, (tiles))); 77 factory.reset(SkNEW_ARGS(SkTileGridFactory, (tiles)));
71 break; 78 break;
72 } 79 }
73
74 case kNoBBH_Mode:
75 case kSkRecord_Mode:
76 break;
77 } 80 }
78 81
79 // A couple GMs draw wrong when using a bounding box hierarchy. 82 // A couple GMs draw wrong when using a bounding box hierarchy.
80 // This almost certainly means we have a bug to fix, but for now 83 // This almost certainly means we have a bug to fix, but for now
81 // just draw without a bounding box hierarchy. 84 // just draw without a bounding box hierarchy.
82 if (fGM->getFlags() & skiagm::GM::kNoBBH_Flag) { 85 if (fGM->getFlags() & skiagm::GM::kNoBBH_Flag) {
83 factory.reset(NULL); 86 factory.reset(NULL);
84 } 87 }
85 88
86 SkAutoTUnref<const SkPicture> recorded( 89 SkAutoTUnref<const SkPicture> recorded(
87 RecordPicture(fGM.get(), factory.get(), kSkRecord_Mode == fMode)); 90 RecordPicture(fGM.get(), factory.get(), kSkRecord_Backend == fBacken d));
88 91
89 SkBitmap full; 92 SkBitmap full;
90 AllocatePixels(fReference, &full); 93 AllocatePixels(fReference, &full);
91 94
92 if (fGM->getFlags() & skiagm::GM::kSkipTiled_Flag) { 95 if (fGM->getFlags() & skiagm::GM::kSkipTiled_Flag) {
93 // Some GMs don't draw exactly the same when tiled. Draw them in one go . 96 // Some GMs don't draw exactly the same when tiled. Draw them in one go .
94 SkCanvas canvas(full); 97 SkCanvas canvas(full);
95 recorded->draw(&canvas); 98 recorded->draw(&canvas);
96 canvas.flush(); 99 canvas.flush();
97 } else { 100 } else {
(...skipping 14 matching lines...) Expand all
112 } 115 }
113 116
114 bool QuiltTask::shouldSkip() const { 117 bool QuiltTask::shouldSkip() const {
115 if (fGM->getFlags() & skiagm::GM::kSkipPicture_Flag) { 118 if (fGM->getFlags() & skiagm::GM::kSkipPicture_Flag) {
116 return true; 119 return true;
117 } 120 }
118 return !FLAGS_quilt; 121 return !FLAGS_quilt;
119 } 122 }
120 123
121 } // namespace DM 124 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DMQuiltTask.h ('k') | include/core/SkPicture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698