Title: [115506] trunk/Source/WebCore
Revision
115506
Author
[email protected]
Date
2012-04-27 16:08:10 -0700 (Fri, 27 Apr 2012)

Log Message

[BlackBerry] OpenGL related bug fixes
https://bugs.webkit.org/show_bug.cgi?id=84836

Patch by Arvid Nilsson <[email protected]> on 2012-04-27
Reviewed by Antonio Gomes.

PR147254, 148933, 149117, 149721, 150228

No new tests, covered by existing BlackBerry browser stress tests

* platform/graphics/blackberry/CanvasLayerWebKitThread.cpp:
(WebCore::CanvasLayerWebKitThread::updateTextureContentsIfNeeded):
* platform/graphics/blackberry/LayerCompositingThread.cpp:
(WebCore::LayerCompositingThread::drawTextures):
* platform/graphics/blackberry/LayerRenderer.cpp:
(WebCore::LayerRenderer::~LayerRenderer):
(WebCore::LayerRenderer::drawLayers):
(WebCore::LayerRenderer::initializeSharedGLObjects):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (115505 => 115506)


--- trunk/Source/WebCore/ChangeLog	2012-04-27 23:06:46 UTC (rev 115505)
+++ trunk/Source/WebCore/ChangeLog	2012-04-27 23:08:10 UTC (rev 115506)
@@ -1,3 +1,23 @@
+2012-04-27  Arvid Nilsson  <[email protected]>
+
+        [BlackBerry] OpenGL related bug fixes
+        https://bugs.webkit.org/show_bug.cgi?id=84836
+
+        Reviewed by Antonio Gomes.
+
+        PR147254, 148933, 149117, 149721, 150228
+
+        No new tests, covered by existing BlackBerry browser stress tests
+
+        * platform/graphics/blackberry/CanvasLayerWebKitThread.cpp:
+        (WebCore::CanvasLayerWebKitThread::updateTextureContentsIfNeeded):
+        * platform/graphics/blackberry/LayerCompositingThread.cpp:
+        (WebCore::LayerCompositingThread::drawTextures):
+        * platform/graphics/blackberry/LayerRenderer.cpp:
+        (WebCore::LayerRenderer::~LayerRenderer):
+        (WebCore::LayerRenderer::drawLayers):
+        (WebCore::LayerRenderer::initializeSharedGLObjects):
+
 2012-04-27  Nat Duca  <[email protected]>
 
         Implement high-resolution time via window.performance.webkitNow()

Modified: trunk/Source/WebCore/platform/graphics/blackberry/CanvasLayerWebKitThread.cpp (115505 => 115506)


--- trunk/Source/WebCore/platform/graphics/blackberry/CanvasLayerWebKitThread.cpp	2012-04-27 23:06:46 UTC (rev 115505)
+++ trunk/Source/WebCore/platform/graphics/blackberry/CanvasLayerWebKitThread.cpp	2012-04-27 23:08:10 UTC (rev 115506)
@@ -80,6 +80,7 @@
     pthread_mutex_lock(m_frontBufferLock);
     glBindTexture(GL_TEXTURE_2D, m_texID);
     glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, m_device->width(), m_device->height(), 0);
+    glFinish(); // This might be implicit in the CopyTexImage2D, but explicit Finish is required on some architectures
     glBindTexture(GL_TEXTURE_2D, previousTexture);
     pthread_mutex_unlock(m_frontBufferLock);
 }

Modified: trunk/Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.cpp (115505 => 115506)


--- trunk/Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.cpp	2012-04-27 23:06:46 UTC (rev 115505)
+++ trunk/Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.cpp	2012-04-27 23:08:10 UTC (rev 115506)
@@ -229,6 +229,7 @@
 #endif
 #if ENABLE(WEBGL)
     if (layerType() == LayerData::WebGLLayer) {
+        m_layerRenderer->addLayerToReleaseTextureResourcesList(this);
         pthread_mutex_lock(m_frontBufferLock);
         glVertexAttribPointer(positionLocation, 2, GL_FLOAT, GL_FALSE, 0, &m_transformedBounds);
         float canvasWidthRatio = 1.0f;
@@ -238,7 +239,6 @@
         glVertexAttribPointer(texCoordLocation, 2, GL_FLOAT, GL_FALSE, 0, upsideDown);
         glBindTexture(GL_TEXTURE_2D, m_texID);
         glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
-        pthread_mutex_unlock(m_frontBufferLock);
         // FIXME: If the canvas/texture is larger than 2048x2048, then we'll die here
         return;
     }

Modified: trunk/Source/WebCore/platform/graphics/blackberry/LayerRenderer.cpp (115505 => 115506)


--- trunk/Source/WebCore/platform/graphics/blackberry/LayerRenderer.cpp	2012-04-27 23:06:46 UTC (rev 115505)
+++ trunk/Source/WebCore/platform/graphics/blackberry/LayerRenderer.cpp	2012-04-27 23:08:10 UTC (rev 115506)
@@ -166,14 +166,15 @@
 
 LayerRenderer::~LayerRenderer()
 {
-    makeContextCurrent();
-    if (m_fbo)
-        glDeleteFramebuffers(1, &m_fbo);
-    glDeleteProgram(m_colorProgramObject);
-    glDeleteProgram(m_checkerProgramObject);
-    for (int i = 0; i < LayerData::NumberOfLayerProgramShaders; ++i)
-        glDeleteProgram(m_layerProgramObject[i]);
     if (m_hardwareCompositing) {
+        makeContextCurrent();
+        if (m_fbo)
+            glDeleteFramebuffers(1, &m_fbo);
+        glDeleteProgram(m_colorProgramObject);
+        glDeleteProgram(m_checkerProgramObject);
+        for (int i = 0; i < LayerData::NumberOfLayerProgramShaders; ++i)
+            glDeleteProgram(m_layerProgramObject[i]);
+
         // Free up all GL textures.
         while (m_layers.begin() != m_layers.end()) {
             LayerSet::iterator iter = m_layers.begin();
@@ -210,6 +211,8 @@
 void LayerRenderer::drawLayers(const FloatRect& visibleRect, const IntRect& layoutRect, const IntSize& contentsSize, const IntRect& dstRect)
 {
     ASSERT(m_hardwareCompositing);
+    if (!m_hardwareCompositing)
+        return;
 
     bool wasEmpty = m_lastRenderingResults.isEmpty();
     m_lastRenderingResults = LayerRenderingResults();
@@ -268,7 +271,8 @@
         return;
 
     // Okay, we're going to do some drawing.
-    makeContextCurrent();
+    if (!makeContextCurrent())
+        return;
 
     // Get rid of any bound buffer that might affect the interpretation of our
     // glVertexAttribPointer calls.
@@ -314,10 +318,12 @@
 #endif
 
     glClearStencil(0);
+    glClearColor(0, 0, 0, 0);
+    GLenum buffersToClear = GL_STENCIL_BUFFER_BIT;
     if (m_clearSurfaceOnDrawLayers) {
-        glClearColor(0, 0, 0, 0);
-        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
+        buffersToClear |= GL_COLOR_BUFFER_BIT;
     }
+    glClear(buffersToClear);
 
     // Don't render the root layer, the BlackBerry port uses the BackingStore to draw the
     // root layer.
@@ -327,6 +333,11 @@
         compositeLayersRecursive(sublayers[i].get(), currentStencilValue, clipRect);
     }
 
+    // We need to make sure that all texture resource usage is finished before
+    // unlocking the texture resources, so force a glFinish() in that case.
+    if (m_layersLockingTextureResources.size())
+        glFinish();
+
     m_context->swapBuffers();
 
 #if ENABLE_SCISSOR
@@ -334,6 +345,12 @@
 #endif
     glDisable(GL_STENCIL_TEST);
 
+    // PR 147254, the EGL implementation crashes when the last bound texture
+    // was an EGLImage, and you try to bind another texture and the pixmap
+    // backing the EGLImage was deleted in between. Make this easier for the
+    // driver by unbinding early (when the pixmap is hopefully still around).
+    glBindTexture(GL_TEXTURE_2D, 0);
+
     LayerSet::iterator iter = m_layersLockingTextureResources.begin();
     for (; iter != m_layersLockingTextureResources.end(); ++iter)
         (*iter)->releaseTextureResources();
@@ -979,7 +996,8 @@
     tmp.replace("GRID", String::format("%.3f", (float)checkerSize));
     CString checkerFragmentShaderString = tmp.latin1();
 
-    makeContextCurrent();
+    if (!makeContextCurrent())
+        return false;
 
     m_layerProgramObject[LayerData::LayerProgramShaderRGBA] =
         loadShaderProgram(vertexShaderString, fragmentShaderStringRGBA);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to