| Index: cc/layer_tree_host_impl.cc
|
| diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc
|
| index 607a50c2344ce9bc1810702f5238d2507b535de4..5eee47e3803ba29969bcb886f2644345e0ea6253 100644
|
| --- a/cc/layer_tree_host_impl.cc
|
| +++ b/cc/layer_tree_host_impl.cc
|
| @@ -48,6 +48,12 @@
|
|
|
| namespace {
|
|
|
| +// Limits for the total number of cheap tile rasterizations we are allowed to
|
| +// perform during a single frame and the time spent rasterizing.
|
| +// TODO(skyostil): Determine these limits more dynamically.
|
| +const int kMaxCheapRasterCount = 6;
|
| +const int kMaxCheapRasterMilliseconds = 6;
|
| +
|
| void didVisibilityChange(cc::LayerTreeHostImpl* id, bool visible)
|
| {
|
| if (visible) {
|
| @@ -159,6 +165,7 @@ LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, LayerTre
|
| , m_lastSentMemoryVisibleAndNearbyBytes(0)
|
| , m_lastSentMemoryUseBytes(0)
|
| , m_animationRegistrar(AnimationRegistrar::create())
|
| + , m_cheapRasterCount(0)
|
| {
|
| DCHECK(m_proxy->isImplThread());
|
| didVisibilityChange(this, m_visible);
|
| @@ -715,6 +722,28 @@ void LayerTreeHostImpl::DidUploadVisibleHighResolutionTile()
|
| m_client->didUploadVisibleHighResolutionTileOnImplThread();
|
| }
|
|
|
| +bool LayerTreeHostImpl::CanDoAnotherCheapRaster() const
|
| +{
|
| + DCHECK(m_settings.useCheapnessEstimator);
|
| + if (m_cheapRasterCount >= kMaxCheapRasterCount) {
|
| + TRACE_EVENT_INSTANT0("cc", "LayerTreeHostImpl::CanDoAnotherCheapRaster did too many");
|
| + return false;
|
| + }
|
| + if (m_cheapRasterDeadline.is_null() || base::TimeTicks::Now() >= m_cheapRasterDeadline) {
|
| + TRACE_EVENT_INSTANT0("cc", "LayerTreeHostImpl::CanDoAnotherCheapRaster out of time");
|
| + m_cheapRasterDeadline = base::TimeTicks();
|
| + return false;
|
| + }
|
| + return true;
|
| +}
|
| +
|
| +void LayerTreeHostImpl::DidPerformCheapRaster()
|
| +{
|
| + DCHECK(m_settings.useCheapnessEstimator);
|
| + m_cheapRasterCount++;
|
| + DCHECK(m_cheapRasterCount <= kMaxCheapRasterCount);
|
| +}
|
| +
|
| bool LayerTreeHostImpl::shouldClearRootRenderPass() const
|
| {
|
| return m_settings.shouldClearRootRenderPass;
|
| @@ -847,6 +876,10 @@ const RendererCapabilities& LayerTreeHostImpl::rendererCapabilities() const
|
|
|
| bool LayerTreeHostImpl::swapBuffers()
|
| {
|
| + if (m_settings.useCheapnessEstimator) {
|
| + m_cheapRasterCount = 0;
|
| + m_cheapRasterDeadline = base::TimeTicks::Now() + base::TimeDelta::FromMilliseconds(kMaxCheapRasterMilliseconds);
|
| + }
|
| return m_renderer->swapBuffers();
|
| }
|
|
|
|
|