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

Side by Side Diff: gm/filterindiabox.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/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"
14 #include "SkImageEncoder.h" 15 #include "SkImageEncoder.h"
15 #include "SkStream.h" 16 #include "SkStream.h"
16 #include "SkTypeface.h" 17 #include "SkTypeface.h"
17 18
18 static SkSize computeSize(const SkBitmap& bm, const SkMatrix& mat) { 19 static SkSize computeSize(const SkBitmap& bm, const SkMatrix& mat) {
19 SkRect bounds = SkRect::MakeWH(SkIntToScalar(bm.width()), 20 SkRect bounds = SkRect::MakeWH(SkIntToScalar(bm.width()),
20 SkIntToScalar(bm.height())); 21 SkIntToScalar(bm.height()));
21 mat.mapRect(&bounds); 22 mat.mapRect(&bounds);
22 return SkSize::Make(bounds.width(), bounds.height()); 23 return SkSize::Make(bounds.width(), bounds.height());
23 } 24 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 92
92 protected: 93 protected:
93 SkString fFilename; 94 SkString fFilename;
94 int fSize; 95 int fSize;
95 96
96 SkScalar getScale() { 97 SkScalar getScale() {
97 return 192.f/fSize; 98 return 192.f/fSize;
98 } 99 }
99 100
100 void makeBitmap() { 101 void makeBitmap() {
101 if (!GetResourceAsBitmap(fFilename.c_str(), &fBM)) { 102 SkImageDecoder* codec = nullptr;
102 fBM.allocN32Pixels(1, 1); 103 SkString resourcePath = GetResourcePath(fFilename.c_str());
103 fBM.eraseARGB(255, 255, 0 , 0); // red == bad 104 SkFILEStream stream(resourcePath.c_str());
104 } 105 if (stream.isValid()) {
105 fSize = fBM.height(); 106 codec = SkImageDecoder::Factory(&stream);
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();
106 } 117 }
107 private: 118 private:
108 typedef skiagm::GM INHERITED; 119 typedef skiagm::GM INHERITED;
109 }; 120 };
110 121
111 ////////////////////////////////////////////////////////////////////////////// 122 //////////////////////////////////////////////////////////////////////////////
112 123
113 124
114 DEF_GM( return new FilterIndiaBoxGM("box.gif"); ) 125 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