From 31882285ebfac4fadca06f2f0c0ea58475c7f426 Mon Sep 17 00:00:00 2001 From: "aelias@chromium.org" Date: Thu, 14 Feb 2013 00:54:27 +0000 Subject: cc: Only allow trees created at the current viewport size to draw. When we're on a small page whose WebKit layout size is equal to the viewport size, and the viewport size grows, we don't have enough content to fill the screen until the pending tree finishes rasterizing. This patch disallows drawing on the active tree when the viewport size has recently changed. NOTRY=true BUG=173449 Review URL: https://chromiumcodereview.appspot.com/12212156 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182357 0039d316-1c4b-4281-b951-d872f2087c98 --- cc/layer_tree_host.cc | 1 + cc/layer_tree_host_impl.cc | 7 +++++++ cc/layer_tree_impl.cc | 20 ++++++++++++++++++++ cc/layer_tree_impl.h | 7 +++++++ cc/thread_proxy.cc | 7 ++++--- 5 files changed, 39 insertions(+), 3 deletions(-) (limited to 'cc') diff --git a/cc/layer_tree_host.cc b/cc/layer_tree_host.cc index 8ce6a29..cddb09b 100644 --- a/cc/layer_tree_host.cc +++ b/cc/layer_tree_host.cc @@ -328,6 +328,7 @@ void LayerTreeHost::finishCommitOnImplThread(LayerTreeHostImpl* hostImpl) if (syncTree->ContentsTexturesPurged()) syncTree->ResetContentsTexturesPurged(); } + syncTree->ResetViewportSizeInvalid(); m_commitNumber++; } diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc index e6c0de7..397a2d3 100644 --- a/cc/layer_tree_host_impl.cc +++ b/cc/layer_tree_host_impl.cc @@ -234,6 +234,10 @@ bool LayerTreeHostImpl::canDraw() TRACE_EVENT_INSTANT0("cc", "LayerTreeHostImpl::canDraw empty viewport"); return false; } + if (m_activeTree->ViewportSizeInvalid()) { + TRACE_EVENT_INSTANT0("cc", "LayerTreeHostImpl::canDraw viewport size recently changed"); + return false; + } if (!m_renderer) { TRACE_EVENT_INSTANT0("cc", "LayerTreeHostImpl::canDraw no renderer"); return false; @@ -1102,6 +1106,9 @@ void LayerTreeHostImpl::setViewportSize(const gfx::Size& layoutViewportSize, con if (layoutViewportSize == m_layoutViewportSize && deviceViewportSize == m_deviceViewportSize) return; + if (pendingTree() && m_deviceViewportSize != deviceViewportSize) + activeTree()->SetViewportSizeInvalid(); + m_layoutViewportSize = layoutViewportSize; m_deviceViewportSize = deviceViewportSize; diff --git a/cc/layer_tree_impl.cc b/cc/layer_tree_impl.cc index 832ecaa..b0d071e 100644 --- a/cc/layer_tree_impl.cc +++ b/cc/layer_tree_impl.cc @@ -27,6 +27,7 @@ LayerTreeImpl::LayerTreeImpl(LayerTreeHostImpl* layer_tree_host_impl) max_page_scale_factor_(0), scrolling_layer_id_from_previous_tree_(0), contents_textures_purged_(false), + viewport_size_invalid_(false), needs_update_draw_properties_(true), needs_full_tree_sync_(true) { } @@ -104,6 +105,11 @@ void LayerTreeImpl::pushPropertiesTo(LayerTreeImpl* target_tree) { else target_tree->ResetContentsTexturesPurged(); + if (ViewportSizeInvalid()) + target_tree->SetViewportSizeInvalid(); + else + target_tree->ResetViewportSizeInvalid(); + if (hud_layer()) target_tree->set_hud_layer(static_cast( LayerTreeHostCommon::findLayerInSubtree( @@ -346,6 +352,20 @@ void LayerTreeImpl::ResetContentsTexturesPurged() { layer_tree_host_impl_->OnCanDrawStateChangedForTree(this); } +bool LayerTreeImpl::ViewportSizeInvalid() const { + return viewport_size_invalid_; +} + +void LayerTreeImpl::SetViewportSizeInvalid() { + viewport_size_invalid_ = true; + layer_tree_host_impl_->OnCanDrawStateChangedForTree(this); +} + +void LayerTreeImpl::ResetViewportSizeInvalid() { + viewport_size_invalid_ = false; + layer_tree_host_impl_->OnCanDrawStateChangedForTree(this); +} + Proxy* LayerTreeImpl::proxy() const { return layer_tree_host_impl_->proxy(); } diff --git a/cc/layer_tree_impl.h b/cc/layer_tree_impl.h index 092027e..729c3d45 100644 --- a/cc/layer_tree_impl.h +++ b/cc/layer_tree_impl.h @@ -179,6 +179,12 @@ class CC_EXPORT LayerTreeImpl { void SetContentsTexturesPurged(); void ResetContentsTexturesPurged(); + // Set on the active tree when the viewport size recently changed + // and the active tree's size is now out of date. + bool ViewportSizeInvalid() const; + void SetViewportSizeInvalid(); + void ResetViewportSizeInvalid(); + // Useful for debug assertions, probably shouldn't be used for anything else. Proxy* proxy() const; @@ -211,6 +217,7 @@ protected: LayerList render_surface_layer_list_; bool contents_textures_purged_; + bool viewport_size_invalid_; bool needs_update_draw_properties_; // In impl-side painting mode, this is true when the tree may contain diff --git a/cc/thread_proxy.cc b/cc/thread_proxy.cc index 9e7773c..ddc61c0 100644 --- a/cc/thread_proxy.cc +++ b/cc/thread_proxy.cc @@ -1176,9 +1176,10 @@ void ThreadProxy::renewTreePriority() if (m_smoothnessTakesPriorityExpirationTime > base::TimeTicks::Now()) priority = SMOOTHNESS_TAKES_PRIORITY; - // New content always takes priority when we have an active tree with - // evicted resources. - if (m_layerTreeHostImpl->activeTree()->ContentsTexturesPurged()) + // New content always takes priority when the active tree has + // evicted resources or there is an invalid viewport size. + if (m_layerTreeHostImpl->activeTree()->ContentsTexturesPurged() || + m_layerTreeHostImpl->activeTree()->ViewportSizeInvalid()) priority = NEW_CONTENT_TAKES_PRIORITY; m_layerTreeHostImpl->setTreePriority(priority); -- cgit v1.1