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

Side by Side Diff: gm/cmykjpeg.cpp

Issue 351133003: Cleanup usage of GetResourcePath() after commit bcbc1788b478b1e54079318ad073e8490aa66fae. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 5 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 | « bench/ETCBitmapBench.cpp ('k') | gm/coloremoji.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 9
10 #include "Resources.h" 10 #include "Resources.h"
11 #include "SkCanvas.h" 11 #include "SkCanvas.h"
12 #include "SkImageDecoder.h" 12 #include "SkImageDecoder.h"
13 #include "SkStream.h" 13 #include "SkStream.h"
14 14
15 namespace skiagm { 15 namespace skiagm {
16 16
17 /** Draw a CMYK encoded jpeg - libjpeg doesn't support CMYK->RGB 17 /** Draw a CMYK encoded jpeg - libjpeg doesn't support CMYK->RGB
18 conversion so this tests Skia's internal processing 18 conversion so this tests Skia's internal processing
19 */ 19 */
20 class CMYKJpegGM : public GM { 20 class CMYKJpegGM : public GM {
21 public: 21 public:
22 CMYKJpegGM() {} 22 CMYKJpegGM() {}
23 23
24 protected: 24 protected:
25 virtual void onOnceBeforeDraw() SK_OVERRIDE { 25 virtual void onOnceBeforeDraw() SK_OVERRIDE {
26 // parameters to the "decode" call 26 // parameters to the "decode" call
27 bool dither = false; 27 bool dither = false;
28 28
29 SkString resourcePath = GetResourcePath(); 29 SkString jpgFilename = GetResourcePath("CMYK.jpg");
30 if (!resourcePath.endsWith("/") && !resourcePath.endsWith("\\")) { 30 SkFILEStream stream(jpgFilename.c_str());
31 resourcePath.append("/");
32 }
33
34 resourcePath.append("CMYK.jpg");
35
36 SkFILEStream stream(resourcePath.c_str());
37 if (!stream.isValid()) { 31 if (!stream.isValid()) {
38 SkDebugf("Could not find CMYK.jpg, please set --resourcePath correct ly.\n"); 32 SkDebugf("Could not find CMYK.jpg, please set --resourcePath correct ly.\n");
39 return; 33 return;
40 } 34 }
41 35
42 SkImageDecoder* codec = SkImageDecoder::Factory(&stream); 36 SkImageDecoder* codec = SkImageDecoder::Factory(&stream);
43 if (codec) { 37 if (codec) {
44 stream.rewind(); 38 stream.rewind();
45 codec->setDitherImage(dither); 39 codec->setDitherImage(dither);
46 codec->decode(&stream, &fBitmap, kN32_SkColorType, SkImageDecoder::k DecodePixels_Mode); 40 codec->decode(&stream, &fBitmap, kN32_SkColorType, SkImageDecoder::k DecodePixels_Mode);
(...skipping 20 matching lines...) Expand all
67 61
68 typedef GM INHERITED; 62 typedef GM INHERITED;
69 }; 63 };
70 64
71 ////////////////////////////////////////////////////////////////////////////// 65 //////////////////////////////////////////////////////////////////////////////
72 66
73 static GM* MyFactory(void*) { return new CMYKJpegGM; } 67 static GM* MyFactory(void*) { return new CMYKJpegGM; }
74 static GMRegistry reg(MyFactory); 68 static GMRegistry reg(MyFactory);
75 69
76 } 70 }
OLDNEW
« no previous file with comments | « bench/ETCBitmapBench.cpp ('k') | gm/coloremoji.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698