diff options
Diffstat (limited to 'WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.cpp')
-rw-r--r-- | WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.cpp | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.cpp b/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.cpp index 1625eb8..e805c55 100644 --- a/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.cpp +++ b/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.cpp @@ -73,10 +73,14 @@ WebGraphicsContext3DDefaultImpl::WebGraphicsContext3DDefaultImpl() , m_texture(0) , m_fbo(0) , m_depthStencilBuffer(0) + , m_cachedWidth(0) + , m_cachedHeight(0) , m_multisampleFBO(0) , m_multisampleDepthStencilBuffer(0) , m_multisampleColorBuffer(0) , m_boundFBO(0) + , m_boundTexture(0) + , m_copyTextureToParentTextureFBO(0) #ifdef FLIP_FRAMEBUFFER_VERTICALLY , m_scanline(0) #endif @@ -101,6 +105,7 @@ WebGraphicsContext3DDefaultImpl::~WebGraphicsContext3DDefaultImpl() glDeleteRenderbuffersEXT(1, &m_depthStencilBuffer); } glDeleteTextures(1, &m_texture); + glDeleteFramebuffersEXT(1, &m_copyTextureToParentTextureFBO); #ifdef FLIP_FRAMEBUFFER_VERTICALLY if (m_scanline) delete[] m_scanline; @@ -165,12 +170,15 @@ bool WebGraphicsContext3DDefaultImpl::initialize(WebGraphicsContext3D::Attribute validateAttributes(); glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); + glEnable(GL_POINT_SPRITE); if (!angleCreateCompilers()) { angleDestroyCompilers(); return false; } + glGenFramebuffersEXT(1, &m_copyTextureToParentTextureFBO); + m_initialized = true; return true; } @@ -211,12 +219,10 @@ void WebGraphicsContext3DDefaultImpl::validateAttributes() void WebGraphicsContext3DDefaultImpl::resolveMultisampledFramebuffer(unsigned x, unsigned y, unsigned width, unsigned height) { if (m_attributes.antialias) { - bool mustRestoreFBO = (m_boundFBO != m_multisampleFBO); glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO); glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo); glBlitFramebufferEXT(x, y, x + width, y + height, x, y, x + width, y + height, GL_COLOR_BUFFER_BIT, GL_LINEAR); - if (mustRestoreFBO) - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_boundFBO); + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_boundFBO); } } @@ -280,6 +286,7 @@ void WebGraphicsContext3DDefaultImpl::prepareTexture() { if (!m_renderDirectlyToWebView) { // We need to prepare our rendering results for the compositor. + makeContextCurrent(); resolveMultisampledFramebuffer(0, 0, m_cachedWidth, m_cachedHeight); } } @@ -558,12 +565,33 @@ void WebGraphicsContext3DDefaultImpl::unmapTexSubImage2DCHROMIUM(const void* mem bool WebGraphicsContext3DDefaultImpl::supportsCopyTextureToParentTextureCHROMIUM() { - // We don't claim support for this extension at this time - return false; + // This extension requires this desktopGL-only function (GLES2 doesn't + // support it), so check for its existence here. + return glGetTexLevelParameteriv; } void WebGraphicsContext3DDefaultImpl::copyTextureToParentTextureCHROMIUM(unsigned id, unsigned id2) { + makeContextCurrent(); + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_copyTextureToParentTextureFBO); + glFramebufferTexture2DEXT(GL_FRAMEBUFFER, + GL_COLOR_ATTACHMENT0, + GL_TEXTURE_2D, + id, + 0); // level + glBindTexture(GL_TEXTURE_2D, id2); + GLsizei width, height; + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height); + glCopyTexImage2D(GL_TEXTURE_2D, + 0, // level + GL_RGBA, + 0, 0, // x, y + width, + height, + 0); // border + glBindTexture(GL_TEXTURE_2D, m_boundTexture); + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_boundFBO); } // Helper macros to reduce the amount of code. @@ -688,7 +716,12 @@ void WebGraphicsContext3DDefaultImpl::bindFramebuffer(unsigned long target, WebG DELEGATE_TO_GL_2(bindRenderbuffer, BindRenderbufferEXT, unsigned long, WebGLId) -DELEGATE_TO_GL_2(bindTexture, BindTexture, unsigned long, WebGLId) +void WebGraphicsContext3DDefaultImpl::bindTexture(unsigned long target, WebGLId texture) +{ + makeContextCurrent(); + glBindTexture(target, texture); + m_boundTexture = texture; +} DELEGATE_TO_GL_4(blendColor, BlendColor, double, double, double, double) |