OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 SkImageDecoder_DEFINED | 8 #ifndef SkImageDecoder_DEFINED |
9 #define SkImageDecoder_DEFINED | 9 #define SkImageDecoder_DEFINED |
10 | 10 |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 bool decodeSubset(SkBitmap* bm, const SkIRect& subset, SkColorType pref); | 281 bool decodeSubset(SkBitmap* bm, const SkIRect& subset, SkColorType pref); |
282 | 282 |
283 /** Given a stream, this will try to find an appropriate decoder object. | 283 /** Given a stream, this will try to find an appropriate decoder object. |
284 If none is found, the method returns NULL. | 284 If none is found, the method returns NULL. |
285 */ | 285 */ |
286 static SkImageDecoder* Factory(SkStreamRewindable*); | 286 static SkImageDecoder* Factory(SkStreamRewindable*); |
287 | 287 |
288 /** Decode the image stored in the specified file, and store the result | 288 /** Decode the image stored in the specified file, and store the result |
289 in bitmap. Return true for success or false on failure. | 289 in bitmap. Return true for success or false on failure. |
290 | 290 |
291 @param pref If the PrefConfigTable is not set, prefer this colortype. | 291 @param pref Prefer this colortype. |
292 See NOTE ABOUT PREFERRED CONFIGS. | |
293 | 292 |
294 @param format On success, if format is non-null, it is set to the format | 293 @param format On success, if format is non-null, it is set to the format |
295 of the decoded file. On failure it is ignored. | 294 of the decoded file. On failure it is ignored. |
296 */ | 295 */ |
297 static bool DecodeFile(const char file[], SkBitmap* bitmap, SkColorType pref
, Mode, | 296 static bool DecodeFile(const char file[], SkBitmap* bitmap, SkColorType pref
, Mode, |
298 Format* format = NULL); | 297 Format* format = NULL); |
299 static bool DecodeFile(const char file[], SkBitmap* bitmap) { | 298 static bool DecodeFile(const char file[], SkBitmap* bitmap) { |
300 return DecodeFile(file, bitmap, kUnknown_SkColorType, kDecodePixels_Mode
, NULL); | 299 return DecodeFile(file, bitmap, kUnknown_SkColorType, kDecodePixels_Mode
, NULL); |
301 } | 300 } |
302 | 301 |
303 /** Decode the image stored in the specified memory buffer, and store the | 302 /** Decode the image stored in the specified memory buffer, and store the |
304 result in bitmap. Return true for success or false on failure. | 303 result in bitmap. Return true for success or false on failure. |
305 | 304 |
306 @param pref If the PrefConfigTable is not set, prefer this colortype. | 305 @param pref Prefer this colortype. |
307 See NOTE ABOUT PREFERRED CONFIGS. | |
308 | 306 |
309 @param format On success, if format is non-null, it is set to the format | 307 @param format On success, if format is non-null, it is set to the format |
310 of the decoded buffer. On failure it is ignored. | 308 of the decoded buffer. On failure it is ignored. |
311 */ | 309 */ |
312 static bool DecodeMemory(const void* buffer, size_t size, SkBitmap* bitmap,
SkColorType pref, | 310 static bool DecodeMemory(const void* buffer, size_t size, SkBitmap* bitmap,
SkColorType pref, |
313 Mode, Format* format = NULL); | 311 Mode, Format* format = NULL); |
314 static bool DecodeMemory(const void* buffer, size_t size, SkBitmap* bitmap){ | 312 static bool DecodeMemory(const void* buffer, size_t size, SkBitmap* bitmap){ |
315 return DecodeMemory(buffer, size, bitmap, kUnknown_SkColorType, kDecodeP
ixels_Mode, NULL); | 313 return DecodeMemory(buffer, size, bitmap, kUnknown_SkColorType, kDecodeP
ixels_Mode, NULL); |
316 } | 314 } |
317 | 315 |
318 /** | 316 /** |
319 * Struct containing information about a pixel destination. | 317 * Struct containing information about a pixel destination. |
320 */ | 318 */ |
321 struct Target { | 319 struct Target { |
322 /** | 320 /** |
323 * Pre-allocated memory. | 321 * Pre-allocated memory. |
324 */ | 322 */ |
325 void* fAddr; | 323 void* fAddr; |
326 | 324 |
327 /** | 325 /** |
328 * Rowbytes of the allocated memory. | 326 * Rowbytes of the allocated memory. |
329 */ | 327 */ |
330 size_t fRowBytes; | 328 size_t fRowBytes; |
331 }; | 329 }; |
332 | 330 |
333 /** Decode the image stored in the specified SkStreamRewindable, and store t
he result | 331 /** Decode the image stored in the specified SkStreamRewindable, and store t
he result |
334 in bitmap. Return true for success or false on failure. | 332 in bitmap. Return true for success or false on failure. |
335 | 333 |
336 @param pref If the PrefConfigTable is not set, prefer this colortype. | 334 @param pref Prefer this colortype. |
337 See NOTE ABOUT PREFERRED CONFIGS. | |
338 | 335 |
339 @param format On success, if format is non-null, it is set to the format | 336 @param format On success, if format is non-null, it is set to the format |
340 of the decoded stream. On failure it is ignored. | 337 of the decoded stream. On failure it is ignored. |
341 */ | 338 */ |
342 static bool DecodeStream(SkStreamRewindable* stream, SkBitmap* bitmap, SkCol
orType pref, Mode, | 339 static bool DecodeStream(SkStreamRewindable* stream, SkBitmap* bitmap, SkCol
orType pref, Mode, |
343 Format* format = NULL); | 340 Format* format = NULL); |
344 static bool DecodeStream(SkStreamRewindable* stream, SkBitmap* bitmap) { | 341 static bool DecodeStream(SkStreamRewindable* stream, SkBitmap* bitmap) { |
345 return DecodeStream(stream, bitmap, kUnknown_SkColorType, kDecodePixels_
Mode, NULL); | 342 return DecodeStream(stream, bitmap, kUnknown_SkColorType, kDecodePixels_
Mode, NULL); |
346 } | 343 } |
347 | 344 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 DECLARE_DECODER_CREATOR(PKMImageDecoder); | 507 DECLARE_DECODER_CREATOR(PKMImageDecoder); |
511 DECLARE_DECODER_CREATOR(KTXImageDecoder); | 508 DECLARE_DECODER_CREATOR(KTXImageDecoder); |
512 DECLARE_DECODER_CREATOR(ASTCImageDecoder); | 509 DECLARE_DECODER_CREATOR(ASTCImageDecoder); |
513 | 510 |
514 // Typedefs to make registering decoder and formatter callbacks easier. | 511 // Typedefs to make registering decoder and formatter callbacks easier. |
515 // These have to be defined outside SkImageDecoder. :( | 512 // These have to be defined outside SkImageDecoder. :( |
516 typedef SkTRegistry<SkImageDecoder*(*)(SkStreamRewindable*)> SkImageDecod
er_DecodeReg; | 513 typedef SkTRegistry<SkImageDecoder*(*)(SkStreamRewindable*)> SkImageDecod
er_DecodeReg; |
517 typedef SkTRegistry<SkImageDecoder::Format(*)(SkStreamRewindable*)> SkImageDecod
er_FormatReg; | 514 typedef SkTRegistry<SkImageDecoder::Format(*)(SkStreamRewindable*)> SkImageDecod
er_FormatReg; |
518 | 515 |
519 #endif | 516 #endif |
OLD | NEW |