[BlackBerry] Simplify the code that gets accelerated compositing output onto the...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 1 Apr 2012 21:22:02 +0000 (21:22 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 1 Apr 2012 21:22:02 +0000 (21:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=82845

Patch by Arvid Nilsson <anilsson@rim.com> on 2012-04-01
Reviewed by Rob Buis.

RIM PR: 136381
The code accounted for a now obsolete setup where we used one OpenGL
window for accelerated compositing and one native window for backing
store output, and let the windowing system composite those two. In that
setup an optimization to try and only update the window that had
changed was viable.

Nowadays, we either use an offscreen surface for accelerated
compositing output, which we blend onto the window containing the
backing store output, or render both backing store and accelerated
compositing output directly to one OpenGL window. We always have to
blit the backingstore contents and draw the accelerated compositing
output every frame with these code paths, so don't try to be clever
about it.

Even when we use an OpenGL window, the compositing surface can be non-
null, so don't try to glFinish() and swap the compositing surface when
the GLES2Context is tied to a window.

* Api/BackingStore.cpp:
(BlackBerry::WebKit::BackingStorePrivate::blitVisibleContents):
(BlackBerry::WebKit::BackingStorePrivate::blitContents):
(WebKit):
* Api/BackingStore_p.h:
(BackingStorePrivate):
* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::drawLayersOnCommit):
* WebKitSupport/GLES2Context.cpp:
(BlackBerry::WebKit::GLES2Context::swapBuffers):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@112819 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/blackberry/Api/BackingStore.cpp
Source/WebKit/blackberry/Api/BackingStore_p.h
Source/WebKit/blackberry/Api/WebPage.cpp
Source/WebKit/blackberry/ChangeLog
Source/WebKit/blackberry/WebKitSupport/GLES2Context.cpp

index 9c321ed..de321b8 100644 (file)
@@ -1135,7 +1135,7 @@ void BackingStorePrivate::blitVisibleContents(bool force)
 
     if (!BlackBerry::Platform::userInterfaceThreadMessageClient()->isCurrentThread()) {
 #if USE(ACCELERATED_COMPOSITING)
-        // The blit will call drawSubLayers if necessary
+        // The blit will draw accelerated compositing layers if necessary
         m_needsDrawLayersOnCommit = false;
 #endif
 
@@ -1231,7 +1231,7 @@ void BackingStorePrivate::blitContents(const Platform::IntRect& dstRect,
 
     if (!BlackBerry::Platform::userInterfaceThreadMessageClient()->isCurrentThread()) {
 #if USE(ACCELERATED_COMPOSITING)
-        // The blit will call drawSubLayers if necessary
+        // The blit will draw accelerated compositing layers if necessary
         m_needsDrawLayersOnCommit = false;
 #endif
 
@@ -1284,13 +1284,6 @@ void BackingStorePrivate::blitContents(const Platform::IntRect& dstRect,
         transformation = TransformationMatrix::rectToRect(FloatRect(FloatPoint(0.0, 0.0), WebCore::IntSize(contents.size())), WebCore::IntRect(dstRect));
 
     bool blittingDirectlyToCompositingWindow = isOpenGLCompositing();
-#if USE(ACCELERATED_COMPOSITING)
-    BackingStoreCompositingSurface* compositingSurface =
-        SurfacePool::globalSurfacePool()->compositingSurface();
-
-    if (!blittingDirectlyToCompositingWindow)
-        drawSubLayers();
-#endif
 
 #if DEBUG_BACKINGSTORE
     BlackBerry::Platform::log(BlackBerry::Platform::LogLevelCritical,
@@ -1454,14 +1447,13 @@ void BackingStorePrivate::blitContents(const Platform::IntRect& dstRect,
     }
 
 #if USE(ACCELERATED_COMPOSITING)
-    if (blittingDirectlyToCompositingWindow) {
-        WebCore::FloatRect contentsRect = m_webPage->d->mapFromTransformedFloatRect(
-            WebCore::FloatRect(WebCore::IntRect(contents)));
-        if (WebPageCompositorPrivate* compositor = m_webPage->d->compositor())
-            compositor->drawLayers(dstRect, contentsRect);
-    } else if (compositingSurface)
-        blendCompositingSurface(dstRect);
+    if (WebPageCompositorPrivate* compositor = m_webPage->d->compositor()) {
+        WebCore::FloatRect contentsRect = m_webPage->d->mapFromTransformedFloatRect(WebCore::FloatRect(WebCore::IntRect(contents)));
+        compositor->drawLayers(dstRect, contentsRect);
+    }
 
+    if (!blittingDirectlyToCompositingWindow)
+        blendCompositingSurface(dstRect);
 #endif
 
 #if ENABLE_SCROLLBARS
@@ -2523,28 +2515,6 @@ BackingStoreWindowBufferState* BackingStorePrivate::windowBackBufferState() cons
 }
 
 #if USE(ACCELERATED_COMPOSITING)
-bool BackingStorePrivate::drawSubLayers()
-{
-    ASSERT(BlackBerry::Platform::userInterfaceThreadMessageClient()->isCurrentThread());
-    if (!BlackBerry::Platform::userInterfaceThreadMessageClient()->isCurrentThread())
-        return false;
-
-    if (m_suspendBackingStoreUpdates && !isOpenGLCompositing())
-        return false;
-
-    if (!m_webPage->d->compositor())
-        return false;
-
-    Platform::IntRect dst = m_webPage->client()->userInterfaceBlittedDestinationRect();
-    if (dst.isEmpty())
-        return false;
-
-    Platform::IntRect src = m_webPage->client()->userInterfaceBlittedVisibleContentsRect();
-    WebCore::FloatRect contentsRect = m_webPage->d->mapFromTransformedFloatRect(
-        WebCore::FloatRect(WebCore::IntRect(src)));
-    return m_webPage->d->compositor()->drawLayers(dst, contentsRect);
-}
-
 bool BackingStorePrivate::drawLayersOnCommitIfNeeded()
 {
     // Check if rendering caused a commit and we need to redraw the layers
index 2695361..4a10442 100644 (file)
@@ -200,7 +200,6 @@ public:
 #if USE(ACCELERATED_COMPOSITING)
     void blendCompositingSurface(const Platform::IntRect& dstRect);
     void clearCompositingSurface();
-    bool drawSubLayers();
     bool drawLayersOnCommitIfNeeded();
     void drawAndBlendLayersForDirectRendering(const Platform::IntRect& dirtyRect);
     // WebPage will call this when drawing layers to tell us we don't need to
index a07e8bf..edd34e7 100644 (file)
@@ -5181,28 +5181,8 @@ void WebPagePrivate::drawLayersOnCommit()
         return;
     }
 
-    if (m_backingStore->d->isOpenGLCompositing()) {
+    if (!m_backingStore->d->shouldDirectRenderingToWindow())
         m_backingStore->d->blitVisibleContents();
-        return; // blitVisibleContents() includes drawSubLayers() in this case.
-    }
-
-    if (!m_backingStore->d->drawSubLayers())
-        return;
-
-    // If we use the compositing surface, we need to re-blit the
-    // backingstore and blend the compositing surface on top of that
-    // in order to get the newly drawn layers on screen.
-    if (!SurfacePool::globalSurfacePool()->compositingSurface())
-        return;
-
-    // If there are no visible layers, return early.
-    if (lastCompositingResults().isEmpty() && lastCompositingResults().wasEmpty)
-        return;
-
-    if (m_backingStore->d->shouldDirectRenderingToWindow())
-        return;
-
-    m_backingStore->d->blitVisibleContents();
 }
 
 void WebPagePrivate::scheduleRootLayerCommit()
index bbe56d5..d23fe96 100644 (file)
@@ -1,3 +1,40 @@
+2012-04-01  Arvid Nilsson  <anilsson@rim.com>
+
+        [BlackBerry] Simplify the code that gets accelerated compositing output onto the screen
+        https://bugs.webkit.org/show_bug.cgi?id=82845
+
+        Reviewed by Rob Buis.
+
+        RIM PR: 136381
+        The code accounted for a now obsolete setup where we used one OpenGL
+        window for accelerated compositing and one native window for backing
+        store output, and let the windowing system composite those two. In that
+        setup an optimization to try and only update the window that had
+        changed was viable.
+
+        Nowadays, we either use an offscreen surface for accelerated
+        compositing output, which we blend onto the window containing the
+        backing store output, or render both backing store and accelerated
+        compositing output directly to one OpenGL window. We always have to
+        blit the backingstore contents and draw the accelerated compositing
+        output every frame with these code paths, so don't try to be clever
+        about it.
+
+        Even when we use an OpenGL window, the compositing surface can be non-
+        null, so don't try to glFinish() and swap the compositing surface when
+        the GLES2Context is tied to a window.
+
+        * Api/BackingStore.cpp:
+        (BlackBerry::WebKit::BackingStorePrivate::blitVisibleContents):
+        (BlackBerry::WebKit::BackingStorePrivate::blitContents):
+        (WebKit):
+        * Api/BackingStore_p.h:
+        (BackingStorePrivate):
+        * Api/WebPage.cpp:
+        (BlackBerry::WebKit::WebPagePrivate::drawLayersOnCommit):
+        * WebKitSupport/GLES2Context.cpp:
+        (BlackBerry::WebKit::GLES2Context::swapBuffers):
+
 2012-03-31  Jonathan Dong  <jonathan.dong@torchmobile.com.cn>
 
         [BlackBerry] http authenticate dialog popup only once no matter authentication pass or fail
index 78f1a24..06507ac 100644 (file)
@@ -108,14 +108,19 @@ bool GLES2Context::swapBuffers()
 {
     ASSERT(glGetError() == GL_NO_ERROR);
 
-#if ENABLE_COMPOSITING_SURFACE
-    // Because we are rendering compositing contents into an off-screen pixmap and
-    // we need to blend the pixmap with the web page window surface we have to call
-    // glFinish() here.
-    glFinish();
+    // If there's a window the backing store will swap it when the time is right.
+    // Return early because there might be an unused but non-null compositing surface
+    if (m_window)
+        return true;
 
-    if (BackingStoreCompositingSurface* surface = compositingSurface())
+#if ENABLE_COMPOSITING_SURFACE
+    if (BackingStoreCompositingSurface* surface = compositingSurface()) {
+        // Because we are rendering compositing contents into an off-screen pixmap and
+        // we need to blend the pixmap with the web page window surface we have to call
+        // glFinish() here.
+        glFinish();
         surface->swapBuffers();
+    }
 #endif
 
     return true;