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
eglcontextchanges.patch (text/plain), 46.26 KB, created by
Kalyan
on 2012-12-24 05:37:20 PST
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Kalyan
Created:
2012-12-24 05:37:20 PST
Size:
46.26 KB
patch
obsolete
>diff --git ChangeLog ChangeLog >index fbaf4dc..51d41f3 100644 >--- ChangeLog >+++ ChangeLog >@@ -1,3 +1,15 @@ >+2012-12-21 Kondapally Kalyan <kalyan.kondapally@intel.com> >+ >+ [EFL][WebGL] Implement EGL support with GLX. >+ https://bugs.webkit.org/show_bug.cgi?id=105602 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Adds support for EGL with GLX backend. EGL support can be enabled during compile time >+ by passing -DENABLE_EGL=ON as cmake config parameter. >+ >+ * Source/cmake/OptionsEfl.cmake: >+ > 2012-12-21 Sheriff Bot <webkit.review.bot@gmail.com> > > Unreviewed, rolling out r138338. >diff --git Source/WebCore/ChangeLog Source/WebCore/ChangeLog >index 1a0404f..04878bd 100644 >--- Source/WebCore/ChangeLog >+++ Source/WebCore/ChangeLog >@@ -1,3 +1,79 @@ >+2012-12-21 Kondapally Kalyan <kalyan.kondapally@intel.com> >+ >+ [EFL][WebGL] Implement EGL support with GLX. >+ https://bugs.webkit.org/show_bug.cgi?id=105602 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This is in preparation for adding GLES2 support. >+ This patch adds support for EGL with GLX backend. EGL support can be enabled during compile time >+ by passing -DENABLE_EGL=ON as cmake config parameter. This is disabled by default. >+ >+ * PlatformEfl.cmake: >+ * platform/graphics/opengl/GLDefs.h: >+ (WebCore): >+ * platform/graphics/opengl/GLPlatformContext.cpp: >+ (WebCore): >+ (WebCore::GLPlatformContext::createContext): Added GLX checks. >+ (WebCore::GLPlatformContext::createOffScreenContext): Added support for creating EGLOffscreen Context. >+ (WebCore::GLPlatformContext::createCurrentContextWrapper): Added support for creating EGLCurrentContextWrapper. >+ * platform/graphics/opengl/GLPlatformContext.h: >+ * platform/graphics/opengl/GLPlatformSurface.cpp: >+ (WebCore::GLPlatformSurface::createTransportSurface): Added support for creating EGLSurface. >+ >+ * platform/graphics/surfaces/egl/EGLContext.cpp: Added. >+ (WebCore): >+ (WebCore::isRobustnessExtSupported): >+ (WebCore::EGLCurrentContextWrapper::EGLCurrentContextWrapper): >+ (WebCore::EGLCurrentContextWrapper::handle): >+ (WebCore::EGLOffScreenContext::EGLOffScreenContext): >+ (WebCore::EGLOffScreenContext::initialize): >+ (WebCore::EGLOffScreenContext::~EGLOffScreenContext): >+ (WebCore::EGLOffScreenContext::isCurrentContext): >+ (WebCore::EGLOffScreenContext::platformMakeCurrent): >+ (WebCore::EGLOffScreenContext::platformReleaseCurrent): >+ (WebCore::EGLOffScreenContext::freeResources): >+ (WebCore::EGLOffScreenContext::destroy): >+ * platform/graphics/surfaces/egl/EGLContext.h: >+ (WebCore): >+ (EGLCurrentContextWrapper): >+ (WebCore::EGLCurrentContextWrapper::~EGLCurrentContextWrapper): >+ (EGLOffScreenContext): >+ >+ EGL implementation for Context Management. >+ >+ * platform/graphics/surfaces/egl/EGLSurface.cpp: Added. >+ (WebCore): >+ (WebCore::EGLWindowTransportSurface::EGLWindowTransportSurface): >+ (WebCore::EGLWindowTransportSurface::~EGLWindowTransportSurface): >+ (WebCore::EGLWindowTransportSurface::configuration): >+ (WebCore::EGLWindowTransportSurface::swapBuffers): >+ (WebCore::EGLWindowTransportSurface::destroy): >+ (WebCore::EGLWindowTransportSurface::freeEGLResources): >+ * platform/graphics/surfaces/egl/EGLSurface.h: >+ (WebCore): >+ (EGLWindowTransportSurface): >+ >+ EGL implementation for Offscreen Surface. The surface is backed by native window. >+ >+ * platform/graphics/surfaces/egl/EGLConfigHelper.cpp: Added. >+ (WebCore): >+ (WebCore::SharedEGLDisplay::deref): >+ (WebCore::SharedEGLDisplay::sharedEGLDisplay): >+ (WebCore::SharedEGLDisplay::SharedEGLDisplay): >+ (WebCore::SharedEGLDisplay::cleanup): >+ (WebCore::SharedEGLDisplay::~SharedEGLDisplay): >+ (WebCore::EGLConfigHelper::EGLConfigHelper): >+ (WebCore::EGLConfigHelper::~EGLConfigHelper): >+ (WebCore::EGLConfigHelper::display): >+ (WebCore::EGLConfigHelper::pBufferContextConfig): >+ (WebCore::EGLConfigHelper::surfaceContextConfig): >+ (WebCore::EGLConfigHelper::nativeVisualId): >+ (WebCore::EGLConfigHelper::reset): >+ (WebCore::EGLConfigHelper::createConfig): >+ >+ Helper class to initialize EGL resources and choose right EGL configiration. >+ > 2012-12-21 Brady Eidson <beidson@apple.com> > > Update localizable strings as a followup to http://trac.webkit.org/changeset/138387 >diff --git Source/WebCore/PlatformEfl.cmake Source/WebCore/PlatformEfl.cmake >index 56e306c..e7e469c 100644 >--- Source/WebCore/PlatformEfl.cmake >+++ Source/WebCore/PlatformEfl.cmake >@@ -265,6 +265,14 @@ if (WTF_USE_3D_GRAPHICS) > "${WEBCORE_DIR}/platform/graphics/surfaces/glx" > "${WEBCORE_DIR}/platform/graphics/texmap" > ) >+ >+ if (WTF_USE_EGL) >+ list(APPEND WebCore_INCLUDE_DIRECTORIES >+ ${EGL_INCLUDE_DIR} >+ "${WEBCORE_DIR}/platform/graphics/surfaces/egl" >+ ) >+ endif () >+ > list(APPEND WebCore_SOURCES > platform/graphics/OpenGLShims.cpp > platform/graphics/cairo/DrawingBufferCairo.cpp >@@ -277,18 +285,36 @@ if (WTF_USE_3D_GRAPHICS) > platform/graphics/opengl/GraphicsContext3DOpenGL.cpp > platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp > platform/graphics/surfaces/GraphicsSurface.cpp >- platform/graphics/surfaces/glx/GLXSurface.cpp >- platform/graphics/surfaces/glx/GLXContext.cpp > platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp > platform/graphics/surfaces/glx/X11WindowResources.cpp > platform/graphics/texmap/TextureMapperGL.cpp > platform/graphics/texmap/TextureMapperShaderManager.cpp > ) >+ >+ if (WTF_USE_EGL) >+ list(APPEND WebCore_SOURCES >+ platform/graphics/surfaces/egl/EGLSurface.cpp >+ platform/graphics/surfaces/egl/EGLContext.cpp >+ ) >+ endif () >+ >+ if (WTF_USE_GLX) >+ list(APPEND WebCore_SOURCES >+ platform/graphics/surfaces/glx/GLXSurface.cpp >+ platform/graphics/surfaces/glx/GLXContext.cpp >+ ) >+ endif () >+ > list(APPEND WebCore_LIBRARIES > ${X11_X11_LIB} > ${X11_Xcomposite_LIB} > ${X11_Xrender_LIB} > ) >+ if (WTF_USE_EGL) >+ list(APPEND WebCore_LIBRARIES >+ ${EGL_LIBRARY} >+ ) >+ endif () > endif () > > add_definitions(-DDATA_DIR="${CMAKE_INSTALL_PREFIX}/${DATA_INSTALL_DIR}") >diff --git Source/WebCore/platform/graphics/opengl/GLDefs.h Source/WebCore/platform/graphics/opengl/GLDefs.h >index 2dfb4c9..f823dc4 100644 >--- Source/WebCore/platform/graphics/opengl/GLDefs.h >+++ Source/WebCore/platform/graphics/opengl/GLDefs.h >@@ -28,12 +28,12 @@ > > #if USE(ACCELERATED_COMPOSITING) > >-#include "OpenGLShims.h" >- > #if USE(OPENGL_ES_2) >+#include "OpenGLESShims.h" > #include <GLES2/gl2.h> > #include <GLES2/gl2ext.h> > #else >+#include "OpenGLShims.h" > #include <GL/gl.h> > #include <GL/glext.h> > #endif >@@ -42,6 +42,12 @@ > #include <GL/glx.h> > #endif > >+#if USE(EGL) >+#define EGL_EGLEXT_PROTOTYPES 1 >+#include <EGL/egl.h> >+#include <EGL/eglext.h> >+#endif >+ > namespace WebCore { > > typedef uint32_t PlatformBufferHandle; >@@ -51,6 +57,16 @@ 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; >diff --git Source/WebCore/platform/graphics/opengl/GLPlatformContext.cpp Source/WebCore/platform/graphics/opengl/GLPlatformContext.cpp >index 7621e2e..79959ba 100644 >--- Source/WebCore/platform/graphics/opengl/GLPlatformContext.cpp >+++ Source/WebCore/platform/graphics/opengl/GLPlatformContext.cpp >@@ -30,6 +30,8 @@ > > #if USE(GLX) > #include "GLXContext.h" >+#elif USE(EGL) >+#include "EGLContext.h" > #endif > > #include "NotImplemented.h" >@@ -44,11 +46,11 @@ PassOwnPtr<GLPlatformContext> GLPlatformContext::createContext(GraphicsContext3D > if (!initializeOpenGLShims()) > return nullptr; > >- if (!glGetGraphicsResetStatusARB) { > #if USE(GLX) >+ if (!glGetGraphicsResetStatusARB) { > glGetGraphicsResetStatusARB = reinterpret_cast<PFNGLGETGRAPHICSRESETSTATUSARBPROC>(glXGetProcAddressARB(reinterpret_cast<const GLubyte*>("glGetGraphicsResetStatusARB"))); >-#endif > } >+#endif > > switch (renderStyle) { > case GraphicsContext3D::RenderOffscreen: >@@ -70,8 +72,9 @@ PassOwnPtr<GLPlatformContext> GLPlatformContext::createContext(GraphicsContext3D > PassOwnPtr<GLPlatformContext> GLPlatformContext::createOffScreenContext() > { > #if USE(GLX) >- OwnPtr<GLPlatformContext> glxContext = adoptPtr(new GLXOffScreenContext()); >- return glxContext.release(); >+ return adoptPtr(new GLXOffScreenContext()); >+#elif USE(EGL) >+ return adoptPtr(new EGLOffScreenContext()); > #endif > > return nullptr; >@@ -80,8 +83,9 @@ PassOwnPtr<GLPlatformContext> GLPlatformContext::createOffScreenContext() > PassOwnPtr<GLPlatformContext> GLPlatformContext::createCurrentContextWrapper() > { > #if USE(GLX) >- OwnPtr<GLPlatformContext> glxContext = adoptPtr(new GLXCurrentContextWrapper()); >- return glxContext.release(); >+ return adoptPtr(new GLXCurrentContextWrapper()); >+#elif USE(EGL) >+ return adoptPtr(new EGLCurrentContextWrapper()); > #endif > > return nullptr; >diff --git Source/WebCore/platform/graphics/opengl/GLPlatformContext.h Source/WebCore/platform/graphics/opengl/GLPlatformContext.h >index 170b76e..0353df8 100644 >--- Source/WebCore/platform/graphics/opengl/GLPlatformContext.h >+++ Source/WebCore/platform/graphics/opengl/GLPlatformContext.h >@@ -64,7 +64,7 @@ public: > // Doesn't have any effect if this is not the current Context. > void releaseCurrent(); > >- PlatformContext handle() const; >+ virtual PlatformContext handle() const; > > virtual bool isCurrentContext() const; > >diff --git Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp >index 8391e47..7f7a564 100644 >--- Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp >+++ Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp >@@ -32,6 +32,10 @@ > #include "GLXSurface.h" > #endif > >+#if USE(EGL) >+#include "EGLSurface.h" >+#endif >+ > #include "NotImplemented.h" > > namespace WebCore { >@@ -50,10 +54,14 @@ PassOwnPtr<GLPlatformSurface> GLPlatformSurface::createOffscreenSurface() > > PassOwnPtr<GLPlatformSurface> GLPlatformSurface::createTransportSurface() > { >-#if USE(GLX) && USE(GRAPHICS_SURFACE) >+#if USE(GRAPHICS_SURFACE) >+#if USE(GLX) > OwnPtr<GLPlatformSurface> surface = adoptPtr(new GLXTransportSurface()); >+#elif USE(EGL) >+ OwnPtr<GLPlatformSurface> surface = adoptPtr(new EGLWindowTransportSurface()); >+#endif > >- if (surface->handle()) >+ if (surface && surface->handle() && surface->drawable()) > return surface.release(); > #endif > >diff --git Source/WebCore/platform/graphics/surfaces/egl/EGLConfigHelper.cpp Source/WebCore/platform/graphics/surfaces/egl/EGLConfigHelper.cpp >new file mode 100644 >index 0000000..254ea49 >--- /dev/null >+++ Source/WebCore/platform/graphics/surfaces/egl/EGLConfigHelper.cpp >@@ -0,0 +1,181 @@ >+/* >+ * Copyright (C) 2012 Intel Corporation. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "EGLConfigHelper.h" >+ >+#if USE(EGL) >+ >+namespace WebCore { >+ >+SharedEGLDisplay* SharedEGLDisplay::m_staticSharedEGLDisplay = 0; >+ >+static EGLint configAttributeList[] = { >+#if USE(OPENGL_ES_2) >+ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, >+#else >+ EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, >+#endif >+ EGL_RED_SIZE, 8, >+ EGL_GREEN_SIZE, 8, >+ EGL_BLUE_SIZE, 8, >+ EGL_STENCIL_SIZE, 8, >+ EGL_ALPHA_SIZE, 8, >+ EGL_SURFACE_TYPE, EGL_NONE, >+ EGL_NONE >+}; >+ >+void SharedEGLDisplay::deref() >+{ >+ if (derefBase()) { >+ m_staticSharedEGLDisplay = 0; >+ delete this; >+ } >+} >+ >+EGLDisplay SharedEGLDisplay::sharedEGLDisplay() >+{ >+ return m_eglDisplay; >+} >+ >+SharedEGLDisplay::SharedEGLDisplay(NativeSharedDisplay* display) >+ : m_eglDisplay(EGL_NO_DISPLAY) >+{ >+ 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.\n"); >+ return; >+ } >+ >+ EGLBoolean success; >+ success = eglInitialize(m_eglDisplay, 0, 0); >+ >+ if (success != EGL_TRUE) { >+ LOG_ERROR("EGLInitialization failed.\n"); >+ m_eglDisplay = EGL_NO_DISPLAY; >+ } >+ >+ success = eglBindAPI(eglAPIVersion); >+ >+ if (success != EGL_TRUE) { >+ LOG_ERROR("Failed to set EGL API(%d).\n", eglGetError()); >+ m_eglDisplay = EGL_NO_DISPLAY; >+ } >+} >+ >+void SharedEGLDisplay::cleanup() >+{ >+ if (m_eglDisplay == EGL_NO_DISPLAY) >+ return; >+ >+ eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); >+ eglTerminate(m_eglDisplay); >+ m_eglDisplay = EGL_NO_DISPLAY; >+} >+ >+SharedEGLDisplay::~SharedEGLDisplay() >+{ >+ cleanup(); >+} >+ >+EGLConfigHelper::EGLConfigHelper(NativeSharedDisplay* display) >+ : m_pbufferfbConfig(0) >+ , m_surfaceContextfbConfig(0) >+{ >+ m_sharedDisplay = SharedEGLDisplay::create(display); >+} >+ >+EGLConfigHelper::~EGLConfigHelper() >+{ >+} >+ >+PlatformDisplay EGLConfigHelper::display() >+{ >+ return m_sharedDisplay->sharedEGLDisplay(); >+} >+ >+EGLConfig EGLConfigHelper::pBufferContextConfig() >+{ >+ if (!m_pbufferfbConfig) { >+ configAttributeList[13] = EGL_PIXMAP_BIT; >+ m_pbufferfbConfig = createConfig(configAttributeList); >+ } >+ >+ return m_pbufferfbConfig; >+} >+ >+EGLConfig EGLConfigHelper::surfaceContextConfig() >+{ >+ if (!m_surfaceContextfbConfig) { >+ configAttributeList[13] = EGL_WINDOW_BIT; >+ m_surfaceContextfbConfig = createConfig(configAttributeList); >+ } >+ >+ return m_surfaceContextfbConfig; >+} >+ >+EGLint EGLConfigHelper::nativeVisualId(const EGLConfig& config) >+{ >+ if (display() == EGL_NO_DISPLAY) >+ return -1; >+ >+ EGLint eglValue = 0; >+ eglGetConfigAttrib(display(), config, EGL_NATIVE_VISUAL_ID, &eglValue); >+ >+ return eglValue; >+} >+ >+void EGLConfigHelper::reset() >+{ >+ m_surfaceContextfbConfig = 0; >+ m_pbufferfbConfig = 0; >+} >+ >+EGLConfig EGLConfigHelper::createConfig(const int attributes[]) >+{ >+ if (display() == EGL_NO_DISPLAY) >+ return 0; >+ >+ int numConfigs; >+ EGLConfig rightConfig = 0; >+ >+ if (!eglChooseConfig(display(), attributes, &rightConfig, 1, &numConfigs)) >+ LOG_ERROR("Failed to get supported configirations.\n"); >+ >+ if (numConfigs != 1) { >+ LOG_ERROR("EGLChooseConfig didn't return exactly one config but (%d).\n", numConfigs); >+ rightConfig = 0; >+ } >+ >+ return rightConfig; >+} >+ >+} >+ >+#endif >diff --git Source/WebCore/platform/graphics/surfaces/egl/EGLConfigHelper.h Source/WebCore/platform/graphics/surfaces/egl/EGLConfigHelper.h >new file mode 100644 >index 0000000..4f86ce9 >--- /dev/null >+++ Source/WebCore/platform/graphics/surfaces/egl/EGLConfigHelper.h >@@ -0,0 +1,92 @@ >+/* >+ * Copyright (C) 2012 Intel Corporation. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef EGLConfigHelper_h >+#define EGLConfigHelper_h >+ >+#if USE(EGL) >+ >+#include <opengl/GLDefs.h> >+#include <wtf/Noncopyable.h> >+#include <wtf/PassRefPtr.h> >+#include <wtf/RefCounted.h> >+#include <wtf/RefPtr.h> >+ >+namespace WebCore { >+ >+typedef Display NativeSharedDisplay; >+ >+class SharedEGLDisplay : public WTF::RefCountedBase { >+ WTF_MAKE_NONCOPYABLE(SharedEGLDisplay); >+ >+public: >+ static PassRefPtr<SharedEGLDisplay> create(NativeSharedDisplay* display) >+ { >+ if (!m_staticSharedEGLDisplay) >+ m_staticSharedEGLDisplay = new SharedEGLDisplay(display); >+ else >+ m_staticSharedEGLDisplay->ref(); >+ >+ return adoptRef(m_staticSharedEGLDisplay); >+ } >+ >+ void deref(); >+ EGLDisplay sharedEGLDisplay(); >+ >+protected: >+ SharedEGLDisplay(NativeSharedDisplay*); >+ void cleanup(); >+ virtual ~SharedEGLDisplay(); >+ >+ static SharedEGLDisplay* m_staticSharedEGLDisplay; >+ EGLDisplay m_eglDisplay; >+}; >+ >+class EGLConfigHelper { >+ WTF_MAKE_NONCOPYABLE(EGLConfigHelper); >+ >+public: >+ EGLConfigHelper(NativeSharedDisplay* = 0); >+ virtual ~EGLConfigHelper(); >+ PlatformDisplay display(); >+ virtual EGLConfig pBufferContextConfig(); >+ virtual EGLConfig surfaceContextConfig(); >+ EGLint nativeVisualId(const EGLConfig&); >+ void reset(); >+ >+private: >+ EGLConfig createConfig(const int attributes[]); >+ >+protected: >+ EGLConfig m_pbufferfbConfig; >+ EGLConfig m_surfaceContextfbConfig; >+ RefPtr<SharedEGLDisplay> m_sharedDisplay; >+}; >+ >+} >+ >+#endif >+ >+#endif >diff --git Source/WebCore/platform/graphics/surfaces/egl/EGLContext.cpp Source/WebCore/platform/graphics/surfaces/egl/EGLContext.cpp >new file mode 100644 >index 0000000..567d738 >--- /dev/null >+++ Source/WebCore/platform/graphics/surfaces/egl/EGLContext.cpp >@@ -0,0 +1,177 @@ >+/* >+ * Copyright (C) 2012 Intel Corporation. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "EGLContext.h" >+ >+#if USE(EGL) >+ >+#include <wtf/text/WTFString.h> >+ >+#if HAVE(GLX) >+#include <GL/glx.h> >+#endif >+ >+namespace WebCore { >+ >+static const EGLint contextAttributes[] = { >+#if USE(OPENGL_ES_2) >+ EGL_CONTEXT_CLIENT_VERSION, 2, >+#endif >+ EGL_NONE >+}; >+ >+static const EGLint contextRobustnessAttributes[] = { >+#if USE(OPENGL_ES_2) >+ EGL_CONTEXT_CLIENT_VERSION, 2, >+#endif >+ EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, >+ EGL_LOSE_CONTEXT_ON_RESET_EXT, >+ EGL_NONE >+}; >+ >+static bool isRobustnessExtSupported(EGLDisplay display) >+{ >+ static bool didQueryForRobustnessExtension = false; >+ static bool isRobustnessExtensionSupported = false; >+ >+ if (!didQueryForRobustnessExtension) { >+ didQueryForRobustnessExtension = true; >+ String supportedExtensions = reinterpret_cast<const char*>(eglQueryString(display, EGL_EXTENSIONS)); >+ >+ if (!supportedExtensions.isEmpty()) { >+ supportedExtensions.append(" "); >+ isRobustnessExtensionSupported = supportedExtensions.contains("EGL_EXT_create_context_robustness "); >+ } >+ } >+ >+ return isRobustnessExtensionSupported; >+} >+ >+EGLCurrentContextWrapper::EGLCurrentContextWrapper() >+ : GLPlatformContext() >+{ >+} >+ >+// FIXME: This is a temporary workaround until we are able to build evas with EGL support. >+PlatformContext EGLCurrentContextWrapper::handle() const >+{ >+ return glXGetCurrentContext(); >+} >+ >+EGLOffScreenContext::EGLOffScreenContext() >+ : GLPlatformContext() >+ , m_display(0) >+{ >+} >+ >+bool EGLOffScreenContext::initialize(GLPlatformSurface* surface) >+{ >+ if (!surface) >+ return false; >+ >+ if (!eglBindAPI(eglAPIVersion)) { >+ LOG_ERROR("Failed to set EGL API(%d).\n", eglGetError()); >+ return false; >+ } >+ >+ m_display = surface->sharedDisplay(); >+ if (!m_display) >+ return false; >+ >+ EGLConfig config = surface->configuration(); >+ if (!config) >+ return false; >+ >+ if (config) { >+ if (isRobustnessExtSupported(m_display)) >+ m_contextHandle = eglCreateContext(m_display, config, EGL_NO_CONTEXT, contextRobustnessAttributes); >+ >+ if (m_contextHandle != EGL_NO_CONTEXT) >+ m_resetLostContext = true; >+ else >+ m_contextHandle = eglCreateContext(m_display, config, EGL_NO_CONTEXT, contextAttributes); >+ >+ if (m_contextHandle != EGL_NO_CONTEXT) >+ return true; >+ } >+ >+ return false; >+} >+ >+EGLOffScreenContext::~EGLOffScreenContext() >+{ >+} >+ >+bool EGLOffScreenContext::isCurrentContext() const >+{ >+ return m_contextHandle == eglGetCurrentContext(); >+} >+ >+bool EGLOffScreenContext::platformMakeCurrent(GLPlatformSurface* surface) >+{ >+ if (!eglBindAPI(eglAPIVersion)) { >+ LOG_ERROR("Failed to set EGL API(%d).\n", eglGetError()); >+ return false; >+ } >+ >+ if (!eglMakeCurrent(m_display, surface->drawable(), surface->drawable(), m_contextHandle)) { >+ LOG_ERROR("Failed to make context current.(%d).\n", eglGetError()); >+ >+ if (m_resetLostContext && eglGetError() == EGL_CONTEXT_LOST) { >+ LOG_ERROR("Lost current context.\n"); >+ m_contextLost = true; >+ } >+ >+ return false; >+ } >+ >+ return true; >+} >+ >+void EGLOffScreenContext::platformReleaseCurrent() >+{ >+ eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); >+} >+ >+void EGLOffScreenContext::freeResources() >+{ >+ if (m_contextHandle == EGL_NO_CONTEXT) >+ return; >+ >+ eglDestroyContext(m_display, m_contextHandle); >+ m_contextHandle = EGL_NO_CONTEXT; >+ m_display = 0; >+} >+ >+void EGLOffScreenContext::destroy() >+{ >+ GLPlatformContext::destroy(); >+ freeResources(); >+} >+ >+} >+ >+#endif >diff --git Source/WebCore/platform/graphics/surfaces/egl/EGLContext.h Source/WebCore/platform/graphics/surfaces/egl/EGLContext.h >new file mode 100644 >index 0000000..28a322e >--- /dev/null >+++ Source/WebCore/platform/graphics/surfaces/egl/EGLContext.h >@@ -0,0 +1,65 @@ >+/* >+ * Copyright (C) 2012 Intel Corporation. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef EGLContext_h >+#define EGLContext_h >+ >+#if USE(EGL) >+ >+#include "GLPlatformContext.h" >+ >+namespace WebCore { >+ >+class EGLCurrentContextWrapper : public GLPlatformContext { >+ WTF_MAKE_NONCOPYABLE(EGLCurrentContextWrapper); >+ >+public: >+ EGLCurrentContextWrapper(); >+ PlatformContext handle() const OVERRIDE; >+ virtual ~EGLCurrentContextWrapper() { } >+}; >+ >+class EGLOffScreenContext : public GLPlatformContext { >+ WTF_MAKE_NONCOPYABLE(EGLOffScreenContext); >+ >+public: >+ EGLOffScreenContext(); >+ virtual ~EGLOffScreenContext(); >+ bool initialize(GLPlatformSurface*) OVERRIDE; >+ bool platformMakeCurrent(GLPlatformSurface*) OVERRIDE; >+ void platformReleaseCurrent() OVERRIDE; >+ void destroy() OVERRIDE; >+ bool isCurrentContext() const OVERRIDE; >+ >+private: >+ void freeResources(); >+ EGLDisplay m_display; >+}; >+ >+} >+ >+#endif >+ >+#endif >diff --git Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp >new file mode 100644 >index 0000000..1934480 >--- /dev/null >+++ Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp >@@ -0,0 +1,142 @@ >+/* >+ * Copyright (C) 2012 Intel Corporation. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "EGLSurface.h" >+ >+#if USE(EGL) && USE(GRAPHICS_SURFACE) >+ >+namespace WebCore { >+ >+EGLWindowTransportSurface::EGLWindowTransportSurface() >+ : GLPlatformSurface() >+{ >+ m_nativeResource = adoptPtr(new NativeOffScreenWindow()); >+ m_eglConfigHelper = adoptPtr(new EGLConfigHelper(m_nativeResource->nativeSharedDisplay())); >+ m_sharedDisplay = m_eglConfigHelper->display(); >+ >+ if (m_sharedDisplay == EGL_NO_DISPLAY) { >+ m_eglConfigHelper = nullptr; >+ m_nativeResource = nullptr; >+ return; >+ } >+ >+ EGLConfig config = m_eglConfigHelper->surfaceContextConfig(); >+ >+ if (!config) { >+ destroy(); >+ return; >+ } >+ >+ EGLint visualId = m_eglConfigHelper->nativeVisualId(config); >+ >+ if (visualId == -1) { >+ destroy(); >+ return; >+ } >+ >+ if (!m_nativeResource->setVisualId(visualId)) { >+ destroy(); >+ return; >+ } >+ >+ m_nativeResource->createOffscreenWindow(&m_bufferHandle); >+ >+ if (!m_bufferHandle) { >+ destroy(); >+ return; >+ } >+ >+ m_drawable = eglCreateWindowSurface(m_sharedDisplay, m_eglConfigHelper->surfaceContextConfig(), (EGLNativeWindowType)m_bufferHandle, 0); >+ >+ if (m_drawable == EGL_NO_SURFACE) { >+ LOG_ERROR("Failed to create EGL surface(%d).\n", eglGetError()); >+ destroy(); >+ } >+} >+ >+EGLWindowTransportSurface::~EGLWindowTransportSurface() >+{ >+} >+ >+PlatformSurfaceConfig EGLWindowTransportSurface::configuration() >+{ >+ return m_eglConfigHelper->surfaceContextConfig(); >+} >+ >+void EGLWindowTransportSurface::swapBuffers() >+{ >+ if (!m_drawable) >+ return; >+ >+ EGLBoolean success = eglBindAPI(eglAPIVersion); >+ >+ if (success != EGL_TRUE) { >+ LOG_ERROR("Failed to set EGL API(%d).\n", eglGetError()); >+ destroy(); >+ } >+ >+ success = eglSwapBuffers(m_sharedDisplay, m_drawable); >+ >+ if (success != EGL_TRUE) { >+ LOG_ERROR("Failed to SwapBuffers(%d).\n", eglGetError()); >+ destroy(); >+ } >+} >+ >+void EGLWindowTransportSurface::destroy() >+{ >+ m_nativeResource->destroyWindow(m_bufferHandle); >+ freeEGLResources(); >+ m_nativeResource = nullptr; >+ m_eglConfigHelper = nullptr; >+ m_bufferHandle = 0; >+} >+ >+void EGLWindowTransportSurface::freeEGLResources() >+{ >+ if (m_drawable == EGL_NO_SURFACE || m_sharedDisplay == EGL_NO_DISPLAY) >+ return; >+ >+ EGLBoolean eglResult = eglBindAPI(eglAPIVersion); >+ >+ if (eglResult != EGL_TRUE) { >+ LOG_ERROR("Failed to set EGL API(%d).\n", eglGetError()); >+ return; >+ } >+ >+ eglDestroySurface(m_sharedDisplay, m_drawable); >+ m_drawable = EGL_NO_SURFACE; >+} >+ >+void EGLWindowTransportSurface::setGeometry(const IntRect& newRect) >+{ >+ GLPlatformSurface::setGeometry(newRect); >+ m_nativeResource->reSizeWindow(newRect, m_bufferHandle); >+} >+ >+} >+ >+#endif >diff --git Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.h Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.h >new file mode 100644 >index 0000000..6b6924b >--- /dev/null >+++ Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.h >@@ -0,0 +1,64 @@ >+/* >+ * Copyright (C) 2012 Intel Corporation. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef EGLSurface_h >+#define EGLSurface_h >+ >+#if USE(EGL) && USE(GRAPHICS_SURFACE) >+ >+#include "EGLConfigHelper.h" >+#include "GLPlatformSurface.h" >+ >+#include <glx/X11WindowResources.h> >+#include <wtf/Noncopyable.h> >+#include <wtf/PassOwnPtr.h> >+ >+namespace WebCore { >+ >+typedef X11OffScreenWindow NativeOffScreenWindow; >+ >+// Contents of the surface are backed by native window. >+class EGLWindowTransportSurface : public GLPlatformSurface { >+ WTF_MAKE_NONCOPYABLE(EGLWindowTransportSurface); >+ >+public: >+ EGLWindowTransportSurface(); >+ virtual ~EGLWindowTransportSurface(); >+ PlatformSurfaceConfig configuration() OVERRIDE; >+ void setGeometry(const IntRect& newRect) OVERRIDE; >+ void swapBuffers() OVERRIDE; >+ void destroy() OVERRIDE; >+ >+private: >+ void freeEGLResources(); >+ OwnPtr<NativeOffScreenWindow> m_nativeResource; >+ OwnPtr<EGLConfigHelper> m_eglConfigHelper; >+}; >+ >+} >+ >+#endif >+ >+#endif >diff --git Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp >index 96a0ab9..c9cd8d2 100644 >--- Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp >+++ Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp >@@ -36,7 +36,7 @@ static const int pbufferAttributes[] = { GLX_PBUFFER_WIDTH, 1, GLX_PBUFFER_HEIGH > GLXTransportSurface::GLXTransportSurface() > : X11OffScreenWindow() > { >- createOffscreenWindow(); >+ createOffscreenWindow(&m_bufferHandle); > m_drawable = m_bufferHandle; > } > >@@ -49,6 +49,12 @@ PlatformSurfaceConfig GLXTransportSurface::configuration() > return m_sharedResources->surfaceContextConfig(); > } > >+void GLXTransportSurface::setGeometry(const IntRect& newRect) >+{ >+ GLPlatformSurface::setGeometry(newRect); >+ reSizeWindow(newRect, m_drawable); >+} >+ > void GLXTransportSurface::swapBuffers() > { > if (!m_drawable) >@@ -66,7 +72,7 @@ void GLXTransportSurface::swapBuffers() > > void GLXTransportSurface::destroy() > { >- destroyWindow(); >+ destroyWindow(m_bufferHandle); > m_bufferHandle = 0; > } > >diff --git Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.h Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.h >index 4e87685..0d84c34 100644 >--- Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.h >+++ Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.h >@@ -43,6 +43,7 @@ public: > virtual ~GLXTransportSurface(); > PlatformSurfaceConfig configuration(); > void swapBuffers(); >+ void setGeometry(const IntRect&); > void destroy(); > > private: >diff --git Source/WebCore/platform/graphics/surfaces/glx/GLXWindowResources.h Source/WebCore/platform/graphics/surfaces/glx/GLXWindowResources.h >index c173557..cbfcc39 100644 >--- Source/WebCore/platform/graphics/surfaces/glx/GLXWindowResources.h >+++ Source/WebCore/platform/graphics/surfaces/glx/GLXWindowResources.h >@@ -51,6 +51,14 @@ public: > return SharedX11Resources::x11Display(); > } > >+ XVisualInfo* visualInfo() >+ { >+ if (!m_VisualInfo) >+ surfaceContextConfig(); >+ >+ return m_VisualInfo; >+ } >+ > virtual GLXFBConfig pBufferContextConfig() > { > if (!m_pbufferfbConfig) { >@@ -98,11 +106,12 @@ public: > return m_surfaceContextfbConfig; > } > >-private: >+protected: > SharedGLXResources() > : SharedX11Resources() > , m_pbufferfbConfig(0) > , m_surfaceContextfbConfig(0) >+ , m_VisualInfo(0) > { > } > >@@ -160,10 +169,16 @@ private: > > if (m_surfaceContextfbConfig) > m_surfaceContextfbConfig = 0; >+ >+ if (m_VisualInfo) { >+ XFree(m_VisualInfo); >+ m_VisualInfo = 0; >+ } > } > > GLXFBConfig m_pbufferfbConfig; > GLXFBConfig m_surfaceContextfbConfig; >+ XVisualInfo* m_VisualInfo; > }; > > } >diff --git Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.cpp Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.cpp >index 60293e7..cab22fb 100644 >--- Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.cpp >+++ Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.cpp >@@ -28,7 +28,9 @@ > > #if USE(ACCELERATED_COMPOSITING) > >+#if USE(GLX) > #include "GLXWindowResources.h" >+#endif > > namespace WebCore { > >@@ -37,26 +39,30 @@ PlatformSharedResources* SharedX11Resources::m_staticSharedResource = 0; > X11OffScreenWindow::X11OffScreenWindow() > : GLPlatformSurface() > , m_sharedResources(0) >+ , m_configVisualInfo(0) > { > m_sharedResources = PlatformSharedResources::create(); > > if (!m_sharedResources) > return; > >- m_sharedDisplay = m_sharedResources->nativeDisplay(); >+ m_sharedDisplay = m_sharedResources->x11Display(); > } > > X11OffScreenWindow::~X11OffScreenWindow() > { >+ if (m_configVisualInfo) { >+ XFree(m_configVisualInfo); >+ m_configVisualInfo = 0; >+ } > } > >-void X11OffScreenWindow::setGeometry(const IntRect& newRect) >+void X11OffScreenWindow::reSizeWindow(const IntRect& newRect, PlatformBufferHandle windowId) > { >- GLPlatformSurface::setGeometry(newRect); >- XResizeWindow(m_sharedResources->x11Display(), m_bufferHandle, newRect.width(), newRect.height()); >+ XResizeWindow(m_sharedResources->x11Display(), windowId, newRect.width(), newRect.height()); > } > >-void X11OffScreenWindow::createOffscreenWindow() >+void X11OffScreenWindow::createOffscreenWindow(PlatformBufferHandle* handleId) > { > if (!m_sharedResources) > return; >@@ -65,14 +71,11 @@ void X11OffScreenWindow::createOffscreenWindow() > if (!display) > return; > >- PlatformSurfaceConfig config = m_sharedResources->surfaceContextConfig(); >- >- if (!config) { >- LOG_ERROR("Failed to retrieve a valid configiration."); >- return; >- } >- >+#if USE(GLX) > XVisualInfo* visInfo = m_sharedResources->visualInfo(); >+#else >+ XVisualInfo* visInfo = m_configVisualInfo; >+#endif > > if (!visInfo) { > LOG_ERROR("Failed to find valid XVisual"); >@@ -88,24 +91,27 @@ void X11OffScreenWindow::createOffscreenWindow() > attribute.background_pixel = WhitePixel(display, 0); > attribute.border_pixel = BlackPixel(display, 0); > attribute.colormap = cmap; >- m_bufferHandle = XCreateWindow(display, xWindow, 0, 0, 1, 1, 0, visInfo->depth, InputOutput, visInfo->visual, CWBackPixel | CWBorderPixel | CWColormap, &attribute); >+ PlatformBufferHandle tempHandleId; >+ tempHandleId = XCreateWindow(display, xWindow, 0, 0, 1, 1, 0, visInfo->depth, InputOutput, visInfo->visual, CWBackPixel | CWBorderPixel | CWColormap, &attribute); > >- if (!m_bufferHandle) { >+ if (!tempHandleId) { > LOG_ERROR("Failed to create offscreen window"); > return; > } > >- XSetWindowBackgroundPixmap(display, m_bufferHandle, 0); >- XCompositeRedirectWindow(display, m_bufferHandle, CompositeRedirectManual); >+ XSetWindowBackgroundPixmap(display, tempHandleId, 0); >+ XCompositeRedirectWindow(display, tempHandleId, CompositeRedirectManual); >+ *handleId = tempHandleId; >+ m_bufferHandle = tempHandleId; > > if (m_sharedResources->isXRenderExtensionSupported()) >- XMapWindow(display, m_bufferHandle); >+ XMapWindow(display, tempHandleId); > > } > >-void X11OffScreenWindow::destroyWindow() >+void X11OffScreenWindow::destroyWindow(PlatformBufferHandle windowId) > { >- if (!m_bufferHandle) >+ if (!windowId) > return; > > GLPlatformSurface::destroy(); >@@ -113,9 +119,67 @@ void X11OffScreenWindow::destroyWindow() > if (!display) > return; > >- XDestroyWindow(display, m_bufferHandle); >- m_bufferHandle = 0; >+ XDestroyWindow(display, windowId); >+} >+ >+Display* X11OffScreenWindow::nativeSharedDisplay() >+{ >+ return m_sharedResources->x11Display(); >+} >+ >+#if USE(EGL) >+bool X11OffScreenWindow::setVisualId(const EGLint id) >+{ >+ VisualID visualId = static_cast<VisualID>(id); >+ >+ if (!visualId) >+ return false; >+ >+ // EGL has suggested a visual id, so get the rest of the visual info for that id. >+ XVisualInfo visualInfoTemplate; >+ memset(&visualInfoTemplate, 0, sizeof(XVisualInfo)); >+ visualInfoTemplate.visualid = visualId; >+ >+ XVisualInfo* chosenVisualInfo; >+ int matchingCount = 0; >+ chosenVisualInfo = XGetVisualInfo(m_sharedResources->x11Display(), VisualIDMask, &visualInfoTemplate, &matchingCount); >+ if (chosenVisualInfo) { >+#if USE(GRAPHICS_SURFACE) >+ if (m_sharedResources->isXRenderExtensionSupported()) { >+ XRenderPictFormat* format = XRenderFindVisualFormat(m_sharedResources->x11Display(), chosenVisualInfo->visual); >+ if (format && format->direct.alphaMask > 0) { >+ m_configVisualInfo = chosenVisualInfo; >+ return true; >+ } >+ } >+#endif >+ if (chosenVisualInfo->depth == 32) { >+ m_configVisualInfo = chosenVisualInfo; >+ return true; >+ } >+ } >+ >+ if (!m_configVisualInfo) { >+ memset(&visualInfoTemplate, 0, sizeof(XVisualInfo)); >+ XVisualInfo* matchingVisuals; >+ int matchingCount = 0; >+ >+ visualInfoTemplate.depth = chosenVisualInfo->depth; >+ matchingVisuals = XGetVisualInfo(m_sharedResources->x11Display(), VisualDepthMask, &visualInfoTemplate, &matchingCount); >+ >+ if (matchingVisuals) { >+ m_configVisualInfo = &matchingVisuals[0]; >+ XFree(matchingVisuals); >+ return true; >+ } >+ } >+ >+ if (!m_configVisualInfo) >+ LOG_ERROR("Failed to retrieve XVisual Info.\n"); >+ >+ return false; > } >+#endif > > } > >diff --git Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.h Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.h >index b25b2ac..9c080c3 100644 >--- Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.h >+++ Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.h >@@ -40,13 +40,30 @@ > > namespace WebCore { > >+#if USE(GLX) > class SharedGLXResources; > typedef SharedGLXResources PlatformSharedResources; >+#elif USE(EGL) >+class SharedX11Resources; >+typedef SharedX11Resources PlatformSharedResources; >+#endif > > class SharedX11Resources : public WTF::RefCountedBase { > WTF_MAKE_NONCOPYABLE(SharedX11Resources); > > public: >+#if USE(EGL) >+ static PassRefPtr<PlatformSharedResources> create() >+ { >+ if (!m_staticSharedResource) >+ m_staticSharedResource = new PlatformSharedResources(); >+ else >+ m_staticSharedResource->ref(); >+ >+ return adoptRef(m_staticSharedResource); >+ } >+#endif >+ > void deref() > { > if (derefBase()) { >@@ -94,29 +111,16 @@ public: > return m_window; > } > >- XVisualInfo* visualInfo() >- { >- if (!m_VisualInfo) >- surfaceContextConfig(); >- >- return m_VisualInfo; >- } >- > bool isXRenderExtensionSupported() > { > return m_supportsXRenderExtension; > } > >- virtual PlatformSurfaceConfig pBufferContextConfig() = 0; >- virtual PlatformSurfaceConfig surfaceContextConfig() = 0; >- virtual PlatformDisplay nativeDisplay() = 0; >- > protected: > SharedX11Resources() > : m_supportsXRenderExtension(false) > , m_window(0) > , m_display(0) >- , m_VisualInfo(0) > { > } > >@@ -131,11 +135,6 @@ protected: > m_window = 0; > } > >- if (m_VisualInfo) { >- XFree(m_VisualInfo); >- m_VisualInfo = 0; >- } >- > XCloseDisplay(m_display); > m_display = 0; > } >@@ -144,7 +143,6 @@ protected: > bool m_supportsXRenderExtension; > Window m_window; > Display* m_display; >- XVisualInfo* m_VisualInfo; > }; > > class X11OffScreenWindow : public GLPlatformSurface { >@@ -153,12 +151,17 @@ class X11OffScreenWindow : public GLPlatformSurface { > public: > X11OffScreenWindow(); > virtual ~X11OffScreenWindow(); >- void setGeometry(const IntRect&); >- void createOffscreenWindow(); >- void destroyWindow(); >+ void createOffscreenWindow(PlatformBufferHandle*); >+ void destroyWindow(PlatformBufferHandle); >+ void reSizeWindow(const IntRect&, PlatformBufferHandle); >+ Display* nativeSharedDisplay(); >+#if USE(EGL) >+ bool setVisualId(const EGLint); >+#endif > > protected: > RefPtr<PlatformSharedResources> m_sharedResources; >+ XVisualInfo* m_configVisualInfo; > }; > > } >diff --git Source/cmake/OptionsEfl.cmake Source/cmake/OptionsEfl.cmake >index 800a709..fe202ef 100644 >--- Source/cmake/OptionsEfl.cmake >+++ Source/cmake/OptionsEfl.cmake >@@ -175,12 +175,25 @@ if (ENABLE_WEBGL OR WTF_USE_TILED_BACKING_STORE) > > if (OPENGLX_FOUND) > add_definitions(-DHAVE_GLX) >- add_definitions(-DWTF_USE_GLX=1) >+ endif () >+ >+ option(ENABLE_EGL ON) > >- if (X11_Xcomposite_FOUND AND X11_Xrender_FOUND) >- set(USE_GRAPHICS_SURFACE 1) >- endif () >+ if (ENABLE_EGL) >+ find_package(EGL REQUIRED) > endif () >+ >+ if (EGL_FOUND) >+ set(WTF_USE_EGL 1) >+ add_definitions(-DWTF_USE_EGL=1) >+ elseif (OPENGLX_FOUND) >+ set(WTF_USE_GLX 1) >+ add_definitions(-DWTF_USE_GLX=1) >+ endif () >+ >+ if ((OPENGLX_FOUND OR EGL_FOUND) AND X11_Xcomposite_FOUND AND X11_Xrender_FOUND) >+ set(USE_GRAPHICS_SURFACE 1) >+ endif () > endif () > > if (ENABLE_INSPECTOR)
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 105602
:
180545
|
180553
|
180557
|
180586
|
180602
|
180633
|
180664
|
180772
|
180806
|
180814