Commit fb648092 authored by commit-queue@webkit.org's avatar commit-queue@webkit.org
Browse files

[BlackBerry] Rotate device from landscape to portrait during youtube streaming...

[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

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: http://svn.webkit.org/repository/webkit/trunk@154701 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9c732100
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
......@@ -567,6 +567,12 @@ void LayerCompositingThread::clearOverride()
m_override.clear();
}
void LayerCompositingThread::discardFrontVisibility()
{
if (m_client)
m_client->discardFrontVisibility();
}
}
#endif // USE(ACCELERATED_COMPOSITING)
......@@ -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; }
......
......@@ -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
......
......@@ -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)
{
......
......@@ -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);
......
......@@ -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());
......
......@@ -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);
......
......@@ -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;
......
......@@ -213,6 +213,8 @@ public:
void releaseLayerResources();
void discardBackVisibility();
static IntRect mapFromTransformed(const IntRect&, double scale);
protected:
......
......@@ -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())
......
......@@ -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;
......
......@@ -102,6 +102,8 @@ public:
void findFixedElementRect(WebCore::LayerCompositingThread*, WebCore::IntRect&);
void discardFrontVisibility();
protected:
WebPageCompositorPrivate(WebPagePrivate*, WebPageCompositorClient*);
......
......@@ -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&);
......
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
......
......@@ -130,6 +130,12 @@ void FrameLayers::releaseLayerResources()
m_rootLayer->releaseLayerResources();
}
void FrameLayers::discardBackVisibility()
{
if (m_rootLayer)
m_rootLayer->discardBackVisibility();
}
} // namespace BlackBerry
} // namespace WebKit
......
......@@ -60,6 +60,8 @@ public:
void releaseLayerResources();
void discardBackVisibility();
private:
WebPagePrivate* m_pagePrivate;
OwnPtr<WebCore::GraphicsLayer> m_rootGraphicsLayer;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment