| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 SkAndroidCodec_DEFINED | 8 #ifndef SkAndroidCodec_DEFINED |
| 9 #define SkAndroidCodec_DEFINED | 9 #define SkAndroidCodec_DEFINED |
| 10 | 10 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 AndroidOptions() | 136 AndroidOptions() |
| 137 : fZeroInitialized(SkCodec::kNo_ZeroInitialized) | 137 : fZeroInitialized(SkCodec::kNo_ZeroInitialized) |
| 138 , fSubset(nullptr) | 138 , fSubset(nullptr) |
| 139 , fColorPtr(nullptr) | 139 , fColorPtr(nullptr) |
| 140 , fColorCount(nullptr) | 140 , fColorCount(nullptr) |
| 141 , fSampleSize(1) | 141 , fSampleSize(1) |
| 142 {} | 142 {} |
| 143 | 143 |
| 144 /** | 144 /** |
| 145 * Indicates is destination pixel memory is zero initialized. | 145 * Indicates is destination pixel memory is zero initialized. |
| 146 * |
| 147 * The default is SkCodec::kNo_ZeroInitialized. |
| 146 */ | 148 */ |
| 147 SkCodec::ZeroInitialized fZeroInitialized; | 149 SkCodec::ZeroInitialized fZeroInitialized; |
| 148 | 150 |
| 149 /** | 151 /** |
| 150 * If not NULL, represents a subset of the original image to decode. | 152 * If not NULL, represents a subset of the original image to decode. |
| 151 * | 153 * |
| 152 * Must be within the bounds returned by getInfo(). | 154 * Must be within the bounds returned by getInfo(). |
| 153 * | 155 * |
| 154 * If the EncodedFormat is kWEBP_SkEncodedFormat, the top and left | 156 * If the EncodedFormat is kWEBP_SkEncodedFormat, the top and left |
| 155 * values must be even. | 157 * values must be even. |
| 158 * |
| 159 * The default is NULL, meaning a decode of the entire image. |
| 156 */ | 160 */ |
| 157 SkIRect* fSubset; | 161 SkIRect* fSubset; |
| 158 | 162 |
| 159 /** | 163 /** |
| 160 * If the client has requested a decode to kIndex8_SkColorType | 164 * If the client has requested a decode to kIndex8_SkColorType |
| 161 * (specified in the SkImageInfo), then the caller must provide | 165 * (specified in the SkImageInfo), then the caller must provide |
| 162 * storage for up to 256 SkPMColor values in fColorPtr. On success, | 166 * storage for up to 256 SkPMColor values in fColorPtr. On success, |
| 163 * the codec must copy N colors into that storage, (where N is the | 167 * the codec must copy N colors into that storage, (where N is the |
| 164 * logical number of table entries) and set fColorCount to N. | 168 * logical number of table entries) and set fColorCount to N. |
| 165 * | 169 * |
| 166 * If the client does not request kIndex8_SkColorType, then the last | 170 * If the client does not request kIndex8_SkColorType, then the last |
| 167 * two parameters may be NULL. If fColorCount is not null, it will be | 171 * two parameters may be NULL. If fColorCount is not null, it will be |
| 168 * set to 0. | 172 * set to 0. |
| 173 * |
| 174 * The default is NULL for both pointers. |
| 169 */ | 175 */ |
| 170 SkPMColor* fColorPtr; | 176 SkPMColor* fColorPtr; |
| 171 int* fColorCount; | 177 int* fColorCount; |
| 172 | 178 |
| 173 /** | 179 /** |
| 174 * The client may provide an integer downscale factor for the decode. | 180 * The client may provide an integer downscale factor for the decode. |
| 175 * The codec may implement this downscaling by sampling or another | 181 * The codec may implement this downscaling by sampling or another |
| 176 * method if it is more efficient. | 182 * method if it is more efficient. |
| 183 * |
| 184 * The default is 1, representing no downscaling. |
| 177 */ | 185 */ |
| 178 int fSampleSize; | 186 int fSampleSize; |
| 179 }; | 187 }; |
| 180 | 188 |
| 181 /** | 189 /** |
| 182 * Decode into the given pixels, a block of memory of size at | 190 * Decode into the given pixels, a block of memory of size at |
| 183 * least (info.fHeight - 1) * rowBytes + (info.fWidth * | 191 * least (info.fHeight - 1) * rowBytes + (info.fWidth * |
| 184 * bytesPerPixel) | 192 * bytesPerPixel) |
| 185 * | 193 * |
| 186 * Repeated calls to this function should give the same results, | 194 * Repeated calls to this function should give the same results, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 200 * | 208 * |
| 201 * If info is kIndex8_SkColorType, then the caller must provide storage for
up to 256 | 209 * If info is kIndex8_SkColorType, then the caller must provide storage for
up to 256 |
| 202 * SkPMColor values in options->fColorPtr. On success the codec must copy N
colors into | 210 * SkPMColor values in options->fColorPtr. On success the codec must copy N
colors into |
| 203 * that storage, (where N is the logical number of table entries) and set | 211 * that storage, (where N is the logical number of table entries) and set |
| 204 * options->fColorCount to N. | 212 * options->fColorCount to N. |
| 205 * | 213 * |
| 206 * If info is not kIndex8_SkColorType, options->fColorPtr and options->fCol
orCount may | 214 * If info is not kIndex8_SkColorType, options->fColorPtr and options->fCol
orCount may |
| 207 * be nullptr. | 215 * be nullptr. |
| 208 * | 216 * |
| 209 * The AndroidOptions object is also used to specify any requested scaling
or subsetting | 217 * The AndroidOptions object is also used to specify any requested scaling
or subsetting |
| 210 * using options->fSampleSize and options->fSubset. | 218 * using options->fSampleSize and options->fSubset. If NULL, the defaults (
as specified above |
| 219 * for AndroidOptions) are used. |
| 211 * | 220 * |
| 212 * @return Result kSuccess, or another value explaining the type of failure
. | 221 * @return Result kSuccess, or another value explaining the type of failure
. |
| 213 */ | 222 */ |
| 214 // FIXME: It's a bit redundant to name this getAndroidPixels() when this cla
ss is already | 223 // FIXME: It's a bit redundant to name this getAndroidPixels() when this cla
ss is already |
| 215 // called SkAndroidCodec. On the other hand, it's may be a bit confu
sing to call | 224 // called SkAndroidCodec. On the other hand, it's may be a bit confu
sing to call |
| 216 // this getPixels() when it is a slightly different API than SkCodec'
s getPixels(). | 225 // this getPixels() when it is a slightly different API than SkCodec'
s getPixels(). |
| 217 // Maybe this should be decode() or decodeSubset()? | 226 // Maybe this should be decode() or decodeSubset()? |
| 218 SkCodec::Result getAndroidPixels(const SkImageInfo& info, void* pixels, size
_t rowBytes, | 227 SkCodec::Result getAndroidPixels(const SkImageInfo& info, void* pixels, size
_t rowBytes, |
| 219 const AndroidOptions* options); | 228 const AndroidOptions* options); |
| 220 | 229 |
| 221 /** | 230 /** |
| 222 * Simplified version of getAndroidPixels() where we supply the default And
roidOptions. | 231 * Simplified version of getAndroidPixels() where we supply the default And
roidOptions as |
| 232 * specified above for AndroidOptions. |
| 223 * | 233 * |
| 224 * This will return an error if the info is kIndex_8_SkColorType and also w
ill not perform | 234 * This will return an error if the info is kIndex_8_SkColorType and also w
ill not perform |
| 225 * any scaling or subsetting. | 235 * any scaling or subsetting. |
| 226 */ | 236 */ |
| 227 SkCodec::Result getAndroidPixels(const SkImageInfo& info, void* pixels, size
_t rowBytes); | 237 SkCodec::Result getAndroidPixels(const SkImageInfo& info, void* pixels, size
_t rowBytes); |
| 228 | 238 |
| 239 SkCodec::Result getPixels(const SkImageInfo& info, void* pixels, size_t rowB
ytes) { |
| 240 return this->getAndroidPixels(info, pixels, rowBytes); |
| 241 } |
| 242 |
| 229 protected: | 243 protected: |
| 230 | 244 |
| 231 SkAndroidCodec(SkCodec*); | 245 SkAndroidCodec(SkCodec*); |
| 232 | 246 |
| 233 SkCodec* codec() const { return fCodec.get(); } | 247 SkCodec* codec() const { return fCodec.get(); } |
| 234 | 248 |
| 235 virtual SkISize onGetSampledDimensions(int sampleSize) const = 0; | 249 virtual SkISize onGetSampledDimensions(int sampleSize) const = 0; |
| 236 | 250 |
| 237 virtual bool onGetSupportedSubset(SkIRect* desiredSubset) const = 0; | 251 virtual bool onGetSupportedSubset(SkIRect* desiredSubset) const = 0; |
| 238 | 252 |
| 239 virtual SkCodec::Result onGetAndroidPixels(const SkImageInfo& info, void* pi
xels, | 253 virtual SkCodec::Result onGetAndroidPixels(const SkImageInfo& info, void* pi
xels, |
| 240 size_t rowBytes, const AndroidOptions& options) = 0; | 254 size_t rowBytes, const AndroidOptions& options) = 0; |
| 241 | 255 |
| 242 private: | 256 private: |
| 243 | 257 |
| 244 // This will always be a reference to the info that is contained by the | 258 // This will always be a reference to the info that is contained by the |
| 245 // embedded SkCodec. | 259 // embedded SkCodec. |
| 246 const SkImageInfo& fInfo; | 260 const SkImageInfo& fInfo; |
| 247 | 261 |
| 248 SkAutoTDelete<SkCodec> fCodec; | 262 SkAutoTDelete<SkCodec> fCodec; |
| 249 }; | 263 }; |
| 250 #endif // SkAndroidCodec_DEFINED | 264 #endif // SkAndroidCodec_DEFINED |
| OLD | NEW |