Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 10d254c

Browse files
authored
Replace several calls to GrGLMakeNativeInterface with more direct APIs (#53064)
We are restructuring Skia and plan to remove GrGLMakeNativeInterface at some point. This updates as many places as possible to use the direct and explicit instantiation instead of having "Skia guess". This should ideally not be changing behavior - if it does, then the PR should be modified. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides]. - [ ] I listed at least one issue that this PR fixes in the description above. - [x] I added new tests to check the change I am making or feature I am adding, or the PR is [test-exempt]. See [testing the engine] for instructions on writing and running engine tests. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I signed the [CLA]. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style [testing the engine]: https://github.com/flutter/flutter/wiki/Testing-the-engine [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat
1 parent fb64b9a commit 10d254c

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

lib/web_ui/skwasm/surface.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "third_party/skia/include/gpu/GrDirectContext.h"
1010
#include "third_party/skia/include/gpu/ganesh/gl/GrGLBackendSurface.h"
1111
#include "third_party/skia/include/gpu/ganesh/gl/GrGLDirectContext.h"
12+
#include "third_party/skia/include/gpu/ganesh/gl/GrGLMakeWebGLInterface.h"
1213

1314
using namespace Skwasm;
1415

@@ -101,7 +102,7 @@ void Surface::_init() {
101102
makeCurrent(_glContext);
102103
emscripten_webgl_enable_extension(_glContext, "WEBGL_debug_renderer_info");
103104

104-
_grContext = GrDirectContexts::MakeGL(GrGLMakeNativeInterface());
105+
_grContext = GrDirectContexts::MakeGL(GrGLInterfaces::MakeWebGL());
105106

106107
// WebGL should already be clearing the color and stencil buffers, but do it
107108
// again here to ensure Skia receives them in the expected state.

shell/gpu/gpu_surface_gl_delegate.cc

+35-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,28 @@
44

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

7+
#include "flutter/fml/build_config.h"
8+
79
#include <cstring>
810

911
#include "third_party/skia/include/gpu/gl/GrGLAssembleInterface.h"
12+
#include "third_party/skia/include/gpu/gl/GrGLInterface.h"
13+
14+
#if defined(FML_OS_ANDROID)
15+
#include "third_party/skia/include/gpu/ganesh/gl/egl/GrGLMakeEGLInterface.h"
16+
#endif
17+
18+
#if defined(FML_OS_LINUX) && defined(SK_GLX)
19+
#include "third_party/skia/include/gpu/ganesh/gl/glx/GrGLMakeGLXInterface.h"
20+
#endif
21+
22+
#if defined(FML_OS_MACOSX)
23+
#include "third_party/skia/include/gpu/ganesh/gl/mac/GrGLMakeMacInterface.h"
24+
#endif
25+
26+
#if defined(FML_OS_IOS)
27+
#include "third_party/skia/include/gpu/ganesh/gl/ios/GrGLMakeIOSInterface.h"
28+
#endif
1029

1130
namespace flutter {
1231

@@ -64,9 +83,24 @@ static bool IsProcResolverOpenGLES(
6483
static sk_sp<const GrGLInterface> CreateGLInterface(
6584
const GPUSurfaceGLDelegate::GLProcResolver& proc_resolver) {
6685
if (proc_resolver == nullptr) {
67-
// If there is no custom proc resolver, ask Skia to guess the native
86+
#if defined(FML_OS_ANDROID)
87+
return GrGLInterfaces::MakeEGL();
88+
#elif defined(FML_OS_LINUX)
89+
#if defined(SK_GLX)
90+
return GrGLInterfaces::MakeGLX();
91+
#else
92+
return nullptr;
93+
#endif // defined(SK_GLX)
94+
#elif defined(FML_OS_IOS)
95+
return GrGLInterfaces::MakeIOS();
96+
#elif defined(FML_OS_MACOSX)
97+
return GrGLInterfaces::MakeMac();
98+
#else
99+
// TODO(kjlubick) update this when Skia has a Windows target for making GL
100+
// interfaces. For now, ask Skia to guess the native
68101
// interface. This often leads to interesting results on most platforms.
69102
return GrGLMakeNativeInterface();
103+
#endif
70104
}
71105

72106
struct ProcResolverContext {

skia/BUILD.gn

+10
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ optional("gpu") {
426426
if (defined(ndk_api) && ndk_api >= 26) {
427427
libs += [ "android" ]
428428
}
429+
public_defines += [ "SK_EGL" ]
429430
} else if (skia_use_webgl) {
430431
sources += [
431432
"$_skia_root/src/gpu/ganesh/gl/webgl/GrGLMakeNativeInterface_webgl.cpp",
@@ -436,6 +437,15 @@ optional("gpu") {
436437
"$_skia_root/src/gpu/ganesh/gl/glx/GrGLMakeNativeInterface_glx.cpp",
437438
]
438439
libs += [ "GL" ]
440+
public_defines += [ "SK_GLX" ]
441+
} else if (is_mac) {
442+
sources += [
443+
"$_skia_root/src/gpu/ganesh/gl/mac/GrGLMakeNativeInterface_mac.cpp",
444+
]
445+
} else if (is_ios) {
446+
sources += [
447+
"$_skia_root/src/gpu/ganesh/gl/iOS/GrGLMakeNativeInterface_iOS.cpp",
448+
]
439449
} else if (is_win) {
440450
sources += [
441451
"$_skia_root/src/gpu/ganesh/gl/win/GrGLMakeNativeInterface_win.cpp",

0 commit comments

Comments
 (0)