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

Side by Side Diff: gm/downsamplebitmap.cpp

Issue 20373002: clean up printf usage in gm (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Clean up printf usage in recent gms Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | gm/filterbitmap.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "gm.h" 8 #include "gm.h"
9 #include "SkGradientShader.h" 9 #include "SkGradientShader.h"
10 10
(...skipping 14 matching lines...) Expand all
25 bool fBitmapMade; 25 bool fBitmapMade;
26 SkPaint::FilterLevel fFilterLevel; 26 SkPaint::FilterLevel fFilterLevel;
27 27
28 DownsampleBitmapGM(SkPaint::FilterLevel filterLevel) 28 DownsampleBitmapGM(SkPaint::FilterLevel filterLevel)
29 : fFilterLevel(filterLevel) 29 : fFilterLevel(filterLevel)
30 { 30 {
31 this->setBGColor(0xFFDDDDDD); 31 this->setBGColor(0xFFDDDDDD);
32 fBitmapMade = false; 32 fBitmapMade = false;
33 } 33 }
34 34
35 void setName(const char name[]) { 35 const char* filterLevelToString() {
36 fName.set(name); 36 static const char *filterLevelNames[] = {
37 } 37 "none", "low", "medium", "high"
38 38 };
39 const char *filterLevelToString() { 39 return filterLevelNames[fFilterLevel];
40 switch(fFilterLevel) {
41 case SkPaint::kNone_FilterLevel:
42 return "none";
43 case SkPaint::kLow_FilterLevel:
44 return "low";
45 case SkPaint::kMedium_FilterLevel:
46 return "medium";
47 case SkPaint::kHigh_FilterLevel:
48 return "high";
49 default:
50 return "unknown";
51 }
52 } 40 }
53 41
54 protected: 42 protected:
55 virtual SkString onShortName() SK_OVERRIDE { 43 virtual SkString onShortName() SK_OVERRIDE {
56 return fName; 44 return fName;
57 } 45 }
58 46
59 virtual SkISize onISize() SK_OVERRIDE { 47 virtual SkISize onISize() SK_OVERRIDE {
60 make_bitmap_wrapper(); 48 make_bitmap_wrapper();
61 return SkISize::Make(4 * fBM.width(), fBM.height()); 49 return SkISize::Make(4 * fBM.width(), fBM.height());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 85
98 private: 86 private:
99 typedef skiagm::GM INHERITED; 87 typedef skiagm::GM INHERITED;
100 }; 88 };
101 89
102 class DownsampleBitmapTextGM: public DownsampleBitmapGM { 90 class DownsampleBitmapTextGM: public DownsampleBitmapGM {
103 public: 91 public:
104 DownsampleBitmapTextGM(float textSize, SkPaint::FilterLevel filterLevel) 92 DownsampleBitmapTextGM(float textSize, SkPaint::FilterLevel filterLevel)
105 : INHERITED(filterLevel), fTextSize(textSize) 93 : INHERITED(filterLevel), fTextSize(textSize)
106 { 94 {
107 char name[1024]; 95 fName.printf("downsamplebitmap_text_%s_%.2fpt", this->filterLevelToS tring(), fTextSize);
108 sprintf(name, "downsamplebitmap_text_%s_%.2fpt", this->filterLevelTo String(), fTextSize);
109 setName(name);
110 } 96 }
111 97
112 protected: 98 protected:
113 float fTextSize; 99 float fTextSize;
114 100
115 virtual void make_bitmap() SK_OVERRIDE { 101 virtual void make_bitmap() SK_OVERRIDE {
116 fBM.setConfig(SkBitmap::kARGB_8888_Config, int(fTextSize * 8), int(fTe xtSize * 6)); 102 fBM.setConfig(SkBitmap::kARGB_8888_Config, int(fTextSize * 8), int(fTe xtSize * 6));
117 fBM.allocPixels(); 103 fBM.allocPixels();
118 SkCanvas canvas(fBM); 104 SkCanvas canvas(fBM);
119 canvas.drawColor(SK_ColorWHITE); 105 canvas.drawColor(SK_ColorWHITE);
(...skipping 14 matching lines...) Expand all
134 } 120 }
135 private: 121 private:
136 typedef DownsampleBitmapGM INHERITED; 122 typedef DownsampleBitmapGM INHERITED;
137 }; 123 };
138 124
139 class DownsampleBitmapCheckerboardGM: public DownsampleBitmapGM { 125 class DownsampleBitmapCheckerboardGM: public DownsampleBitmapGM {
140 public: 126 public:
141 DownsampleBitmapCheckerboardGM(int size, int numChecks, SkPaint::FilterLev el filterLevel) 127 DownsampleBitmapCheckerboardGM(int size, int numChecks, SkPaint::FilterLev el filterLevel)
142 : INHERITED(filterLevel), fSize(size), fNumChecks(numChecks) 128 : INHERITED(filterLevel), fSize(size), fNumChecks(numChecks)
143 { 129 {
144 char name[1024]; 130 fName.printf("downsamplebitmap_checkerboard_%s_%d_%d", this->filterL evelToString(), fSize, fNumChecks);
145 sprintf(name, "downsamplebitmap_checkerboard_%s_%d_%d", this->filter LevelToString(), fSize, fNumChecks);
146 setName(name);
147 } 131 }
148 132
149 protected: 133 protected:
150 int fSize; 134 int fSize;
151 int fNumChecks; 135 int fNumChecks;
152 136
153 virtual void make_bitmap() SK_OVERRIDE { 137 virtual void make_bitmap() SK_OVERRIDE {
154 fBM.setConfig(SkBitmap::kARGB_8888_Config, fSize, fSize); 138 fBM.setConfig(SkBitmap::kARGB_8888_Config, fSize, fSize);
155 fBM.allocPixels(); 139 fBM.allocPixels();
156 SkAutoLockPixels lock(fBM); 140 SkAutoLockPixels lock(fBM);
(...skipping 12 matching lines...) Expand all
169 } 153 }
170 private: 154 private:
171 typedef DownsampleBitmapGM INHERITED; 155 typedef DownsampleBitmapGM INHERITED;
172 }; 156 };
173 157
174 class DownsampleBitmapImageGM: public DownsampleBitmapGM { 158 class DownsampleBitmapImageGM: public DownsampleBitmapGM {
175 public: 159 public:
176 DownsampleBitmapImageGM(const char filename[], SkPaint::FilterLevel filter Level) 160 DownsampleBitmapImageGM(const char filename[], SkPaint::FilterLevel filter Level)
177 : INHERITED(filterLevel), fFilename(filename) 161 : INHERITED(filterLevel), fFilename(filename)
178 { 162 {
179 char name[1024]; 163 fName.printf("downsamplebitmap_image_%s_%s", this->filterLevelToStri ng(), filename);
180 sprintf(name, "downsamplebitmap_image_%s_%s", this->filterLevelToStr ing(), filename);
181 setName(name);
182 } 164 }
183 165
184 protected: 166 protected:
185 SkString fFilename; 167 SkString fFilename;
186 int fSize; 168 int fSize;
187 169
188 virtual void make_bitmap() SK_OVERRIDE { 170 virtual void make_bitmap() SK_OVERRIDE {
189 SkString path(skiagm::GM::gResourcePath); 171 SkString path(skiagm::GM::gResourcePath);
190 path.append("/"); 172 path.append("/");
191 path.append(fFilename); 173 path.append(fFilename);
(...skipping 29 matching lines...) Expand all
221 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, SkPaint::kMedium_Filt erLevel); ) 203 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, SkPaint::kMedium_Filt erLevel); )
222 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", SkPaint::kMedium_ FilterLevel); ) 204 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", SkPaint::kMedium_ FilterLevel); )
223 205
224 DEF_GM( return new DownsampleBitmapTextGM(72, SkPaint::kLow_FilterLevel); ) 206 DEF_GM( return new DownsampleBitmapTextGM(72, SkPaint::kLow_FilterLevel); )
225 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, SkPaint::kLow_FilterL evel); ) 207 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, SkPaint::kLow_FilterL evel); )
226 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", SkPaint::kLow_Fil terLevel); ) 208 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", SkPaint::kLow_Fil terLevel); )
227 209
228 DEF_GM( return new DownsampleBitmapTextGM(72, SkPaint::kNone_FilterLevel); ) 210 DEF_GM( return new DownsampleBitmapTextGM(72, SkPaint::kNone_FilterLevel); )
229 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, SkPaint::kNone_Filter Level); ) 211 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, SkPaint::kNone_Filter Level); )
230 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", SkPaint::kNone_Fi lterLevel); ) 212 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", SkPaint::kNone_Fi lterLevel); )
OLDNEW
« no previous file with comments | « no previous file | gm/filterbitmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698