OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "SkView.h" | 9 #include "SkView.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
11 #include "SkData.h" | 11 #include "SkData.h" |
12 #include "SkDecodingImageGenerator.h" | 12 #include "SkImageGenerator.h" |
13 #include "SkGradientShader.h" | 13 #include "SkGradientShader.h" |
14 #include "SkGraphics.h" | 14 #include "SkGraphics.h" |
15 #include "SkImageDecoder.h" | 15 #include "SkImageDecoder.h" |
16 #include "SkImageEncoder.h" | 16 #include "SkImageEncoder.h" |
17 #include "SkPath.h" | 17 #include "SkPath.h" |
18 #include "SkRegion.h" | 18 #include "SkRegion.h" |
19 #include "SkShader.h" | 19 #include "SkShader.h" |
20 #include "SkUtils.h" | 20 #include "SkUtils.h" |
21 #include "SkXfermode.h" | 21 #include "SkXfermode.h" |
22 #include "SkColorPriv.h" | 22 #include "SkColorPriv.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 yy += SkIntToScalar(fBitmaps[i].height() + 10); | 186 yy += SkIntToScalar(fBitmaps[i].height() + 10); |
187 | 187 |
188 SkBitmap bm; | 188 SkBitmap bm; |
189 SkData* encoded = NULL; | 189 SkData* encoded = NULL; |
190 if (SkImageEncoder::kJPEG_Type == gTypes[j]) { | 190 if (SkImageEncoder::kJPEG_Type == gTypes[j]) { |
191 encoded = fEncodedJPEGs[i].get(); | 191 encoded = fEncodedJPEGs[i].get(); |
192 } else if (SkImageEncoder::kPNG_Type == gTypes[j]) { | 192 } else if (SkImageEncoder::kPNG_Type == gTypes[j]) { |
193 encoded = fEncodedPNGs[i].get(); | 193 encoded = fEncodedPNGs[i].get(); |
194 } | 194 } |
195 if (encoded) { | 195 if (encoded) { |
196 if (!SkInstallDiscardablePixelRef( | 196 if (!SkInstallDiscardablePixelRef(encoded, &bm)) { |
197 SkDecodingImageGenerator::Create(encoded, | |
198 SkDecodingImageGenerator::Options()), | |
199 &bm)) { | |
200 SkDebugf("[%s:%d] failed to decode %s%s\n", | 197 SkDebugf("[%s:%d] failed to decode %s%s\n", |
201 __FILE__, __LINE__,gConfigLabels[i], gExt[j]); | 198 __FILE__, __LINE__,gConfigLabels[i], gExt[j]); |
202 } | 199 } |
203 canvas->drawBitmap(bm, x, yy); | 200 canvas->drawBitmap(bm, x, yy); |
204 } | 201 } |
205 } | 202 } |
206 | 203 |
207 x += SkIntToScalar(fBitmaps[i].width() + SPACER); | 204 x += SkIntToScalar(fBitmaps[i].width() + SPACER); |
208 if (x > maxX) { | 205 if (x > maxX) { |
209 maxX = x; | 206 maxX = x; |
(...skipping 17 matching lines...) Expand all Loading... |
227 } | 224 } |
228 | 225 |
229 private: | 226 private: |
230 typedef SampleView INHERITED; | 227 typedef SampleView INHERITED; |
231 }; | 228 }; |
232 | 229 |
233 ////////////////////////////////////////////////////////////////////////////// | 230 ////////////////////////////////////////////////////////////////////////////// |
234 | 231 |
235 static SkView* MyFactory() { return new EncodeView; } | 232 static SkView* MyFactory() { return new EncodeView; } |
236 static SkViewRegister reg(MyFactory); | 233 static SkViewRegister reg(MyFactory); |
OLD | NEW |