summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-27 05:41:18 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-27 05:41:18 +0000
commit4c9bb9593a27f25e1d14d477899a38d8b57ca887 (patch)
tree0583790fa1c29d7865ff4c4b4afd475de5108973 /cc
parenta30a0a3661c01b689cddfd2e8c5eb76169782962 (diff)
downloadchromium_src-4c9bb9593a27f25e1d14d477899a38d8b57ca887.zip
chromium_src-4c9bb9593a27f25e1d14d477899a38d8b57ca887.tar.gz
chromium_src-4c9bb9593a27f25e1d14d477899a38d8b57ca887.tar.bz2
cc: Throttle tile priority updates to once a frame.
The tile priority updates happen when calcDrawProperties is called. Now we make sure we early out except in the following cases. On the pending tree, we calculate tile priorities: - Immediately after a commit, so that we can start raster jobs appropriately. - On an animation tick if it is not the same impl frame as the commit occured in. On the active tree, we calculate tile priorities: - During draw, if it is not in the same impl frame as the tree activation occured in. In that frame, we already have priorities from the pending tree. BUG=170807 Review URL: https://chromiumcodereview.appspot.com/12045086 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179079 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/damage_tracker_unittest.cc2
-rw-r--r--cc/layer_impl.h3
-rw-r--r--cc/layer_tree_host_common.cc31
-rw-r--r--cc/layer_tree_host_common.h21
-rw-r--r--cc/layer_tree_host_common_unittest.cc36
-rw-r--r--cc/layer_tree_host_impl.cc8
-rw-r--r--cc/layer_tree_impl.cc20
-rw-r--r--cc/layer_tree_impl.h8
-rw-r--r--cc/occlusion_tracker_unittest.cc2
-rw-r--r--cc/picture_layer_impl.cc37
-rw-r--r--cc/picture_layer_impl.h5
11 files changed, 119 insertions, 54 deletions
diff --git a/cc/damage_tracker_unittest.cc b/cc/damage_tracker_unittest.cc
index 74408c3d..034291b 100644
--- a/cc/damage_tracker_unittest.cc
+++ b/cc/damage_tracker_unittest.cc
@@ -32,7 +32,7 @@ void executeCalculateDrawProperties(LayerImpl* root, std::vector<LayerImpl*>& re
ASSERT_TRUE(root->renderSurface());
ASSERT_FALSE(renderSurfaceLayerList.size());
- LayerTreeHostCommon::calculateDrawProperties(root, root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawProperties(root, root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false);
}
void clearDamageForAllSurfaces(LayerImpl* layer)
diff --git a/cc/layer_impl.h b/cc/layer_impl.h
index c05fb553..b02db83 100644
--- a/cc/layer_impl.h
+++ b/cc/layer_impl.h
@@ -107,6 +107,8 @@ public:
virtual RenderPass::Id firstContributingRenderPassId() const;
virtual RenderPass::Id nextContributingRenderPassId(RenderPass::Id) const;
+ virtual void updateTilePriorities() { }
+
virtual ScrollbarLayerImpl* toScrollbarLayer();
// Returns true if this layer has content to draw.
@@ -278,7 +280,6 @@ public:
virtual Region visibleContentOpaqueRegion() const;
- virtual void didUpdateTransforms() { }
virtual void didBecomeActive();
// Indicates that the surface previously used to render this layer
diff --git a/cc/layer_tree_host_common.cc b/cc/layer_tree_host_common.cc
index 7c559b7..bffc7db 100644
--- a/cc/layer_tree_host_common.cc
+++ b/cc/layer_tree_host_common.cc
@@ -235,22 +235,19 @@ static inline bool subtreeShouldBeSkipped(Layer* layer)
// Called on each layer that could be drawn after all information from
// calcDrawProperties has been updated on that layer. May have some false
// positives (e.g. layers get this called on them but don't actually get drawn).
-static inline void markLayerAsUpdated(LayerImpl* layer)
+static inline void updateTilePrioritiesForLayer(LayerImpl* layer)
{
- layer->didUpdateTransforms();
+ layer->updateTilePriorities();
// Mask layers don't get this call, so explicitly update them so they can
// kick off tile rasterization.
if (layer->maskLayer())
- layer->maskLayer()->didUpdateTransforms();
- if (layer->replicaLayer()) {
- layer->replicaLayer()->didUpdateTransforms();
- if (layer->replicaLayer()->maskLayer())
- layer->replicaLayer()->maskLayer()->didUpdateTransforms();
- }
+ layer->maskLayer()->updateTilePriorities();
+ if (layer->replicaLayer() && layer->replicaLayer()->maskLayer())
+ layer->replicaLayer()->maskLayer()->updateTilePriorities();
}
-static inline void markLayerAsUpdated(Layer* layer)
+static inline void updateTilePrioritiesForLayer(Layer* layer)
{
}
@@ -534,7 +531,7 @@ static void calculateDrawPropertiesInternal(LayerType* layer, const gfx::Transfo
const gfx::Rect& clipRectFromAncestor, const gfx::Rect& clipRectFromAncestorInDescendantSpace, bool ancestorClipsSubtree,
RenderSurfaceType* nearestAncestorThatMovesPixels, LayerList& renderSurfaceLayerList, LayerList& layerList,
LayerSorter* layerSorter, int maxTextureSize, float deviceScaleFactor, float pageScaleFactor, bool subtreeCanUseLCDText,
- gfx::Rect& drawableContentRectOfSubtree)
+ gfx::Rect& drawableContentRectOfSubtree, bool updateTilePriorities)
{
// This function computes the new matrix transformations recursively for this
// layer and all its descendants. It also computes the appropriate render surfaces.
@@ -880,7 +877,7 @@ static void calculateDrawPropertiesInternal(LayerType* layer, const gfx::Transfo
calculateDrawPropertiesInternal<LayerType, LayerList, RenderSurfaceType>(child, sublayerMatrix, nextHierarchyMatrix, nextScrollCompensationMatrix,
clipRectForSubtree, clipRectForSubtreeInDescendantSpace, subtreeShouldBeClipped, nearestAncestorThatMovesPixels,
renderSurfaceLayerList, descendants, layerSorter, maxTextureSize, deviceScaleFactor, pageScaleFactor,
- subtreeCanUseLCDText, drawableContentRectOfChildSubtree);
+ subtreeCanUseLCDText, drawableContentRectOfChildSubtree, updateTilePriorities);
if (!drawableContentRectOfChildSubtree.IsEmpty()) {
accumulatedDrawableContentRectOfChildren.Union(drawableContentRectOfChildSubtree);
if (child->renderSurface())
@@ -980,7 +977,8 @@ static void calculateDrawPropertiesInternal(LayerType* layer, const gfx::Transfo
}
}
- markLayerAsUpdated(layer);
+ if (updateTilePriorities)
+ updateTilePrioritiesForLayer(layer);
// If neither this layer nor any of its children were added, early out.
if (sortingStartIndex == descendants.size())
@@ -1012,6 +1010,7 @@ void LayerTreeHostCommon::calculateDrawProperties(Layer* rootLayer, const gfx::S
// The root layer's renderSurface should receive the deviceViewport as the initial clipRect.
bool subtreeShouldBeClipped = true;
gfx::Rect deviceViewportRect(gfx::Point(), deviceViewportSize);
+ bool updateTilePriorities = false;
// This function should have received a root layer.
DCHECK(isRootLayer(rootLayer));
@@ -1021,7 +1020,8 @@ void LayerTreeHostCommon::calculateDrawProperties(Layer* rootLayer, const gfx::S
rootLayer, deviceScaleTransform, identityMatrix, identityMatrix,
deviceViewportRect, deviceViewportRect, subtreeShouldBeClipped, 0, renderSurfaceLayerList,
dummyLayerList, 0, maxTextureSize,
- deviceScaleFactor, pageScaleFactor, canUseLCDText, totalDrawableContentRect);
+ deviceScaleFactor, pageScaleFactor, canUseLCDText, totalDrawableContentRect,
+ updateTilePriorities);
// The dummy layer list should not have been used.
DCHECK(dummyLayerList.size() == 0);
@@ -1029,7 +1029,7 @@ void LayerTreeHostCommon::calculateDrawProperties(Layer* rootLayer, const gfx::S
DCHECK(rootLayer->renderSurface());
}
-void LayerTreeHostCommon::calculateDrawProperties(LayerImpl* rootLayer, const gfx::Size& deviceViewportSize, float deviceScaleFactor, float pageScaleFactor, int maxTextureSize, bool canUseLCDText, std::vector<LayerImpl*>& renderSurfaceLayerList)
+void LayerTreeHostCommon::calculateDrawProperties(LayerImpl* rootLayer, const gfx::Size& deviceViewportSize, float deviceScaleFactor, float pageScaleFactor, int maxTextureSize, bool canUseLCDText, std::vector<LayerImpl*>& renderSurfaceLayerList, bool updateTilePriorities)
{
gfx::Rect totalDrawableContentRect;
gfx::Transform identityMatrix;
@@ -1050,7 +1050,8 @@ void LayerTreeHostCommon::calculateDrawProperties(LayerImpl* rootLayer, const gf
rootLayer, deviceScaleTransform, identityMatrix, identityMatrix,
deviceViewportRect, deviceViewportRect, subtreeShouldBeClipped, 0, renderSurfaceLayerList,
dummyLayerList, &layerSorter, maxTextureSize,
- deviceScaleFactor, pageScaleFactor, canUseLCDText, totalDrawableContentRect);
+ deviceScaleFactor, pageScaleFactor, canUseLCDText, totalDrawableContentRect,
+ updateTilePriorities);
// The dummy layer list should not have been used.
DCHECK(dummyLayerList.size() == 0);
diff --git a/cc/layer_tree_host_common.h b/cc/layer_tree_host_common.h
index d91eecc..8d8e5d9 100644
--- a/cc/layer_tree_host_common.h
+++ b/cc/layer_tree_host_common.h
@@ -22,7 +22,7 @@ public:
static gfx::Rect calculateVisibleRect(const gfx::Rect& targetSurfaceRect, const gfx::Rect& layerBoundRect, const gfx::Transform&);
static void calculateDrawProperties(Layer* rootLayer, const gfx::Size& deviceViewportSize, float deviceScaleFactor, float pageScaleFactor, int maxTextureSize, bool canUseLCDText, std::vector<scoped_refptr<Layer> >& renderSurfaceLayerList);
- static void calculateDrawProperties(LayerImpl* rootLayer, const gfx::Size& deviceViewportSize, float deviceScaleFactor, float pageScaleFactor, int maxTextureSize, bool canUseLCDText, std::vector<LayerImpl*>& renderSurfaceLayerList);
+ static void calculateDrawProperties(LayerImpl* rootLayer, const gfx::Size& deviceViewportSize, float deviceScaleFactor, float pageScaleFactor, int maxTextureSize, bool canUseLCDText, std::vector<LayerImpl*>& renderSurfaceLayerList, bool updateTilePriorities);
// Performs hit testing for a given renderSurfaceLayerList.
static LayerImpl* findLayerThatIsHitByPoint(const gfx::PointF& screenSpacePoint, const std::vector<LayerImpl*>& renderSurfaceLayerList);
@@ -33,6 +33,8 @@ public:
template<typename LayerType> static bool renderSurfaceContributesToTarget(LayerType*, int targetSurfaceLayerID);
+ template<class Function, typename LayerType> static void callFunctionForSubtree(LayerType* rootLayer);
+
// Returns a layer with the given id if one exists in the subtree starting
// from the given root layer (including mask and replica layers).
template<typename LayerType> static LayerType* findLayerInSubtree(LayerType* rootLayer, int layerId);
@@ -94,6 +96,23 @@ LayerType* LayerTreeHostCommon::findLayerInSubtree(LayerType* rootLayer, int lay
return 0;
}
+template<class Function, typename LayerType>
+void LayerTreeHostCommon::callFunctionForSubtree(LayerType* rootLayer)
+{
+ Function()(rootLayer);
+
+ if (LayerType* maskLayer = rootLayer->maskLayer())
+ Function()(maskLayer);
+ if (LayerType* replicaLayer = rootLayer->replicaLayer()) {
+ Function()(replicaLayer);
+ if (LayerType* maskLayer = replicaLayer->maskLayer())
+ Function()(maskLayer);
+ }
+
+ for (size_t i = 0; i < rootLayer->children().size(); ++i)
+ callFunctionForSubtree<Function>(getChildAsRawPtr(rootLayer->children(), i));
+}
+
} // namespace cc
#endif // CC_LAYER_TREE_HOST_COMMON_H_
diff --git a/cc/layer_tree_host_common_unittest.cc b/cc/layer_tree_host_common_unittest.cc
index 27c7e6c..587f9e5 100644
--- a/cc/layer_tree_host_common_unittest.cc
+++ b/cc/layer_tree_host_common_unittest.cc
@@ -70,7 +70,7 @@ void executeCalculateDrawProperties(LayerImpl* rootLayer, float deviceScaleFacto
// We are probably not testing what is intended if the rootLayer bounds are empty.
DCHECK(!rootLayer->bounds().IsEmpty());
- LayerTreeHostCommon::calculateDrawProperties(rootLayer, deviceViewportSize, deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, canUseLCDText, dummyRenderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawProperties(rootLayer, deviceViewportSize, deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, canUseLCDText, dummyRenderSurfaceLayerList, false);
}
scoped_ptr<LayerImpl> createTreeForFixedPositionTests(LayerTreeHostImpl* hostImpl)
@@ -2916,7 +2916,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayer)
std::vector<LayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false);
// Sanity check the scenario we just created.
ASSERT_EQ(1u, renderSurfaceLayerList.size());
@@ -2965,7 +2965,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform)
std::vector<LayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false);
// Sanity check the scenario we just created.
ASSERT_EQ(1u, renderSurfaceLayerList.size());
@@ -3019,7 +3019,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePositionedLayer)
std::vector<LayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false);
// Sanity check the scenario we just created.
ASSERT_EQ(1u, renderSurfaceLayerList.size());
@@ -3066,7 +3066,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleRotatedLayer)
std::vector<LayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false);
// Sanity check the scenario we just created.
ASSERT_EQ(1u, renderSurfaceLayerList.size());
@@ -3122,7 +3122,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePerspectiveLayer)
std::vector<LayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false);
// Sanity check the scenario we just created.
ASSERT_EQ(1u, renderSurfaceLayerList.size());
@@ -3187,7 +3187,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayerWithScaledContents)
std::vector<LayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false);
// Sanity check the scenario we just created.
// The visibleContentRect for testLayer is actually 100x100, even though its layout size is 50x50, positioned at 25x25.
@@ -3251,7 +3251,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSimpleClippedLayer)
std::vector<LayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false);
// Sanity check the scenario we just created.
ASSERT_EQ(1u, renderSurfaceLayerList.size());
@@ -3341,7 +3341,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForMultiClippedRotatedLayer)
std::vector<LayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false);
// Sanity check the scenario we just created.
// The grandChild is expected to create a renderSurface because it masksToBounds and is not axis aligned.
@@ -3423,7 +3423,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForNonClippingIntermediateLayer)
std::vector<LayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false);
// Sanity check the scenario we just created.
ASSERT_EQ(1u, renderSurfaceLayerList.size());
@@ -3503,7 +3503,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayers)
std::vector<LayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false);
// Sanity check the scenario we just created.
ASSERT_TRUE(child1);
@@ -3611,7 +3611,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayerLists)
std::vector<LayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false);
// Sanity check the scenario we just created.
ASSERT_TRUE(child1);
@@ -3697,7 +3697,7 @@ TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer
std::vector<LayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false);
// Sanity check the scenario we just created.
ASSERT_EQ(1u, renderSurfaceLayerList.size());
@@ -3763,7 +3763,7 @@ TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForUninvertibl
std::vector<LayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false);
// Sanity check the scenario we just created.
ASSERT_EQ(1u, renderSurfaceLayerList.size());
@@ -3819,7 +3819,7 @@ TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSinglePosit
std::vector<LayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false);
// Sanity check the scenario we just created.
ASSERT_EQ(1u, renderSurfaceLayerList.size());
@@ -3891,7 +3891,7 @@ TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer
std::vector<LayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false);
// Sanity check the scenario we just created.
// The visibleContentRect for testLayer is actually 100x100, even though its layout size is 50x50, positioned at 25x25.
@@ -3967,7 +3967,7 @@ TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer
pageScaleTransform.Scale(pageScaleFactor, pageScaleFactor);
root->setImplTransform(pageScaleTransform); // Applying the pageScaleFactor through implTransform.
gfx::Size scaledBoundsForRoot = gfx::ToCeiledSize(gfx::ScaleSize(root->bounds(), deviceScaleFactor * pageScaleFactor));
- LayerTreeHostCommon::calculateDrawProperties(root.get(), scaledBoundsForRoot, deviceScaleFactor, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawProperties(root.get(), scaledBoundsForRoot, deviceScaleFactor, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false);
// Sanity check the scenario we just created.
// The visibleContentRect for testLayer is actually 100x100, even though its layout size is 50x50, positioned at 25x25.
@@ -4051,7 +4051,7 @@ TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSimpleClipp
std::vector<LayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false);
// Sanity check the scenario we just created.
ASSERT_EQ(1u, renderSurfaceLayerList.size());
diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc
index 7dec266..1c60e7981 100644
--- a/cc/layer_tree_host_impl.cc
+++ b/cc/layer_tree_host_impl.cc
@@ -193,7 +193,7 @@ void LayerTreeHostImpl::commitComplete()
// more lazily when needed prior to drawing.
if (m_settings.implSidePainting) {
pendingTree()->set_needs_update_draw_properties();
- pendingTree()->UpdateDrawProperties();
+ pendingTree()->UpdateDrawProperties(LayerTreeImpl::UPDATE_PENDING_TREE);
} else {
activeTree()->set_needs_update_draw_properties();
}
@@ -650,7 +650,7 @@ bool LayerTreeHostImpl::prepareToDraw(FrameData& frame)
if (m_topControlsManager)
m_topControlsManager->UpdateDrawPositions();
- activeTree()->UpdateDrawProperties();
+ activeTree()->UpdateDrawProperties(LayerTreeImpl::UPDATE_ACTIVE_TREE_FOR_DRAW);
frame.renderSurfaceLayerList = &activeTree()->RenderSurfaceLayerList();
frame.renderPasses.clear();
@@ -934,7 +934,7 @@ void LayerTreeHostImpl::activatePendingTreeIfNeeded()
if (!pendingTree())
return;
- pendingTree()->UpdateDrawProperties();
+ pendingTree()->UpdateDrawProperties(LayerTreeImpl::UPDATE_PENDING_TREE);
// It's always fine to activate to an empty tree. Otherwise, only
// activate once all visible resources in pending tree are ready.
@@ -1161,7 +1161,7 @@ void LayerTreeHostImpl::setNeedsRedraw()
bool LayerTreeHostImpl::ensureRenderSurfaceLayerList()
{
- activeTree()->UpdateDrawProperties();
+ activeTree()->UpdateDrawProperties(LayerTreeImpl::UPDATE_ACTIVE_TREE);
return activeTree()->RenderSurfaceLayerList().size();
}
diff --git a/cc/layer_tree_impl.cc b/cc/layer_tree_impl.cc
index e57bc51..f7e59b4 100644
--- a/cc/layer_tree_impl.cc
+++ b/cc/layer_tree_impl.cc
@@ -121,9 +121,19 @@ void LayerTreeImpl::UpdateMaxScrollOffset() {
root_scroll_layer_->setMaxScrollOffset(gfx::ToFlooredVector2d(max_scroll));
}
-void LayerTreeImpl::UpdateDrawProperties() {
- if (!needs_update_draw_properties_)
+struct UpdateTilePrioritiesForLayer {
+ void operator()(LayerImpl *layer) {
+ layer->updateTilePriorities();
+ }
+};
+
+void LayerTreeImpl::UpdateDrawProperties(UpdateDrawPropertiesReason reason) {
+ if (!needs_update_draw_properties_) {
+ if (reason == UPDATE_ACTIVE_TREE_FOR_DRAW && RootLayer())
+ LayerTreeHostCommon::callFunctionForSubtree<UpdateTilePrioritiesForLayer>(
+ RootLayer());
return;
+ }
needs_update_draw_properties_ = false;
render_surface_layer_list_.clear();
@@ -144,6 +154,9 @@ void LayerTreeImpl::UpdateDrawProperties() {
{
TRACE_EVENT1("cc", "LayerTreeImpl::UpdateDrawProperties", "IsActive", IsActiveTree());
+ bool update_tile_priorities =
+ reason == UPDATE_PENDING_TREE ||
+ reason == UPDATE_ACTIVE_TREE_FOR_DRAW;
LayerTreeHostCommon::calculateDrawProperties(
RootLayer(),
device_viewport_size(),
@@ -151,7 +164,8 @@ void LayerTreeImpl::UpdateDrawProperties() {
pinch_zoom_viewport().total_page_scale_factor(),
MaxTextureSize(),
settings().canUseLCDText,
- render_surface_layer_list_);
+ render_surface_layer_list_,
+ update_tile_priorities);
}
DCHECK(!needs_update_draw_properties_) <<
diff --git a/cc/layer_tree_impl.h b/cc/layer_tree_impl.h
index d212aac..31d5a67 100644
--- a/cc/layer_tree_impl.h
+++ b/cc/layer_tree_impl.h
@@ -112,8 +112,14 @@ class CC_EXPORT LayerTreeImpl {
has_transparent_background_ = transparent;
}
+ enum UpdateDrawPropertiesReason {
+ UPDATE_PENDING_TREE,
+ UPDATE_ACTIVE_TREE,
+ UPDATE_ACTIVE_TREE_FOR_DRAW
+ };
+
// Updates draw properties and render surface layer list
- void UpdateDrawProperties();
+ void UpdateDrawProperties(UpdateDrawPropertiesReason reason);
void set_needs_update_draw_properties() {
needs_update_draw_properties_ = true;
}
diff --git a/cc/occlusion_tracker_unittest.cc b/cc/occlusion_tracker_unittest.cc
index 494c05e..0065401 100644
--- a/cc/occlusion_tracker_unittest.cc
+++ b/cc/occlusion_tracker_unittest.cc
@@ -277,7 +277,7 @@ protected:
DCHECK(!root->renderSurface());
- LayerTreeHostCommon::calculateDrawProperties(root, root->bounds(), 1, 1, dummyMaxTextureSize, false, m_renderSurfaceLayerListImpl);
+ LayerTreeHostCommon::calculateDrawProperties(root, root->bounds(), 1, 1, dummyMaxTextureSize, false, m_renderSurfaceLayerListImpl, false);
m_layerIterator = m_layerIteratorBegin = Types::TestLayerIterator::begin(&m_renderSurfaceLayerListImpl);
}
diff --git a/cc/picture_layer_impl.cc b/cc/picture_layer_impl.cc
index 97a79f4..22d0653 100644
--- a/cc/picture_layer_impl.cc
+++ b/cc/picture_layer_impl.cc
@@ -27,7 +27,8 @@ namespace cc {
PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* treeImpl, int id)
: LayerImpl(treeImpl, id),
pile_(PicturePileImpl::Create()),
- last_update_time_(0),
+ last_source_frame_number_(0),
+ last_impl_frame_time_(0),
last_content_scale_(0),
ideal_contents_scale_(0),
is_mask_(false) {
@@ -66,6 +67,10 @@ void PictureLayerImpl::pushPropertiesTo(LayerImpl* base_layer) {
layer_impl->SetIsMask(is_mask_);
layer_impl->TransferTilingSet(tilings_.Pass());
layer_impl->pile_ = pile_;
+ // Sync over the last source frame number so the active tree does not respond
+ // to the source frame number changing in its tree.
+ layer_impl->last_source_frame_number_ = last_source_frame_number_;
+ layer_impl->last_impl_frame_time_ = last_impl_frame_time_;
pile_ = PicturePileImpl::Create();
pile_->set_slow_down_raster_scale_factor(
layerTreeImpl()->debug_state().slowDownRasterScaleFactor);
@@ -197,16 +202,33 @@ void PictureLayerImpl::dumpLayerProperties(std::string*, int indent) const {
// TODO(enne): implement me
}
-void PictureLayerImpl::didUpdateTransforms() {
+void PictureLayerImpl::updateTilePriorities() {
+ int current_source_frame_number = layerTreeImpl()->source_frame_number();
+ bool first_update_in_new_source_frame =
+ current_source_frame_number != last_source_frame_number_;
+
+ double current_frame_time =
+ (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF();
+ bool first_update_in_new_impl_frame =
+ current_frame_time != last_impl_frame_time_;
+
+ // In pending tree, this is always called. We update priorities:
+ // - Immediately after a commit (first_update_in_new_source_frame).
+ // - On animation ticks after the first frame in the tree
+ // (first_update_in_new_impl_frame).
+ // In active tree, this is only called during draw. We update priorities:
+ // - On draw if properties were not already computed by the pending tree
+ // and activated for the frame (first_update_in_new_impl_frame).
+ if (!first_update_in_new_impl_frame && !first_update_in_new_source_frame)
+ return;
+
gfx::Transform current_screen_space_transform =
screenSpaceTransform();
- double current_time =
- (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF();
double time_delta = 0;
- if (last_update_time_ != 0 && last_bounds_ == bounds() &&
+ if (last_impl_frame_time_ != 0 && last_bounds_ == bounds() &&
last_content_bounds_ == contentBounds() &&
last_content_scale_ == contentsScaleX()) {
- time_delta = current_time - last_update_time_;
+ time_delta = current_frame_time - last_impl_frame_time_;
}
WhichTree tree = layerTreeImpl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE;
tilings_->UpdateTilePriorities(
@@ -218,8 +240,9 @@ void PictureLayerImpl::didUpdateTransforms() {
current_screen_space_transform,
time_delta);
+ last_source_frame_number_ = current_source_frame_number;
last_screen_space_transform_ = current_screen_space_transform;
- last_update_time_ = current_time;
+ last_impl_frame_time_ = current_frame_time;
last_bounds_ = bounds();
last_content_bounds_ = contentBounds();
last_content_scale_ = contentsScaleX();
diff --git a/cc/picture_layer_impl.h b/cc/picture_layer_impl.h
index 6456ee3..1367335 100644
--- a/cc/picture_layer_impl.h
+++ b/cc/picture_layer_impl.h
@@ -34,7 +34,7 @@ public:
virtual void pushPropertiesTo(LayerImpl* layer) OVERRIDE;
virtual void appendQuads(QuadSink&, AppendQuadsData&) OVERRIDE;
virtual void dumpLayerProperties(std::string*, int indent) const OVERRIDE;
- virtual void didUpdateTransforms() OVERRIDE;
+ virtual void updateTilePriorities() OVERRIDE;
virtual void didBecomeActive() OVERRIDE;
virtual void didLoseOutputSurface() OVERRIDE;
virtual void calculateContentsScale(
@@ -76,8 +76,9 @@ protected:
scoped_refptr<PicturePileImpl> pile_;
Region invalidation_;
+ int last_source_frame_number_;
gfx::Transform last_screen_space_transform_;
- double last_update_time_;
+ double last_impl_frame_time_;
gfx::Size last_bounds_;
gfx::Size last_content_bounds_;
float last_content_scale_;