Skip to content

Commit

Permalink
[Skia] Do not use the legacy native GL/EGL interface factory
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=270047

Reviewed by Carlos Garcia Campos.

Explicitly instantiate a GrGLInterface used for creating the Skia GL
context. This is done in a helper function which may return the Epoxy or
the plain EGL interface depending on USE(LIBEPOXY). In any case, when
USE(EGL) is not effect for now this produces a build error for now.
Ports that want to use the EGL instead of the Epoxy factory will still
need some CMake work to build Skia's EGL native interface instead of the
Epoxy one in a follow-up patch, this only leaves the instantiation code
ready for that.

* Source/ThirdParty/skia/CMakeLists.txt: Do not build GrGLMakeNativeInterface_epoxy.cpp
* Source/ThirdParty/skia/src/gpu/ganesh/gl/epoxy/GrGLMakeNativeInterface_epoxy.cpp: Removed.
* Source/WebCore/platform/graphics/skia/PlatformDisplaySkia.cpp:
(WebCore::skiaGLInterface): Added. Helper function that returns the correct
GrGLInterface for the current build configuration.
(WebCore::PlatformDisplay::skiaGLContext): Pass the GrGLInterface
returned by skiaGLInterface() when instantiating the Skia GL context.

Canonical link: https://commits.webkit.org/275311@main
  • Loading branch information
aperezdc committed Feb 26, 2024
1 parent b6d185a commit c6ffba6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Source/ThirdParty/skia/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,6 @@ add_library(Skia STATIC
src/gpu/ganesh/gl/builders/GrGLProgramBuilder.cpp
src/gpu/ganesh/gl/builders/GrGLShaderStringBuilder.cpp
src/gpu/ganesh/gl/epoxy/GrGLMakeEpoxyEGLInterface.cpp
src/gpu/ganesh/gl/epoxy/GrGLMakeNativeInterface_epoxy.cpp
src/gpu/ganesh/glsl/GrGLSLBlend.cpp
src/gpu/ganesh/glsl/GrGLSLFragmentShaderBuilder.cpp
src/gpu/ganesh/glsl/GrGLSLProgramBuilder.cpp
Expand Down Expand Up @@ -913,6 +912,7 @@ target_compile_definitions(Skia PRIVATE
)
target_compile_definitions(Skia PUBLIC
SK_DISABLE_LEGACY_GL_MAKE_NATIVE_INTERFACE
SK_DISABLE_LEGACY_IMAGE_READBUFFER
SK_DISABLE_LEGACY_INIT_DECODERS
SK_DISABLE_LEGACY_PNG_WRITEBUFFER
Expand Down

This file was deleted.

28 changes: 27 additions & 1 deletion Source/WebCore/platform/graphics/skia/PlatformDisplaySkia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,35 @@ IGNORE_CLANG_WARNINGS_END
#include <skia/gpu/ganesh/gl/GrGLDirectContext.h>
#include <skia/gpu/gl/GrGLInterface.h>
#include <skia/gpu/gl/GrGLTypes.h>
#include <wtf/NeverDestroyed.h>

#if USE(EGL)
#if USE(LIBEPOXY)
#include <skia/gpu/gl/epoxy/GrGLMakeEpoxyEGLInterface.h>
#else
#include <skia/gpu/gl/egl/GrGLMakeEGLInterface.h>
#endif
#endif

namespace WebCore {

static sk_sp<const GrGLInterface> skiaGLInterface()
{
static NeverDestroyed<sk_sp<const GrGLInterface>> interface {
#if USE(EGL)
#if USE(LIBEPOXY)
GrGLMakeEpoxyEGLInterface()
#else
GrGLInterfaces::MakeEGL()
#endif
#else
# error No implementation available for getSkiaGLInterface()
#endif
};

return interface.get();
}

GLContext* PlatformDisplay::skiaGLContext()
{
if (m_skiaGLContext)
Expand All @@ -49,7 +75,7 @@ GLContext* PlatformDisplay::skiaGLContext()
m_skiaGLContext = GLContext::createOffscreen(*this);
GLContext::ScopedGLContextCurrent scopedCurrent(*m_skiaGLContext);
// FIXME: add GrContextOptions, shader cache, etc.
m_skiaGrContext = GrDirectContexts::MakeGL();
m_skiaGrContext = GrDirectContexts::MakeGL(skiaGLInterface());
return m_skiaGLContext.get();
}

Expand Down

0 comments on commit c6ffba6

Please sign in to comment.