OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkImageDecoder_DEFINED | 10 #ifndef SkImageDecoder_DEFINED |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 of the decoded stream. On failure it is ignored. | 355 of the decoded stream. On failure it is ignored. |
356 */ | 356 */ |
357 static bool DecodeStream(SkStreamRewindable* stream, SkBitmap* bitmap, | 357 static bool DecodeStream(SkStreamRewindable* stream, SkBitmap* bitmap, |
358 SkBitmap::Config prefConfig, Mode, | 358 SkBitmap::Config prefConfig, Mode, |
359 Format* format = NULL); | 359 Format* format = NULL); |
360 static bool DecodeStream(SkStreamRewindable* stream, SkBitmap* bitmap) { | 360 static bool DecodeStream(SkStreamRewindable* stream, SkBitmap* bitmap) { |
361 return DecodeStream(stream, bitmap, SkBitmap::kNo_Config, | 361 return DecodeStream(stream, bitmap, SkBitmap::kNo_Config, |
362 kDecodePixels_Mode, NULL); | 362 kDecodePixels_Mode, NULL); |
363 } | 363 } |
364 | 364 |
365 /** Return the default config for the running device. | |
366 Currently this used as a suggestion to image decoders that need to guess | |
367 what config they should decode into. | |
368 Default is kNo_Config, but this can be changed with SetDeviceConfig() | |
369 */ | |
370 static SkBitmap::Config GetDeviceConfig(); | |
371 /** Set the default config for the running device. | |
372 Currently this used as a suggestion to image decoders that need to guess | |
373 what config they should decode into. | |
374 Default is kNo_Config. | |
375 This can be queried with GetDeviceConfig() | |
376 */ | |
377 static void SetDeviceConfig(SkBitmap::Config); | |
378 | |
379 protected: | 365 protected: |
380 // must be overridden in subclasses. This guy is called by decode(...) | 366 // must be overridden in subclasses. This guy is called by decode(...) |
381 virtual bool onDecode(SkStream*, SkBitmap* bitmap, Mode) = 0; | 367 virtual bool onDecode(SkStream*, SkBitmap* bitmap, Mode) = 0; |
382 | 368 |
383 // If the decoder wants to support tiled based decoding, | 369 // If the decoder wants to support tiled based decoding, |
384 // this method must be overridden. This guy is called by buildTileIndex(...) | 370 // this method must be overridden. This guy is called by buildTileIndex(...) |
385 virtual bool onBuildTileIndex(SkStreamRewindable*, int *width, int *height)
{ | 371 virtual bool onBuildTileIndex(SkStreamRewindable*, int *width, int *height)
{ |
386 return false; | 372 return false; |
387 } | 373 } |
388 | 374 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 kIndex_SrcDepth, | 444 kIndex_SrcDepth, |
459 // Grayscale in 8 bits. | 445 // Grayscale in 8 bits. |
460 k8BitGray_SrcDepth, | 446 k8BitGray_SrcDepth, |
461 // 8 bits per component. Used for 24 bit if there is no alpha. | 447 // 8 bits per component. Used for 24 bit if there is no alpha. |
462 k32Bit_SrcDepth, | 448 k32Bit_SrcDepth, |
463 }; | 449 }; |
464 /** The subclass, inside onDecode(), calls this to determine the colorType o
f | 450 /** The subclass, inside onDecode(), calls this to determine the colorType o
f |
465 the returned bitmap. SrcDepth and hasAlpha reflect the raw data of the | 451 the returned bitmap. SrcDepth and hasAlpha reflect the raw data of the |
466 src image. This routine returns the caller's preference given | 452 src image. This routine returns the caller's preference given |
467 srcDepth and hasAlpha, or kUnknown_SkColorType if there is no preference
. | 453 srcDepth and hasAlpha, or kUnknown_SkColorType if there is no preference
. |
468 | |
469 Note: this also takes into account GetDeviceConfig(), so the subclass | |
470 need not call that. | |
471 */ | 454 */ |
472 SkColorType getPrefColorType(SrcDepth, bool hasAlpha) const; | 455 SkColorType getPrefColorType(SrcDepth, bool hasAlpha) const; |
473 | 456 |
474 private: | 457 private: |
475 Peeker* fPeeker; | 458 Peeker* fPeeker; |
476 #ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER | 459 #ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER |
477 Chooser* fChooser; | 460 Chooser* fChooser; |
478 #endif | 461 #endif |
479 SkBitmap::Allocator* fAllocator; | 462 SkBitmap::Allocator* fAllocator; |
480 int fSampleSize; | 463 int fSampleSize; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 DECLARE_DECODER_CREATOR(WEBPImageDecoder); | 518 DECLARE_DECODER_CREATOR(WEBPImageDecoder); |
536 DECLARE_DECODER_CREATOR(PKMImageDecoder); | 519 DECLARE_DECODER_CREATOR(PKMImageDecoder); |
537 DECLARE_DECODER_CREATOR(KTXImageDecoder); | 520 DECLARE_DECODER_CREATOR(KTXImageDecoder); |
538 | 521 |
539 // Typedefs to make registering decoder and formatter callbacks easier. | 522 // Typedefs to make registering decoder and formatter callbacks easier. |
540 // These have to be defined outside SkImageDecoder. :( | 523 // These have to be defined outside SkImageDecoder. :( |
541 typedef SkTRegistry<SkImageDecoder*(*)(SkStreamRewindable*)> SkImageDecod
er_DecodeReg; | 524 typedef SkTRegistry<SkImageDecoder*(*)(SkStreamRewindable*)> SkImageDecod
er_DecodeReg; |
542 typedef SkTRegistry<SkImageDecoder::Format(*)(SkStreamRewindable*)> SkImageDecod
er_FormatReg; | 525 typedef SkTRegistry<SkImageDecoder::Format(*)(SkStreamRewindable*)> SkImageDecod
er_FormatReg; |
543 | 526 |
544 #endif | 527 #endif |
OLD | NEW |