Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace several calls to GrGLMakeNativeInterface with more direct APIs #53064

Merged
merged 4 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/web_ui/skwasm/surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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.
Expand Down
36 changes: 35 additions & 1 deletion shell/gpu/gpu_surface_gl_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,28 @@

#include "flutter/shell/gpu/gpu_surface_gl_delegate.h"

#include "flutter/fml/build_config.h"

#include <cstring>

#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 {

Expand Down Expand Up @@ -64,9 +83,24 @@ static bool IsProcResolverOpenGLES(
static sk_sp<const GrGLInterface> 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 {
Expand Down
10 changes: 10 additions & 0 deletions skia/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down