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) 16 #include "include/codec/SkBmpDecoder.h" 17 #endif 18 19 #if defined(SK_CODEC_DECODES_GIF) 20 #include "include/codec/SkGifDecoder.h" 21 #endif 22 23 #if defined(SK_HAS_HEIF_LIBRARY) 24 #include "include/android/SkHeifDecoder.h" 25 #endif 26 27 #if defined(SK_CODEC_DECODES_ICO) 28 #include "include/codec/SkIcoDecoder.h" 29 #endif 30 31 #if defined(SK_CODEC_DECODES_JPEG) 32 #include "include/codec/SkJpegDecoder.h" 33 #endif 34 35 #if defined(SK_CODEC_DECODES_JPEGXL) 36 #include "include/codec/SkJpegxlDecoder.h" 37 #endif 38 39 #if defined(SK_CODEC_DECODES_PNG_WITH_LIBPNG) 40 #include "include/codec/SkPngDecoder.h" 41 #endif 42 43 #if defined(SK_CODEC_DECODES_PNG_WITH_RUST) 44 #include "experimental/rust_png/decoder/SkPngRustDecoder.h" 45 #endif 46 47 #if defined(SK_CODEC_DECODES_RAW) 48 #include "include/codec/SkRawDecoder.h" 49 #endif 50 51 #if defined(SK_CODEC_DECODES_WBMP) 52 #include "include/codec/SkWbmpDecoder.h" 53 #endif 54 55 #if defined(SK_CODEC_DECODES_WEBP) 56 #include "include/codec/SkWebpDecoder.h" 57 #endif 58 59 namespace CodecUtils { 60 // Register all codecs which were compiled in. Our modular codecs set a define to signal if they 61 // were compiled in or not. It is safe to call this more than once, as the SkCodecs::Register 62 // function is idempotent. This function *cannot* go in src/ (e.g. as part of Skia proper) because 63 // then Skia itself would need to depend on codecs, which we want to avoid. RegisterAllAvailable()64inline void RegisterAllAvailable() { 65 #if defined(SK_CODEC_DECODES_AVIF) 66 SkCodecs::Register(SkAvifDecoder::Decoder()); 67 #endif 68 #if 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_HAS_HEIF_LIBRARY) 75 SkCodecs::Register(SkHeifDecoder::Decoder()); 76 #endif 77 #if defined(SK_CODEC_DECODES_ICO) 78 SkCodecs::Register(SkIcoDecoder::Decoder()); 79 #endif 80 #if defined(SK_CODEC_DECODES_JPEG) 81 SkCodecs::Register(SkJpegDecoder::Decoder()); 82 #endif 83 #if defined(SK_CODEC_DECODES_JPEGXL) 84 SkCodecs::Register(SkJpegxlDecoder::Decoder()); 85 #endif 86 #if defined(SK_CODEC_DECODES_PNG_WITH_LIBPNG) 87 SkCodecs::Register(SkPngDecoder::Decoder()); 88 #endif 89 #if defined(SK_CODEC_DECODES_PNG_WITH_RUST) 90 SkCodecs::Register(SkPngRustDecoder::Decoder()); 91 #endif 92 #if defined(SK_CODEC_DECODES_RAW) 93 SkCodecs::Register(SkRawDecoder::Decoder()); 94 #endif 95 #if defined(SK_CODEC_DECODES_WBMP) 96 SkCodecs::Register(SkWbmpDecoder::Decoder()); 97 #endif 98 #if defined(SK_CODEC_DECODES_WEBP) 99 SkCodecs::Register(SkWebpDecoder::Decoder()); 100 #endif 101 } 102 103 } // namespace CodecUtils 104 105 #endif 106