void DrawingBuffer::paintCompositedResultsToCanvas(ImageBuffer* imageBuffer) { if (!m_context || !m_context->makeContextCurrent() || m_context->getGraphicsResetStatusARB() != GL_NO_ERROR) return; if (!imageBuffer) return; Platform3DObject tex = imageBuffer->getBackingTexture(); if (tex) { m_context->copyTextureCHROMIUM(GL_TEXTURE_2D, m_frontColorBuffer, tex, 0, GL_RGBA, GL_UNSIGNED_BYTE); return; } // Since the m_frontColorBuffer was produced and sent to the compositor, it cannot be bound to an fbo. // We have to make a copy of it here and bind that copy instead. // FIXME: That's not true any more, provided we don't change texture // parameters. unsigned sourceTexture = createColorTexture(m_size); m_context->copyTextureCHROMIUM(GL_TEXTURE_2D, m_frontColorBuffer, sourceTexture, 0, GL_RGBA, GL_UNSIGNED_BYTE); // Since we're using the same context as WebGL, we have to restore any state we change (in this case, just the framebuffer binding). // FIXME: The WebGLRenderingContext tracks the current framebuffer binding, it would be slightly more efficient to use this value // rather than querying it off of the context. GLint previousFramebuffer = 0; m_context->getIntegerv(GL_FRAMEBUFFER_BINDING, &previousFramebuffer); Platform3DObject framebuffer = m_context->createFramebuffer(); m_context->bindFramebuffer(GL_FRAMEBUFFER, framebuffer); m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, sourceTexture, 0); paintFramebufferToCanvas(framebuffer, size().width(), size().height(), !m_attributes.premultipliedAlpha, imageBuffer); m_context->deleteFramebuffer(framebuffer); m_context->deleteTexture(sourceTexture); m_context->bindFramebuffer(GL_FRAMEBUFFER, previousFramebuffer); }
void DrawingBuffer::paintRenderingResultsToCanvas(ImageBuffer* imageBuffer) { paintFramebufferToCanvas(framebuffer(), size().width(), size().height(), !m_attributes.premultipliedAlpha, imageBuffer); }
void GraphicsContext3DPrivate::paintRenderingResultsToCanvas(CanvasRenderingContext* context) { ImageBuffer* imageBuffer = context->canvas()->buffer(); paintFramebufferToCanvas(0, m_impl->width(), m_impl->height(), !m_impl->getContextAttributes().premultipliedAlpha, imageBuffer); }