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

Side by Side Diff: dm/DMQuiltTask.cpp

Issue 256373002: Turn on quilt mode in DM. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 7 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/DMTileGridTask.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 "DMTileGridTask.h" 1 #include "DMQuiltTask.h"
2 #include "DMUtil.h"
2 #include "DMWriteTask.h" 3 #include "DMWriteTask.h"
3 #include "DMUtil.h"
4 4
5 #include "SkBBHFactory.h"
6 #include "SkCommandLineFlags.h" 5 #include "SkCommandLineFlags.h"
7 #include "SkPicture.h" 6 #include "SkPicture.h"
8 7
9 // TODO(mtklein): Tile grid tests are currently failing. (Skia issue 1198). Wh en fixed, -> true. 8 DEFINE_bool(quilt, true, "If true, draw into a quilt of small tiles and compare. ");
10 DEFINE_bool(tileGrid, false, "If true, run picture replay tests with a tile grid ."); 9 DEFINE_int32(quiltTile, 16, "Dimension of (square) quilt tile.");
11 10
12 namespace DM { 11 namespace DM {
13 12
14 TileGridTask::TileGridTask(const Task& parent, skiagm::GM* gm, SkBitmap referenc e, SkISize tileSize) 13 QuiltTask::QuiltTask(const Task& parent, skiagm::GM* gm, SkBitmap reference)
15 : CpuTask(parent) 14 : CpuTask(parent)
16 , fName(UnderJoin(parent.name().c_str(), "tilegrid")) 15 , fName(UnderJoin(parent.name().c_str(), "quilt"))
17 , fGM(gm) 16 , fGM(gm)
18 , fReference(reference) 17 , fReference(reference)
19 , fTileSize(tileSize)
20 {} 18 {}
21 19
22 static int tiles_needed(int fullDimension, int tileDimension) { 20 static int tiles_needed(int fullDimension, int tileDimension) {
23 return (fullDimension + tileDimension - 1) / tileDimension; 21 return (fullDimension + tileDimension - 1) / tileDimension;
24 } 22 }
25 23
26 void TileGridTask::draw() { 24 void QuiltTask::draw() {
27 const SkTileGridFactory::TileGridInfo info = { 25 SkAutoTUnref<SkPicture> recorded(RecordPicture(fGM.get()));
28 fTileSize,
29 SkISize::Make(0,0), // Overlap between adjacent tiles.
30 SkIPoint::Make(0,0), // Offset.
31 };
32 SkTileGridFactory factory(info);
33 SkAutoTUnref<SkPicture> recorded(RecordPicture(fGM.get(),
34 SkPicture::kUsePathBoundsForC lip_RecordingFlag,
35 &factory));
36 26
37 SkBitmap full; 27 SkBitmap full;
38 SetupBitmap(fReference.colorType(), fGM.get(), &full); 28 SetupBitmap(fReference.colorType(), fGM.get(), &full);
39 SkCanvas fullCanvas(full); 29 SkCanvas fullCanvas(full);
40 30
41 SkBitmap tile; 31 SkBitmap tile;
42 tile.allocPixels(SkImageInfo::Make(fTileSize.width(), fTileSize.height(), 32 tile.allocPixels(SkImageInfo::Make(FLAGS_quiltTile, FLAGS_quiltTile,
43 fReference.colorType(), kPremul_SkAlphaTy pe)); 33 fReference.colorType(), kPremul_SkAlphaTy pe));
44 SkCanvas tileCanvas(tile); 34 SkCanvas tileCanvas(tile);
45 35
46 SkPaint paint;
47 paint.setXfermodeMode(SkXfermode::kSrc_Mode);
48
49 for (int y = 0; y < tiles_needed(full.height(), tile.height()); y++) { 36 for (int y = 0; y < tiles_needed(full.height(), tile.height()); y++) {
50 for (int x = 0; x < tiles_needed(full.width(), tile.width()); x++) { 37 for (int x = 0; x < tiles_needed(full.width(), tile.width()); x++) {
51 SkAutoCanvasRestore ar(&tileCanvas, true/*also save now*/); 38 SkAutoCanvasRestore ar(&tileCanvas, true/*also save now*/);
52 39
53 const SkScalar xOffset = SkIntToScalar(x * tile.width()), 40 const SkScalar xOffset = SkIntToScalar(x * tile.width()),
54 yOffset = SkIntToScalar(y * tile.height()); 41 yOffset = SkIntToScalar(y * tile.height());
55 SkMatrix matrix = tileCanvas.getTotalMatrix(); 42 SkMatrix matrix = tileCanvas.getTotalMatrix();
56 matrix.postTranslate(-xOffset, -yOffset); 43 matrix.postTranslate(-xOffset, -yOffset);
57 tileCanvas.setMatrix(matrix); 44 tileCanvas.setMatrix(matrix);
58 45
59 recorded->draw(&tileCanvas); 46 recorded->draw(&tileCanvas);
60 tileCanvas.flush(); 47 tileCanvas.flush();
61 fullCanvas.drawBitmap(tile, xOffset, yOffset, &paint); 48 fullCanvas.drawBitmap(tile, xOffset, yOffset, NULL);
62 } 49 }
63 } 50 }
64 51
65 if (!BitmapsEqual(full, fReference)) { 52 if (!BitmapsEqual(full, fReference)) {
66 this->fail(); 53 this->fail();
67 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, full))); 54 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, full)));
68 } 55 }
69 } 56 }
70 57
71 bool TileGridTask::shouldSkip() const { 58 bool QuiltTask::shouldSkip() const {
72 if (fGM->getFlags() & skiagm::GM::kSkipPicture_Flag) { 59 if (fGM->getFlags() & skiagm::GM::kSkipPicture_Flag) {
73 return true; 60 return true;
74 } 61 }
75 if (fGM->getFlags() & skiagm::GM::kSkipTiled_Flag) { 62 if (fGM->getFlags() & skiagm::GM::kSkipTiled_Flag) {
76 return true; 63 return true;
77 } 64 }
78 return !FLAGS_tileGrid; 65 return !FLAGS_quilt;
79 } 66 }
80 67
81 } // namespace DM 68 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DMQuiltTask.h ('k') | dm/DMTileGridTask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698