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

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

Powered by Google App Engine
This is Rietveld 408576698