| OLD | NEW |
| 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 |
| 10 #include "Resources.h" |
| 9 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
| 10 #include "SkImageDecoder.h" | 12 #include "SkImageDecoder.h" |
| 11 #include "SkStream.h" | 13 #include "SkStream.h" |
| 12 | 14 |
| 13 namespace skiagm { | 15 namespace skiagm { |
| 14 | 16 |
| 15 /** Draw a CMYK encoded jpeg - libjpeg doesn't support CMYK->RGB | 17 /** Draw a CMYK encoded jpeg - libjpeg doesn't support CMYK->RGB |
| 16 conversion so this tests Skia's internal processing | 18 conversion so this tests Skia's internal processing |
| 17 */ | 19 */ |
| 18 class CMYKJpegGM : public GM { | 20 class CMYKJpegGM : public GM { |
| 19 public: | 21 public: |
| 20 CMYKJpegGM() {} | 22 CMYKJpegGM() {} |
| 21 | 23 |
| 22 protected: | 24 protected: |
| 23 virtual void onOnceBeforeDraw() SK_OVERRIDE { | 25 virtual void onOnceBeforeDraw() SK_OVERRIDE { |
| 24 | |
| 25 // parameters to the "decode" call | 26 // parameters to the "decode" call |
| 26 bool dither = false; | 27 bool dither = false; |
| 27 | 28 |
| 28 SkString filename(INHERITED::gResourcePath); | 29 SkString resourcePath = GetResourcePath(); |
| 29 if (!filename.endsWith("/") && !filename.endsWith("\\")) { | 30 if (!resourcePath.endsWith("/") && !resourcePath.endsWith("\\")) { |
| 30 filename.append("/"); | 31 resourcePath.append("/"); |
| 31 } | 32 } |
| 32 | 33 |
| 33 filename.append("CMYK.jpg"); | 34 resourcePath.append("CMYK.jpg"); |
| 34 | 35 |
| 35 SkFILEStream stream(filename.c_str()); | 36 SkFILEStream stream(resourcePath.c_str()); |
| 36 if (!stream.isValid()) { | 37 if (!stream.isValid()) { |
| 37 SkDebugf("Could not find CMYK.jpg, please set --resourcePath correct
ly.\n"); | 38 SkDebugf("Could not find CMYK.jpg, please set --resourcePath correct
ly.\n"); |
| 38 return; | 39 return; |
| 39 } | 40 } |
| 40 | 41 |
| 41 SkImageDecoder* codec = SkImageDecoder::Factory(&stream); | 42 SkImageDecoder* codec = SkImageDecoder::Factory(&stream); |
| 42 if (codec) { | 43 if (codec) { |
| 43 stream.rewind(); | 44 stream.rewind(); |
| 44 codec->setDitherImage(dither); | 45 codec->setDitherImage(dither); |
| 45 codec->decode(&stream, &fBitmap, kN32_SkColorType, SkImageDecoder::k
DecodePixels_Mode); | 46 codec->decode(&stream, &fBitmap, kN32_SkColorType, SkImageDecoder::k
DecodePixels_Mode); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 66 | 67 |
| 67 typedef GM INHERITED; | 68 typedef GM INHERITED; |
| 68 }; | 69 }; |
| 69 | 70 |
| 70 ////////////////////////////////////////////////////////////////////////////// | 71 ////////////////////////////////////////////////////////////////////////////// |
| 71 | 72 |
| 72 static GM* MyFactory(void*) { return new CMYKJpegGM; } | 73 static GM* MyFactory(void*) { return new CMYKJpegGM; } |
| 73 static GMRegistry reg(MyFactory); | 74 static GMRegistry reg(MyFactory); |
| 74 | 75 |
| 75 } | 76 } |
| OLD | NEW |