| 1 |
/* |
| 2 |
* Copyright 2024 Google LLC |
| 3 |
* |
| 4 |
* Use of this source code is governed by a BSD-style license that can be |
| 5 |
* found in the LICENSE file. |
| 6 |
*/ |
| 7 |
#ifndef CodecUtils_DEFINED |
| 8 |
#define CodecUtils_DEFINED |
| 9 |
#include "include/codec/SkCodec.h" |
| 10 |
|
| 11 |
#if defined(SK_CODEC_DECODES_AVIF) |
| 12 |
#include "include/codec/SkAvifDecoder.h" |
| 13 |
#endif |
| 14 |
|
| 15 |
#if defined(SK_CODEC_DECODES_BMP_WITH_RUST) |
| 16 |
#include "experimental/rust_bmp/decoder/SkBmpRustDecoder.h" |
| 17 |
#elif defined(SK_CODEC_DECODES_BMP) |
| 18 |
#include "include/codec/SkBmpDecoder.h" |
| 19 |
#endif |
| 20 |
|
| 21 |
#if defined(SK_CODEC_DECODES_GIF) |
| 22 |
#include "include/codec/SkGifDecoder.h" |
| 23 |
#endif |
| 24 |
|
| 25 |
#if defined(SK_CODEC_DECODES_ICO) |
| 26 |
#include "include/codec/SkIcoDecoder.h" |
| 27 |
#endif |
| 28 |
|
| 29 |
#if defined(SK_CODEC_DECODES_JPEG) |
| 30 |
#include "include/codec/SkJpegDecoder.h" |
| 31 |
#endif |
| 32 |
|
| 33 |
#if defined(SK_CODEC_DECODES_JPEGXL) |
| 34 |
#include "include/codec/SkJpegxlDecoder.h" |
| 35 |
#endif |
| 36 |
|
| 37 |
#if defined(SK_CODEC_DECODES_PNG_WITH_LIBPNG) |
| 38 |
#include "include/codec/SkPngDecoder.h" |
| 39 |
#endif |
| 40 |
|
| 41 |
#if defined(SK_CODEC_DECODES_PNG_WITH_RUST) |
| 42 |
#include "include/codec/SkPngRustDecoder.h" |
| 43 |
#endif |
| 44 |
|
| 45 |
#if defined(SK_CODEC_DECODES_RAW) |
| 46 |
#include "include/codec/SkRawDecoder.h" |
| 47 |
#endif |
| 48 |
|
| 49 |
#if defined(SK_CODEC_DECODES_WBMP) |
| 50 |
#include "include/codec/SkWbmpDecoder.h" |
| 51 |
#endif |
| 52 |
|
| 53 |
#if defined(SK_CODEC_DECODES_WEBP) |
| 54 |
#include "include/codec/SkWebpDecoder.h" |
| 55 |
#endif |
| 56 |
|
| 57 |
namespace CodecUtils { |
| 58 |
// Register all codecs which were compiled in. Our modular codecs set a define to signal if they |
| 59 |
// were compiled in or not. It is safe to call this more than once, as the SkCodecs::Register |
| 60 |
// function is idempotent. This function *cannot* go in src/ (e.g. as part of Skia proper) because |
| 61 |
// then Skia itself would need to depend on codecs, which we want to avoid. |
| 62 |
inline void RegisterAllAvailable() { |
| 63 |
#if defined(SK_CODEC_DECODES_AVIF) |
| 64 |
SkCodecs::Register(SkAvifDecoder::Decoder()); |
| 65 |
#endif |
| 66 |
#if defined(SK_CODEC_DECODES_BMP_WITH_RUST) |
| 67 |
SkCodecs::Register(SkBmpRustDecoder::Decoder()); |
| 68 |
#elif defined(SK_CODEC_DECODES_BMP) |
| 69 |
SkCodecs::Register(SkBmpDecoder::Decoder()); |
| 70 |
#endif |
| 71 |
#if defined(SK_CODEC_DECODES_GIF) |
| 72 |
SkCodecs::Register(SkGifDecoder::Decoder()); |
| 73 |
#endif |
| 74 |
#if defined(SK_CODEC_DECODES_ICO) |
| 75 |
SkCodecs::Register(SkIcoDecoder::Decoder()); |
| 76 |
#endif |
| 77 |
#if defined(SK_CODEC_DECODES_JPEG) |
| 78 |
SkCodecs::Register(SkJpegDecoder::Decoder()); |
| 79 |
#endif |
| 80 |
#if defined(SK_CODEC_DECODES_JPEGXL) |
| 81 |
SkCodecs::Register(SkJpegxlDecoder::Decoder()); |
| 82 |
#endif |
| 83 |
#if defined(SK_CODEC_DECODES_PNG_WITH_LIBPNG) |
| 84 |
SkCodecs::Register(SkPngDecoder::Decoder()); |
| 85 |
#endif |
| 86 |
#if defined(SK_CODEC_DECODES_PNG_WITH_RUST) |
| 87 |
SkCodecs::Register(SkPngRustDecoder::Decoder()); |
| 88 |
#endif |
| 89 |
#if defined(SK_CODEC_DECODES_RAW) |
| 90 |
SkCodecs::Register(SkRawDecoder::Decoder()); |
| 91 |
#endif |
| 92 |
#if defined(SK_CODEC_DECODES_WBMP) |
| 93 |
SkCodecs::Register(SkWbmpDecoder::Decoder()); |
| 94 |
#endif |
| 95 |
#if defined(SK_CODEC_DECODES_WEBP) |
| 96 |
SkCodecs::Register(SkWebpDecoder::Decoder()); |
| 97 |
#endif |
| 98 |
} |
| 99 |
|
| 100 |
} // namespace CodecUtils |
| 101 |
|
| 102 |
#endif |