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

Side by Side Diff: gm/filterindiabox.cpp

Issue 1791583002: 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/filterbitmap.cpp ('k') | gm/pixelxorxfermode.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 2011 Google Inc. 2 * Copyright 2011 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 "SkBitmapProcState.h" 11 #include "SkBitmapProcState.h"
12 #include "SkBitmapScaler.h" 12 #include "SkBitmapScaler.h"
13 #include "SkGradientShader.h" 13 #include "SkGradientShader.h"
14 #include "SkImageDecoder.h"
15 #include "SkImageEncoder.h" 14 #include "SkImageEncoder.h"
16 #include "SkStream.h" 15 #include "SkStream.h"
17 #include "SkTypeface.h" 16 #include "SkTypeface.h"
18 17
19 static SkSize computeSize(const SkBitmap& bm, const SkMatrix& mat) { 18 static SkSize computeSize(const SkBitmap& bm, const SkMatrix& mat) {
20 SkRect bounds = SkRect::MakeWH(SkIntToScalar(bm.width()), 19 SkRect bounds = SkRect::MakeWH(SkIntToScalar(bm.width()),
21 SkIntToScalar(bm.height())); 20 SkIntToScalar(bm.height()));
22 mat.mapRect(&bounds); 21 mat.mapRect(&bounds);
23 return SkSize::Make(bounds.width(), bounds.height()); 22 return SkSize::Make(bounds.width(), bounds.height());
24 } 23 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 91
93 protected: 92 protected:
94 SkString fFilename; 93 SkString fFilename;
95 int fSize; 94 int fSize;
96 95
97 SkScalar getScale() { 96 SkScalar getScale() {
98 return 192.f/fSize; 97 return 192.f/fSize;
99 } 98 }
100 99
101 void makeBitmap() { 100 void makeBitmap() {
102 SkImageDecoder* codec = nullptr; 101 if (!GetResourceAsBitmap(fFilename.c_str(), &fBM)) {
103 SkString resourcePath = GetResourcePath(fFilename.c_str()); 102 fBM.allocN32Pixels(1, 1);
104 SkFILEStream stream(resourcePath.c_str()); 103 fBM.eraseARGB(255, 255, 0 , 0); // red == bad
105 if (stream.isValid()) { 104 }
106 codec = SkImageDecoder::Factory(&stream); 105 fSize = fBM.height();
107 }
108 if (codec) {
109 stream.rewind();
110 codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDe codePixels_Mode);
111 delete codec;
112 } else {
113 fBM.allocN32Pixels(1, 1);
114 *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad
115 }
116 fSize = fBM.height();
117 } 106 }
118 private: 107 private:
119 typedef skiagm::GM INHERITED; 108 typedef skiagm::GM INHERITED;
120 }; 109 };
121 110
122 ////////////////////////////////////////////////////////////////////////////// 111 //////////////////////////////////////////////////////////////////////////////
123 112
124 113
125 DEF_GM( return new FilterIndiaBoxGM("box.gif"); ) 114 DEF_GM( return new FilterIndiaBoxGM("box.gif"); )
OLDNEW
« no previous file with comments | « gm/filterbitmap.cpp ('k') | gm/pixelxorxfermode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698