| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 #ifndef SkDecodingImageGenerator_DEFINED | 8 #ifndef SkDecodingImageGenerator_DEFINED |
| 9 #define SkDecodingImageGenerator_DEFINED | 9 #define SkDecodingImageGenerator_DEFINED |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 * | 33 * |
| 34 * @param fDitherImage Set to true if the the decoder should try to | 34 * @param fDitherImage Set to true if the the decoder should try to |
| 35 * dither the resulting image when decoding to a smaller | 35 * dither the resulting image when decoding to a smaller |
| 36 * color-space. The default is true. | 36 * color-space. The default is true. |
| 37 * | 37 * |
| 38 * @param fRequestedColorType If not given, then use whichever | 38 * @param fRequestedColorType If not given, then use whichever |
| 39 * config the decoder wants. Else try to use this color | 39 * config the decoder wants. Else try to use this color |
| 40 * type. If the decoder won't support this color type, | 40 * type. If the decoder won't support this color type, |
| 41 * SkDecodingImageGenerator::Create will return | 41 * SkDecodingImageGenerator::Create will return |
| 42 * NULL. kIndex_8_SkColorType is not supported. | 42 * NULL. kIndex_8_SkColorType is not supported. |
| 43 * |
| 44 * @param fRequireUnpremul If true, the decoder will attempt to |
| 45 * decode without premultiplying the alpha. If it cannot, |
| 46 * the pixels will be set to NULL. |
| 43 */ | 47 */ |
| 44 struct Options { | 48 struct Options { |
| 45 Options() | 49 Options() |
| 46 : fSampleSize(1) | 50 : fSampleSize(1) |
| 47 , fDitherImage(true) | 51 , fDitherImage(true) |
| 48 , fUseRequestedColorType(false) | 52 , fUseRequestedColorType(false) |
| 49 , fRequestedColorType() { } | 53 , fRequestedColorType() |
| 54 , fRequireUnpremul(false) { } |
| 50 Options(int sampleSize, bool dither) | 55 Options(int sampleSize, bool dither) |
| 51 : fSampleSize(sampleSize) | 56 : fSampleSize(sampleSize) |
| 52 , fDitherImage(dither) | 57 , fDitherImage(dither) |
| 53 , fUseRequestedColorType(false) | 58 , fUseRequestedColorType(false) |
| 54 , fRequestedColorType() { } | 59 , fRequestedColorType() |
| 60 , fRequireUnpremul(false) { } |
| 55 Options(int sampleSize, bool dither, SkColorType colorType) | 61 Options(int sampleSize, bool dither, SkColorType colorType) |
| 56 : fSampleSize(sampleSize) | 62 : fSampleSize(sampleSize) |
| 57 , fDitherImage(dither) | 63 , fDitherImage(dither) |
| 58 , fUseRequestedColorType(true) | 64 , fUseRequestedColorType(true) |
| 59 , fRequestedColorType(colorType) { } | 65 , fRequestedColorType(colorType) |
| 66 , fRequireUnpremul(false) { } |
| 67 Options(int sampleSize, bool dither, SkColorType colorType, |
| 68 bool requireUnpremul) |
| 69 : fSampleSize(sampleSize) |
| 70 , fDitherImage(dither) |
| 71 , fUseRequestedColorType(true) |
| 72 , fRequestedColorType(colorType) |
| 73 , fRequireUnpremul(requireUnpremul) { } |
| 60 const int fSampleSize; | 74 const int fSampleSize; |
| 61 const bool fDitherImage; | 75 const bool fDitherImage; |
| 62 const bool fUseRequestedColorType; | 76 const bool fUseRequestedColorType; |
| 63 const SkColorType fRequestedColorType; | 77 const SkColorType fRequestedColorType; |
| 78 const bool fRequireUnpremul; |
| 64 }; | 79 }; |
| 65 | 80 |
| 66 /** | 81 /** |
| 67 * These two functions return a SkImageGenerator that calls into | 82 * These two functions return a SkImageGenerator that calls into |
| 68 * SkImageDecoder. They return NULL on failure. | 83 * SkImageDecoder. They return NULL on failure. |
| 69 * | 84 * |
| 70 * The SkData version of this function is preferred. If the stream | 85 * The SkData version of this function is preferred. If the stream |
| 71 * has an underlying SkData (such as a SkMemoryStream) pass that in. | 86 * has an underlying SkData (such as a SkMemoryStream) pass that in. |
| 72 * | 87 * |
| 73 * This object will unref the stream when done or on failure. Since | 88 * This object will unref the stream when done or on failure. Since |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 // SkDecodingImageGenerator::Create( | 122 // SkDecodingImageGenerator::Create( |
| 108 // data, SkDecodingImageGenerator::Options()), dst, NULL); | 123 // data, SkDecodingImageGenerator::Options()), dst, NULL); |
| 109 // } | 124 // } |
| 110 // bool install_stream(SkStreamRewindable* stream, SkBitmap* dst) { | 125 // bool install_stream(SkStreamRewindable* stream, SkBitmap* dst) { |
| 111 // return SkInstallDiscardablePixelRef( | 126 // return SkInstallDiscardablePixelRef( |
| 112 // SkDecodingImageGenerator::Create( | 127 // SkDecodingImageGenerator::Create( |
| 113 // stream, SkDecodingImageGenerator::Options()), dst, NULL); | 128 // stream, SkDecodingImageGenerator::Options()), dst, NULL); |
| 114 // } | 129 // } |
| 115 | 130 |
| 116 #endif // SkDecodingImageGenerator_DEFINED | 131 #endif // SkDecodingImageGenerator_DEFINED |
| OLD | NEW |