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
sharedcontext.patch (text/plain), 39.40 KB, created by
Kalyan
on 2013-02-16 12:30:59 PST
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Kalyan
Created:
2013-02-16 12:30:59 PST
Size:
39.40 KB
patch
obsolete
>diff --git Source/WebCore/ChangeLog Source/WebCore/ChangeLog >index ae4759e..19954b9 100644 >--- Source/WebCore/ChangeLog >+++ Source/WebCore/ChangeLog >@@ -1,3 +1,80 @@ >+2013-02-16 Kondapally Kalyan <kalyan.kondapally@intel.com> >+ >+ [WebGL][EFL] Refactor GraphicsContext3DPrivate to add support for SharedContext. >+ https://bugs.webkit.org/show_bug.cgi?id=109988 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Covered by existing WebGL tests. >+ >+ This patch refactors PlatformContext and GraphicsContext3DPrivate to >+ add support for Shared Context. This would help share GL resources >+ between transport surface and offscreen surface without having to worry >+ about the context state. So far, we used the same drawable as transport >+ surface and offscreen surface. After this patch we use pixmap surface as >+ offscreen surface and use shared context to render texture content to >+ transport surface. This would also align as to how shared surface is implemented >+ on EFL and Qt ports. >+ >+ * platform/graphics/efl/GraphicsContext3DEfl.cpp: >+ (WebCore::GraphicsContext3D::GraphicsContext3D): >+ * platform/graphics/efl/GraphicsContext3DPrivate.cpp: >+ (WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate): >+ (WebCore): >+ (WebCore::GraphicsContext3DPrivate::initialize): >+ (WebCore::GraphicsContext3DPrivate::makeSharedContextCurrent): >+ (WebCore::GraphicsContext3DPrivate::copyToGraphicsSurface): >+ * platform/graphics/efl/GraphicsContext3DPrivate.h: >+ (GraphicsContext3DPrivate): >+ * platform/graphics/opengl/GLPlatformContext.cpp: >+ (WebCore::GLPlatformContext::initialize): >+ * platform/graphics/opengl/GLPlatformContext.h: >+ Needed changes to take shared context into use. >+ >+ * platform/graphics/opengl/GLPlatformSurface.cpp: >+ (WebCore::GLPlatformSurface::createOffScreenSurface): >+ (WebCore::GLPlatformSurface::updateContents): >+ * platform/graphics/opengl/GLPlatformSurface.h: >+ (GLPlatformSurface): >+ * platform/graphics/surfaces/glx/GLXConfigSelector.h: >+ (WebCore::GLXConfigSelector::GLXConfigSelector): >+ (WebCore::GLXConfigSelector::visualInfo): >+ (WebCore::GLXConfigSelector::pixmapContextConfig): >+ (GLXConfigSelector): >+ (WebCore::GLXConfigSelector::reset): >+ * platform/graphics/surfaces/glx/GLXContext.cpp: >+ Added support to query configiration supporting >+ pixmap surface. >+ >+ (WebCore::GLXOffScreenContext::initialize): >+ * platform/graphics/surfaces/glx/GLXContext.h: >+ (GLXOffScreenContext): >+ * platform/graphics/surfaces/glx/GLXSurface.cpp: >+ (WebCore::GLXTransportSurface::GLXTransportSurface): >+ (WebCore::GLXTransportSurface::swapBuffers): >+ (WebCore::GLXOffScreenSurface::GLXOffScreenSurface): >+ (WebCore::GLXOffScreenSurface::~GLXOffScreenSurface): >+ (WebCore::GLXOffScreenSurface::initialize): >+ (WebCore::GLXOffScreenSurface::configuration): >+ (WebCore::GLXOffScreenSurface::destroy): >+ (WebCore::GLXOffScreenSurface::freeResources): >+ (WebCore::GLXOffScreenSurface::setGeometry): >+ Renamed GLXPBuffer surface as GLXOffScreenSurface. >+ >+ * platform/graphics/surfaces/glx/GLXSurface.h: >+ (GLXTransportSurface): >+ (GLXOffScreenSurface): >+ * platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp: >+ (WebCore::GraphicsSurfacePrivate::createSurface): >+ * platform/graphics/surfaces/glx/X11Helper.cpp: >+ (WebCore::X11Helper::createPixmap): >+ (WebCore): >+ (WebCore::X11Helper::destroyPixmap): >+ (WebCore::X11Helper::createOffScreenWindow): >+ * platform/graphics/surfaces/glx/X11Helper.h: >+ (X11Helper): >+ Added functions to create and destroy pixmap. >+ > 2013-02-15 Chris Fleizach <cfleizach@apple.com> > > AX: Split WebAccessibilityObjectWrapper so code can be shared with iOS >diff --git Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp >index 2ffbb78..ba473ae 100644 >--- Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp >+++ Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp >@@ -34,9 +34,6 @@ namespace WebCore { > > PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, RenderStyle renderStyle) > { >- if (renderStyle == RenderDirectlyToHostWindow) >- return 0; >- > RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, renderStyle)); > return context->m_private ? context.release() : 0; > } >@@ -63,18 +60,16 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi > , m_multisampleFBO(0) > , m_multisampleDepthStencilBuffer(0) > , m_multisampleColorBuffer(0) >- , m_private(adoptPtr(new GraphicsContext3DPrivate(this, hostWindow, renderStyle))) >+ , m_private(GraphicsContext3DPrivate::create(this, hostWindow)) > { >- if (!m_private || !m_private->m_platformContext) { >- m_private = nullptr; >+ if (!m_private) > return; >- } > > validateAttributes(); > > if (renderStyle == RenderOffscreen) { > // Create buffers for the canvas FBO. >- glGenFramebuffers(/* count */ 1, &m_fbo); >+ glGenFramebuffers(1, &m_fbo); > > // Create a texture to render into. > glGenTextures(1, &m_texture); >@@ -134,30 +129,38 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi > > GraphicsContext3D::~GraphicsContext3D() > { >- if (!m_private || !makeContextCurrent()) >+ if (!m_private || (m_renderStyle == RenderToCurrentGLContext) || !makeContextCurrent()) > return; > >- glDeleteTextures(1, &m_texture); >+ glBindFramebuffer(GL_FRAMEBUFFER, 0); >+ glBindTexture(GL_TEXTURE_2D, 0); >+ >+ if (m_texture) >+ glDeleteTextures(1, &m_texture); >+ >+ if (m_fbo) >+ glDeleteFramebuffers(1, &m_fbo); > > if (m_attrs.antialias) { >- glDeleteRenderbuffers(1, &m_multisampleColorBuffer); >+ if (m_multisampleColorBuffer) >+ glDeleteRenderbuffers(1, &m_multisampleColorBuffer); > >- if (m_attrs.stencil || m_attrs.depth) >+ if (m_multisampleDepthStencilBuffer) > glDeleteRenderbuffers(1, &m_multisampleDepthStencilBuffer); > >- glDeleteFramebuffers(1, &m_multisampleFBO); >+ if (m_multisampleFBO) >+ glDeleteFramebuffers(1, &m_multisampleFBO); > } else if (m_attrs.stencil || m_attrs.depth) { > #if USE(OPENGL_ES_2) >- if (m_attrs.depth) >+ if (m_depthBuffer) > glDeleteRenderbuffers(1, &m_depthBuffer); > >- if (m_attrs.stencil) >+ if (m_stencilBuffer) > glDeleteRenderbuffers(1, &m_stencilBuffer); > #endif >- glDeleteRenderbuffers(1, &m_depthStencilBuffer); >+ if (m_depthStencilBuffer) >+ glDeleteRenderbuffers(1, &m_depthStencilBuffer); > } >- >- m_private->releaseResources(); > } > > PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D() >diff --git Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp >index d109567..f8824c4 100644 >--- Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp >+++ Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp >@@ -28,58 +28,106 @@ > > namespace WebCore { > >-GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle) >+PassOwnPtr<GraphicsContext3DPrivate> GraphicsContext3DPrivate::create(GraphicsContext3D* context, HostWindow* hostWindow) >+{ >+ OwnPtr<GraphicsContext3DPrivate> platformLayer = adoptPtr(new GraphicsContext3DPrivate(context, hostWindow)); >+ >+ if (platformLayer && platformLayer->initialize()) >+ return platformLayer.release(); >+ >+ return nullptr; >+} >+ >+GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, HostWindow* hostWindow) > : m_context(context) > , m_hostWindow(hostWindow) >- , m_pendingSurfaceResize(false) > { >+} >+ >+bool GraphicsContext3DPrivate::initialize() >+{ >+ if (m_context->m_renderStyle == GraphicsContext3D::RenderDirectlyToHostWindow) >+ return false; >+ > if (m_hostWindow && m_hostWindow->platformPageClient()) { > // FIXME: Implement this code path for WebKit1. > // Get Evas object from platformPageClient and set EvasGL related members. >- return; >+ return false; > } > >- m_platformContext = GLPlatformContext::createContext(renderStyle); >- if (!m_platformContext) >- return; >+ m_offScreenContext = GLPlatformContext::createContext(m_context->m_renderStyle); >+ if (!m_offScreenContext) >+ return false; > >- if (renderStyle == GraphicsContext3D::RenderOffscreen) { >+ if (m_context->m_renderStyle == GraphicsContext3D::RenderOffscreen) { > #if USE(GRAPHICS_SURFACE) >- m_platformSurface = GLPlatformSurface::createTransportSurface(); >-#else >- m_platformSurface = GLPlatformSurface::createOffscreenSurface(); >+ m_sharedSurface = GLPlatformSurface::createTransportSurface(); >+ if (!m_sharedSurface) >+ goto initializationFailed; >+ >+ m_sharedContext = GLPlatformContext::createContext(m_context->m_renderStyle); >+ if (!m_sharedContext) >+ goto initializationFailed; > #endif >- if (!m_platformSurface) { >- m_platformContext = nullptr; >- return; >- } > >- if (!m_platformContext->initialize(m_platformSurface.get()) || !m_platformContext->makeCurrent(m_platformSurface.get())) { >- releaseResources(); >- m_platformContext = nullptr; >- m_platformSurface = nullptr; >+ m_offScreenSurface = GLPlatformSurface::createOffScreenSurface(); >+ >+ if (!m_offScreenSurface) >+ goto initializationFailed; >+ >+ if (!m_offScreenContext->initialize(m_offScreenSurface.get())) >+ goto initializationFailed; >+ > #if USE(GRAPHICS_SURFACE) >- } else >- m_surfaceHandle = GraphicsSurfaceToken(m_platformSurface->handle()); >-#else >- } >+ if (!m_sharedContext->initialize(m_sharedSurface.get(), m_offScreenContext->handle())) >+ goto initializationFailed; >+ >+ if (!makeSharedContextCurrent()) >+ goto initializationFailed; >+ >+ m_surfaceHandle = GraphicsSurfaceToken(m_sharedSurface->handle()); > #endif > } >+ >+ if (!makeContextCurrent()) >+ goto initializationFailed; >+ >+ return true; >+ >+initializationFailed: >+ releaseResources(); >+ return false; > } > > GraphicsContext3DPrivate::~GraphicsContext3DPrivate() > { >+ releaseResources(); > } > > void GraphicsContext3DPrivate::releaseResources() > { >+ if (m_context->m_renderStyle == GraphicsContext3D::RenderToCurrentGLContext) >+ return; >+ > // Release the current context and drawable only after destroying any associated gl resources. >- if (m_platformSurface) >- m_platformSurface->destroy(); >+#if USE(GRAPHICS_SURFACE) >+ if (m_sharedContext && m_sharedContext->handle() && m_sharedSurface) >+ makeSharedContextCurrent(); >+ >+ if (m_sharedSurface) >+ m_sharedSurface->destroy(); >+ >+ if (m_sharedContext) { >+ m_sharedContext->destroy(); >+ m_sharedContext->releaseCurrent(); >+ } >+#endif >+ if (m_offScreenSurface) >+ m_offScreenSurface->destroy(); > >- if (m_platformContext) { >- m_platformContext->destroy(); >- m_platformContext->releaseCurrent(); >+ if (m_offScreenContext) { >+ m_offScreenContext->destroy(); >+ m_offScreenContext->releaseCurrent(); > } > } > >@@ -96,14 +144,14 @@ void GraphicsContext3DPrivate::setContextLostCallback(PassOwnPtr<GraphicsContext > > PlatformGraphicsContext3D GraphicsContext3DPrivate::platformGraphicsContext3D() const > { >- return m_platformContext->handle(); >+ return m_offScreenContext->handle(); > } > >-bool GraphicsContext3DPrivate::makeContextCurrent() >+bool GraphicsContext3DPrivate::makeContextCurrent() const > { >- bool success = m_platformContext->makeCurrent(m_platformSurface.get()); >+ bool success = m_offScreenContext->makeCurrent(m_offScreenSurface.get()); > >- if (!m_platformContext->isValid()) { >+ if (!m_offScreenContext->isValid()) { > // FIXME: Restore context > if (m_contextLostCallback) > m_contextLostCallback->onContextLost(); >@@ -114,32 +162,13 @@ bool GraphicsContext3DPrivate::makeContextCurrent() > return success; > } > >-#if USE(TEXTURE_MAPPER_GL) >-void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper*, const FloatRect& /* target */, const TransformationMatrix&, float /* opacity */, BitmapTexture* /* mask */) >-{ >- notImplemented(); >-} >-#endif >- >-#if USE(GRAPHICS_SURFACE) >-void GraphicsContext3DPrivate::didResizeCanvas(const IntSize& size) >-{ >- m_pendingSurfaceResize = true; >- m_size = size; >-} >- >-uint32_t GraphicsContext3DPrivate::copyToGraphicsSurface() >+bool GraphicsContext3DPrivate::prepareBuffer() const > { >- if (!m_platformContext || !makeContextCurrent()) >- return 0; >+ if (!m_offScreenContext || !makeContextCurrent()) >+ return false; > > m_context->markLayerComposited(); > >- if (m_pendingSurfaceResize) { >- m_pendingSurfaceResize = false; >- m_platformSurface->setGeometry(IntRect(0, 0, m_context->m_currentWidth, m_context->m_currentHeight)); >- } >- > if (m_context->m_attrs.antialias) { > bool enableScissorTest = false; > int width = m_context->m_currentWidth; >@@ -161,8 +190,46 @@ uint32_t GraphicsContext3DPrivate::copyToGraphicsSurface() > m_context->enable(GraphicsContext3D::SCISSOR_TEST); > } > >- m_platformSurface->updateContents(m_context->m_texture, m_context->m_boundFBO, m_context->m_boundTexture0); >+ return true; >+} >+ >+#if USE(TEXTURE_MAPPER_GL) >+void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper*, const FloatRect& /* target */, const TransformationMatrix&, float /* opacity */, BitmapTexture* /* mask */) >+{ >+ notImplemented(); >+} >+#endif > >+#if USE(GRAPHICS_SURFACE) >+bool GraphicsContext3DPrivate::makeSharedContextCurrent() const >+{ >+ bool success = m_sharedContext->makeCurrent(m_sharedSurface.get()); >+ >+ if (!m_sharedContext->isValid()) { >+ // FIXME: Restore context >+ if (m_contextLostCallback) >+ m_contextLostCallback->onContextLost(); >+ >+ success = false; >+ } >+ >+ return success; >+} >+ >+void GraphicsContext3DPrivate::didResizeCanvas(const IntSize& size) >+{ >+ m_size = size; >+ m_sharedSurface->setGeometry(IntRect(0, 0, m_size.width(), m_size.height())); >+} >+ >+uint32_t GraphicsContext3DPrivate::copyToGraphicsSurface() >+{ >+ if (m_context->m_layerComposited || !prepareBuffer() || !makeSharedContextCurrent()) >+ return 0; >+ >+ m_sharedSurface->updateContents(m_context->m_texture); >+ makeContextCurrent(); >+ glBindFramebuffer(GL_FRAMEBUFFER, m_context->m_boundFBO); > return 0; > } > >@@ -175,7 +242,6 @@ IntSize GraphicsContext3DPrivate::platformLayerSize() const > { > return m_size; > } >- > #endif > > } // namespace WebCore >diff --git Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.h Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.h >index 2eb2f75..8e8062c 100644 >--- Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.h >+++ Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.h >@@ -41,37 +41,42 @@ class GraphicsContext3DPrivate > #endif > { > public: >- GraphicsContext3DPrivate(GraphicsContext3D*, HostWindow*, GraphicsContext3D::RenderStyle); >+ static PassOwnPtr<GraphicsContext3DPrivate> create(GraphicsContext3D*, HostWindow*); > ~GraphicsContext3DPrivate(); > > bool createSurface(PageClientEfl*, bool); >+ bool initialize(); > PlatformGraphicsContext3D platformGraphicsContext3D() const; >- void setContextLostCallback(PassOwnPtr<GraphicsContext3D::ContextLostCallback> callBack); >-#if USE(ACCELERATED_COMPOSITING) >- PlatformLayer* platformLayer() const; >-#endif >+ void setContextLostCallback(PassOwnPtr<GraphicsContext3D::ContextLostCallback>); >+ bool prepareBuffer() const; > #if USE(TEXTURE_MAPPER_GL) >- virtual void paintToTextureMapper(TextureMapper*, const FloatRect& target, const TransformationMatrix&, float opacity, BitmapTexture* mask); >+ virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float, BitmapTexture*) OVERRIDE; > #endif > #if USE(GRAPHICS_SURFACE) >- virtual IntSize platformLayerSize() const; >- virtual uint32_t copyToGraphicsSurface(); >- virtual GraphicsSurfaceToken graphicsSurfaceToken() const; >+ virtual IntSize platformLayerSize() const OVERRIDE; >+ virtual uint32_t copyToGraphicsSurface() OVERRIDE; >+ virtual GraphicsSurfaceToken graphicsSurfaceToken() const OVERRIDE; > void didResizeCanvas(const IntSize&); > #endif >- bool makeContextCurrent(); >+ bool makeContextCurrent() const; > void releaseResources(); >- GraphicsContext3D::Attributes m_attributes; >+ >+private: >+ GraphicsContext3DPrivate(GraphicsContext3D*, HostWindow*); >+#if USE(GRAPHICS_SURFACE) >+ bool makeSharedContextCurrent() const; >+#endif > GraphicsContext3D* m_context; > HostWindow* m_hostWindow; >- OwnPtr<GLPlatformContext> m_platformContext; >- OwnPtr<GLPlatformSurface> m_platformSurface; >+ OwnPtr<GLPlatformContext> m_offScreenContext; >+ OwnPtr<GLPlatformSurface> m_offScreenSurface; > #if USE(GRAPHICS_SURFACE) >+ OwnPtr<GLPlatformContext> m_sharedContext; >+ OwnPtr<GLPlatformSurface> m_sharedSurface; > GraphicsSurfaceToken m_surfaceHandle; > #endif > OwnPtr<GraphicsContext3D::ContextLostCallback> m_contextLostCallback; > ListHashSet<GC3Denum> m_syntheticErrors; >- bool m_pendingSurfaceResize; > IntSize m_size; > }; > >diff --git Source/WebCore/platform/graphics/opengl/GLPlatformContext.cpp Source/WebCore/platform/graphics/opengl/GLPlatformContext.cpp >index 4d440f8..ced7bb8 100644 >--- Source/WebCore/platform/graphics/opengl/GLPlatformContext.cpp >+++ Source/WebCore/platform/graphics/opengl/GLPlatformContext.cpp >@@ -207,7 +207,7 @@ bool GLPlatformContext::makeCurrent(GLPlatformSurface* surface) > > m_currentContext = 0; > >- if (!surface || (surface && !surface->handle())) >+ if (!surface || (surface && !surface->drawable())) > platformReleaseCurrent(); > else if (platformMakeCurrent(surface)) > m_currentContext = this; >@@ -262,7 +262,7 @@ bool GLPlatformContext::isCurrentContext() const > return true; > } > >-bool GLPlatformContext::initialize(GLPlatformSurface*) >+bool GLPlatformContext::initialize(GLPlatformSurface*, PlatformContext) > { > return true; > } >diff --git Source/WebCore/platform/graphics/opengl/GLPlatformContext.h Source/WebCore/platform/graphics/opengl/GLPlatformContext.h >index 3e13624..2e41db3 100644 >--- Source/WebCore/platform/graphics/opengl/GLPlatformContext.h >+++ Source/WebCore/platform/graphics/opengl/GLPlatformContext.h >@@ -63,7 +63,7 @@ public: > > virtual ~GLPlatformContext(); > >- virtual bool initialize(GLPlatformSurface*); >+ virtual bool initialize(GLPlatformSurface*, PlatformContext = 0); > > // Makes this and surface as current context and drawable. > // Calling this function with no surface is same as calling releaseCurrent. >diff --git Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp >index 7f7a564..071a83b 100644 >--- Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp >+++ Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp >@@ -40,12 +40,12 @@ > > namespace WebCore { > >-PassOwnPtr<GLPlatformSurface> GLPlatformSurface::createOffscreenSurface() >+PassOwnPtr<GLPlatformSurface> GLPlatformSurface::createOffScreenSurface() > { > #if USE(GLX) >- OwnPtr<GLPlatformSurface> surface = adoptPtr(new GLXPBuffer()); >+ OwnPtr<GLPlatformSurface> surface = adoptPtr(new GLXOffScreenSurface()); > >- if (surface->handle() && surface->drawable()) >+ if (surface->drawable()) > return surface.release(); > #endif > >@@ -54,7 +54,6 @@ PassOwnPtr<GLPlatformSurface> GLPlatformSurface::createOffscreenSurface() > > PassOwnPtr<GLPlatformSurface> GLPlatformSurface::createTransportSurface() > { >-#if USE(GRAPHICS_SURFACE) > #if USE(GLX) > OwnPtr<GLPlatformSurface> surface = adoptPtr(new GLXTransportSurface()); > #elif USE(EGL) >@@ -63,14 +62,12 @@ PassOwnPtr<GLPlatformSurface> GLPlatformSurface::createTransportSurface() > > if (surface && surface->handle() && surface->drawable()) > return surface.release(); >-#endif > > return nullptr; > } > > GLPlatformSurface::GLPlatformSurface() >- : m_restoreNeeded(true) >- , m_fboId(0) >+ : m_fboId(0) > , m_sharedDisplay(0) > , m_drawable(0) > , m_bufferHandle(0) >@@ -111,13 +108,11 @@ void GLPlatformSurface::swapBuffers() > notImplemented(); > } > >-void GLPlatformSurface::updateContents(const uint32_t texture, const GLuint bindFboId, const uint32_t bindTexture) >+void GLPlatformSurface::updateContents(const uint32_t texture) > { > if (!m_fboId) > glGenFramebuffers(1, &m_fboId); > >- m_restoreNeeded = false; >- > int x = 0; > int y = 0; > int width = m_rect.width(); >@@ -130,9 +125,6 @@ void GLPlatformSurface::updateContents(const uint32_t texture, const GLuint bind > // Use NEAREST as no scale is performed during the blit. > glBlitFramebuffer(x, y, width, height, x, y, width, height, GL_COLOR_BUFFER_BIT, GL_NEAREST); > swapBuffers(); >- glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); >- glBindTexture(GL_TEXTURE_2D, bindTexture); >- glBindFramebuffer(GL_FRAMEBUFFER, bindFboId); > } > > void GLPlatformSurface::setGeometry(const IntRect& newRect) >@@ -144,10 +136,12 @@ void GLPlatformSurface::destroy() > { > m_rect = IntRect(); > >- if (m_fboId) >+ if (m_fboId) { >+ glBindFramebuffer(GL_FRAMEBUFFER, 0); >+ glBindTexture(GL_TEXTURE_2D, 0); > glDeleteFramebuffers(1, &m_fboId); >- >- m_fboId = 0; >+ m_fboId = 0; >+ } > } > > } >diff --git Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h >index e8db425..d34eb71 100644 >--- Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h >+++ Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h >@@ -42,7 +42,7 @@ class GLPlatformSurface { > > public: > // Creates a GL surface used for offscreen rendering. >- static PassOwnPtr<GLPlatformSurface> createOffscreenSurface(); >+ static PassOwnPtr<GLPlatformSurface> createOffScreenSurface(); > > // Creates a GL surface used for offscreen rendering. The results can be transported > // to the UI process for display. >@@ -53,6 +53,8 @@ public: > const IntRect& geometry() const; > > // Get the underlying platform specific buffer handle. >+ // The handle will be null if surface doesnot support >+ // buffer sharing. > PlatformBufferHandle handle() const; > > PlatformDrawable drawable() const; >@@ -61,12 +63,12 @@ public: > > virtual void swapBuffers(); > >- // Convenience Function to update surface backbuffer with texture contents, restore current FBO and Texture. >+ // Convenience Function to update surface backbuffer with texture contents. >+ // Note that the function doesnot track or restore any GL states. > // Function does the following(in order): > // a) Blits texture contents to back buffer. > // b) Calls Swap Buffers. >- // c) Sets current FBO as bindFboId. >- virtual void updateContents(const uint32_t texture, const GLuint bindFboId, const uint32_t bindTexture); >+ virtual void updateContents(const uint32_t texture); > > virtual void setGeometry(const IntRect& newRect); > >@@ -76,7 +78,6 @@ public: > > protected: > GLPlatformSurface(); >- bool m_restoreNeeded; > IntRect m_rect; > GLuint m_fboId; > PlatformDisplay m_sharedDisplay; >diff --git Source/WebCore/platform/graphics/surfaces/egl/EGLContext.cpp Source/WebCore/platform/graphics/surfaces/egl/EGLContext.cpp >index 789b69b..c208dcc 100644 >--- Source/WebCore/platform/graphics/surfaces/egl/EGLContext.cpp >+++ Source/WebCore/platform/graphics/surfaces/egl/EGLContext.cpp >@@ -67,7 +67,7 @@ EGLOffScreenContext::EGLOffScreenContext() > { > } > >-bool EGLOffScreenContext::initialize(GLPlatformSurface* surface) >+bool EGLOffScreenContext::initialize(GLPlatformSurface* surface, PlatformContext sharedContext) > { > if (!surface) > return false; >@@ -86,7 +86,7 @@ bool EGLOffScreenContext::initialize(GLPlatformSurface* surface) > return false; > > if (isRobustnessExtSupported(m_display)) >- m_contextHandle = eglCreateContext(m_display, config, EGL_NO_CONTEXT, contextRobustnessAttributes); >+ m_contextHandle = eglCreateContext(m_display, config, sharedContext, contextRobustnessAttributes); > > if (m_contextHandle != EGL_NO_CONTEXT) { > // The EGL_EXT_create_context_robustness spec requires that a context created with >@@ -100,7 +100,7 @@ bool EGLOffScreenContext::initialize(GLPlatformSurface* surface) > } > > if (m_contextHandle == EGL_NO_CONTEXT) >- m_contextHandle = eglCreateContext(m_display, config, EGL_NO_CONTEXT, contextAttributes); >+ m_contextHandle = eglCreateContext(m_display, config, sharedContext, contextAttributes); > > if (m_contextHandle != EGL_NO_CONTEXT) > return true; >diff --git Source/WebCore/platform/graphics/surfaces/egl/EGLContext.h Source/WebCore/platform/graphics/surfaces/egl/EGLContext.h >index ee132cc..ec31913 100644 >--- Source/WebCore/platform/graphics/surfaces/egl/EGLContext.h >+++ Source/WebCore/platform/graphics/surfaces/egl/EGLContext.h >@@ -37,7 +37,7 @@ class EGLOffScreenContext : public GLPlatformContext { > public: > EGLOffScreenContext(); > virtual ~EGLOffScreenContext(); >- virtual bool initialize(GLPlatformSurface*) OVERRIDE; >+ virtual bool initialize(GLPlatformSurface*, PlatformContext) OVERRIDE; > virtual bool platformMakeCurrent(GLPlatformSurface*) OVERRIDE; > virtual void platformReleaseCurrent() OVERRIDE; > virtual void destroy() OVERRIDE; >diff --git Source/WebCore/platform/graphics/surfaces/glx/GLXConfigSelector.h Source/WebCore/platform/graphics/surfaces/glx/GLXConfigSelector.h >index ea73921..c13c26c 100644 >--- Source/WebCore/platform/graphics/surfaces/glx/GLXConfigSelector.h >+++ Source/WebCore/platform/graphics/surfaces/glx/GLXConfigSelector.h >@@ -48,8 +48,8 @@ class GLXConfigSelector { > > public: > GLXConfigSelector() >- : m_pbufferFBConfig(0) >- , m_surfaceContextFBConfig(0) >+ : m_surfaceContextFBConfig(0) >+ , m_pixmapContextFBConfig(0) > { > } > >@@ -57,34 +57,33 @@ public: > { > } > >- XVisualInfo* visualInfo() >+ XVisualInfo* visualInfo(const GLXFBConfig& config) > { >- if (!surfaceContextConfig()) >- return 0; >- >- return glXGetVisualFromFBConfig(X11Helper::nativeDisplay(), m_surfaceContextFBConfig); >+ return glXGetVisualFromFBConfig(X11Helper::nativeDisplay(), config); > } > >- GLXFBConfig pBufferContextConfig() >+ GLXFBConfig pixmapContextConfig() > { >- if (!m_pbufferFBConfig) { >+ if (!m_pixmapContextFBConfig) { > static const int attributes[] = { > GLX_LEVEL, 0, >- GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT, >+ GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT, > GLX_RENDER_TYPE, GLX_RGBA_BIT, > GLX_RED_SIZE, 1, > GLX_GREEN_SIZE, 1, > GLX_BLUE_SIZE, 1, >+ GLX_ALPHA_SIZE, 1, > GLX_DOUBLEBUFFER, GL_FALSE, > None > }; > >- m_pbufferFBConfig = findMatchingConfig(attributes); >+ m_pixmapContextFBConfig = findMatchingConfig(attributes); > } > >- return m_pbufferFBConfig; >+ return m_pixmapContextFBConfig; > } > >+ > GLXFBConfig surfaceContextConfig() > { > if (!m_surfaceContextFBConfig) >@@ -103,8 +102,8 @@ public: > > void reset() > { >- m_pbufferFBConfig = 0; > m_surfaceContextFBConfig = 0; >+ m_pixmapContextFBConfig = 0; > } > > private: >@@ -159,8 +158,8 @@ private: > return temp[0]; > } > >- GLXFBConfig m_pbufferFBConfig; > GLXFBConfig m_surfaceContextFBConfig; >+ GLXFBConfig m_pixmapContextFBConfig; > }; > > } >diff --git Source/WebCore/platform/graphics/surfaces/glx/GLXContext.cpp Source/WebCore/platform/graphics/surfaces/glx/GLXContext.cpp >index 8f40463..19d4b7b 100644 >--- Source/WebCore/platform/graphics/surfaces/glx/GLXContext.cpp >+++ Source/WebCore/platform/graphics/surfaces/glx/GLXContext.cpp >@@ -56,7 +56,7 @@ GLXOffScreenContext::GLXOffScreenContext() > { > } > >-bool GLXOffScreenContext::initialize(GLPlatformSurface* surface) >+bool GLXOffScreenContext::initialize(GLPlatformSurface* surface, PlatformContext sharedContext) > { > if (!surface) > return false; >@@ -71,7 +71,7 @@ bool GLXOffScreenContext::initialize(GLPlatformSurface* surface) > initializeARBExtensions(); > > if (glXCreateContextAttribsARB) >- m_contextHandle = glXCreateContextAttribsARB(x11Display, config, 0, true, Attribs); >+ m_contextHandle = glXCreateContextAttribsARB(x11Display, config, sharedContext, true, Attribs); > > if (m_contextHandle) { > // The GLX_ARB_create_context_robustness spec requires that a context created with >@@ -85,7 +85,7 @@ bool GLXOffScreenContext::initialize(GLPlatformSurface* surface) > } > > if (!m_contextHandle) >- m_contextHandle = glXCreateNewContext(x11Display, config, GLX_RGBA_TYPE, 0, true); >+ m_contextHandle = glXCreateNewContext(x11Display, config, GLX_RGBA_TYPE, sharedContext, true); > > if (m_contextHandle) > return true; >@@ -105,7 +105,7 @@ bool GLXOffScreenContext::isCurrentContext() const > > bool GLXOffScreenContext::platformMakeCurrent(GLPlatformSurface* surface) > { >- return glXMakeCurrent(surface->sharedDisplay(), surface->handle(), m_contextHandle); >+ return glXMakeCurrent(surface->sharedDisplay(), surface->drawable(), m_contextHandle); > } > > void GLXOffScreenContext::platformReleaseCurrent() >diff --git Source/WebCore/platform/graphics/surfaces/glx/GLXContext.h Source/WebCore/platform/graphics/surfaces/glx/GLXContext.h >index 444e7f2..3cc43bc 100644 >--- Source/WebCore/platform/graphics/surfaces/glx/GLXContext.h >+++ Source/WebCore/platform/graphics/surfaces/glx/GLXContext.h >@@ -37,7 +37,7 @@ class GLXOffScreenContext : public GLPlatformContext { > public: > GLXOffScreenContext(); > virtual ~GLXOffScreenContext(); >- virtual bool initialize(GLPlatformSurface*) OVERRIDE; >+ virtual bool initialize(GLPlatformSurface*, PlatformContext) OVERRIDE; > virtual bool platformMakeCurrent(GLPlatformSurface*) OVERRIDE; > virtual void platformReleaseCurrent() OVERRIDE; > virtual void destroy() OVERRIDE; >diff --git Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp >index c03c3d0..ebd30f3 100644 >--- Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp >+++ Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp >@@ -32,13 +32,12 @@ namespace WebCore { > > static const int pbufferAttributes[] = { GLX_PBUFFER_WIDTH, 1, GLX_PBUFFER_HEIGHT, 1, 0 }; > >-#if USE(GRAPHICS_SURFACE) > GLXTransportSurface::GLXTransportSurface() > : GLPlatformSurface() > { > m_sharedDisplay = X11Helper::nativeDisplay(); > m_configSelector = adoptPtr(new GLXConfigSelector()); >- OwnPtrX11<XVisualInfo> visInfo(m_configSelector->visualInfo()); >+ OwnPtrX11<XVisualInfo> visInfo(m_configSelector->visualInfo(m_configSelector->surfaceContextConfig())); > > if (!visInfo.get()) { > destroy(); >@@ -77,14 +76,7 @@ void GLXTransportSurface::swapBuffers() > if (!m_drawable) > return; > >- if (m_restoreNeeded) { >- GLint oldFBO; >- glGetIntegerv(GL_FRAMEBUFFER_BINDING, &oldFBO); >- glBindFramebuffer(GL_FRAMEBUFFER, 0); >- glXSwapBuffers(sharedDisplay(), m_drawable); >- glBindFramebuffer(GL_FRAMEBUFFER, oldFBO); >- } else >- glXSwapBuffers(sharedDisplay(), m_drawable); >+ glXSwapBuffers(sharedDisplay(), m_drawable); > } > > void GLXTransportSurface::destroy() >@@ -100,67 +92,73 @@ void GLXTransportSurface::destroy() > m_configSelector = nullptr; > } > >-#endif >- >-GLXPBuffer::GLXPBuffer() >+GLXOffScreenSurface::GLXOffScreenSurface() > : GLPlatformSurface() >+ , m_pixmap(0) >+ , m_glxPixmap(0) > { > initialize(); > } > >-GLXPBuffer::~GLXPBuffer() >+GLXOffScreenSurface::~GLXOffScreenSurface() > { > } > >-void GLXPBuffer::initialize() >+void GLXOffScreenSurface::initialize() > { > m_sharedDisplay = X11Helper::nativeDisplay(); > > m_configSelector = adoptPtr(new GLXConfigSelector()); >- GLXFBConfig config = m_configSelector->pBufferContextConfig(); > >- if (!config) { >+ OwnPtrX11<XVisualInfo> visualInfo(m_configSelector->visualInfo(m_configSelector->pixmapContextConfig())); >+ X11Helper::createPixmap(&m_pixmap, *visualInfo.get()); >+ >+ if (!m_pixmap) { > destroy(); > return; > } > >- m_drawable = glXCreatePbuffer(m_sharedDisplay, config, pbufferAttributes); >+ m_glxPixmap = glXCreateGLXPixmap(m_sharedDisplay, visualInfo.get(), m_pixmap); > >- if (!m_drawable) { >+ if (!m_glxPixmap) { > destroy(); > return; > } > >- m_bufferHandle = m_drawable; >+ m_drawable = m_glxPixmap; > } > >-PlatformSurfaceConfig GLXPBuffer::configuration() >+PlatformSurfaceConfig GLXOffScreenSurface::configuration() > { >- return m_configSelector->pBufferContextConfig(); >+ return m_configSelector->pixmapContextConfig(); > } > >-void GLXPBuffer::destroy() >+void GLXOffScreenSurface::destroy() > { > freeResources(); > } > >-void GLXPBuffer::freeResources() >+void GLXOffScreenSurface::freeResources() > { > GLPlatformSurface::destroy(); > Display* display = sharedDisplay(); > >- if (m_drawable && display) { >- glXDestroyPbuffer(display, m_drawable); >- m_drawable = 0; >- m_bufferHandle = 0; >+ if (!display) >+ return; >+ >+ if (m_glxPixmap) { >+ glXDestroyGLXPixmap(display, m_glxPixmap); >+ glXWaitGL(); >+ m_glxPixmap = 0; > } > >- m_configSelector = nullptr; >-} >+ if (m_pixmap) { >+ X11Helper::destroyPixmap(m_pixmap); >+ m_pixmap = 0; >+ } > >-void GLXPBuffer::setGeometry(const IntRect& newRect) >-{ >- GLPlatformSurface::setGeometry(newRect); >+ m_configSelector = nullptr; >+ m_drawable = 0; > } > > } >diff --git Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.h Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.h >index 9e7732a..430fe51 100644 >--- Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.h >+++ Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.h >@@ -34,7 +34,6 @@ > > namespace WebCore { > >-#if USE(GRAPHICS_SURFACE) > class GLXTransportSurface : public GLPlatformSurface { > > public: >@@ -49,21 +48,21 @@ private: > void initialize(); > OwnPtr<GLXConfigSelector> m_configSelector; > }; >-#endif > >-class GLXPBuffer : public GLPlatformSurface { >+class GLXOffScreenSurface : public GLPlatformSurface { > > public: >- GLXPBuffer(); >- virtual ~GLXPBuffer(); >+ GLXOffScreenSurface(); >+ virtual ~GLXOffScreenSurface(); > virtual PlatformSurfaceConfig configuration() OVERRIDE; >- virtual void setGeometry(const IntRect&) OVERRIDE; > virtual void destroy() OVERRIDE; > > private: > void initialize(); > void freeResources(); > OwnPtr<GLXConfigSelector> m_configSelector; >+ Pixmap m_pixmap; >+ GLXPixmap m_glxPixmap; > }; > > } >diff --git Source/WebCore/platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp Source/WebCore/platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp >index 68678ca..5e18a59 100644 >--- Source/WebCore/platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp >+++ Source/WebCore/platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp >@@ -123,7 +123,8 @@ struct GraphicsSurfacePrivate { > if (!display() || !m_configSelector) > return 0; > >- OwnPtrX11<XVisualInfo> visInfo(m_configSelector->visualInfo()); >+ GLXFBConfig config = m_configSelector->surfaceContextConfig(); >+ OwnPtrX11<XVisualInfo> visInfo(m_configSelector->visualInfo(config)); > > if (!visInfo.get()) { > clear(); >@@ -137,7 +138,7 @@ struct GraphicsSurfacePrivate { > return 0; > } > >- m_glxSurface = glXCreateWindow(display(), m_configSelector->surfaceContextConfig(), m_surface, 0); >+ m_glxSurface = glXCreateWindow(display(), config, m_surface, 0); > return m_surface; > } > >diff --git Source/WebCore/platform/graphics/surfaces/glx/X11Helper.cpp Source/WebCore/platform/graphics/surfaces/glx/X11Helper.cpp >index 100bb2e..247274a 100644 >--- Source/WebCore/platform/graphics/surfaces/glx/X11Helper.cpp >+++ Source/WebCore/platform/graphics/surfaces/glx/X11Helper.cpp >@@ -140,6 +140,47 @@ void X11Helper::resizeWindow(const IntRect& newRect, const uint32_t windowId) > XFlush(nativeDisplay()); > } > >+void X11Helper::createPixmap(Pixmap* handleId, const XVisualInfo& visualInfo, const IntSize& size) >+{ >+ Display* display = nativeDisplay(); >+ if (!display) >+ return; >+ >+ if (!visualInfo.visual) { >+ LOG_ERROR("Failed to find valid XVisual."); >+ return; >+ } >+ >+ Window xWindow = offscreenRootWindow(); >+ if (!xWindow) { >+ LOG_ERROR("Failed to create offscreen root window."); >+ return; >+ } >+ >+ Pixmap tempHandleId = XCreatePixmap(display, xWindow, size.width(), size.height(), visualInfo.depth); >+ >+ if (!tempHandleId) { >+ LOG_ERROR("Failed to create offscreen pixmap."); >+ return; >+ } >+ >+ *handleId = tempHandleId; >+ XSync(X11Helper::nativeDisplay(), false); >+} >+ >+void X11Helper::destroyPixmap(const uint32_t pixmapId) >+{ >+ if (!pixmapId) >+ return; >+ >+ Display* display = nativeDisplay(); >+ if (!display) >+ return; >+ >+ XFreePixmap(display, pixmapId); >+ XSync(X11Helper::nativeDisplay(), false); >+} >+ > void X11Helper::createOffScreenWindow(uint32_t* handleId, const XVisualInfo& visInfo, const IntSize& size) > { > #if USE(GRAPHICS_SURFACE) >@@ -162,8 +203,7 @@ void X11Helper::createOffScreenWindow(uint32_t* handleId, const XVisualInfo& vis > attribute.border_pixel = BlackPixel(display, 0); > attribute.colormap = cmap; > attribute.event_mask = ResizeRedirectMask; >- uint32_t tempHandleId; >- tempHandleId = XCreateWindow(display, xWindow, 0, 0, size.width(), size.height(), 0, visInfo.depth, InputOutput, visInfo.visual, CWBackPixel | CWBorderPixel | CWColormap, &attribute); >+ uint32_t tempHandleId = XCreateWindow(display, xWindow, 0, 0, size.width(), size.height(), 0, visInfo.depth, InputOutput, visInfo.visual, CWBackPixel | CWBorderPixel | CWColormap, &attribute); > > if (!tempHandleId) { > LOG_ERROR("Failed to create offscreen window."); >diff --git Source/WebCore/platform/graphics/surfaces/glx/X11Helper.h Source/WebCore/platform/graphics/surfaces/glx/X11Helper.h >index 6e7a682..68c75dd 100644 >--- Source/WebCore/platform/graphics/surfaces/glx/X11Helper.h >+++ Source/WebCore/platform/graphics/surfaces/glx/X11Helper.h >@@ -46,11 +46,13 @@ namespace WebCore { > class X11Helper { > > public: >+ static void createPixmap(Pixmap*, const XVisualInfo&, const IntSize& = IntSize(1, 1)); > static void createOffScreenWindow(uint32_t*, const XVisualInfo&, const IntSize& = IntSize(1, 1)); > #if USE(EGL) > static void createOffScreenWindow(uint32_t*, const EGLint, const IntSize& = IntSize(1, 1)); > #endif > static void destroyWindow(const uint32_t); >+ static void destroyPixmap(const uint32_t); > static void resizeWindow(const IntRect&, const uint32_t); > static bool isXRenderExtensionSupported(); > static Display* nativeDisplay();
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 109988
:
188722
|
188869
|
188875