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

Side by Side Diff: gm/cmykjpeg.cpp

Issue 334793002: hide Config in SkImageDecoder -- use SkColorType instead (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix warning Created 6 years, 6 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 | « experimental/PdfViewer/chop_transparency_main.cpp ('k') | gm/copyTo4444.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 2012 Google Inc. 2 * Copyright 2012 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 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkImageDecoder.h" 10 #include "SkImageDecoder.h"
11 #include "SkStream.h" 11 #include "SkStream.h"
12 12
13 namespace skiagm { 13 namespace skiagm {
14 14
15 /** Draw a CMYK encoded jpeg - libjpeg doesn't support CMYK->RGB 15 /** Draw a CMYK encoded jpeg - libjpeg doesn't support CMYK->RGB
16 conversion so this tests Skia's internal processing 16 conversion so this tests Skia's internal processing
17 */ 17 */
18 class CMYKJpegGM : public GM { 18 class CMYKJpegGM : public GM {
19 public: 19 public:
20 CMYKJpegGM() {} 20 CMYKJpegGM() {}
21 21
22 protected: 22 protected:
23 virtual void onOnceBeforeDraw() SK_OVERRIDE { 23 virtual void onOnceBeforeDraw() SK_OVERRIDE {
24 24
25 // parameters to the "decode" call 25 // parameters to the "decode" call
26 bool dither = false; 26 bool dither = false;
27 SkBitmap::Config prefConfig = SkBitmap::kARGB_8888_Config;
28 27
29 SkString filename(INHERITED::gResourcePath); 28 SkString filename(INHERITED::gResourcePath);
30 if (!filename.endsWith("/") && !filename.endsWith("\\")) { 29 if (!filename.endsWith("/") && !filename.endsWith("\\")) {
31 filename.append("/"); 30 filename.append("/");
32 } 31 }
33 32
34 filename.append("CMYK.jpg"); 33 filename.append("CMYK.jpg");
35 34
36 SkFILEStream stream(filename.c_str()); 35 SkFILEStream stream(filename.c_str());
37 if (!stream.isValid()) { 36 if (!stream.isValid()) {
38 SkDebugf("Could not find CMYK.jpg, please set --resourcePath correct ly.\n"); 37 SkDebugf("Could not find CMYK.jpg, please set --resourcePath correct ly.\n");
39 return; 38 return;
40 } 39 }
41 40
42 SkImageDecoder* codec = SkImageDecoder::Factory(&stream); 41 SkImageDecoder* codec = SkImageDecoder::Factory(&stream);
43 if (codec) { 42 if (codec) {
44 stream.rewind(); 43 stream.rewind();
45 codec->setDitherImage(dither); 44 codec->setDitherImage(dither);
46 codec->decode(&stream, &fBitmap, prefConfig, 45 codec->decode(&stream, &fBitmap, kN32_SkColorType, SkImageDecoder::k DecodePixels_Mode);
47 SkImageDecoder::kDecodePixels_Mode);
48 SkDELETE(codec); 46 SkDELETE(codec);
49 } 47 }
50 } 48 }
51 49
52 virtual SkString onShortName() { 50 virtual SkString onShortName() {
53 return SkString("cmykjpeg"); 51 return SkString("cmykjpeg");
54 } 52 }
55 53
56 virtual SkISize onISize() { 54 virtual SkISize onISize() {
57 return SkISize::Make(640, 480); 55 return SkISize::Make(640, 480);
(...skipping 10 matching lines...) Expand all
68 66
69 typedef GM INHERITED; 67 typedef GM INHERITED;
70 }; 68 };
71 69
72 ////////////////////////////////////////////////////////////////////////////// 70 //////////////////////////////////////////////////////////////////////////////
73 71
74 static GM* MyFactory(void*) { return new CMYKJpegGM; } 72 static GM* MyFactory(void*) { return new CMYKJpegGM; }
75 static GMRegistry reg(MyFactory); 73 static GMRegistry reg(MyFactory);
76 74
77 } 75 }
OLDNEW
« no previous file with comments | « experimental/PdfViewer/chop_transparency_main.cpp ('k') | gm/copyTo4444.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698