diff --git a/engine/src/flutter/shell/common/shell.cc b/engine/src/flutter/shell/common/shell.cc index 1d7537cb4f..eb51bc5f96 100644 --- a/engine/src/flutter/shell/common/shell.cc +++ b/engine/src/flutter/shell/common/shell.cc @@ -29,6 +29,14 @@ #include "rapidjson/stringbuffer.h" #include "rapidjson/writer.h" #include "third_party/dart/runtime/include/dart_tools_api.h" +#include "third_party/skia/include/codec/SkBmpDecoder.h" +#include "third_party/skia/include/codec/SkCodec.h" +#include "third_party/skia/include/codec/SkGifDecoder.h" +#include "third_party/skia/include/codec/SkIcoDecoder.h" +#include "third_party/skia/include/codec/SkJpegDecoder.h" +#include "third_party/skia/include/codec/SkPngDecoder.h" +#include "third_party/skia/include/codec/SkWbmpDecoder.h" +#include "third_party/skia/include/codec/SkWebpDecoder.h" #include "third_party/skia/include/core/SkGraphics.h" #include "third_party/skia/include/utils/SkBase64.h" #include "third_party/tonic/common/log.h" @@ -74,6 +82,20 @@ std::unique_ptr CreateEngine( gpu_disabled_switch); } +void RegisterCodecsWithSkia() { + // These are in the order they will be attempted to be decoded from. + // If we have data to back it up, we can order these by "frequency used in + // the wild" for a very small performance bump, but for now we mirror the + // order Skia had them in. + SkCodecs::Register(SkPngDecoder::Decoder()); + SkCodecs::Register(SkJpegDecoder::Decoder()); + SkCodecs::Register(SkWebpDecoder::Decoder()); + SkCodecs::Register(SkGifDecoder::Decoder()); + SkCodecs::Register(SkBmpDecoder::Decoder()); + SkCodecs::Register(SkWbmpDecoder::Decoder()); + SkCodecs::Register(SkIcoDecoder::Decoder()); +} + // Though there can be multiple shells, some settings apply to all components in // the process. These have to be set up before the shell or any of its // sub-components can be initialized. In a perfect world, this would be empty. @@ -106,6 +128,7 @@ void PerformInitializationTasks(Settings& settings) { } else { FML_DLOG(INFO) << "Skia deterministic rendering is enabled."; } + RegisterCodecsWithSkia(); if (settings.icu_initialization_required) { if (!settings.icu_data_path.empty()) {