diff --git a/engine/src/flutter/lib/web_ui/skwasm/surface.cpp b/engine/src/flutter/lib/web_ui/skwasm/surface.cpp index e91d343a50..c671c44ceb 100644 --- a/engine/src/flutter/lib/web_ui/skwasm/surface.cpp +++ b/engine/src/flutter/lib/web_ui/skwasm/surface.cpp @@ -9,6 +9,7 @@ #include "third_party/skia/include/gpu/GrDirectContext.h" #include "third_party/skia/include/gpu/ganesh/gl/GrGLBackendSurface.h" #include "third_party/skia/include/gpu/ganesh/gl/GrGLDirectContext.h" +#include "third_party/skia/include/gpu/ganesh/gl/GrGLMakeWebGLInterface.h" using namespace Skwasm; @@ -101,7 +102,7 @@ void Surface::_init() { makeCurrent(_glContext); emscripten_webgl_enable_extension(_glContext, "WEBGL_debug_renderer_info"); - _grContext = GrDirectContexts::MakeGL(GrGLMakeNativeInterface()); + _grContext = GrDirectContexts::MakeGL(GrGLInterfaces::MakeWebGL()); // WebGL should already be clearing the color and stencil buffers, but do it // again here to ensure Skia receives them in the expected state. diff --git a/engine/src/flutter/shell/gpu/gpu_surface_gl_delegate.cc b/engine/src/flutter/shell/gpu/gpu_surface_gl_delegate.cc index 2e737f03a9..61631b028f 100644 --- a/engine/src/flutter/shell/gpu/gpu_surface_gl_delegate.cc +++ b/engine/src/flutter/shell/gpu/gpu_surface_gl_delegate.cc @@ -4,9 +4,28 @@ #include "flutter/shell/gpu/gpu_surface_gl_delegate.h" +#include "flutter/fml/build_config.h" + #include #include "third_party/skia/include/gpu/gl/GrGLAssembleInterface.h" +#include "third_party/skia/include/gpu/gl/GrGLInterface.h" + +#if defined(FML_OS_ANDROID) +#include "third_party/skia/include/gpu/ganesh/gl/egl/GrGLMakeEGLInterface.h" +#endif + +#if defined(FML_OS_LINUX) && defined(SK_GLX) +#include "third_party/skia/include/gpu/ganesh/gl/glx/GrGLMakeGLXInterface.h" +#endif + +#if defined(FML_OS_MACOSX) +#include "third_party/skia/include/gpu/ganesh/gl/mac/GrGLMakeMacInterface.h" +#endif + +#if defined(FML_OS_IOS) +#include "third_party/skia/include/gpu/ganesh/gl/ios/GrGLMakeIOSInterface.h" +#endif namespace flutter { @@ -64,9 +83,24 @@ static bool IsProcResolverOpenGLES( static sk_sp CreateGLInterface( const GPUSurfaceGLDelegate::GLProcResolver& proc_resolver) { if (proc_resolver == nullptr) { - // If there is no custom proc resolver, ask Skia to guess the native +#if defined(FML_OS_ANDROID) + return GrGLInterfaces::MakeEGL(); +#elif defined(FML_OS_LINUX) +#if defined(SK_GLX) + return GrGLInterfaces::MakeGLX(); +#else + return nullptr; +#endif // defined(SK_GLX) +#elif defined(FML_OS_IOS) + return GrGLInterfaces::MakeIOS(); +#elif defined(FML_OS_MACOSX) + return GrGLInterfaces::MakeMac(); +#else + // TODO(kjlubick) update this when Skia has a Windows target for making GL + // interfaces. For now, ask Skia to guess the native // interface. This often leads to interesting results on most platforms. return GrGLMakeNativeInterface(); +#endif } struct ProcResolverContext { diff --git a/engine/src/flutter/skia/BUILD.gn b/engine/src/flutter/skia/BUILD.gn index ea0031fd7f..31956cf645 100644 --- a/engine/src/flutter/skia/BUILD.gn +++ b/engine/src/flutter/skia/BUILD.gn @@ -426,6 +426,7 @@ optional("gpu") { if (defined(ndk_api) && ndk_api >= 26) { libs += [ "android" ] } + public_defines += [ "SK_EGL" ] } else if (skia_use_webgl) { sources += [ "$_skia_root/src/gpu/ganesh/gl/webgl/GrGLMakeNativeInterface_webgl.cpp", @@ -436,6 +437,15 @@ optional("gpu") { "$_skia_root/src/gpu/ganesh/gl/glx/GrGLMakeNativeInterface_glx.cpp", ] libs += [ "GL" ] + public_defines += [ "SK_GLX" ] + } else if (is_mac) { + sources += [ + "$_skia_root/src/gpu/ganesh/gl/mac/GrGLMakeNativeInterface_mac.cpp", + ] + } else if (is_ios) { + sources += [ + "$_skia_root/src/gpu/ganesh/gl/iOS/GrGLMakeNativeInterface_iOS.cpp", + ] } else if (is_win) { sources += [ "$_skia_root/src/gpu/ganesh/gl/win/GrGLMakeNativeInterface_win.cpp",