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) 40 #include "include/codec/SkPngDecoder.h" 41 #endif 42 43 #if defined(SK_CODEC_DECODES_RAW) 44 #include "include/codec/SkRawDecoder.h" 45 #endif 46 47 #if defined(SK_CODEC_DECODES_WBMP) 48 #include "include/codec/SkWbmpDecoder.h" 49 #endif 50 51 #if defined(SK_CODEC_DECODES_WEBP) 52 #include "include/codec/SkWebpDecoder.h" 53 #endif 54 55 namespace CodecUtils { 56 // Register all codecs which were compiled in. Our modular codecs set a define to signal if they 57 // were compiled in or not. It is safe to call this more than once, as the SkCodecs::Register 58 // function is idempotent. This function *cannot* go in src/ (e.g. as part of Skia proper) because 59 // then Skia itself would need to depend on codecs, which we want to avoid. RegisterAllAvailable()60inline void RegisterAllAvailable() { 61 #if defined(SK_CODEC_DECODES_AVIF) 62 SkCodecs::Register(SkAvifDecoder::Decoder()); 63 #endif 64 #if defined(SK_CODEC_DECODES_BMP) 65 SkCodecs::Register(SkBmpDecoder::Decoder()); 66 #endif 67 #if defined(SK_CODEC_DECODES_GIF) 68 SkCodecs::Register(SkGifDecoder::Decoder()); 69 #endif 70 #if defined(SK_HAS_HEIF_LIBRARY) 71 SkCodecs::Register(SkHeifDecoder::Decoder()); 72 #endif 73 #if defined(SK_CODEC_DECODES_ICO) 74 SkCodecs::Register(SkIcoDecoder::Decoder()); 75 #endif 76 #if defined(SK_CODEC_DECODES_JPEG) 77 SkCodecs::Register(SkJpegDecoder::Decoder()); 78 #endif 79 #if defined(SK_CODEC_DECODES_JPEGXL) 80 SkCodecs::Register(SkJpegxlDecoder::Decoder()); 81 #endif 82 #if defined(SK_CODEC_DECODES_PNG) 83 SkCodecs::Register(SkPngDecoder::Decoder()); 84 #endif 85 #if defined(SK_CODEC_DECODES_RAW) 86 SkCodecs::Register(SkRawDecoder::Decoder()); 87 #endif 88 #if defined(SK_CODEC_DECODES_WBMP) 89 SkCodecs::Register(SkWbmpDecoder::Decoder()); 90 #endif 91 #if defined(SK_CODEC_DECODES_WEBP) 92 SkCodecs::Register(SkWebpDecoder::Decoder()); 93 #endif 94 } 95 96 } // namespace CodecUtils 97 98 #endif 99