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 26 matching lines...) Expand all Loading... |
37 * then the returned bitmap will be 1/3 as wide and high, | 37 * then the returned bitmap will be 1/3 as wide and high, |
38 * and will contain 1/9 as many pixels as the original. | 38 * and will contain 1/9 as many pixels as the original. |
39 * Note: this is a hint, and the codec may choose to | 39 * Note: this is a hint, and the codec may choose to |
40 * ignore this, or only approximate the sample size. | 40 * ignore this, or only approximate the sample size. |
41 * | 41 * |
42 * @param fDitherImage Set to true if the the decoder should try to | 42 * @param fDitherImage Set to true if the the decoder should try to |
43 * dither the resulting image when decoding to a smaller | 43 * dither the resulting image when decoding to a smaller |
44 * color-space. The default is true. | 44 * color-space. The default is true. |
45 * | 45 * |
46 * @param fRequestedColorType If not given, then use whichever | 46 * @param fRequestedColorType If not given, then use whichever |
47 * config the decoder wants. Else try to use this color | 47 * colortype the decoder wants. Else try to use this color |
48 * type. If the decoder won't support this color type, | 48 * type. If the decoder won't support this color type, |
49 * SkDecodingImageGenerator::Create will return | 49 * SkDecodingImageGenerator::Create will return |
50 * NULL. kIndex_8_SkColorType is not supported. | 50 * NULL. kIndex_8_SkColorType is not supported. |
51 */ | 51 */ |
52 struct Options { | 52 struct Options { |
53 Options() | 53 Options() |
54 : fSampleSize(1) | 54 : fSampleSize(1) |
55 , fDitherImage(true) | 55 , fDitherImage(true) |
56 , fUseRequestedColorType(false) | 56 , fUseRequestedColorType(false) |
57 , fRequestedColorType() { } | 57 , fRequestedColorType() { } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 * SkImageGenerator constructor and and unref()ed on deletion. | 106 * SkImageGenerator constructor and and unref()ed on deletion. |
107 */ | 107 */ |
108 static SkImageGenerator* Create(SkData* data, const Options& opt); | 108 static SkImageGenerator* Create(SkData* data, const Options& opt); |
109 | 109 |
110 private: | 110 private: |
111 SkData* fData; | 111 SkData* fData; |
112 SkStreamRewindable* fStream; | 112 SkStreamRewindable* fStream; |
113 const SkImageInfo fInfo; | 113 const SkImageInfo fInfo; |
114 const int fSampleSize; | 114 const int fSampleSize; |
115 const bool fDitherImage; | 115 const bool fDitherImage; |
116 const SkBitmap::Config fRequestedConfig; | 116 const SkColorType fRequestedColorType; |
| 117 |
117 SkDecodingImageGenerator(SkData* data, | 118 SkDecodingImageGenerator(SkData* data, |
118 SkStreamRewindable* stream, | 119 SkStreamRewindable* stream, |
119 const SkImageInfo& info, | 120 const SkImageInfo& info, |
120 int sampleSize, | 121 int sampleSize, |
121 bool ditherImage, | 122 bool ditherImage, |
122 SkBitmap::Config requestedConfig); | 123 SkColorType requestedColorType); |
123 static SkImageGenerator* Create(SkData*, SkStreamRewindable*, | 124 static SkImageGenerator* Create(SkData*, SkStreamRewindable*, |
124 const Options&); | 125 const Options&); |
125 typedef SkImageGenerator INHERITED; | 126 typedef SkImageGenerator INHERITED; |
126 }; | 127 }; |
127 | 128 |
128 // // Example of most basic use case: | 129 // // Example of most basic use case: |
129 // | 130 // |
130 // bool install_data(SkData* data, SkBitmap* dst) { | 131 // bool install_data(SkData* data, SkBitmap* dst) { |
131 // return SkInstallDiscardablePixelRef( | 132 // return SkInstallDiscardablePixelRef( |
132 // SkDecodingImageGenerator::Create( | 133 // SkDecodingImageGenerator::Create( |
133 // data, SkDecodingImageGenerator::Options()), dst, NULL); | 134 // data, SkDecodingImageGenerator::Options()), dst, NULL); |
134 // } | 135 // } |
135 // bool install_stream(SkStreamRewindable* stream, SkBitmap* dst) { | 136 // bool install_stream(SkStreamRewindable* stream, SkBitmap* dst) { |
136 // return SkInstallDiscardablePixelRef( | 137 // return SkInstallDiscardablePixelRef( |
137 // SkDecodingImageGenerator::Create( | 138 // SkDecodingImageGenerator::Create( |
138 // stream, SkDecodingImageGenerator::Options()), dst, NULL); | 139 // stream, SkDecodingImageGenerator::Options()), dst, NULL); |
139 // } | 140 // } |
140 | 141 |
141 #endif // SkDecodingImageGenerator_DEFINED | 142 #endif // SkDecodingImageGenerator_DEFINED |
OLD | NEW |