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

Side by Side Diff: gm/downsamplebitmap.cpp

Issue 346453002: Refactor how we handle resources path in Tests. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix rebase conflict Created 6 years, 6 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 | « gm/copyTo4444.cpp ('k') | gm/etc1bitmap.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
10 #include "Resources.h"
9 #include "SkGradientShader.h" 11 #include "SkGradientShader.h"
10
11 #include "SkTypeface.h" 12 #include "SkTypeface.h"
12 #include "SkImageDecoder.h" 13 #include "SkImageDecoder.h"
13 #include "SkStream.h" 14 #include "SkStream.h"
14 #include "SkPaint.h" 15 #include "SkPaint.h"
15 16
16 static void setTypeface(SkPaint* paint, const char name[], SkTypeface::Style sty le) { 17 static void setTypeface(SkPaint* paint, const char name[], SkTypeface::Style sty le) {
17 SkSafeUnref(paint->setTypeface(SkTypeface::CreateFromName(name, style))); 18 SkSafeUnref(paint->setTypeface(SkTypeface::CreateFromName(name, style)));
18 } 19 }
19 20
20 class DownsampleBitmapGM : public skiagm::GM { 21 class DownsampleBitmapGM : public skiagm::GM {
21
22 public: 22 public:
23 SkBitmap fBM; 23 SkBitmap fBM;
24 SkString fName; 24 SkString fName;
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);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 : INHERITED(filterLevel), fFilename(filename) 165 : INHERITED(filterLevel), fFilename(filename)
166 { 166 {
167 fName.printf("downsamplebitmap_image_%s_%s", this->filterLevelToStri ng(), filename); 167 fName.printf("downsamplebitmap_image_%s_%s", this->filterLevelToStri ng(), filename);
168 } 168 }
169 169
170 protected: 170 protected:
171 SkString fFilename; 171 SkString fFilename;
172 int fSize; 172 int fSize;
173 173
174 virtual void make_bitmap() SK_OVERRIDE { 174 virtual void make_bitmap() SK_OVERRIDE {
175 SkString path(skiagm::GM::gResourcePath); 175 SkString resourcePath = GetResourcePath();
176 path.append("/"); 176 resourcePath.append("/");
177 path.append(fFilename); 177 resourcePath.append(fFilename);
178 178
179 SkImageDecoder *codec = NULL; 179 SkImageDecoder* codec = NULL;
180 SkFILEStream stream(path.c_str()); 180 SkFILEStream stream(resourcePath.c_str());
181 if (stream.isValid()) { 181 if (stream.isValid()) {
182 codec = SkImageDecoder::Factory(&stream); 182 codec = SkImageDecoder::Factory(&stream);
183 } 183 }
184 if (codec) { 184 if (codec) {
185 stream.rewind(); 185 stream.rewind();
186 codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDe codePixels_Mode); 186 codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDe codePixels_Mode);
187 SkDELETE(codec); 187 SkDELETE(codec);
188 } else { 188 } else {
189 fBM.allocN32Pixels(1, 1); 189 fBM.allocN32Pixels(1, 1);
190 *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad 190 *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad
(...skipping 14 matching lines...) Expand all
205 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, SkPaint::kMedium_Filt erLevel); ) 205 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, SkPaint::kMedium_Filt erLevel); )
206 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", SkPaint::kMedium_ FilterLevel); ) 206 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", SkPaint::kMedium_ FilterLevel); )
207 207
208 DEF_GM( return new DownsampleBitmapTextGM(72, SkPaint::kLow_FilterLevel); ) 208 DEF_GM( return new DownsampleBitmapTextGM(72, SkPaint::kLow_FilterLevel); )
209 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, SkPaint::kLow_FilterL evel); ) 209 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, SkPaint::kLow_FilterL evel); )
210 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", SkPaint::kLow_Fil terLevel); ) 210 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", SkPaint::kLow_Fil terLevel); )
211 211
212 DEF_GM( return new DownsampleBitmapTextGM(72, SkPaint::kNone_FilterLevel); ) 212 DEF_GM( return new DownsampleBitmapTextGM(72, SkPaint::kNone_FilterLevel); )
213 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, SkPaint::kNone_Filter Level); ) 213 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, SkPaint::kNone_Filter Level); )
214 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", SkPaint::kNone_Fi lterLevel); ) 214 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", SkPaint::kNone_Fi lterLevel); )
OLDNEW
« no previous file with comments | « gm/copyTo4444.cpp ('k') | gm/etc1bitmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698