From 6fd73be90639a72fafcf198b68fc3f9d5643b828 Mon Sep 17 00:00:00 2001 From: Brian Osman Date: Mon, 21 May 2018 14:41:56 -0400 Subject: [PATCH] Set fPreferExternalImagesOverES3 option in Skia (flutter/engine#5331) This causes Skia to fall back to the ES2 shading language when the GL driver doesn't clearly communicate that it supports the ES3 external image extension. Doing so ensures that video playback (which relies on external images) works on many more devices. --- engine/src/flutter/shell/common/io_manager.cc | 4 ++++ engine/src/flutter/shell/gpu/gpu_surface_gl.cc | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/engine/src/flutter/shell/common/io_manager.cc b/engine/src/flutter/shell/common/io_manager.cc index 2b4523a46f..2d004fedb1 100644 --- a/engine/src/flutter/shell/common/io_manager.cc +++ b/engine/src/flutter/shell/common/io_manager.cc @@ -23,6 +23,10 @@ sk_sp IOManager::CreateCompatibleResourceLoadingContext( // that feature, which will cause texture uploads to do CPU YUV conversion. options.fDisableGpuYUVConversion = true; + // To get video playback on the widest range of devices, we limit Skia to + // ES2 shading language when the ES3 external image extension is missing. + options.fPreferExternalImagesOverES3 = true; + if (auto context = GrContext::MakeGL(GrGLMakeNativeInterface(), options)) { // Do not cache textures created by the image decoder. These textures // should be deleted when they are no longer referenced by an SkImage. diff --git a/engine/src/flutter/shell/gpu/gpu_surface_gl.cc b/engine/src/flutter/shell/gpu/gpu_surface_gl.cc index 11482e48f6..317d2ba29f 100644 --- a/engine/src/flutter/shell/gpu/gpu_surface_gl.cc +++ b/engine/src/flutter/shell/gpu/gpu_surface_gl.cc @@ -45,6 +45,10 @@ GPUSurfaceGL::GPUSurfaceGL(GPUSurfaceGLDelegate* delegate) GrContextOptions options; options.fAvoidStencilBuffers = true; + // To get video playback on the widest range of devices, we limit Skia to + // ES2 shading language when the ES3 external image extension is missing. + options.fPreferExternalImagesOverES3 = true; + auto context = GrContext::MakeGL(GrGLMakeNativeInterface(), options); if (context == nullptr) {