WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
rebasedpatch
rebasedpatch.patch (text/plain), 34.23 KB, created by
Kalyan
on 2012-12-22 05:26:01 PST
(
hide
)
Description:
rebasedpatch
Filename:
MIME Type:
Creator:
Kalyan
Created:
2012-12-22 05:26:01 PST
Size:
34.23 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..8e80df5 100644 >--- Source/WebCore/ChangeLog >+++ Source/WebCore/ChangeLog >@@ -1,3 +1,74 @@ >+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): >+ (WebCore::GLPlatformContext::createOffScreenContext): >+ (WebCore::GLPlatformContext::createCurrentContextWrapper): >+ * platform/graphics/opengl/GLPlatformContext.h: >+ * platform/graphics/opengl/GLPlatformSurface.cpp: >+ (WebCore::GLPlatformSurface::createTransportSurface): >+ >+ EGL implementation for Context Management. >+ * 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 Offscreen Surface. >+ * platform/graphics/surfaces/egl/EGLSurface.cpp: Added. >+ (WebCore): >+ (WebCore::EGLTransportSurface::EGLTransportSurface): >+ (WebCore::EGLTransportSurface::~EGLTransportSurface): >+ (WebCore::EGLTransportSurface::configuration): >+ (WebCore::EGLTransportSurface::swapBuffers): >+ (WebCore::EGLTransportSurface::destroy): >+ (WebCore::EGLTransportSurface::freeEGLResources): >+ * platform/graphics/surfaces/egl/EGLSurface.h: >+ (WebCore): >+ (EGLTransportSurface): >+ >+ X integration. >+ * platform/graphics/surfaces/glx/EGLXWindowResources.h: Added. >+ (WebCore): >+ (SharedEGLResources): >+ (WebCore::SharedEGLResources::create): >+ (WebCore::SharedEGLResources::nativeDisplay): >+ (WebCore::SharedEGLResources::pBufferContextConfig): >+ (WebCore::SharedEGLResources::surfaceContextConfig): >+ (WebCore::SharedEGLResources::SharedEGLResources): >+ (WebCore::SharedEGLResources::cleanup): >+ (WebCore::SharedEGLResources::createConfig): >+ (WebCore::SharedEGLResources::~SharedEGLResources): >+ * platform/graphics/surfaces/glx/X11WindowResources.cpp: >+ * platform/graphics/surfaces/glx/X11WindowResources.h: >+ > 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..5735340 100644 >--- Source/WebCore/platform/graphics/opengl/GLDefs.h >+++ Source/WebCore/platform/graphics/opengl/GLDefs.h >@@ -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..39ecc7f 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,11 @@ PassOwnPtr<GLPlatformContext> GLPlatformContext::createContext(GraphicsContext3D > PassOwnPtr<GLPlatformContext> GLPlatformContext::createOffScreenContext() > { > #if USE(GLX) >- OwnPtr<GLPlatformContext> glxContext = adoptPtr(new GLXOffScreenContext()); >- return glxContext.release(); >+ OwnPtr<GLPlatformContext> context = adoptPtr(new GLXOffScreenContext()); >+ return context.release(); >+#elif USE(EGL) >+ OwnPtr<GLPlatformContext> context = adoptPtr(new EGLOffScreenContext()); >+ return context.release(); > #endif > > return nullptr; >@@ -80,8 +85,11 @@ PassOwnPtr<GLPlatformContext> GLPlatformContext::createOffScreenContext() > PassOwnPtr<GLPlatformContext> GLPlatformContext::createCurrentContextWrapper() > { > #if USE(GLX) >- OwnPtr<GLPlatformContext> glxContext = adoptPtr(new GLXCurrentContextWrapper()); >- return glxContext.release(); >+ OwnPtr<GLPlatformContext> context = adoptPtr(new GLXCurrentContextWrapper()); >+ return context.release(); >+#elif USE(EGL) >+ OwnPtr<GLPlatformContext> context = adoptPtr(new EGLCurrentContextWrapper()); >+ return context.release(); > #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..ed025f2 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 EGLTransportSurface()); >+#endif > >- if (surface->handle()) >+ if (surface && surface->handle() && surface->drawable()) > return surface.release(); > #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..1c0a897 >--- /dev/null >+++ Source/WebCore/platform/graphics/surfaces/egl/EGLContext.cpp >@@ -0,0 +1,176 @@ >+/* >+ * 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(ACCELERATED_COMPOSITING) && 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 queryDone = false; >+ static bool isEGLEXTsupported = false; >+ >+ if (!queryDone) { >+ queryDone = true; >+ String supportedExtensions = reinterpret_cast<const char*>(eglQueryString(display, EGL_EXTENSIONS)); >+ if (!supportedExtensions.isEmpty()) { >+ supportedExtensions.append(" "); >+ isEGLEXTsupported = supportedExtensions.contains("EGL_EXT_create_context_robustness "); >+ } >+ } >+ >+ return isEGLEXTsupported; >+} >+ >+EGLCurrentContextWrapper::EGLCurrentContextWrapper() >+ : GLPlatformContext() >+{ >+} >+ >+// FIXME: This is a temporary workaround till 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 && m_contextHandle != EGL_NO_CONTEXT) >+ m_resetLostContext = true; >+ else >+ m_contextHandle = eglCreateContext(m_display, config, EGL_NO_CONTEXT, contextAttributes); >+ >+ if (m_contextHandle && 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) >+ eglDestroyContext(m_display, m_contextHandle); >+ >+ m_contextHandle = 0; >+ 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..180793e >--- /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(ACCELERATED_COMPOSITING) && USE(EGL) >+ >+#include "GLPlatformContext.h" >+ >+namespace WebCore { >+ >+class EGLCurrentContextWrapper : public GLPlatformContext { >+ WTF_MAKE_NONCOPYABLE(EGLCurrentContextWrapper); >+ >+public: >+ EGLCurrentContextWrapper(); >+ PlatformContext handle() const; >+ virtual ~EGLCurrentContextWrapper() { } >+}; >+ >+class EGLOffScreenContext : public GLPlatformContext { >+ WTF_MAKE_NONCOPYABLE(EGLOffScreenContext); >+ >+public: >+ EGLOffScreenContext(); >+ virtual ~EGLOffScreenContext(); >+ bool initialize(GLPlatformSurface*); >+ bool platformMakeCurrent(GLPlatformSurface*); >+ void platformReleaseCurrent(); >+ void destroy(); >+ bool isCurrentContext() const; >+ >+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..dc3e06b >--- /dev/null >+++ Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp >@@ -0,0 +1,115 @@ >+/* >+ * 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(ACCELERATED_COMPOSITING) && USE(EGL) && USE(GRAPHICS_SURFACE) >+ >+namespace WebCore { >+ >+EGLTransportSurface::EGLTransportSurface() >+ : X11OffScreenWindow() >+{ >+ if (m_sharedDisplay == EGL_NO_DISPLAY) { >+ LOG_ERROR("No valid hardware display found.\n"); >+ return; >+ } >+ >+ if (!configuration()) { >+ destroy(); >+ return; >+ } >+ >+ createOffscreenWindow(); >+ >+ if (!m_bufferHandle) { >+ LOG_ERROR("Failed to create XWindow.\n"); >+ destroy(); >+ return; >+ } >+ >+ m_drawable = eglCreateWindowSurface(m_sharedResources->nativeDisplay(), configuration(), (EGLNativeWindowType)m_bufferHandle, 0); >+ >+ if (m_drawable == EGL_NO_SURFACE) { >+ LOG_ERROR("Failed to create EGL surface(%d).\n", eglGetError()); >+ destroy(); >+ } >+} >+ >+EGLTransportSurface::~EGLTransportSurface() >+{ >+} >+ >+PlatformSurfaceConfig EGLTransportSurface::configuration() >+{ >+ return m_sharedResources->surfaceContextConfig(); >+} >+ >+void EGLTransportSurface::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(sharedDisplay(), m_drawable); >+ >+ if (success != EGL_TRUE) { >+ LOG_ERROR("Failed to SwapBuffers(%d).\n", eglGetError()); >+ destroy(); >+ } >+} >+ >+void EGLTransportSurface::destroy() >+{ >+ destroyWindow(); >+ freeEGLResources(); >+} >+ >+void EGLTransportSurface::freeEGLResources() >+{ >+ if (m_drawable == EGL_NO_SURFACE) >+ return; >+ >+ EGLBoolean eglResult = eglBindAPI(eglAPIVersion); >+ >+ if (eglResult != EGL_TRUE) { >+ LOG_ERROR("Failed to set EGL API(%d).\n", eglGetError()); >+ return; >+ } >+ >+ eglDestroySurface(sharedDisplay(), m_drawable); >+ m_drawable = EGL_NO_SURFACE; >+} >+ >+} >+ >+#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..4a69e49 >--- /dev/null >+++ Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.h >@@ -0,0 +1,55 @@ >+/* >+ * 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(ACCELERATED_COMPOSITING) && USE(EGL) && USE(GRAPHICS_SURFACE) >+ >+#include <glx/EGLXWindowResources.h> >+#include <wtf/Noncopyable.h> >+#include <wtf/RefCounted.h> >+ >+namespace WebCore { >+ >+class EGLTransportSurface : public X11OffScreenWindow { >+ WTF_MAKE_NONCOPYABLE(EGLTransportSurface); >+ >+public: >+ EGLTransportSurface(); >+ virtual ~EGLTransportSurface(); >+ PlatformSurfaceConfig configuration(); >+ void swapBuffers(); >+ void destroy(); >+ >+private: >+ void freeEGLResources(); >+}; >+ >+} >+ >+#endif >+ >+#endif >diff --git Source/WebCore/platform/graphics/surfaces/glx/EGLXWindowResources.h Source/WebCore/platform/graphics/surfaces/glx/EGLXWindowResources.h >new file mode 100644 >index 0000000..7afbe91 >--- /dev/null >+++ Source/WebCore/platform/graphics/surfaces/glx/EGLXWindowResources.h >@@ -0,0 +1,240 @@ >+/* >+ * 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 EGLXWindowResources_h >+#define EGLXWindowResources_h >+ >+#include "X11WindowResources.h" >+ >+#if USE(ACCELERATED_COMPOSITING) && USE(EGL) >+ >+#include <opengl/GLDefs.h> >+ >+namespace WebCore { >+ >+class SharedEGLResources : public SharedX11Resources { >+ >+public: >+ static PassRefPtr<SharedEGLResources> create() >+ { >+ if (!m_staticSharedResource) >+ m_staticSharedResource = new SharedEGLResources(); >+ else >+ m_staticSharedResource->ref(); >+ >+ return adoptRef(m_staticSharedResource); >+ } >+ >+ PlatformDisplay nativeDisplay() >+ { >+ if (m_eglDisplay == EGL_NO_DISPLAY) { >+ EGLBoolean success; >+ >+ m_eglDisplay = eglGetDisplay(reinterpret_cast<EGLNativeDisplayType>(SharedX11Resources::x11Display())); >+ >+ if (m_eglDisplay == EGL_NO_DISPLAY) { >+ LOG_ERROR("EGLDisplay Initialization failed.\n"); >+ return m_eglDisplay; >+ } >+ >+ success = eglInitialize(m_eglDisplay, 0, 0); >+ >+ if (success != EGL_TRUE) { >+ LOG_ERROR("EGLInitialization failed.\n"); >+ cleanup(); >+ return m_eglDisplay; >+ } >+ >+ success = eglBindAPI(eglAPIVersion); >+ >+ if (success != EGL_TRUE) { >+ LOG_ERROR("failed to set EGL API(%d).\n", eglGetError()); >+ cleanup(); >+ } >+ } >+ >+ return m_eglDisplay; >+ } >+ >+ virtual EGLConfig pBufferContextConfig() >+ { >+ if (!m_pbufferfbConfig) { >+ EGLint attributeList[] = { >+#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_PIXMAP_BIT, >+ EGL_NONE >+ }; >+ m_pbufferfbConfig = createConfig(attributeList); >+ } >+ return m_pbufferfbConfig; >+ } >+ >+ virtual EGLConfig surfaceContextConfig() >+ { >+ if (!m_surfaceContextfbConfig) { >+ EGLint attributeList[] = { >+ EGL_LEVEL, 0, >+#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_DEPTH_SIZE, 8, >+ EGL_SURFACE_TYPE, EGL_WINDOW_BIT, >+ EGL_NONE >+ }; >+ m_surfaceContextfbConfig = createConfig(attributeList); >+ } >+ >+ return m_surfaceContextfbConfig; >+ } >+ >+private: >+ SharedEGLResources() >+ : SharedX11Resources() >+ { >+ m_eglDisplay = EGL_NO_DISPLAY; >+ m_surfaceContextfbConfig = 0; >+ m_pbufferfbConfig = 0; >+ } >+ >+ void cleanup() >+ { >+ eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); >+ eglTerminate(m_eglDisplay); >+ m_eglDisplay = EGL_NO_DISPLAY; >+ } >+ >+ EGLConfig createConfig(const int attributes[]) >+ { >+ if (m_eglDisplay == EGL_NO_DISPLAY) { >+ // Try to initialize Display if already not done. >+ nativeDisplay(); >+ >+ if (m_eglDisplay == EGL_NO_DISPLAY) >+ return 0; >+ } >+ >+ int numConfigs; >+ EGLConfig rightConfig = 0; >+ >+ if (!eglChooseConfig(m_eglDisplay, attributes, &rightConfig, 1, &numConfigs)) { >+ LOG_ERROR("Failed to get supported configirations.\n"); >+ cleanup(); >+ } >+ >+ if (numConfigs != 1) { >+ LOG_ERROR("EGLChooseConfig didn't return exactly one config but (%d).\n", numConfigs); >+ cleanup(); >+ } >+ >+ VisualID visualId = 0; >+ EGLint eglValue = 0; >+ >+ // Check if EGL provides us with a valid visual id. >+ eglGetConfigAttrib(m_eglDisplay, rightConfig, EGL_NATIVE_VISUAL_ID, &eglValue); >+ visualId = static_cast<VisualID>(eglValue); >+ if (visualId) { >+ // 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(x11Display(), VisualIDMask, &visualInfoTemplate, &matchingCount); >+ if (chosenVisualInfo) { >+#if USE(GRAPHICS_SURFACE) >+ if (m_supportsXRenderExtension) { >+ XRenderPictFormat* format = XRenderFindVisualFormat(x11Display(), chosenVisualInfo->visual); >+ if (format && format->direct.alphaMask > 0) >+ m_VisualInfo = chosenVisualInfo; >+ } >+#endif >+ if (!m_VisualInfo && chosenVisualInfo->depth == 32) >+ m_VisualInfo = chosenVisualInfo; >+ } >+ >+ if (!m_VisualInfo) { >+ XVisualInfo visualInfoTemplate; >+ memset(&visualInfoTemplate, 0, sizeof(XVisualInfo)); >+ XVisualInfo *matchingVisuals; >+ int matchingCount = 0; >+ >+ visualInfoTemplate.depth = chosenVisualInfo->depth; >+ matchingVisuals = XGetVisualInfo(x11Display(), VisualDepthMask, &visualInfoTemplate, &matchingCount); >+ >+ if (matchingVisuals) { >+ m_VisualInfo = &matchingVisuals[0]; >+ XFree(matchingVisuals); >+ } >+ } >+ } >+ >+ if (!m_VisualInfo) { >+ LOG_ERROR("Failed to get Visual Info.\n"); >+ cleanup(); >+ } >+ >+ return rightConfig; >+ } >+ >+ virtual ~SharedEGLResources() >+ { >+ if (m_eglDisplay == EGL_NO_DISPLAY) >+ return; >+ >+ if (m_surfaceContextfbConfig) >+ m_surfaceContextfbConfig = 0; >+ >+ eglTerminate(m_eglDisplay); >+ m_eglDisplay = EGL_NO_DISPLAY; >+ } >+ >+protected: >+ EGLDisplay m_eglDisplay; >+ EGLConfig m_pbufferfbConfig; >+ EGLConfig m_surfaceContextfbConfig; >+}; >+ >+} >+ >+#endif >+ >+#endif >diff --git Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.cpp Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.cpp >index 60293e7..48525f5 100644 >--- Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.cpp >+++ Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.cpp >@@ -28,7 +28,13 @@ > > #if USE(ACCELERATED_COMPOSITING) > >+#if USE(GLX) > #include "GLXWindowResources.h" >+#endif >+ >+#if USE(EGL) >+#include "EGLXWindowResources.h" >+#endif > > namespace WebCore { > >diff --git Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.h Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.h >index b25b2ac..87e3701 100644 >--- Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.h >+++ Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.h >@@ -40,8 +40,13 @@ > > namespace WebCore { > >+#if USE(GLX) > class SharedGLXResources; > typedef SharedGLXResources PlatformSharedResources; >+#elif USE(EGL) >+class SharedEGLResources; >+typedef SharedEGLResources PlatformSharedResources; >+#endif > > class SharedX11Resources : public WTF::RefCountedBase { > WTF_MAKE_NONCOPYABLE(SharedX11Resources); >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
Flags:
noam
:
review-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 105602
:
180545
|
180553
|
180557
|
180586
|
180602
|
180633
|
180664
|
180772
|
180806
|
180814