[BlackBerry] Rotate device from landscape to portrait during youtube streaming will...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Aug 2013 18:32:57 +0000 (18:32 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Aug 2013 18:32:57 +0000 (18:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=120364

Patch by Jacky Jiang <zhajiang@blackberry.com> on 2013-08-27
Reviewed by Rob Buis.
Internally reviewed by Arvid Nilsson.

Source/WebCore:

JIRA 461232
When rotating device from landscape mode to portrait mode, we updated
texture contents based on landscape mode front visibility and back
visibility on WebKit thread at the very beginning and the landscape mode
tiles wouldn't be able to cover the portrait mode screen which resulted
in the screen flash.
It's hard to compute front visibility information on WebKit thread because
it doesn't know where the layers will be on the screen. Therefore, the
front visibility won't be updated until the first time we draw textures
on compositing thread.
The patch traverses through LayerWebKitThread and LayerCompositingThread
and discards back visibility and front visibility respectively if there
is a pending orientation. In this way, we can pick up layerTilerPrefillRect
as visibleRect instead of the visibleRect from the stale visibilities
and add more tiles for uncovered screen when updating texture contents
on WebKit thread.
The patch also fixes a bug that we prune tiles based on the stale
m_requiredTextureSize in pruneTextures(). We should prune tiles based
on the updated pendingTextureSize instead.

* platform/graphics/blackberry/LayerCompositingThread.cpp:
(WebCore::LayerCompositingThread::discardFrontVisibility):
* platform/graphics/blackberry/LayerCompositingThread.h:
* platform/graphics/blackberry/LayerCompositingThreadClient.h:
(WebCore::LayerCompositingThreadClient::discardFrontVisibility):
* platform/graphics/blackberry/LayerRenderer.cpp:
(WebCore::LayerRenderer::discardFrontVisibility):
* platform/graphics/blackberry/LayerRenderer.h:
* platform/graphics/blackberry/LayerTiler.cpp:
(WebCore::LayerTiler::discardFrontVisibility):
(WebCore::LayerTiler::processTextureJob):
(WebCore::LayerTiler::pruneTextures):
(WebCore::LayerTiler::discardBackVisibility):
* platform/graphics/blackberry/LayerTiler.h:
* platform/graphics/blackberry/LayerWebKitThread.cpp:
(WebCore::LayerWebKitThread::discardBackVisibility):
* platform/graphics/blackberry/LayerWebKitThread.h:

Source/WebKit/blackberry:

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::setViewportSize):
(BlackBerry::WebKit::WebPagePrivate::discardLayerVisibilities):
(BlackBerry::WebKit::WebPagePrivate::discardFrontVisibilityCompositingThread):
* Api/WebPageCompositor.cpp:
(BlackBerry::WebKit::WebPageCompositorPrivate::discardFrontVisibility):
* Api/WebPageCompositor_p.h:
* Api/WebPage_p.h:
* WebKitSupport/FrameLayers.cpp:
(BlackBerry::WebKit::FrameLayers::discardBackVisibility):
* WebKitSupport/FrameLayers.h:

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

17 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.cpp
Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.h
Source/WebCore/platform/graphics/blackberry/LayerCompositingThreadClient.h
Source/WebCore/platform/graphics/blackberry/LayerRenderer.cpp
Source/WebCore/platform/graphics/blackberry/LayerRenderer.h
Source/WebCore/platform/graphics/blackberry/LayerTiler.cpp
Source/WebCore/platform/graphics/blackberry/LayerTiler.h
Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.cpp
Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.h
Source/WebKit/blackberry/Api/WebPage.cpp
Source/WebKit/blackberry/Api/WebPageCompositor.cpp
Source/WebKit/blackberry/Api/WebPageCompositor_p.h
Source/WebKit/blackberry/Api/WebPage_p.h
Source/WebKit/blackberry/ChangeLog
Source/WebKit/blackberry/WebKitSupport/FrameLayers.cpp
Source/WebKit/blackberry/WebKitSupport/FrameLayers.h

index 393cc521124fe1c3e92f9e29ac034e8f355069f8..29dd2d9d14677e5f5072085fd2b065e675edc74f 100644 (file)
@@ -1,3 +1,49 @@
+2013-08-27  Jacky Jiang  <zhajiang@blackberry.com>
+
+        [BlackBerry] Rotate device from landscape to portrait during youtube streaming will cause device screen flash with video list page
+        https://bugs.webkit.org/show_bug.cgi?id=120364
+
+        Reviewed by Rob Buis.
+        Internally reviewed by Arvid Nilsson.
+
+        JIRA 461232
+        When rotating device from landscape mode to portrait mode, we updated
+        texture contents based on landscape mode front visibility and back
+        visibility on WebKit thread at the very beginning and the landscape mode
+        tiles wouldn't be able to cover the portrait mode screen which resulted
+        in the screen flash.
+        It's hard to compute front visibility information on WebKit thread because
+        it doesn't know where the layers will be on the screen. Therefore, the
+        front visibility won't be updated until the first time we draw textures
+        on compositing thread.
+        The patch traverses through LayerWebKitThread and LayerCompositingThread
+        and discards back visibility and front visibility respectively if there
+        is a pending orientation. In this way, we can pick up layerTilerPrefillRect
+        as visibleRect instead of the visibleRect from the stale visibilities
+        and add more tiles for uncovered screen when updating texture contents
+        on WebKit thread.
+        The patch also fixes a bug that we prune tiles based on the stale
+        m_requiredTextureSize in pruneTextures(). We should prune tiles based
+        on the updated pendingTextureSize instead.
+
+        * platform/graphics/blackberry/LayerCompositingThread.cpp:
+        (WebCore::LayerCompositingThread::discardFrontVisibility):
+        * platform/graphics/blackberry/LayerCompositingThread.h:
+        * platform/graphics/blackberry/LayerCompositingThreadClient.h:
+        (WebCore::LayerCompositingThreadClient::discardFrontVisibility):
+        * platform/graphics/blackberry/LayerRenderer.cpp:
+        (WebCore::LayerRenderer::discardFrontVisibility):
+        * platform/graphics/blackberry/LayerRenderer.h:
+        * platform/graphics/blackberry/LayerTiler.cpp:
+        (WebCore::LayerTiler::discardFrontVisibility):
+        (WebCore::LayerTiler::processTextureJob):
+        (WebCore::LayerTiler::pruneTextures):
+        (WebCore::LayerTiler::discardBackVisibility):
+        * platform/graphics/blackberry/LayerTiler.h:
+        * platform/graphics/blackberry/LayerWebKitThread.cpp:
+        (WebCore::LayerWebKitThread::discardBackVisibility):
+        * platform/graphics/blackberry/LayerWebKitThread.h:
+
 2013-08-27  Antti Koivisto  <antti@apple.com>
 
         Better mutation and event assertions for descendant iterators
index ffba7f2ff8cc97c1f51ba70ad2ffda4c78077f4f..7a986a73439be5eb71c742aa166564c0b3186753 100644 (file)
@@ -567,6 +567,12 @@ void LayerCompositingThread::clearOverride()
     m_override.clear();
 }
 
+void LayerCompositingThread::discardFrontVisibility()
+{
+    if (m_client)
+        m_client->discardFrontVisibility();
+}
+
 }
 
 #endif // USE(ACCELERATED_COMPOSITING)
index 8bee2668baa9339d5ab3ff2672fe6cc809dbc0f2..7d49c898f6e2eef2cd16c67d36e93077727217db 100644 (file)
@@ -230,6 +230,8 @@ public:
     LayerOverride* override();
     void clearOverride();
 
+    void discardFrontVisibility();
+
 #if ENABLE(CSS_FILTERS)
     bool filterOperationsChanged() const { return m_filterOperationsChanged; }
     void setFilterOperationsChanged(bool changed) { m_filterOperationsChanged = changed; }
index 08cfe1aa5619204eb536facbe831e4c086b480e5..65efe2e732964c06140fd7a855193dd474a87dea 100644 (file)
@@ -54,6 +54,8 @@ public:
 
     // Unlike the other methods here, this one will be called on the WebKit thread
     virtual void scheduleCommit() { }
+
+    virtual void discardFrontVisibility() { }
 };
 
 } // namespace WebCore
index 013bfd0aad315d4a2aa1d6758130d4fc9f96b8d3..24a806f74dea7c8d5039b0fa7468927e7ce4faa3 100644 (file)
@@ -593,6 +593,15 @@ void LayerRenderer::drawDebugBorder(const Vector<FloatPoint>& transformedBounds,
     glDrawArrays(GL_LINE_LOOP, 0, transformedBounds.size());
 }
 
+void LayerRenderer::discardFrontVisibility()
+{
+    if (m_hardwareCompositing) {
+        makeContextCurrent();
+        for (LayerSet::iterator iter = m_layers.begin(); iter != m_layers.end(); ++iter)
+            (*iter)->discardFrontVisibility();
+    }
+}
+
 // Draws a debug border around the layer's bounds.
 void LayerRenderer::drawDebugBorder(LayerCompositingThread* layer)
 {
index 4957ec63301d8791a3e61e008c5d1053ccf7be37..db6679e2f6abb615db680bd22d8a8a36d3990a24 100644 (file)
@@ -136,6 +136,8 @@ public:
 
     void drawDebugBorder(const Vector<FloatPoint>&, const Color&, float borderWidth);
 
+    void discardFrontVisibility();
+
     static GLuint loadShader(GLenum type, const char* shaderSource);
     static GLuint loadShaderProgram(const char* vertexShaderSource, const char* fragmentShaderSource);
 
index e5be104e7fc8245c1b4eb01f700309af46326ac2..10447722b90ad550aee02eec512a9eee036ba955 100644 (file)
@@ -348,6 +348,12 @@ void LayerTiler::commitPendingTextureUploads(LayerCompositingThread*)
     m_pendingTextureJobs.clear();
 }
 
+void LayerTiler::discardFrontVisibility()
+{
+    delete m_frontVisibility;
+    m_frontVisibility = 0;
+}
+
 LayerVisibility* LayerTiler::swapFrontVisibility(LayerVisibility* visibility)
 {
     return reinterpret_cast<LayerVisibility*>(_smp_xchg(reinterpret_cast<unsigned*>(&m_frontVisibility), reinterpret_cast<unsigned>(visibility)));
@@ -406,7 +412,7 @@ void LayerTiler::processTextureJob(const TextureJob& job, TileJobsMap& tileJobsM
     if (job.m_type == TextureJob::ResizeContents) {
         IntSize pendingTextureSize = job.m_dirtyRect.size();
         if (pendingTextureSize.width() < m_requiredTextureSize.width() || pendingTextureSize.height() < m_requiredTextureSize.height())
-            pruneTextures();
+            pruneTextures(pendingTextureSize);
 
         m_requiredTextureSize = pendingTextureSize;
         return;
@@ -633,7 +639,7 @@ void LayerTiler::deleteTextures(LayerCompositingThread*)
     m_requiredTextureSize = IntSize();
 }
 
-void LayerTiler::pruneTextures()
+void LayerTiler::pruneTextures(const IntSize& pendingTextureSize)
 {
     // Prune tiles that are no longer needed.
     Vector<TileIndex> tilesToDelete;
@@ -641,7 +647,7 @@ void LayerTiler::pruneTextures()
         TileIndex index = (*it).key;
 
         IntPoint origin = originOfTile(index);
-        if (origin.x() >= m_requiredTextureSize.width() || origin.y() >= m_requiredTextureSize.height())
+        if (origin.x() >= pendingTextureSize.width() || origin.y() >= pendingTextureSize.height())
             tilesToDelete.append(index);
     }
 
@@ -674,6 +680,12 @@ void LayerTiler::setNeedsBacking(bool needsBacking)
     updateTileSize();
 }
 
+void LayerTiler::discardBackVisibility()
+{
+    delete m_backVisibility;
+    m_backVisibility = 0;
+}
+
 void LayerTiler::scheduleCommit()
 {
     ASSERT(isWebKitThread());
index 5d3d75737f02f817027cd8e8f50eb15f997fab50..8ecd9e7aaed16d9b9da8087fb4ebd5d3e1516dbe 100644 (file)
@@ -61,6 +61,7 @@ public:
     void setNeedsDisplay();
     void updateTextureContentsIfNeeded(double scale);
     void setNeedsBacking(bool);
+    void discardBackVisibility();
     virtual void scheduleCommit();
 
     // Compositing thread
@@ -72,6 +73,7 @@ public:
     virtual void deleteTextures(LayerCompositingThread*);
     static void willCommit();
     virtual void commitPendingTextureUploads(LayerCompositingThread*);
+    virtual void discardFrontVisibility();
 
 private:
     struct TextureJob {
@@ -144,7 +146,7 @@ private:
     void addTileJob(const TileIndex&, const TextureJob&, TileJobsMap&);
     void performTileJob(LayerCompositingThread*, LayerTile*, const TextureJob&);
     void processTextureJob(const TextureJob&, TileJobsMap&);
-    void pruneTextures();
+    void pruneTextures(const IntSize& pendingTextureSize);
     void visibilityChanged(bool needsDisplay);
     bool drawTile(LayerCompositingThread*, LayerTile*, const TileIndex&, double scale, const FloatRect& dst, const FloatRect& dstClip);
     void setFrontVisibility(const FloatRect& visibleRect, HashSet<TileIndex>& tilesNeedingRender);
index 76618a5e6ce3552be605dd53b5031b3079671350..d951e1c96c6bd2a74c632ea6fd75ab8ba09397cc 100644 (file)
@@ -529,6 +529,26 @@ void LayerWebKitThread::releaseLayerResources()
         replicaLayer()->releaseLayerResources();
 }
 
+void LayerWebKitThread::discardBackVisibility()
+{
+    if (m_tiler)
+        m_tiler->discardBackVisibility();
+
+    size_t listSize = m_sublayers.size();
+    for (size_t i = 0; i < listSize; ++i)
+        m_sublayers[i]->discardBackVisibility();
+
+    listSize = m_overlays.size();
+    for (size_t i = 0; i < listSize; ++i)
+        m_overlays[i]->discardBackVisibility();
+
+    if (maskLayer())
+        maskLayer()->discardBackVisibility();
+
+    if (replicaLayer())
+        replicaLayer()->discardBackVisibility();
+}
+
 IntRect LayerWebKitThread::mapFromTransformed(const IntRect& contentsRect, double scale)
 {
     IntRect untransformedContentsRect = contentsRect;
index dd54fc6a6368584b05ff5f11a7fc1dcd5bf456d4..d0a47b744e2ef6f8e30bd8cb70ac1418319b7dfb 100644 (file)
@@ -213,6 +213,8 @@ public:
 
     void releaseLayerResources();
 
+    void discardBackVisibility();
+
     static IntRect mapFromTransformed(const IntRect&, double scale);
 
 protected:
index b70408d7308d080ce025ab5a337f1ac25c53e7a5..a4d07f4593616c99ea03a8e26a51493a03b31fe4 100644 (file)
@@ -3559,6 +3559,11 @@ bool WebPagePrivate::setViewportSize(const IntSize& transformedActualVisibleSize
 
     bool hasPendingOrientation = m_pendingOrientation != -1;
 
+#if USE(ACCELERATED_COMPOSITING)
+    if (hasPendingOrientation)
+        discardLayerVisibilities();
+#endif
+
     IntSize viewportSizeBefore = actualVisibleSize();
     FloatPoint centerOfVisibleContentsRect = this->centerOfVisibleContentsRect();
     bool newVisibleRectContainsOldVisibleRect = (m_actualVisibleHeight <= transformedActualVisibleSize.height())
@@ -5241,6 +5246,23 @@ void WebPagePrivate::scheduleRootLayerCommit()
     }
 }
 
+void WebPagePrivate::discardLayerVisibilities()
+{
+    if (!isAcceleratedCompositingActive())
+        return;
+
+    if (m_frameLayers)
+        m_frameLayers->discardBackVisibility();
+
+    Platform::userInterfaceThreadMessageClient()->dispatchSyncMessage(
+        Platform::createMethodCallMessage(&WebPagePrivate::discardFrontVisibilityCompositingThread, this));
+}
+
+void WebPagePrivate::discardFrontVisibilityCompositingThread()
+{
+    m_compositor->discardFrontVisibility();
+}
+
 static bool needsLayoutRecursive(FrameView* view)
 {
     if (view->needsLayout())
index af1c790f001dbe1ac556462cc0441066e465ead8..0b93a44aa1d453813a6cd92c5d9e26328f4f185b 100644 (file)
@@ -296,6 +296,12 @@ void WebPageCompositorPrivate::findFixedElementRect(LayerCompositingThread* laye
         findFixedElementRect(sublayers[i].get(), fixedElementRect);
 }
 
+void WebPageCompositorPrivate::discardFrontVisibility()
+{
+    if (m_layerRenderer)
+        m_layerRenderer->discardFrontVisibility();
+}
+
 WebPageCompositor::WebPageCompositor(WebPage* page, WebPageCompositorClient* client)
 {
     using namespace BlackBerry::Platform;
index 3ae463650e0bd2246bd9e65820895789731d2554..99ea33a535b48e112375a5e2f43b5ae8310a4b5a 100644 (file)
@@ -102,6 +102,8 @@ public:
 
     void findFixedElementRect(WebCore::LayerCompositingThread*, WebCore::IntRect&);
 
+    void discardFrontVisibility();
+
 protected:
     WebPageCompositorPrivate(WebPagePrivate*, WebPageCompositorClient*);
 
index b330f1bd44f3ccea29c719c2a7c62275a12e9ea5..3af6a749c0958bbb4fd0958a62a5a28f2607bacd 100644 (file)
@@ -394,6 +394,7 @@ public:
     void setRootLayerWebKitThread(WebCore::Frame*, WebCore::LayerWebKitThread*);
     void setNeedsOneShotDrawingSynchronization();
     void scheduleRootLayerCommit();
+    void discardLayerVisibilities();
 
     // Compositing thread.
     void setRootLayerCompositingThread(WebCore::LayerCompositingThread*);
@@ -411,6 +412,7 @@ public:
     void updateRootLayerCommitEnabled();
 
     void scheduleCompositingRun();
+    void discardFrontVisibilityCompositingThread();
 #endif
 
     bool dispatchTouchEventToFullScreenPlugin(WebCore::PluginView*, const Platform::TouchEvent&);
index c98ffdc19588b5893c14132391258d4058d57bd6..7c156fee419524ce248644affa31becd8eecd418 100644 (file)
@@ -1,3 +1,23 @@
+2013-08-27  Jacky Jiang  <zhajiang@blackberry.com>
+
+        [BlackBerry] Rotate device from landscape to portrait during youtube streaming will cause device screen flash with video list page
+        https://bugs.webkit.org/show_bug.cgi?id=120364
+
+        Reviewed by Rob Buis.
+        Internally reviewed by Arvid Nilsson.
+
+        * Api/WebPage.cpp:
+        (BlackBerry::WebKit::WebPagePrivate::setViewportSize):
+        (BlackBerry::WebKit::WebPagePrivate::discardLayerVisibilities):
+        (BlackBerry::WebKit::WebPagePrivate::discardFrontVisibilityCompositingThread):
+        * Api/WebPageCompositor.cpp:
+        (BlackBerry::WebKit::WebPageCompositorPrivate::discardFrontVisibility):
+        * Api/WebPageCompositor_p.h:
+        * Api/WebPage_p.h:
+        * WebKitSupport/FrameLayers.cpp:
+        (BlackBerry::WebKit::FrameLayers::discardBackVisibility):
+        * WebKitSupport/FrameLayers.h:
+
 2013-08-26  Pratik Solanki  <psolanki@apple.com>
 
         PageGroup::groupSettings() should return a reference
index 10ba6b7ac693ae9f51cba7c5ae10aff726f07cef..ff5e9ab49b7d395a798c98a3cc8d4ac55c23e55f 100644 (file)
@@ -130,6 +130,12 @@ void FrameLayers::releaseLayerResources()
         m_rootLayer->releaseLayerResources();
 }
 
+void FrameLayers::discardBackVisibility()
+{
+    if (m_rootLayer)
+        m_rootLayer->discardBackVisibility();
+}
+
 } // namespace BlackBerry
 } // namespace WebKit
 
index 4a8ba13b0d555c19f2a6ee5a9d354a998d00cf71..656e6337d7f814208a39efab60346573e557449a 100644 (file)
@@ -60,6 +60,8 @@ public:
 
     void releaseLayerResources();
 
+    void discardBackVisibility();
+
 private:
     WebPagePrivate* m_pagePrivate;
     OwnPtr<WebCore::GraphicsLayer> m_rootGraphicsLayer;