| Index: Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp
|
| ===================================================================
|
| --- Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp (revision 146732)
|
| +++ Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp (working copy)
|
| @@ -68,13 +68,37 @@
|
| if (!m_offScreenContext->initialize(m_offScreenSurface.get()))
|
| return false;
|
|
|
| +#if USE(GRAPHICS_SURFACE)
|
| if (!makeContextCurrent())
|
| return false;
|
| -#if USE(GRAPHICS_SURFACE)
|
| - m_surfaceOperation = CreateSurface;
|
| +
|
| + m_context->validateAttributes();
|
| + GLPlatformSurface::SurfaceAttributes sharedSurfaceAttributes = GLPlatformSurface::Default;
|
| + if (m_context->m_attrs.alpha)
|
| + sharedSurfaceAttributes = GLPlatformSurface::SupportAlpha;
|
| +
|
| + m_offScreenContext->releaseCurrent();
|
| + m_sharedSurface = GLPlatformSurface::createTransportSurface(sharedSurfaceAttributes);
|
| + if (!m_sharedSurface)
|
| + return false;
|
| +
|
| + m_sharedContext = GLPlatformContext::createContext(m_context->m_renderStyle);
|
| + if (!m_sharedContext)
|
| + return false;
|
| +
|
| + if (!m_sharedContext->initialize(m_sharedSurface.get(), m_offScreenContext->handle()))
|
| + return false;
|
| +
|
| + if (!makeSharedContextCurrent())
|
| + return false;
|
| +
|
| + m_surfaceHandle = GraphicsSurfaceToken(m_sharedSurface->handle());
|
| #endif
|
| }
|
|
|
| + if (!makeContextCurrent())
|
| + return false;
|
| +
|
| return true;
|
| }
|
|
|
| @@ -90,13 +114,16 @@
|
|
|
| // Release the current context and drawable only after destroying any associated gl resources.
|
| #if USE(GRAPHICS_SURFACE)
|
| - if (m_previousGraphicsSurface)
|
| - m_previousGraphicsSurface = nullptr;
|
| + if (m_sharedContext && m_sharedContext->handle() && m_sharedSurface)
|
| + makeSharedContextCurrent();
|
|
|
| - if (m_graphicsSurface)
|
| - m_graphicsSurface = nullptr;
|
| + if (m_sharedSurface)
|
| + m_sharedSurface->destroy();
|
|
|
| - m_surfaceHandle = GraphicsSurfaceToken();
|
| + if (m_sharedContext) {
|
| + m_sharedContext->destroy();
|
| + m_sharedContext->releaseCurrent();
|
| + }
|
| #endif
|
| if (m_offScreenSurface)
|
| m_offScreenSurface->destroy();
|
| @@ -164,8 +191,6 @@
|
|
|
| if (enableScissorTest)
|
| m_context->enable(GraphicsContext3D::SCISSOR_TEST);
|
| -
|
| - glBindFramebuffer(GL_FRAMEBUFFER, m_context->m_state.boundFBO);
|
| }
|
|
|
| return true;
|
| @@ -179,80 +204,38 @@
|
| #endif
|
|
|
| #if USE(GRAPHICS_SURFACE)
|
| -void GraphicsContext3DPrivate::createGraphicsSurface()
|
| +bool GraphicsContext3DPrivate::makeSharedContextCurrent() const
|
| {
|
| - static PendingSurfaceOperation pendingOperation = DeletePreviousSurface | Resize | CreateSurface;
|
| - if (!(m_surfaceOperation & pendingOperation))
|
| - return;
|
| + bool success = m_sharedContext->makeCurrent(m_sharedSurface.get());
|
|
|
| - if (m_surfaceOperation & DeletePreviousSurface) {
|
| - m_previousGraphicsSurface = nullptr;
|
| - m_surfaceOperation &= ~DeletePreviousSurface;
|
| - }
|
| + if (!m_sharedContext->isValid()) {
|
| + // FIXME: Restore context
|
| + if (m_contextLostCallback)
|
| + m_contextLostCallback->onContextLost();
|
|
|
| - if (!(m_surfaceOperation & pendingOperation))
|
| - return;
|
| -
|
| - // Don't release current graphics surface until we have prepared surface
|
| - // with requested size. This is to avoid flashing during resize.
|
| - if (m_surfaceOperation & Resize) {
|
| - m_previousGraphicsSurface = m_graphicsSurface;
|
| - m_surfaceOperation &= ~Resize;
|
| - m_surfaceOperation |= DeletePreviousSurface;
|
| - m_size = IntSize(m_context->m_currentWidth, m_context->m_currentHeight);
|
| - } else
|
| - m_surfaceOperation &= ~CreateSurface;
|
| -
|
| - m_targetRect = IntRect(IntPoint(), m_size);
|
| -
|
| - if (m_size.isEmpty()) {
|
| - if (m_graphicsSurface) {
|
| - m_graphicsSurface = nullptr;
|
| - m_surfaceHandle = GraphicsSurfaceToken();
|
| - makeContextCurrent();
|
| - }
|
| -
|
| - return;
|
| + return false;
|
| }
|
|
|
| - m_offScreenContext->releaseCurrent();
|
| - GraphicsSurface::Flags flags = GraphicsSurface::SupportsTextureTarget | GraphicsSurface::SupportsSharing;
|
| -
|
| - if (m_context->m_attrs.alpha)
|
| - flags |= GraphicsSurface::SupportsAlpha;
|
| -
|
| - m_graphicsSurface = GraphicsSurface::create(m_size, flags, m_offScreenContext->handle());
|
| -
|
| - if (!m_graphicsSurface)
|
| - m_surfaceHandle = GraphicsSurfaceToken();
|
| - else
|
| - m_surfaceHandle = GraphicsSurfaceToken(m_graphicsSurface->exportToken());
|
| -
|
| - makeContextCurrent();
|
| + return success;
|
| }
|
|
|
| void GraphicsContext3DPrivate::didResizeCanvas(const IntSize& size)
|
| {
|
| - if (m_surfaceOperation & CreateSurface) {
|
| - m_size = size;
|
| - createGraphicsSurface();
|
| - return;
|
| - }
|
| + m_size = size;
|
|
|
| - m_surfaceOperation |= Resize;
|
| + if (makeSharedContextCurrent())
|
| + m_sharedSurface->setGeometry(IntRect(0, 0, m_size.width(), m_size.height()));
|
| }
|
|
|
| uint32_t GraphicsContext3DPrivate::copyToGraphicsSurface()
|
| {
|
| - createGraphicsSurface();
|
| -
|
| - if (!m_graphicsSurface || m_context->m_layerComposited || !prepareBuffer())
|
| + if (m_context->m_layerComposited || !prepareBuffer() || !makeSharedContextCurrent())
|
| return 0;
|
|
|
| - m_graphicsSurface->copyFromTexture(m_context->m_texture, m_targetRect);
|
| + m_sharedSurface->updateContents(m_context->m_texture);
|
| makeContextCurrent();
|
| -
|
| - return m_graphicsSurface->frontBuffer();
|
| + glBindFramebuffer(GL_FRAMEBUFFER, m_context->m_state.boundFBO);
|
| + return 0;
|
| }
|
|
|
| GraphicsSurfaceToken GraphicsContext3DPrivate::graphicsSurfaceToken() const
|
|
|