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
+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
m_override.clear();
}
+void LayerCompositingThread::discardFrontVisibility()
+{
+ if (m_client)
+ m_client->discardFrontVisibility();
+}
+
}
#endif // USE(ACCELERATED_COMPOSITING)
LayerOverride* override();
void clearOverride();
+ void discardFrontVisibility();
+
#if ENABLE(CSS_FILTERS)
bool filterOperationsChanged() const { return m_filterOperationsChanged; }
void setFilterOperationsChanged(bool changed) { m_filterOperationsChanged = changed; }
// Unlike the other methods here, this one will be called on the WebKit thread
virtual void scheduleCommit() { }
+
+ virtual void discardFrontVisibility() { }
};
} // namespace WebCore
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)
{
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);
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)));
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;
m_requiredTextureSize = IntSize();
}
-void LayerTiler::pruneTextures()
+void LayerTiler::pruneTextures(const IntSize& pendingTextureSize)
{
// Prune tiles that are no longer needed.
Vector<TileIndex> tilesToDelete;
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);
}
updateTileSize();
}
+void LayerTiler::discardBackVisibility()
+{
+ delete m_backVisibility;
+ m_backVisibility = 0;
+}
+
void LayerTiler::scheduleCommit()
{
ASSERT(isWebKitThread());
void setNeedsDisplay();
void updateTextureContentsIfNeeded(double scale);
void setNeedsBacking(bool);
+ void discardBackVisibility();
virtual void scheduleCommit();
// Compositing thread
virtual void deleteTextures(LayerCompositingThread*);
static void willCommit();
virtual void commitPendingTextureUploads(LayerCompositingThread*);
+ virtual void discardFrontVisibility();
private:
struct TextureJob {
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);
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;
void releaseLayerResources();
+ void discardBackVisibility();
+
static IntRect mapFromTransformed(const IntRect&, double scale);
protected:
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())
}
}
+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())
findFixedElementRect(sublayers[i].get(), fixedElementRect);
}
+void WebPageCompositorPrivate::discardFrontVisibility()
+{
+ if (m_layerRenderer)
+ m_layerRenderer->discardFrontVisibility();
+}
+
WebPageCompositor::WebPageCompositor(WebPage* page, WebPageCompositorClient* client)
{
using namespace BlackBerry::Platform;
void findFixedElementRect(WebCore::LayerCompositingThread*, WebCore::IntRect&);
+ void discardFrontVisibility();
+
protected:
WebPageCompositorPrivate(WebPagePrivate*, WebPageCompositorClient*);
void setRootLayerWebKitThread(WebCore::Frame*, WebCore::LayerWebKitThread*);
void setNeedsOneShotDrawingSynchronization();
void scheduleRootLayerCommit();
+ void discardLayerVisibilities();
// Compositing thread.
void setRootLayerCompositingThread(WebCore::LayerCompositingThread*);
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
m_rootLayer->releaseLayerResources();
}
+void FrameLayers::discardBackVisibility()
+{
+ if (m_rootLayer)
+ m_rootLayer->discardBackVisibility();
+}
+
} // namespace BlackBerry
} // namespace WebKit
void releaseLayerResources();
+ void discardBackVisibility();
+
private:
WebPagePrivate* m_pagePrivate;
OwnPtr<WebCore::GraphicsLayer> m_rootGraphicsLayer;