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

Side by Side Diff: gm/downsamplebitmap.cpp

Issue 1806383002: Revert of Remove uses of SkImageDecoder from gms (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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 9
10 #include "Resources.h" 10 #include "Resources.h"
11 #include "SkGradientShader.h" 11 #include "SkGradientShader.h"
12 #include "SkTypeface.h" 12 #include "SkTypeface.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 make_checker(SkBitmap* bm, int size, int numChecks) { 17 static void make_checker(SkBitmap* bm, int size, int numChecks) {
17 bm->allocN32Pixels(size, size); 18 bm->allocN32Pixels(size, size);
18 for (int y = 0; y < size; ++y) { 19 for (int y = 0; y < size; ++y) {
19 for (int x = 0; x < size; ++x) { 20 for (int x = 0; x < size; ++x) {
20 SkPMColor* s = bm->getAddr32(x, y); 21 SkPMColor* s = bm->getAddr32(x, y);
21 int cx = (x * numChecks) / size; 22 int cx = (x * numChecks) / size;
22 int cy = (y * numChecks) / size; 23 int cy = (y * numChecks) / size;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 : INHERITED(filterQuality), fFilename(filename) 164 : INHERITED(filterQuality), fFilename(filename)
164 { 165 {
165 fName.printf("downsamplebitmap_image_%s_%s", this->filterQualityToSt ring(), filename); 166 fName.printf("downsamplebitmap_image_%s_%s", this->filterQualityToSt ring(), filename);
166 } 167 }
167 168
168 protected: 169 protected:
169 SkString fFilename; 170 SkString fFilename;
170 int fSize; 171 int fSize;
171 172
172 void make_bitmap() override { 173 void make_bitmap() override {
173 if (!GetResourceAsBitmap(fFilename.c_str(), &fBM)) { 174 SkImageDecoder* codec = nullptr;
174 fBM.allocN32Pixels(1, 1); 175 SkString resourcePath = GetResourcePath(fFilename.c_str());
175 fBM.eraseARGB(255, 255, 0 , 0); // red == bad 176 SkFILEStream stream(resourcePath.c_str());
176 } 177 if (stream.isValid()) {
177 fSize = fBM.height(); 178 codec = SkImageDecoder::Factory(&stream);
179 }
180 if (codec) {
181 stream.rewind();
182 codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDe codePixels_Mode);
183 delete codec;
184 } else {
185 fBM.allocN32Pixels(1, 1);
186 *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad
187 }
188 fSize = fBM.height();
178 } 189 }
179 private: 190 private:
180 typedef DownsampleBitmapGM INHERITED; 191 typedef DownsampleBitmapGM INHERITED;
181 }; 192 };
182 193
183 DEF_GM( return new DownsampleBitmapTextGM(72, kHigh_SkFilterQuality); ) 194 DEF_GM( return new DownsampleBitmapTextGM(72, kHigh_SkFilterQuality); )
184 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, kHigh_SkFilterQuality ); ) 195 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, kHigh_SkFilterQuality ); )
185 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", kHigh_SkFilterQua lity); ) 196 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", kHigh_SkFilterQua lity); )
186 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc", 197 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc",
187 kHigh_SkFilterQuality); ) 198 kHigh_SkFilterQuality); )
188 199
189 DEF_GM( return new DownsampleBitmapTextGM(72, kMedium_SkFilterQuality); ) 200 DEF_GM( return new DownsampleBitmapTextGM(72, kMedium_SkFilterQuality); )
190 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, kMedium_SkFilterQuali ty); ) 201 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, kMedium_SkFilterQuali ty); )
191 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", kMedium_SkFilterQ uality); ) 202 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", kMedium_SkFilterQ uality); )
192 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc", 203 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc",
193 kMedium_SkFilterQuality); ) 204 kMedium_SkFilterQuality); )
194 205
195 DEF_GM( return new DownsampleBitmapTextGM(72, kLow_SkFilterQuality); ) 206 DEF_GM( return new DownsampleBitmapTextGM(72, kLow_SkFilterQuality); )
196 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, kLow_SkFilterQuality) ; ) 207 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, kLow_SkFilterQuality) ; )
197 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", kLow_SkFilterQual ity); ) 208 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", kLow_SkFilterQual ity); )
198 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc", 209 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc",
199 kLow_SkFilterQuality); ) 210 kLow_SkFilterQuality); )
200 211
201 DEF_GM( return new DownsampleBitmapTextGM(72, kNone_SkFilterQuality); ) 212 DEF_GM( return new DownsampleBitmapTextGM(72, kNone_SkFilterQuality); )
202 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, kNone_SkFilterQuality ); ) 213 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, kNone_SkFilterQuality ); )
203 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", kNone_SkFilterQua lity); ) 214 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", kNone_SkFilterQua lity); )
204 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc", 215 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc",
205 kNone_SkFilterQuality); ) 216 kNone_SkFilterQuality); )
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