From b0dc211d4969bae386e68a5149f9deb3beb1cf10 Mon Sep 17 00:00:00 2001 From: amirh Date: Fri, 10 Nov 2017 12:52:32 -0800 Subject: [PATCH] Load animation frames to GPU textures from the IO thread (flutter/engine#4352) --- engine/src/flutter/lib/ui/painting/codec.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/lib/ui/painting/codec.cc b/engine/src/flutter/lib/ui/painting/codec.cc index 6a5de26aaf..7b06786ce6 100644 --- a/engine/src/flutter/lib/ui/painting/codec.cc +++ b/engine/src/flutter/lib/ui/painting/codec.cc @@ -15,6 +15,7 @@ #include "lib/tonic/logging/dart_invoke.h" #include "lib/tonic/typed_data/uint8_list.h" #include "third_party/skia/include/codec/SkCodec.h" +#include "third_party/skia/include/core/SkPixelRef.h" using tonic::DartInvoke; using tonic::DartPersistentValue; @@ -236,7 +237,17 @@ sk_sp MultiFrameCodec::GetNextFrameImage() { } } - return SkImage::MakeFromBitmap(bitmap); + GrContext* context = ResourceContext::Get(); + if (context) { + SkPixmap pixmap(bitmap.info(), bitmap.pixelRef()->pixels(), + bitmap.pixelRef()->rowBytes()); + // This acts as a flag to indicate that we want a color space aware decode. + sk_sp dstColorSpace = SkColorSpace::MakeSRGB(); + return SkImage::MakeCrossContextFromPixmap(context, pixmap, false, + dstColorSpace.get()); + } else { + return SkImage::MakeFromBitmap(bitmap); + } } void MultiFrameCodec::GetNextFrameAndInvokeCallback(