Skip to content

Commit

Permalink
Unreviewed, reverting 275316@main.
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=270113

GTK, WPE and WinCairo are crashing for WebGL tests

Reverted changeset:

"[TextureMapper] Add GLContextWrapper to handle the current GL context"
https://bugs.webkit.org/show_bug.cgi?id=270078
https://commits.webkit.org/275316@main

Canonical link: https://commits.webkit.org/275340@main
  • Loading branch information
webkit-commit-queue authored and fujii committed Feb 26, 2024
1 parent 85b38f4 commit 09b4cd8
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 185 deletions.
1 change: 0 additions & 1 deletion Source/WebCore/Headers.cmake
Expand Up @@ -2090,7 +2090,6 @@ set(WebCore_PRIVATE_FRAMEWORK_HEADERS
platform/graphics/cv/ImageTransferSessionVT.h

platform/graphics/egl/GLContext.h
platform/graphics/egl/GLContextWrapper.h

platform/graphics/filters/DistantLightSource.h
platform/graphics/filters/FEBlend.h
Expand Down
1 change: 0 additions & 1 deletion Source/WebCore/PlatformPlayStation.cmake
Expand Up @@ -38,7 +38,6 @@ list(APPEND WebCore_SOURCES

platform/graphics/egl/GLContext.cpp
platform/graphics/egl/GLContextLibWPE.cpp
platform/graphics/egl/GLContextWrapper.cpp

platform/graphics/libwpe/PlatformDisplayLibWPE.cpp

Expand Down
1 change: 0 additions & 1 deletion Source/WebCore/PlatformWin.cmake
Expand Up @@ -55,7 +55,6 @@ list(APPEND WebCore_SOURCES
platform/graphics/angle/PlatformDisplayANGLE.cpp

platform/graphics/egl/GLContext.cpp
platform/graphics/egl/GLContextWrapper.cpp

platform/graphics/opentype/OpenTypeUtilities.cpp

Expand Down
1 change: 0 additions & 1 deletion Source/WebCore/SourcesGTK.txt
Expand Up @@ -60,7 +60,6 @@ platform/graphics/PlatformDisplay.cpp @no-unify
platform/graphics/angle/PlatformDisplayANGLE.cpp @no-unify

platform/graphics/egl/GLContext.cpp @no-unify
platform/graphics/egl/GLContextWrapper.cpp @no-unify
platform/graphics/egl/PlatformDisplaySurfaceless.cpp @no-unify

platform/graphics/gbm/GBMBufferSwapchain.cpp
Expand Down
1 change: 0 additions & 1 deletion Source/WebCore/SourcesWPE.txt
Expand Up @@ -61,7 +61,6 @@ platform/graphics/wpe/SystemFontDatabaseWPE.cpp

platform/graphics/egl/GLContext.cpp @no-unify
platform/graphics/egl/GLContextLibWPE.cpp @no-unify
platform/graphics/egl/GLContextWrapper.cpp @no-unify
platform/graphics/egl/PlatformDisplaySurfaceless.cpp @no-unify

platform/graphics/gbm/GBMBufferSwapchain.cpp
Expand Down
77 changes: 41 additions & 36 deletions Source/WebCore/platform/graphics/egl/GLContext.cpp
Expand Up @@ -22,6 +22,7 @@
#if USE(EGL)
#include "GraphicsContextGL.h"
#include "Logging.h"
#include <wtf/ThreadSpecific.h>
#include <wtf/Vector.h>
#include <wtf/text/StringToIntegerConversion.h>

Expand All @@ -37,6 +38,16 @@

namespace WebCore {

static ThreadSpecific<GLContext*>& currentContext()
{
static ThreadSpecific<GLContext*>* context;
static std::once_flag flag;
std::call_once(flag, [] {
context = new ThreadSpecific<GLContext*>();
});
return *context;
}

const char* GLContext::errorString(int statusCode)
{
static_assert(sizeof(int) >= sizeof(EGLint), "EGLint must not be wider than int");
Expand Down Expand Up @@ -398,6 +409,9 @@ GLContext::~GLContext()
#if USE(WPE_RENDERER)
destroyWPETarget();
#endif

if (this == *currentContext())
*currentContext() = nullptr;
}

EGLContext GLContext::createContextForEGLVersion(PlatformDisplay& platformDisplay, EGLConfig config, EGLContext sharingContext)
Expand All @@ -416,33 +430,31 @@ EGLContext GLContext::createContextForEGLVersion(PlatformDisplay& platformDispla
return eglCreateContext(platformDisplay.eglDisplay(), config, sharingContext, contextAttributes);
}

bool GLContext::makeCurrentImpl()
bool GLContext::makeContextCurrent()
{
ASSERT(m_context);
return eglMakeCurrent(m_display.eglDisplay(), m_surface, m_surface, m_context);
}

bool GLContext::unmakeCurrentImpl()
{
return eglMakeCurrent(m_display.eglDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
}
*currentContext() = this;
if (eglGetCurrentContext() == m_context)
return true;

bool GLContext::makeContextCurrent()
{
return makeCurrent();
return eglMakeCurrent(m_display.eglDisplay(), m_surface, m_surface, m_context);
}

bool GLContext::unmakeContextCurrent()
{
return unmakeCurrent();
if (this != *currentContext())
return false;

eglMakeCurrent(m_display.eglDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
*currentContext() = nullptr;

return true;
}

GLContext* GLContext::current()
{
auto* context = currentContext();
if (context && context->type() == GLContextWrapper::Type::Native)
return static_cast<GLContext*>(context);
return nullptr;
return *currentContext();
}

void GLContext::swapBuffers()
Expand Down Expand Up @@ -515,41 +527,32 @@ const GLContext::GLExtensions& GLContext::glExtensions() const
GLContext::ScopedGLContext::ScopedGLContext(std::unique_ptr<GLContext>&& context)
: m_context(WTFMove(context))
{
auto eglContext = eglGetCurrentContext();
m_previous.glContext = GLContext::current();
if (!m_previous.glContext || m_previous.glContext->platformContext() != eglContext) {
m_previous.context = eglContext;
if (m_previous.context != EGL_NO_CONTEXT) {
m_previous.display = eglGetCurrentDisplay();
m_previous.readSurface = eglGetCurrentSurface(EGL_READ);
m_previous.drawSurface = eglGetCurrentSurface(EGL_DRAW);
}
m_previous.context = eglGetCurrentContext();
if (m_previous.context) {
m_previous.display = eglGetCurrentDisplay();
m_previous.readSurface = eglGetCurrentSurface(EGL_READ);
m_previous.drawSurface = eglGetCurrentSurface(EGL_DRAW);
}
m_context->makeContextCurrent();
}

GLContext::ScopedGLContext::~ScopedGLContext()
{
m_context = nullptr;

if (m_previous.context != EGL_NO_CONTEXT)
if (m_previous.context)
eglMakeCurrent(m_previous.display, m_previous.drawSurface, m_previous.readSurface, m_previous.context);
else if (m_previous.glContext)
m_previous.glContext->makeContextCurrent();
}

GLContext::ScopedGLContextCurrent::ScopedGLContextCurrent(GLContext& context)
: m_context(context)
{
auto eglContext = eglGetCurrentContext();
m_previous.glContext = GLContext::current();
m_previous.glContext = *currentContext();
if (!m_previous.glContext || m_previous.glContext->platformContext() != eglContext) {
m_previous.context = eglContext;
if (m_previous.context != EGL_NO_CONTEXT) {
m_previous.display = eglGetCurrentDisplay();
m_previous.readSurface = eglGetCurrentSurface(EGL_READ);
m_previous.drawSurface = eglGetCurrentSurface(EGL_DRAW);
}
m_previous.display = eglGetCurrentDisplay();
m_previous.readSurface = eglGetCurrentSurface(EGL_READ);
m_previous.drawSurface = eglGetCurrentSurface(EGL_DRAW);
}
m_context.makeContextCurrent();
}
Expand All @@ -561,10 +564,12 @@ GLContext::ScopedGLContextCurrent::~ScopedGLContextCurrent()
return;
}

m_context.unmakeContextCurrent();

if (m_previous.context)
eglMakeCurrent(m_previous.display, m_previous.drawSurface, m_previous.readSurface, m_previous.context);
else
m_context.unmakeContextCurrent();

*currentContext() = m_previous.glContext;
}

} // namespace WebCore
Expand Down
9 changes: 1 addition & 8 deletions Source/WebCore/platform/graphics/egl/GLContext.h
Expand Up @@ -20,7 +20,6 @@
#pragma once

#if USE(EGL)
#include "GLContextWrapper.h"
#include "IntSize.h"
#include "PlatformDisplay.h"
#include <wtf/Noncopyable.h>
Expand All @@ -44,7 +43,7 @@ typedef void* EGLSurface;

namespace WebCore {

class GLContext final : public GLContextWrapper {
class GLContext {
WTF_MAKE_NONCOPYABLE(GLContext); WTF_MAKE_FAST_ALLOCATED;
public:
WEBCORE_EXPORT static std::unique_ptr<GLContext> create(GLNativeWindowType, PlatformDisplay&);
Expand Down Expand Up @@ -86,7 +85,6 @@ class GLContext final : public GLContextWrapper {
~ScopedGLContext();
private:
struct {
GLContext* glContext { nullptr };
EGLDisplay display { nullptr };
EGLContext context { nullptr };
EGLSurface readSurface { nullptr };
Expand Down Expand Up @@ -125,11 +123,6 @@ class GLContext final : public GLContextWrapper {

static bool getEGLConfig(PlatformDisplay&, EGLConfig*, EGLSurfaceType);

// GLContextWrapper
GLContextWrapper::Type type() const override { return GLContextWrapper::Type::Native; }
bool makeCurrentImpl() override;
bool unmakeCurrentImpl() override;

PlatformDisplay& m_display;
unsigned m_version { 0 };
EGLContext m_context { nullptr };
Expand Down
67 changes: 0 additions & 67 deletions Source/WebCore/platform/graphics/egl/GLContextWrapper.cpp

This file was deleted.

46 changes: 0 additions & 46 deletions Source/WebCore/platform/graphics/egl/GLContextWrapper.h

This file was deleted.

Expand Up @@ -95,7 +95,7 @@ GraphicsContextGLANGLE::~GraphicsContextGLANGLE()

bool GraphicsContextGLANGLE::makeContextCurrent()
{
return static_cast<GraphicsContextGLTextureMapperANGLE*>(this)->makeCurrent();
return !!EGL_MakeCurrent(m_displayObj, m_surfaceObj, m_surfaceObj, m_contextObj);
}

void GraphicsContextGLANGLE::checkGPUStatus()
Expand Down Expand Up @@ -353,21 +353,6 @@ void GraphicsContextGLTextureMapperANGLE::prepareForDisplay()
swapCompositorTexture();
}

GLContextWrapper::Type GraphicsContextGLTextureMapperANGLE::type() const
{
return GLContextWrapper::Type::Angle;
}

bool GraphicsContextGLTextureMapperANGLE::makeCurrentImpl()
{
return !!EGL_MakeCurrent(m_displayObj, m_surfaceObj, m_surfaceObj, m_contextObj);
}

bool GraphicsContextGLTextureMapperANGLE::unmakeCurrentImpl()
{
return !!EGL_MakeCurrent(m_displayObj, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
}

} // namespace WebCore

#endif // ENABLE(WEBGL) && USE(TEXTURE_MAPPER)

0 comments on commit 09b4cd8

Please sign in to comment.