WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
wk-egl-display.diff (text/plain), 18.39 KB, created by
Carlos Garcia Campos
on 2015-05-06 06:44:11 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Carlos Garcia Campos
Created:
2015-05-06 06:44:11 PDT
Size:
18.39 KB
patch
obsolete
>diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index c6ccb4e..7bb443d 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,53 @@ >+2015-05-06 Carlos Garcia Campos <cgarcia@igalia.com> >+ >+ [EGL] Move EGLDisplay handling to PlatformDisplay >+ https://bugs.webkit.org/show_bug.cgi?id=144685 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ The EGL display is also initialized in multiple places, and could >+ be unified in PlatformDisplay. Remove the PlatformDisplay >+ definition from platform/graphics/opengl/GLDefs.h to avoid conflicts. >+ >+ * platform/graphics/PlatformDisplay.cpp: >+ (WebCore::PlatformDisplay::PlatformDisplay): Initialize m_eglDisplay. >+ (WebCore::PlatformDisplay::~PlatformDisplay): Call terminateEGLDisplay(). >+ (WebCore::PlatformDisplay::eglDisplay): Lazy intialize the EGL >+ display and return it. >+ (WebCore::PlatformDisplay::initializeEGLDisplay): >+ (WebCore::PlatformDisplay::terminateEGLDisplay): >+ * platform/graphics/PlatformDisplay.h: >+ * platform/graphics/egl/GLContextEGL.cpp: >+ (WebCore::sharedEGLDisplay): Use PlatformDisplay::eglDisplay(). >+ * platform/graphics/opengl/GLDefs.h: Remove unneeded definitions. >+ * platform/graphics/opengl/GLPlatformSurface.cpp: >+ (WebCore::GLPlatformSurface::GLPlatformSurface): Remove >+ m_sharedDisplay member, PlatformDisplay::sharedDisplay() can be used instead. >+ (WebCore::GLPlatformSurface::sharedDisplay): Deleted. >+ * platform/graphics/opengl/GLPlatformSurface.h: >+ * platform/graphics/surfaces/egl/EGLConfigSelector.h: Use >+ EGLDisplay instead of PlatformDisplay. >+ * platform/graphics/surfaces/egl/EGLContext.cpp: >+ (WebCore::EGLOffScreenContext::initialize): Use PlatformDisplay::eglDisplay(). >+ * platform/graphics/surfaces/egl/EGLHelper.cpp: Remove the >+ EGLDisplayConnection clas and use PlatformDisplay instead. >+ (WebCore::EGLHelper::eglDisplay): >+ (WebCore::EGLHelper::currentDisplay): >+ (WebCore::EGLDisplayConnection::EGLDisplayConnection): Deleted. >+ (WebCore::EGLDisplayConnection::~EGLDisplayConnection): Deleted. >+ (WebCore::EGLDisplayConnection::display): Deleted. >+ (WebCore::EGLDisplayConnection::terminate): Deleted. >+ * platform/graphics/surfaces/egl/EGLHelper.h: >+ * platform/graphics/wayland/PlatformDisplayWayland.cpp: >+ (WebCore::PlatformDisplayWayland::PlatformDisplayWayland): Call >+ PlatformDisplay::initializeEGLDisplay() to insialize the EGL display. >+ * platform/graphics/wayland/PlatformDisplayWayland.h: >+ * platform/graphics/x11/PlatformDisplayX11.cpp: >+ (WebCore::PlatformDisplayX11::initializeEGLDisplay): Override >+ PlatformDisplay::initializeEGLDisplay() to initialize the >+ m_eglDisplay member. >+ * platform/graphics/x11/PlatformDisplayX11.h: >+ > 2015-05-05 Carlos Garcia Campos <cgarcia@igalia.com> > > [SOUP] Network Cache: Implement ShareableResource for Soup and enable it for GTK platform >diff --git a/Source/WebCore/platform/graphics/PlatformDisplay.cpp b/Source/WebCore/platform/graphics/PlatformDisplay.cpp >index 58bdd69..d6210a2 100644 >--- a/Source/WebCore/platform/graphics/PlatformDisplay.cpp >+++ b/Source/WebCore/platform/graphics/PlatformDisplay.cpp >@@ -45,6 +45,10 @@ > #include <Ecore_X.h> > #endif > >+#if USE(EGL) >+#include <EGL/egl.h> >+#endif >+ > namespace WebCore { > > std::unique_ptr<PlatformDisplay> PlatformDisplay::createPlatformDisplay() >@@ -85,4 +89,63 @@ PlatformDisplay& PlatformDisplay::sharedDisplay() > return *display; > } > >+PlatformDisplay::PlatformDisplay() >+#if USE(EGL) >+ : m_eglDisplay(EGL_NO_DISPLAY) >+#endif >+{ >+} >+ >+PlatformDisplay::~PlatformDisplay() >+{ >+#if USE(EGL) >+ terminateEGLDisplay(); >+#endif >+} >+ >+#if USE(EGL) >+EGLDisplay PlatformDisplay::eglDisplay() const >+{ >+ if (!m_eglDisplayInitialized) >+ const_cast<PlatformDisplay*>(this)->initializeEGLDisplay(); >+ return m_eglDisplay; >+} >+ >+void PlatformDisplay::initializeEGLDisplay() >+{ >+ m_eglDisplayInitialized = true; >+ >+ if (m_eglDisplay == EGL_NO_DISPLAY) { >+ m_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); >+ if (m_eglDisplay == EGL_NO_DISPLAY) >+ return; >+ } >+ >+ if (eglInitialize(m_eglDisplay, 0, 0) == EGL_FALSE) { >+ LOG_ERROR("EGLDisplay Initialization failed."); >+ terminateEGLDisplay(); >+ return; >+ } >+ >+#if USE(OPENGL_ES_2) >+ static const EGLenum eglAPIVersion = EGL_OPENGL_ES_API; >+#else >+ static const EGLenum eglAPIVersion = EGL_OPENGL_API; >+#endif >+ if (eglBindAPI(eglAPIVersion) == EGL_FALSE) { >+ LOG_ERROR("Failed to set EGL API(%d).", eglGetError()); >+ terminateEGLDisplay(); >+ return; >+ } >+} >+ >+void PlatformDisplay::terminateEGLDisplay() >+{ >+ if (m_eglDisplay == EGL_NO_DISPLAY) >+ return; >+ eglTerminate(m_eglDisplay); >+ m_eglDisplay = EGL_NO_DISPLAY; >+} >+#endif // USE(EGL) >+ > } // namespace WebCore >diff --git a/Source/WebCore/platform/graphics/PlatformDisplay.h b/Source/WebCore/platform/graphics/PlatformDisplay.h >index 231270f..18a679c 100644 >--- a/Source/WebCore/platform/graphics/PlatformDisplay.h >+++ b/Source/WebCore/platform/graphics/PlatformDisplay.h >@@ -29,13 +29,17 @@ > #include <wtf/Noncopyable.h> > #include <wtf/TypeCasts.h> > >+#if USE(EGL) >+typedef void *EGLDisplay; >+#endif >+ > namespace WebCore { > > class PlatformDisplay { > WTF_MAKE_NONCOPYABLE(PlatformDisplay); WTF_MAKE_FAST_ALLOCATED; > public: > static PlatformDisplay& sharedDisplay(); >- virtual ~PlatformDisplay() = default; >+ virtual ~PlatformDisplay(); > > enum class Type { > #if PLATFORM(X11) >@@ -48,11 +52,27 @@ public: > > virtual Type type() const = 0; > >+#if USE(EGL) >+ EGLDisplay eglDisplay() const; >+#endif >+ > protected: >- PlatformDisplay() = default; >+ PlatformDisplay(); >+ >+#if USE(EGL) >+ virtual void initializeEGLDisplay(); >+ >+ EGLDisplay m_eglDisplay; >+#endif > > private: > static std::unique_ptr<PlatformDisplay> createPlatformDisplay(); >+ >+#if USE(EGL) >+ void terminateEGLDisplay(); >+ >+ bool m_eglDisplayInitialized { false }; >+#endif > }; > > } // namespace WebCore >diff --git a/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp b/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp >index 89b9612..777ccf0 100644 >--- a/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp >+++ b/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp >@@ -22,6 +22,7 @@ > #if USE(EGL) > > #include "GraphicsContext3D.h" >+#include "PlatformDisplay.h" > > #if USE(CAIRO) > #include <cairo.h> >@@ -38,10 +39,6 @@ > #include "PlatformDisplayX11.h" > #endif > >-#if PLATFORM(WAYLAND) >-#include "PlatformDisplayWayland.h" >-#endif >- > #if ENABLE(ACCELERATED_2D_CANVAS) > // cairo-gl.h includes some definitions from GLX that conflict with > // the ones provided by us. Since GLContextEGL doesn't use any GLX >@@ -52,34 +49,9 @@ > > namespace WebCore { > >-static EGLDisplay gSharedEGLDisplay = EGL_NO_DISPLAY; >- >-#if USE(OPENGL_ES_2) >-static const EGLenum gGLAPI = EGL_OPENGL_ES_API; >-#else >-static const EGLenum gGLAPI = EGL_OPENGL_API; >-#endif >- > static EGLDisplay sharedEGLDisplay() > { >- static bool initialized = false; >- if (!initialized) { >- initialized = true; >- >-#if PLATFORM(WAYLAND) >- if (is<PlatformDisplayWayland>(PlatformDisplay::sharedDisplay())) >- gSharedEGLDisplay = eglGetDisplay(downcast<PlatformDisplayWayland>(PlatformDisplay::sharedDisplay()).native()); >- else // Note that this branch continutes outside this #if-guarded segment. >-#endif >-#if PLATFORM(X11) >- gSharedEGLDisplay = eglGetDisplay(downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native()); >-#else >- gSharedEGLDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); >-#endif >- if (gSharedEGLDisplay != EGL_NO_DISPLAY && (!eglInitialize(gSharedEGLDisplay, 0, 0) || !eglBindAPI(gGLAPI))) >- gSharedEGLDisplay = EGL_NO_DISPLAY; >- } >- return gSharedEGLDisplay; >+ return PlatformDisplay::sharedDisplay().eglDisplay(); > } > > static const EGLint gContextAttributes[] = { >diff --git a/Source/WebCore/platform/graphics/opengl/GLDefs.h b/Source/WebCore/platform/graphics/opengl/GLDefs.h >index a091f13..9a2c2ff 100644 >--- a/Source/WebCore/platform/graphics/opengl/GLDefs.h >+++ b/Source/WebCore/platform/graphics/opengl/GLDefs.h >@@ -57,22 +57,14 @@ typedef uint32_t PlatformBufferHandle; > > #if USE(GLX) > typedef GLXContext PlatformContext; >-typedef Display* PlatformDisplay; > typedef GLXFBConfig PlatformSurfaceConfig; > typedef GLXDrawable PlatformDrawable; > #elif USE(EGL) >-#if USE(OPENGL_ES_2) >-static const EGLenum eglAPIVersion = EGL_OPENGL_ES_API; >-#else >-static const EGLenum eglAPIVersion = EGL_OPENGL_API; >-#endif > typedef EGLContext PlatformContext; >-typedef EGLDisplay PlatformDisplay; > typedef EGLConfig PlatformSurfaceConfig; > typedef EGLSurface PlatformDrawable; > #else > typedef void* PlatformContext; >-typedef void* PlatformDisplay; > typedef void* PlatformSurfaceConfig; > typedef void* PlatformDrawable; > #endif >diff --git a/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp b/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp >index 4f03ef6..a49c3d8 100644 >--- a/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp >+++ b/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp >@@ -61,8 +61,7 @@ std::unique_ptr<GLPlatformSurface> GLPlatformSurface::createOffScreenSurface(Sur > } > > GLPlatformSurface::GLPlatformSurface(SurfaceAttributes) >- : m_sharedDisplay(0) >- , m_drawable(0) >+ : m_drawable(0) > , m_bufferHandle(0) > { > } >@@ -88,11 +87,6 @@ const IntRect& GLPlatformSurface::geometry() const > return m_rect; > } > >-PlatformDisplay GLPlatformSurface::sharedDisplay() const >-{ >- return m_sharedDisplay; >-} >- > PlatformSurfaceConfig GLPlatformSurface::configuration() > { > return 0; >diff --git a/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h b/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h >index f5e4f53..f141d36 100644 >--- a/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h >+++ b/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h >@@ -59,8 +59,6 @@ public: > > PlatformDrawable drawable() const; > >- PlatformDisplay sharedDisplay() const; >- > virtual SurfaceAttributes attributes() const; > > virtual void swapBuffers(); >@@ -84,7 +82,6 @@ public: > protected: > GLPlatformSurface(SurfaceAttributes); > >- PlatformDisplay m_sharedDisplay; > PlatformDrawable m_drawable; > PlatformBufferHandle m_bufferHandle; > IntRect m_rect; >diff --git a/Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.h b/Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.h >index 272cbdb..139c0b5 100644 >--- a/Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.h >+++ b/Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.h >@@ -61,7 +61,7 @@ protected: > EGLConfig m_pixmapFBConfig; > EGLConfig m_surfaceContextFBConfig; > unsigned m_attributes : 3; >- PlatformDisplay m_sharedDisplay; >+ EGLDisplay m_sharedDisplay; > }; > > } >diff --git a/Source/WebCore/platform/graphics/surfaces/egl/EGLContext.cpp b/Source/WebCore/platform/graphics/surfaces/egl/EGLContext.cpp >index 62af443..1fe7a32 100644 >--- a/Source/WebCore/platform/graphics/surfaces/egl/EGLContext.cpp >+++ b/Source/WebCore/platform/graphics/surfaces/egl/EGLContext.cpp >@@ -28,6 +28,7 @@ > > #if USE(EGL) > >+#include "PlatformDisplay.h" > #include <wtf/text/WTFString.h> > > namespace WebCore { >@@ -72,12 +73,7 @@ bool EGLOffScreenContext::initialize(GLPlatformSurface* surface, PlatformContext > if (!surface) > return false; > >- if (!eglBindAPI(eglAPIVersion)) { >- LOG_ERROR("Failed to set EGL API(%d).", eglGetError()); >- return false; >- } >- >- m_display = surface->sharedDisplay(); >+ m_display = PlatformDisplay::sharedDisplay().eglDisplay(); > if (!m_display) > return false; > >diff --git a/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.cpp b/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.cpp >index 9aed9af..a015e83 100644 >--- a/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.cpp >+++ b/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.cpp >@@ -28,89 +28,22 @@ > > #if USE(EGL) > >+#include "PlatformDisplay.h" > #include <opengl/GLPlatformContext.h> > >-#if PLATFORM(X11) >-#include "X11Helper.h" >-#endif > > namespace WebCore { > >-#if PLATFORM(X11) >-typedef X11Helper NativeWrapper; >-typedef Display NativeSharedDisplay; >-#else >-typedef void NativeSharedDisplay; >-#endif >- > static PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR = 0; > static PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR = 0; > static PFNGLEGLIMAGETARGETTEXTURE2DOESPROC eglImageTargetTexture2DOES = 0; > >-struct EGLDisplayConnection { >- >- EGLDisplayConnection(NativeSharedDisplay* display = 0) >- { >- if (display) >- m_eglDisplay = eglGetDisplay(reinterpret_cast<EGLNativeDisplayType>(display)); >- else >- m_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); >- >- if (m_eglDisplay == EGL_NO_DISPLAY) { >- LOG_ERROR("EGLDisplay Initialization failed."); >- return; >- } >- >- EGLBoolean success; >- success = eglInitialize(m_eglDisplay, 0, 0); >- >- if (success != EGL_TRUE) { >- LOG_ERROR("EGLInitialization failed."); >- terminate(); >- return; >- } >- >- success = eglBindAPI(eglAPIVersion); >- >- if (success != EGL_TRUE) { >- LOG_ERROR("Failed to set EGL API(%d).", eglGetError()); >- terminate(); >- return; >- } >- } >- >- ~EGLDisplayConnection() >- { >- terminate(); >- } >- >- EGLDisplay display() { return m_eglDisplay; } >- >-private: >- void terminate() >- { >- if (m_eglDisplay == EGL_NO_DISPLAY) >- return; >- >- eglTerminate(m_eglDisplay); >- m_eglDisplay = EGL_NO_DISPLAY; >- } >- >- EGLDisplay m_eglDisplay; >-}; >- >-PlatformDisplay EGLHelper::eglDisplay() >+EGLDisplay EGLHelper::eglDisplay() > { >- // Display connection will only be broken at program shutdown. >-#if PLATFORM(X11) >- static EGLDisplayConnection displayConnection(NativeWrapper::nativeDisplay()); >-#else >- static EGLDisplayConnection displayConnection; >-#endif >- return displayConnection.display(); >+ PlatformDisplay::sharedDisplay().eglDisplay(); > } > >-PlatformDisplay EGLHelper::currentDisplay() >+EGLDisplay EGLHelper::currentDisplay() > { > EGLDisplay display = eglGetCurrentDisplay(); > >diff --git a/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.h b/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.h >index f2458fb..88222a7 100644 >--- a/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.h >+++ b/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.h >@@ -34,8 +34,8 @@ namespace WebCore { > > class EGLHelper { > public: >- static PlatformDisplay eglDisplay(); >- static PlatformDisplay currentDisplay(); >+ static EGLDisplay eglDisplay(); >+ static EGLDisplay currentDisplay(); > static void resolveEGLBindings(); > static void createEGLImage(EGLImageKHR*, GLenum, const EGLClientBuffer, const EGLint* = 0); > static void destroyEGLImage(const EGLImageKHR); >diff --git a/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp b/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp >index 27f61eb..ccbc35f 100644 >--- a/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp >+++ b/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp >@@ -87,20 +87,9 @@ PlatformDisplayWayland::PlatformDisplayWayland(struct wl_display* wlDisplay) > }; > > m_eglDisplay = eglGetDisplay(m_display); >- if (m_eglDisplay == EGL_NO_DISPLAY) { >- g_warning("PlatformDisplayWayland initialization: failed to acquire EGL display."); >+ PlatformDisplay::initializeEGLDisplay(); >+ if (m_eglDisplay == EGL_NO_DISPLAY) > return; >- } >- >- if (eglInitialize(m_eglDisplay, 0, 0) == EGL_FALSE) { >- g_warning("PlatformDisplayWayland initialization: failed to initialize the EGL display."); >- return; >- } >- >- if (eglBindAPI(EGL_OPENGL_ES_API) == EGL_FALSE) { >- g_warning("PlatformDisplayWayland initialization: failed to set EGL_OPENGL_ES_API as the rendering API."); >- return; >- } > > EGLint numberOfConfigs; > if (!eglChooseConfig(m_eglDisplay, configAttributes, &m_eglConfig, 1, &numberOfConfigs) || numberOfConfigs != 1) { >diff --git a/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h b/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h >index 19589be..154fbbe 100644 >--- a/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h >+++ b/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h >@@ -47,7 +47,6 @@ public: > virtual ~PlatformDisplayWayland(); > > struct wl_display* native() const { return m_display; } >- EGLDisplay eglDisplay() const { return m_eglDisplay; } > > std::unique_ptr<WaylandSurface> createSurface(const IntSize&, int widgetID); > >@@ -68,7 +67,6 @@ private: > struct wl_compositor* m_compositor; > struct wl_webkitgtk* m_webkitgtk; > >- EGLDisplay m_eglDisplay; > EGLConfig m_eglConfig; > bool m_eglConfigChosen; > }; >diff --git a/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp b/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp >index 8ab021b..97c872d 100644 >--- a/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp >+++ b/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp >@@ -29,6 +29,10 @@ > #if PLATFORM(X11) > #include <X11/Xlib.h> > >+#if USE(EGL) >+#include <EGL/egl.h> >+#endif >+ > namespace WebCore { > > PlatformDisplayX11::PlatformDisplayX11() >@@ -49,6 +53,14 @@ PlatformDisplayX11::~PlatformDisplayX11() > XCloseDisplay(m_display); > } > >+#if USE(EGL) >+void PlatformDisplayX11::initializeEGLDisplay() >+{ >+ m_eglDisplay = eglGetDisplay(m_display); >+ PlatformDisplay::initializeEGLDisplay(); >+} >+#endif >+ > } // namespace WebCore > > #endif // PLATFORM(X11) >diff --git a/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.h b/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.h >index 347d8ae..07c8b49 100644 >--- a/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.h >+++ b/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.h >@@ -45,6 +45,10 @@ public: > private: > virtual Type type() const override { return PlatformDisplay::Type::X11; } > >+#if USE(EGL) >+ void initializeEGLDisplay() override; >+#endif >+ > Display* m_display; > bool m_ownedDisplay; > };
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 144685
:
252469
|
252470
|
252475
|
252476
|
252478