| OLD | NEW |
| 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 "SkCommandLineFlags.h" | 5 #include "SkCommandLineFlags.h" |
| 6 #include "SkPicture.h" | 6 #include "SkPicture.h" |
| 7 | 7 |
| 8 DEFINE_bool(quilt, true, "If true, draw into a quilt of small tiles and compare.
"); | 8 DEFINE_bool(quilt, true, "If true, draw into a quilt of small tiles and compare.
"); |
| 9 DEFINE_int32(quiltTile, 16, "Dimension of (square) quilt tile."); | 9 DEFINE_int32(quiltTile, 16, "Dimension of (square) quilt tile."); |
| 10 | 10 |
| 11 namespace DM { | 11 namespace DM { |
| 12 | 12 |
| 13 QuiltTask::QuiltTask(const Task& parent, skiagm::GM* gm, SkBitmap reference) | 13 QuiltTask::QuiltTask(const Task& parent, skiagm::GM* gm, SkBitmap reference) |
| 14 : CpuTask(parent) | 14 : CpuTask(parent) |
| 15 , fName(UnderJoin(parent.name().c_str(), "quilt")) | 15 , fName(UnderJoin(parent.name().c_str(), "quilt")) |
| 16 , fGM(gm) | 16 , fGM(gm) |
| 17 , fReference(reference) | 17 , fReference(reference) |
| 18 {} | 18 {} |
| 19 | 19 |
| 20 static int tiles_needed(int fullDimension, int tileDimension) { | 20 static int tiles_needed(int fullDimension, int tileDimension) { |
| 21 return (fullDimension + tileDimension - 1) / tileDimension; | 21 return (fullDimension + tileDimension - 1) / tileDimension; |
| 22 } | 22 } |
| 23 | 23 |
| 24 void QuiltTask::draw() { | 24 void QuiltTask::draw() { |
| 25 SkAutoTUnref<SkPicture> recorded(RecordPicture(fGM.get())); | 25 SkAutoTUnref<SkPicture> recorded(RecordPicture(fGM.get())); |
| 26 | 26 |
| 27 SkBitmap full; | 27 SkBitmap full; |
| 28 SetupBitmap(fReference.colorType(), fGM.get(), &full); | 28 AllocatePixels(fReference, &full); |
| 29 SkCanvas fullCanvas(full); | 29 SkCanvas fullCanvas(full); |
| 30 | 30 |
| 31 SkBitmap tile; | 31 SkBitmap tile; |
| 32 tile.allocPixels(SkImageInfo::Make(FLAGS_quiltTile, FLAGS_quiltTile, | 32 tile.allocPixels(SkImageInfo::Make(FLAGS_quiltTile, FLAGS_quiltTile, |
| 33 fReference.colorType(), kPremul_SkAlphaTy
pe)); | 33 fReference.colorType(), kPremul_SkAlphaTy
pe)); |
| 34 SkCanvas tileCanvas(tile); | 34 SkCanvas tileCanvas(tile); |
| 35 | 35 |
| 36 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++) { |
| 37 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++) { |
| 38 SkAutoCanvasRestore ar(&tileCanvas, true/*also save now*/); | 38 SkAutoCanvasRestore ar(&tileCanvas, true/*also save now*/); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 59 if (fGM->getFlags() & skiagm::GM::kSkipPicture_Flag) { | 59 if (fGM->getFlags() & skiagm::GM::kSkipPicture_Flag) { |
| 60 return true; | 60 return true; |
| 61 } | 61 } |
| 62 if (fGM->getFlags() & skiagm::GM::kSkipTiled_Flag) { | 62 if (fGM->getFlags() & skiagm::GM::kSkipTiled_Flag) { |
| 63 return true; | 63 return true; |
| 64 } | 64 } |
| 65 return !FLAGS_quilt; | 65 return !FLAGS_quilt; |
| 66 } | 66 } |
| 67 | 67 |
| 68 } // namespace DM | 68 } // namespace DM |
| OLD | NEW |