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

Side by Side Diff: dm/DMQuiltTask.cpp

Issue 377373003: Merge Replay and Quilt tasks, adding in all BBH implementations. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 5 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') | dm/DMReplayTask.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 "SkCommandLineFlags.h" 6 #include "SkCommandLineFlags.h"
6 #include "SkPicture.h" 7 #include "SkPicture.h"
7 #include "SkThreadPool.h" 8 #include "SkThreadPool.h"
8 9
9 DEFINE_bool(quilt, true, "If true, draw into a quilt of small tiles and compare. "); 10 DEFINE_bool(quilt, true, "If true, draw GM via a picture into a quilt of small t iles and compare.");
10 DEFINE_int32(quiltTile, 256, "Dimension of (square) quilt tile."); 11 DEFINE_int32(quiltTile, 256, "Dimension of (square) quilt tile.");
11 DEFINE_bool(quiltThreaded, true, "If true, draw quilt tiles with multiple thread s.");
12 12
13 static const char* kSuffixes[] = { "quilt", "quilt_skr" }; 13 static const char* kSuffixes[] = { "nobbh", "rtree", "quadtree", "tilegrid", "sk r" };
14 14
15 namespace DM { 15 namespace DM {
16 16
17 QuiltTask::QuiltTask(const Task& parent, skiagm::GM* gm, SkBitmap reference, Qui ltTask::Mode mode) 17 QuiltTask::QuiltTask(const Task& parent, skiagm::GM* gm, SkBitmap reference, Qui ltTask::Mode mode)
18 : CpuTask(parent) 18 : CpuTask(parent)
19 , fMode(mode) 19 , fMode(mode)
20 , fName(UnderJoin(parent.name().c_str(), kSuffixes[mode])) 20 , fName(UnderJoin(parent.name().c_str(), kSuffixes[mode]))
21 , fGM(gm) 21 , fGM(gm)
22 , fReference(reference) 22 , fReference(reference)
23 {} 23 {}
(...skipping 22 matching lines...) Expand all
46 delete this; 46 delete this;
47 } 47 }
48 48
49 private: 49 private:
50 const int fX, fY; 50 const int fX, fY;
51 const SkPicture& fPicture; 51 const SkPicture& fPicture;
52 SkBitmap* fQuilt; 52 SkBitmap* fQuilt;
53 }; 53 };
54 54
55 void QuiltTask::draw() { 55 void QuiltTask::draw() {
56 SkAutoTUnref<SkPicture> recorded( 56 SkAutoTDelete<SkBBHFactory> factory;
57 RecordPicture(fGM.get(), NULL/*bbh factory*/, kSkRecord_Mode == fMod e)); 57 switch (fMode) {
58 case kRTree_Mode:
59 factory.reset(SkNEW(SkRTreeFactory));
60 break;
61 case kQuadTree_Mode:
62 factory.reset(SkNEW(SkQuadTreeFactory));
63 break;
64 case kTileGrid_Mode: {
65 const SkTileGridFactory::TileGridInfo tiles = {
66 { FLAGS_quiltTile, FLAGS_quiltTile },
67 /*overlap: */{0, 0},
68 /*offset: */{0, 0},
69 };
70 factory.reset(SkNEW_ARGS(SkTileGridFactory, (tiles)));
71 break;
72 }
73
74 case kNoBBH_Mode:
75 case kSkRecord_Mode:
76 break;
77 }
78
79 // 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
81 // just draw without a bounding box hierarchy.
82 if (fGM->getFlags() & skiagm::GM::kNoBBH_Flag) {
83 factory.reset(NULL);
84 }
85
86 SkAutoTUnref<const SkPicture> recorded(
87 RecordPicture(fGM.get(), factory.get(), kSkRecord_Mode == fMode));
58 88
59 SkBitmap full; 89 SkBitmap full;
60 AllocatePixels(fReference, &full); 90 AllocatePixels(fReference, &full);
61 91
62 int threads = 0; 92 if (fGM->getFlags() & skiagm::GM::kSkipTiled_Flag) {
63 if (kSkRecord_Mode == fMode || FLAGS_quiltThreaded) { 93 // Some GMs don't draw exactly the same when tiled. Draw them in one go .
64 threads = SkThreadPool::kThreadPerCore; 94 SkCanvas canvas(full);
65 } 95 recorded->draw(&canvas);
66 SkThreadPool pool(threads); 96 canvas.flush();
67 97 } else {
68 for (int y = 0; y < tiles_needed(full.height(), FLAGS_quiltTile); y++) { 98 // Draw tiles in parallel into the same bitmap, simulating aggressive im pl-side painting.
69 for (int x = 0; x < tiles_needed(full.width(), FLAGS_quiltTile); x++) { 99 SkThreadPool pool(SkThreadPool::kThreadPerCore);
70 // Deletes itself when done. 100 for (int y = 0; y < tiles_needed(full.height(), FLAGS_quiltTile); y++) {
71 pool.add(new Tile(x, y, *recorded, &full)); 101 for (int x = 0; x < tiles_needed(full.width(), FLAGS_quiltTile); x++ ) {
102 // Deletes itself when done.
103 pool.add(new Tile(x, y, *recorded, &full));
104 }
72 } 105 }
73 } 106 }
74 107
75 pool.wait();
76
77 if (!BitmapsEqual(full, fReference)) { 108 if (!BitmapsEqual(full, fReference)) {
78 this->fail(); 109 this->fail();
79 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, full))); 110 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, full)));
80 } 111 }
81 } 112 }
82 113
83 bool QuiltTask::shouldSkip() const { 114 bool QuiltTask::shouldSkip() const {
84 if (fGM->getFlags() & skiagm::GM::kSkipPicture_Flag) { 115 if (fGM->getFlags() & skiagm::GM::kSkipPicture_Flag) {
85 return true; 116 return true;
86 } 117 }
87 if (fGM->getFlags() & skiagm::GM::kSkipTiled_Flag) {
88 return true;
89 }
90 return !FLAGS_quilt; 118 return !FLAGS_quilt;
91 } 119 }
92 120
93 } // namespace DM 121 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DMQuiltTask.h ('k') | dm/DMReplayTask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698