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

Side by Side Diff: dm/DMUtil.cpp

Issue 563723005: Add --matrix to DM, to play around with and maybe use on a bot. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 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/DMUtil.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "DMUtil.h" 1 #include "DMUtil.h"
2 2
3 #include "SkColorPriv.h" 3 #include "SkColorPriv.h"
4 #include "SkCommandLineFlags.h"
4 #include "SkPicture.h" 5 #include "SkPicture.h"
5 #include "SkPictureRecorder.h" 6 #include "SkPictureRecorder.h"
6 7
8 DEFINE_string(matrix, "1 0 0 0 1 0 0 0 1",
9 "Matrix to apply to the canvas before drawing.");
10
7 namespace DM { 11 namespace DM {
8 12
13 void CanvasPreflight(SkCanvas* canvas) {
14 if (FLAGS_matrix.count() == 9) {
15 SkMatrix m;
16 for (int i = 0; i < 9; i++) {
17 m[i] = (SkScalar)atof(FLAGS_matrix[i]);
18 }
19 canvas->concat(m);
20 }
21 }
22
9 SkString UnderJoin(const char* a, const char* b) { 23 SkString UnderJoin(const char* a, const char* b) {
10 SkString s; 24 SkString s;
11 s.appendf("%s_%s", a, b); 25 s.appendf("%s_%s", a, b);
12 return s; 26 return s;
13 } 27 }
14 28
15 SkString FileToTaskName(SkString filename) { 29 SkString FileToTaskName(SkString filename) {
16 for (size_t i = 0; i < filename.size(); i++) { 30 for (size_t i = 0; i < filename.size(); i++) {
17 if ('_' == filename[i]) { filename[i] = '-'; } 31 if ('_' == filename[i]) { filename[i] = '-'; }
18 if ('.' == filename[i]) { filename[i] = '_'; } 32 if ('.' == filename[i]) { filename[i] = '_'; }
19 } 33 }
20 return filename; 34 return filename;
21 } 35 }
22 36
23 SkPicture* RecordPicture(skiagm::GM* gm, SkBBHFactory* factory, bool skr) { 37 SkPicture* RecordPicture(skiagm::GM* gm, SkBBHFactory* factory, bool skr) {
24 const SkScalar w = SkIntToScalar(gm->getISize().width()), 38 const SkScalar w = SkIntToScalar(gm->getISize().width()),
25 h = SkIntToScalar(gm->getISize().height()); 39 h = SkIntToScalar(gm->getISize().height());
26 SkPictureRecorder recorder; 40 SkPictureRecorder recorder;
27 41
28 SkCanvas* canvas = skr ? recorder.EXPERIMENTAL_beginRecording(w, h, factory) 42 SkCanvas* canvas = skr ? recorder.EXPERIMENTAL_beginRecording(w, h, factory)
29 : recorder. DEPRECATED_beginRecording(w, h, factory) ; 43 : recorder. DEPRECATED_beginRecording(w, h, factory) ;
44 CanvasPreflight(canvas);
30 canvas->concat(gm->getInitialTransform()); 45 canvas->concat(gm->getInitialTransform());
31 gm->draw(canvas); 46 gm->draw(canvas);
32 canvas->flush(); 47 canvas->flush();
33 return recorder.endRecording(); 48 return recorder.endRecording();
34 } 49 }
35 50
36 void AllocatePixels(SkColorType ct, int width, int height, SkBitmap* bitmap) { 51 void AllocatePixels(SkColorType ct, int width, int height, SkBitmap* bitmap) {
37 bitmap->allocPixels(SkImageInfo::Make(width, height, ct, kPremul_SkAlphaType )); 52 bitmap->allocPixels(SkImageInfo::Make(width, height, ct, kPremul_SkAlphaType ));
38 bitmap->eraseColor(0x00000000); 53 bitmap->eraseColor(0x00000000);
39 } 54 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 110
96 bool BitmapsEqual(const SkBitmap& a, const SkBitmap& b) { 111 bool BitmapsEqual(const SkBitmap& a, const SkBitmap& b) {
97 if (a.info() != b.info()) { 112 if (a.info() != b.info()) {
98 return false; 113 return false;
99 } 114 }
100 const SkAutoLockPixels lockA(a), lockB(b); 115 const SkAutoLockPixels lockA(a), lockB(b);
101 return 0 == memcmp(a.getPixels(), b.getPixels(), a.getSize()); 116 return 0 == memcmp(a.getPixels(), b.getPixels(), a.getSize());
102 } 117 }
103 118
104 } // namespace DM 119 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DMUtil.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698