Title: [153895] trunk/Source/WebCore
Revision
153895
Author
[email protected]
Date
2013-08-09 08:28:24 -0700 (Fri, 09 Aug 2013)

Log Message

[BlackBerry] Don't release the canvas Drawable, flush it directly instead.
https://bugs.webkit.org/show_bug.cgi?id=119589
https://jira.bbqnx.net/browse/BRWSR-12531
JIRA 444857

Patch by Jakob Petsovits <[email protected]> on 2013-08-09
Reviewed by George Staikos.

The previous code here used releaseBufferDrawable() to
flush painted ImageBuffer contents, but then proceeded
to use that released Drawable for further painting
without ever locking a new one.

In an implementation that actually releases the Drawable
rather than keeping it around and just flushing it,
this will wreak havoc as bad as black screens or crashes.

As a solution that doesn't require the ImageBuffer object
to swap out its m_canvas member for a new Drawable, we can
access the PlatformGraphicsContext::flush() method directly
to achieve the same effect as was previously intended by
calling releaseBufferDrawable(). All it needs is letting
the canvas layer know about the Drawable so it can call
that flush() method by itself.

No new tests, verified by not crashing with an aforementioned
implementation of releaseBufferDrawable().

* platform/graphics/blackberry/CanvasLayerWebKitThread.cpp:
(WebCore::CanvasLayerCompositingThreadClient::CanvasLayerCompositingThreadClient):
(WebCore::CanvasLayerCompositingThreadClient::commitPendingTextureUploads):
(WebCore::CanvasLayerWebKitThread::CanvasLayerWebKitThread):
* platform/graphics/blackberry/CanvasLayerWebKitThread.h:
(WebCore::CanvasLayerWebKitThread::create):
* platform/graphics/blackberry/ImageBufferBlackBerry.cpp:
(WebCore::ImageBuffer::ImageBuffer):
(WebCore::ImageBuffer::~ImageBuffer):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (153894 => 153895)


--- trunk/Source/WebCore/ChangeLog	2013-08-09 15:26:33 UTC (rev 153894)
+++ trunk/Source/WebCore/ChangeLog	2013-08-09 15:28:24 UTC (rev 153895)
@@ -1,3 +1,42 @@
+2013-08-09  Jakob Petsovits  <[email protected]>
+
+        [BlackBerry] Don't release the canvas Drawable, flush it directly instead.
+        https://bugs.webkit.org/show_bug.cgi?id=119589
+        https://jira.bbqnx.net/browse/BRWSR-12531
+        JIRA 444857
+
+        Reviewed by George Staikos.
+
+        The previous code here used releaseBufferDrawable() to
+        flush painted ImageBuffer contents, but then proceeded
+        to use that released Drawable for further painting
+        without ever locking a new one.
+
+        In an implementation that actually releases the Drawable
+        rather than keeping it around and just flushing it,
+        this will wreak havoc as bad as black screens or crashes.
+
+        As a solution that doesn't require the ImageBuffer object
+        to swap out its m_canvas member for a new Drawable, we can
+        access the PlatformGraphicsContext::flush() method directly
+        to achieve the same effect as was previously intended by
+        calling releaseBufferDrawable(). All it needs is letting
+        the canvas layer know about the Drawable so it can call
+        that flush() method by itself.
+
+        No new tests, verified by not crashing with an aforementioned
+        implementation of releaseBufferDrawable().
+
+        * platform/graphics/blackberry/CanvasLayerWebKitThread.cpp:
+        (WebCore::CanvasLayerCompositingThreadClient::CanvasLayerCompositingThreadClient):
+        (WebCore::CanvasLayerCompositingThreadClient::commitPendingTextureUploads):
+        (WebCore::CanvasLayerWebKitThread::CanvasLayerWebKitThread):
+        * platform/graphics/blackberry/CanvasLayerWebKitThread.h:
+        (WebCore::CanvasLayerWebKitThread::create):
+        * platform/graphics/blackberry/ImageBufferBlackBerry.cpp:
+        (WebCore::ImageBuffer::ImageBuffer):
+        (WebCore::ImageBuffer::~ImageBuffer):
+
 2013-08-08  Allan Sandfeld Jensen  <[email protected]>
 
         [Qt][WK2] Composited and transformed links asserts in tap highlight

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


--- trunk/Source/WebCore/platform/graphics/blackberry/CanvasLayerWebKitThread.cpp	2013-08-09 15:26:33 UTC (rev 153894)
+++ trunk/Source/WebCore/platform/graphics/blackberry/CanvasLayerWebKitThread.cpp	2013-08-09 15:28:24 UTC (rev 153895)
@@ -35,7 +35,7 @@
 
 class CanvasLayerCompositingThreadClient : public LayerCompositingThreadClient {
 public:
-    CanvasLayerCompositingThreadClient(BlackBerry::Platform::Graphics::Buffer*, const IntSize&);
+    CanvasLayerCompositingThreadClient(BlackBerry::Platform::Graphics::Buffer*, BlackBerry::Platform::Graphics::PlatformGraphicsContext*, const IntSize&);
 
     void layerCompositingThreadDestroyed(LayerCompositingThread*) { }
     void layerVisibilityChanged(LayerCompositingThread*, bool) { }
@@ -50,11 +50,13 @@
 
 private:
     BlackBerry::Platform::Graphics::Buffer* m_buffer;
+    BlackBerry::Platform::Graphics::PlatformGraphicsContext* m_context;
     IntSize m_size;
 };
 
-CanvasLayerCompositingThreadClient::CanvasLayerCompositingThreadClient(BlackBerry::Platform::Graphics::Buffer* buffer, const IntSize& size)
+CanvasLayerCompositingThreadClient::CanvasLayerCompositingThreadClient(BlackBerry::Platform::Graphics::Buffer* buffer, BlackBerry::Platform::Graphics::PlatformGraphicsContext* context, const IntSize& size)
     : m_buffer(buffer)
+    , m_context(context)
     , m_size(size)
 {
 }
@@ -78,23 +80,23 @@
 
 void CanvasLayerCompositingThreadClient::commitPendingTextureUploads(LayerCompositingThread*)
 {
-    if (!m_buffer)
+    if (!m_buffer || !m_context)
         return;
 
     // This method is called during a synchronization point between WebKit and compositing thread.
     // This is our only chance to transfer the back display list to the front display list without
     // race conditions.
     // 1. Flush back display list to front
-    BlackBerry::Platform::Graphics::releaseBufferDrawable(m_buffer);
+    m_context->flush();
     // 2. Draw front display list to FBO
     BlackBerry::Platform::Graphics::updateBufferBackingSurface(m_buffer);
 }
 
 
-CanvasLayerWebKitThread::CanvasLayerWebKitThread(BlackBerry::Platform::Graphics::Buffer* buffer, const IntSize& size)
+CanvasLayerWebKitThread::CanvasLayerWebKitThread(BlackBerry::Platform::Graphics::Buffer* buffer, BlackBerry::Platform::Graphics::PlatformGraphicsContext* context, const IntSize& size)
     : LayerWebKitThread(CanvasLayer, 0)
 {
-    m_compositingThreadClient = new CanvasLayerCompositingThreadClient(buffer, size);
+    m_compositingThreadClient = new CanvasLayerCompositingThreadClient(buffer, context, size);
     layerCompositingThread()->setClient(m_compositingThreadClient);
 }
 

Modified: trunk/Source/WebCore/platform/graphics/blackberry/CanvasLayerWebKitThread.h (153894 => 153895)


--- trunk/Source/WebCore/platform/graphics/blackberry/CanvasLayerWebKitThread.h	2013-08-09 15:26:33 UTC (rev 153894)
+++ trunk/Source/WebCore/platform/graphics/blackberry/CanvasLayerWebKitThread.h	2013-08-09 15:28:24 UTC (rev 153895)
@@ -23,15 +23,18 @@
 
 #include "EGLImageLayerWebKitThread.h"
 
+#include <BlackBerryPlatformGraphics.h>
+#include <BlackBerryPlatformGraphicsContext.h>
+
 namespace WebCore {
 
 class CanvasLayerCompositingThreadClient;
 
 class CanvasLayerWebKitThread : public LayerWebKitThread {
 public:
-    static PassRefPtr<CanvasLayerWebKitThread> create(BlackBerry::Platform::Graphics::Buffer* buffer, const IntSize& size)
+    static PassRefPtr<CanvasLayerWebKitThread> create(BlackBerry::Platform::Graphics::Buffer* buffer, BlackBerry::Platform::Graphics::PlatformGraphicsContext* context, const IntSize& size)
     {
-        return adoptRef(new CanvasLayerWebKitThread(buffer, size));
+        return adoptRef(new CanvasLayerWebKitThread(buffer, context, size));
     }
 
     virtual ~CanvasLayerWebKitThread();
@@ -42,7 +45,7 @@
     virtual void deleteTextures();
 
 private:
-    CanvasLayerWebKitThread(BlackBerry::Platform::Graphics::Buffer*, const IntSize&);
+    CanvasLayerWebKitThread(BlackBerry::Platform::Graphics::Buffer*, BlackBerry::Platform::Graphics::PlatformGraphicsContext*, const IntSize&);
     CanvasLayerCompositingThreadClient* m_compositingThreadClient;
 };
 

Modified: trunk/Source/WebCore/platform/graphics/blackberry/ImageBufferBlackBerry.cpp (153894 => 153895)


--- trunk/Source/WebCore/platform/graphics/blackberry/ImageBufferBlackBerry.cpp	2013-08-09 15:26:33 UTC (rev 153894)
+++ trunk/Source/WebCore/platform/graphics/blackberry/ImageBufferBlackBerry.cpp	2013-08-09 15:28:24 UTC (rev 153895)
@@ -179,9 +179,16 @@
     }
 
     m_data.m_buffer = BlackBerry::Platform::Graphics::createBuffer(m_size, BlackBerry::Platform::Graphics::AlwaysBacked);
-    m_data.m_platformLayer = CanvasLayerWebKitThread::create(m_data.m_buffer, m_size);
+    BlackBerry::Platform::Graphics::Drawable* drawable = BlackBerry::Platform::Graphics::lockBufferDrawable(m_data.m_buffer);
+    if (!drawable) {
+        BlackBerry::Platform::Graphics::destroyBuffer(m_data.m_buffer);
+        m_data.m_buffer = 0;
+        return;
+    }
+
+    m_data.m_platformLayer = CanvasLayerWebKitThread::create(m_data.m_buffer, drawable, m_size);
     m_data.m_window = window;
-    m_context = adoptPtr(new GraphicsContext(lockBufferDrawable(m_data.m_buffer)));
+    m_context = adoptPtr(new GraphicsContext(drawable));
     m_context->scale(FloatSize(m_resolutionScale, m_resolutionScale));
     m_context->setIsAcceleratedContext(renderingMode == Accelerated);
     success = true;
@@ -197,6 +204,7 @@
             &CanvasLayerWebKitThread::clearBuffer, m_data.m_platformLayer.get()));
     }
 
+    BlackBerry::Platform::Graphics::releaseBufferDrawable(m_data.m_buffer);
     BlackBerry::Platform::Graphics::destroyBuffer(m_data.m_buffer);
     m_data.m_buffer = 0;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to