summaryrefslogtreecommitdiffstats
path: root/cc/trees/layer_tree_host_common.cc
diff options
context:
space:
mode:
authorweiliangc <weiliangc@chromium.org>2016-02-18 17:38:49 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-19 01:40:35 +0000
commit15346d2c3c89c3496f310f17079e0382489ecb10 (patch)
treec9a9e3e9e3c5f3d944cb700dfd4257dd4894cbef /cc/trees/layer_tree_host_common.cc
parent3898d506818649c772175ea95bcdf9a7ee9bbadc (diff)
downloadchromium_src-15346d2c3c89c3496f310f17079e0382489ecb10.zip
chromium_src-15346d2c3c89c3496f310f17079e0382489ecb10.tar.gz
chromium_src-15346d2c3c89c3496f310f17079e0382489ecb10.tar.bz2
Delete CalcDrawProps
We always use property trees. Delete CalcDrawProps. Delete |use_property_trees| because it's always true. Delete |verify_property_trees| because we don't have CDP to verify against. R=enne, piman, ajuma, vollick, dtrainor BUG=581832 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1706903002 Cr-Commit-Position: refs/heads/master@{#376337}
Diffstat (limited to 'cc/trees/layer_tree_host_common.cc')
-rw-r--r--cc/trees/layer_tree_host_common.cc1541
1 files changed, 165 insertions, 1376 deletions
diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc
index 489a9e9..c8baceb 100644
--- a/cc/trees/layer_tree_host_common.cc
+++ b/cc/trees/layer_tree_host_common.cc
@@ -82,8 +82,6 @@ LayerTreeHostCommon::CalcDrawPropsImplInputs::CalcDrawPropsImplInputs(
bool layers_always_allowed_lcd_text,
bool can_render_to_separate_surface,
bool can_adjust_raster_scales,
- bool verify_property_trees,
- bool use_property_trees,
LayerImplList* render_surface_layer_list,
int current_render_surface_layer_list_id,
PropertyTrees* property_trees)
@@ -103,8 +101,6 @@ LayerTreeHostCommon::CalcDrawPropsImplInputs::CalcDrawPropsImplInputs(
layers_always_allowed_lcd_text(layers_always_allowed_lcd_text),
can_render_to_separate_surface(can_render_to_separate_surface),
can_adjust_raster_scales(can_adjust_raster_scales),
- verify_property_trees(verify_property_trees),
- use_property_trees(use_property_trees),
render_surface_layer_list(render_surface_layer_list),
current_render_surface_layer_list_id(
current_render_surface_layer_list_id),
@@ -131,8 +127,6 @@ LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting::
false,
true,
false,
- true,
- true,
render_surface_layer_list,
current_render_surface_layer_list_id,
GetPropertyTrees(root_layer)) {
@@ -201,36 +195,6 @@ void ScrollAndScaleSet::FromProtobuf(const proto::ScrollAndScaleSet& proto) {
top_controls_delta = proto.top_controls_delta();
}
-static gfx::Vector2dF GetEffectiveScrollDelta(LayerImpl* layer) {
- // Layer's scroll offset can have an integer part and fractional part.
- // Due to Blink's limitation, it only counter-scrolls the position-fixed
- // layer using the integer part of Layer's scroll offset.
- // CC scrolls the layer using the full scroll offset, so we have to
- // add the ScrollCompensationAdjustment (fractional part of the scroll
- // offset) to the effective scroll delta which is used to counter-scroll
- // the position-fixed layer.
- gfx::Vector2dF scroll_delta =
- layer->ScrollDelta() + layer->ScrollCompensationAdjustment();
- // The scroll parent's scroll delta is the amount we've scrolled on the
- // compositor thread since the commit for this layer tree's source frame.
- // we last reported to the main thread. I.e., it's the discrepancy between
- // a scroll parent's scroll delta and offset, so we must add it here.
- if (layer->scroll_parent())
- scroll_delta += layer->scroll_parent()->ScrollDelta() +
- layer->ScrollCompensationAdjustment();
- return scroll_delta;
-}
-
-static gfx::ScrollOffset GetEffectiveCurrentScrollOffset(LayerImpl* layer) {
- gfx::ScrollOffset offset = layer->CurrentScrollOffset();
- // The scroll parent's total scroll offset (scroll offset + scroll delta)
- // can't be used because its scroll offset has already been applied to the
- // scroll children's positions by the main thread layer positioning code.
- if (layer->scroll_parent())
- offset += gfx::ScrollOffset(layer->scroll_parent()->ScrollDelta());
- return offset;
-}
-
inline gfx::Rect CalculateVisibleRectWithCachedLayerRect(
const gfx::Rect& target_surface_rect,
const gfx::Rect& layer_bound_rect,
@@ -330,51 +294,6 @@ static gfx::Rect TranslateRectToTargetSpace(const LayerImpl& ancestor_layer,
gfx::RectF(rect_f.origin() + translation, rect_f.size()));
}
-// Attempts to update the clip rects for the given layer. If the layer has a
-// clip_parent, it may not inherit its immediate ancestor's clip.
-static void UpdateClipRectsForClipChild(
- const LayerImpl* layer,
- gfx::Rect* clip_rect_in_parent_target_space,
- bool* subtree_should_be_clipped) {
- // If the layer has no clip_parent, or the ancestor is the same as its actual
- // parent, then we don't need special clip rects. Bail now and leave the out
- // parameters untouched.
- const LayerImpl* clip_parent = layer->scroll_parent();
-
- if (!clip_parent)
- clip_parent = layer->clip_parent();
-
- if (!clip_parent || clip_parent == layer->parent())
- return;
-
- // The root layer is never a clip child.
- DCHECK(layer->parent());
-
- // Grab the cached values.
- *clip_rect_in_parent_target_space = clip_parent->clip_rect();
- *subtree_should_be_clipped = clip_parent->is_clipped();
-
- // We may have to project the clip rect into our parent's target space. Note,
- // it must be our parent's target space, not ours. For one, we haven't
- // computed our transforms, so we couldn't put it in our space yet even if we
- // wanted to. But more importantly, this matches the expectations of
- // CalculateDrawPropertiesInternal. If we, say, create a render surface, these
- // clip rects will want to be in its target space, not ours.
- if (clip_parent == layer->clip_parent()) {
- *clip_rect_in_parent_target_space = TranslateRectToTargetSpace(
- *clip_parent, *layer->parent(), *clip_rect_in_parent_target_space,
- TRANSLATE_RECT_DIRECTION_TO_DESCENDANT);
- } else {
- // If we're being clipped by our scroll parent, we must translate through
- // our common ancestor. This happens to be our parent, so it is sufficent to
- // translate from our clip parent's space to the space of its ancestor (our
- // parent).
- *clip_rect_in_parent_target_space = TranslateRectToTargetSpace(
- *layer->parent(), *clip_parent, *clip_rect_in_parent_target_space,
- TRANSLATE_RECT_DIRECTION_TO_ANCESTOR);
- }
-}
-
// We collect an accumulated drawable content rect per render surface.
// Typically, a layer will contribute to only one surface, the surface
// associated with its render target. Clip children, however, may affect
@@ -497,7 +416,6 @@ static bool IsRootLayerOfNewRenderingContext(LayerImpl* layer) {
}
static bool IsLayerBackFaceVisible(LayerImpl* layer,
- bool use_property_trees,
const TransformTree& transform_tree) {
// The current W3C spec on CSS transforms says that backface visibility should
// be determined differently depending on whether the layer is in a "3d
@@ -505,13 +423,8 @@ static bool IsLayerBackFaceVisible(LayerImpl* layer,
// are in a 3d rendering context by checking if the parent preserves 3d.
if (LayerIsInExisting3DRenderingContext(layer)) {
- if (use_property_trees) {
- return DrawTransformFromPropertyTrees(layer, transform_tree)
- .IsBackFaceVisible();
- } else {
- return layer->draw_properties()
- .target_space_transform.IsBackFaceVisible();
- }
+ return DrawTransformFromPropertyTrees(layer, transform_tree)
+ .IsBackFaceVisible();
}
// In this case, either the layer establishes a new 3d rendering context, or
@@ -538,51 +451,8 @@ static inline bool LayerClipsSubtree(LayerType* layer) {
return layer->masks_to_bounds() || layer->mask_layer();
}
-static gfx::Rect CalculateVisibleLayerRect(
- LayerImpl* layer,
- const gfx::Rect& clip_rect_of_target_surface_in_target_space,
- const gfx::Rect& layer_rect_in_target_space) {
- DCHECK(layer->render_target());
-
- // Nothing is visible if the layer bounds are empty.
- if (!layer->DrawsContent() || layer->bounds().IsEmpty() ||
- layer->drawable_content_rect().IsEmpty())
- return gfx::Rect();
-
- // The layer is fully visible if it has copy requests.
- if (layer->HasCopyRequest())
- return gfx::Rect(layer->bounds());
-
- // Compute visible bounds in target surface space.
- gfx::Rect visible_rect_in_target_surface_space =
- layer->drawable_content_rect();
-
- if (layer->render_target()->render_surface()->is_clipped()) {
- // The |layer| L has a target T which owns a surface Ts. The surface Ts
- // has a target TsT.
- //
- // In this case the target surface Ts does clip the layer L that contributes
- // to it. So, we have to convert the clip rect of Ts from the target space
- // of Ts (that is the space of TsT), to the current render target's space
- // (that is the space of T). This conversion is done outside this function
- // so that it can be cached instead of computing it redundantly for every
- // layer.
- visible_rect_in_target_surface_space.Intersect(
- clip_rect_of_target_surface_in_target_space);
- }
-
- if (visible_rect_in_target_surface_space.IsEmpty())
- return gfx::Rect();
-
- return CalculateVisibleRectWithCachedLayerRect(
- visible_rect_in_target_surface_space, gfx::Rect(layer->bounds()),
- layer_rect_in_target_space,
- layer->draw_properties().target_space_transform);
-}
-
static bool LayerShouldBeSkipped(LayerImpl* layer,
bool layer_is_drawn,
- bool use_property_trees,
const TransformTree& transform_tree) {
// Layers can be skipped if any of these conditions are met.
// - is not drawn due to it or one of its ancestors being hidden (or having
@@ -617,8 +487,7 @@ static bool LayerShouldBeSkipped(LayerImpl* layer,
// The layer should not be drawn if (1) it is not double-sided and (2) the
// back of the layer is known to be facing the screen.
if (!backface_test_layer->double_sided() &&
- IsLayerBackFaceVisible(backface_test_layer, use_property_trees,
- transform_tree))
+ IsLayerBackFaceVisible(backface_test_layer, transform_tree))
return true;
return false;
@@ -671,8 +540,6 @@ static inline bool SubtreeShouldBeSkipped(LayerImpl* layer,
return !layer->EffectiveOpacity();
}
-static inline void SavePaintPropertiesLayer(LayerImpl* layer) {}
-
// This function returns a translation matrix that can be applied on a vector
// that's in the layer's target surface coordinate, while the position offset is
// specified in some ancestor layer's coordinate.
@@ -895,106 +762,6 @@ gfx::Transform ComputeScrollCompensationMatrixForChildren(
return next_scroll_compensation_matrix;
}
-static inline void UpdateLayerScaleDrawProperties(
- LayerImpl* layer,
- float maximum_animation_contents_scale,
- float starting_animation_contents_scale) {
- layer->draw_properties().maximum_animation_contents_scale =
- maximum_animation_contents_scale;
- layer->draw_properties().starting_animation_contents_scale =
- starting_animation_contents_scale;
-}
-
-static inline void CalculateAnimationContentsScale(
- LayerImpl* layer,
- bool ancestor_is_animating_scale,
- float ancestor_maximum_animation_contents_scale,
- float ancestor_starting_animation_contents_scale,
- const gfx::Transform& ancestor_transform,
- const gfx::Transform& combined_transform,
- bool* combined_is_animating_scale,
- float* combined_maximum_animation_contents_scale,
- float* combined_starting_animation_contents_scale) {
- if (ancestor_is_animating_scale &&
- ancestor_maximum_animation_contents_scale == 0.f) {
- // We've already failed to compute a maximum animated scale at an
- // ancestor, so we'll continue to fail.
- *combined_maximum_animation_contents_scale = 0.f;
- *combined_starting_animation_contents_scale = 0.f;
- *combined_is_animating_scale = true;
- return;
- }
-
- if (!combined_transform.IsScaleOrTranslation()) {
- // Computing maximum animated scale in the presence of
- // non-scale/translation transforms isn't supported.
- *combined_maximum_animation_contents_scale = 0.f;
- *combined_starting_animation_contents_scale = 0.f;
- *combined_is_animating_scale = true;
- return;
- }
-
- // We currently only support computing maximum scale for combinations of
- // scales and translations. We treat all non-translations as potentially
- // affecting scale. Animations that include non-translation/scale components
- // will cause the computation of MaximumScale below to fail.
- bool layer_is_animating_scale = !layer->HasOnlyTranslationTransforms();
-
- if (!layer_is_animating_scale && !ancestor_is_animating_scale) {
- *combined_maximum_animation_contents_scale = 0.f;
- *combined_starting_animation_contents_scale = 0.f;
- *combined_is_animating_scale = false;
- return;
- }
-
- // We don't attempt to accumulate animation scale from multiple nodes,
- // because of the risk of significant overestimation. For example, one node
- // may be increasing scale from 1 to 10 at the same time as a descendant is
- // decreasing scale from 10 to 1. Naively combining these scales would produce
- // a scale of 100.
- if (layer_is_animating_scale && ancestor_is_animating_scale) {
- *combined_maximum_animation_contents_scale = 0.f;
- *combined_starting_animation_contents_scale = 0.f;
- *combined_is_animating_scale = true;
- return;
- }
-
- // At this point, we know either the layer or an ancestor, but not both,
- // is animating scale.
- *combined_is_animating_scale = true;
- if (!layer_is_animating_scale) {
- gfx::Vector2dF layer_transform_scales =
- MathUtil::ComputeTransform2dScaleComponents(layer->transform(), 0.f);
- float max_layer_scale =
- std::max(layer_transform_scales.x(), layer_transform_scales.y());
- *combined_maximum_animation_contents_scale =
- ancestor_maximum_animation_contents_scale * max_layer_scale;
- *combined_starting_animation_contents_scale =
- ancestor_starting_animation_contents_scale * max_layer_scale;
- return;
- }
-
- float layer_maximum_animated_scale = 0.f;
- float layer_start_animated_scale = 0.f;
- if (!layer->MaximumTargetScale(&layer_maximum_animated_scale)) {
- *combined_maximum_animation_contents_scale = 0.f;
- return;
- }
- if (!layer->AnimationStartScale(&layer_start_animated_scale)) {
- *combined_starting_animation_contents_scale = 0.f;
- return;
- }
-
- gfx::Vector2dF ancestor_transform_scales =
- MathUtil::ComputeTransform2dScaleComponents(ancestor_transform, 0.f);
- float max_scale_xy =
- std::max(ancestor_transform_scales.x(), ancestor_transform_scales.y());
- *combined_maximum_animation_contents_scale =
- layer_maximum_animated_scale * max_scale_xy;
- *combined_starting_animation_contents_scale =
- layer_start_animated_scale * max_scale_xy;
-}
-
static inline void MarkLayerWithRenderSurfaceLayerListId(
LayerImpl* layer,
int current_render_surface_layer_list_id) {
@@ -1321,26 +1088,6 @@ static void AddScrollParentChain(std::vector<LayerImpl*>* out,
child->set_sorted_for_recursion(sorted_for_recursion);
}
-static bool SortChildrenForRecursion(std::vector<LayerImpl*>* out,
- const LayerImpl& parent) {
- out->reserve(parent.children().size());
- bool order_changed = false;
- for (size_t i = 0; i < parent.children().size(); ++i) {
- LayerImpl* current =
- LayerTreeHostCommon::get_layer_as_raw_ptr(parent.children(), i);
-
- if (current->sorted_for_recursion()) {
- order_changed = true;
- continue;
- }
-
- AddScrollParentChain(out, parent, current);
- }
-
- DCHECK_EQ(parent.children().size(), out->size());
- return order_changed;
-}
-
static bool CdpPerfTracingEnabled() {
bool tracing_enabled;
TRACE_EVENT_CATEGORY_GROUP_ENABLED("cdp.perf", &tracing_enabled);
@@ -1371,775 +1118,6 @@ static float TranslationFromActiveTreeLayerScreenSpaceTransform(
return 0.f;
}
-// Recursively walks the layer tree starting at the given node and computes all
-// the necessary transformations, clip rects, render surfaces, etc.
-static void CalculateDrawPropertiesInternal(
- LayerImpl* layer,
- const SubtreeGlobals& globals,
- const DataForRecursion& data_from_ancestor,
- std::vector<AccumulatedSurfaceState>* accumulated_surface_state) {
- // This function computes the new matrix transformations recursively for this
- // layer and all its descendants. It also computes the appropriate render
- // surfaces.
- // Some important points to remember:
- //
- // 0. Here, transforms are notated in Matrix x Vector order, and in words we
- // describe what the transform does from left to right.
- //
- // 1. In our terminology, the "layer origin" refers to the top-left corner of
- // a layer, and the positive Y-axis points downwards. This interpretation is
- // valid because the orthographic projection applied at draw time flips the Y
- // axis appropriately.
- //
- // 2. The anchor point, when given as a PointF object, is specified in "unit
- // layer space", where the bounds of the layer map to [0, 1]. However, as a
- // Transform object, the transform to the anchor point is specified in "layer
- // space", where the bounds of the layer map to [bounds.width(),
- // bounds.height()].
- //
- // 3. Definition of various transforms used:
- // M[parent] is the parent matrix, with respect to the nearest render
- // surface, passed down recursively.
- //
- // M[root] is the full hierarchy, with respect to the root, passed down
- // recursively.
- //
- // Tr[origin] is the translation matrix from the parent's origin to
- // this layer's origin.
- //
- // Tr[origin2anchor] is the translation from the layer's origin to its
- // anchor point
- //
- // Tr[origin2center] is the translation from the layer's origin to its
- // center
- //
- // M[layer] is the layer's matrix (applied at the anchor point)
- //
- // S[layer2content] is the ratio of a layer's content_bounds() to its
- // Bounds().
- //
- // Some composite transforms can help in understanding the sequence of
- // transforms:
- // composite_layer_transform = Tr[origin2anchor] * M[layer] *
- // Tr[origin2anchor].inverse()
- //
- // 4. When a layer (or render surface) is drawn, it is drawn into a "target
- // render surface". Therefore the draw transform does not necessarily
- // transform from screen space to local layer space. Instead, the draw
- // transform is the transform between the "target render surface space" and
- // local layer space. Note that render surfaces, except for the root, also
- // draw themselves into a different target render surface, and so their draw
- // transform and origin transforms are also described with respect to the
- // target.
- //
- // Using these definitions, then:
- //
- // The draw transform for the layer is:
- // M[draw] = M[parent] * Tr[origin] * composite_layer_transform *
- // S[layer2content] = M[parent] * Tr[layer->position() + anchor] *
- // M[layer] * Tr[anchor2origin] * S[layer2content]
- //
- // Interpreting the math left-to-right, this transforms from the
- // layer's render surface to the origin of the layer in content space.
- //
- // The screen space transform is:
- // M[screenspace] = M[root] * Tr[origin] * composite_layer_transform *
- // S[layer2content]
- // = M[root] * Tr[layer->position() + anchor] * M[layer]
- // * Tr[anchor2origin] * S[layer2content]
- //
- // Interpreting the math left-to-right, this transforms from the root
- // render surface's content space to the origin of the layer in content
- // space.
- //
- // The transform hierarchy that is passed on to children (i.e. the child's
- // parent_matrix) is:
- // M[parent]_for_child = M[parent] * Tr[origin] *
- // composite_layer_transform
- // = M[parent] * Tr[layer->position() + anchor] *
- // M[layer] * Tr[anchor2origin]
- //
- // and a similar matrix for the full hierarchy with respect to the
- // root.
- //
- // Finally, note that the final matrix used by the shader for the layer is P *
- // M[draw] * S . This final product is computed in drawTexturedQuad(), where:
- // P is the projection matrix
- // S is the scale adjustment (to scale up a canonical quad to the
- // layer's size)
- //
- // When a render surface has a replica layer, that layer's transform is used
- // to draw a second copy of the surface. gfx::Transforms named here are
- // relative to the surface, unless they specify they are relative to the
- // replica layer.
- //
- // We will denote a scale by device scale S[deviceScale]
- //
- // The render surface draw transform to its target surface origin is:
- // M[surfaceDraw] = M[owningLayer->Draw]
- //
- // The render surface origin transform to its the root (screen space) origin
- // is:
- // M[surface2root] = M[owningLayer->screenspace] *
- // S[deviceScale].inverse()
- //
- // The replica draw transform to its target surface origin is:
- // M[replicaDraw] = S[deviceScale] * M[surfaceDraw] *
- // Tr[replica->position() + replica->anchor()] * Tr[replica] *
- // Tr[origin2anchor].inverse() * S[contents_scale].inverse()
- //
- // The replica draw transform to the root (screen space) origin is:
- // M[replica2root] = M[surface2root] * Tr[replica->position()] *
- // Tr[replica] * Tr[origin2anchor].inverse()
- //
-
- // It makes no sense to have a non-unit page_scale_factor without specifying
- // which layer roots the subtree the scale is applied to.
- DCHECK(globals.page_scale_layer || (globals.page_scale_factor == 1.f));
-
- CHECK(!layer->visited());
- bool visited = true;
- layer->set_visited(visited);
-
- DataForRecursion data_for_children;
- data_for_children.in_subtree_of_page_scale_layer =
- data_from_ancestor.in_subtree_of_page_scale_layer;
- data_for_children.subtree_can_use_lcd_text =
- data_from_ancestor.subtree_can_use_lcd_text;
-
- // Layers that are marked as hidden will hide themselves and their subtree.
- // Exception: Layers with copy requests, whether hidden or not, must be drawn
- // anyway. In this case, we will inform their subtree they are visible to get
- // the right results.
- const bool layer_is_visible =
- data_from_ancestor.subtree_is_visible_from_ancestor &&
- layer->EffectiveOpacity() != 0;
- const bool layer_is_drawn = layer_is_visible || layer->HasCopyRequest();
-
- // The root layer cannot skip CalcDrawProperties.
- if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_drawn)) {
- return;
- }
-
- // We need to circumvent the normal recursive flow of information for clip
- // children (they don't inherit their direct ancestor's clip information).
- // This is unfortunate, and would be unnecessary if we were to formally
- // separate the clipping hierarchy from the layer hierarchy.
- bool ancestor_clips_subtree = data_from_ancestor.ancestor_clips_subtree;
- gfx::Rect ancestor_clip_rect_in_target_space =
- data_from_ancestor.clip_rect_in_target_space;
-
- // Update our clipping state. If we have a clip parent we will need to pull
- // from the clip state cache rather than using the clip state passed from our
- // immediate ancestor.
- UpdateClipRectsForClipChild(layer, &ancestor_clip_rect_in_target_space,
- &ancestor_clips_subtree);
-
- // As this function proceeds, these are the properties for the current
- // layer that actually get computed. To avoid unnecessary copies
- // (particularly for matrices), we do computations directly on these values
- // when possible.
- DrawProperties& layer_draw_properties = layer->draw_properties();
-
- gfx::Rect clip_rect_in_target_space;
- bool layer_or_ancestor_clips_descendants = false;
-
- // This value is cached on the stack so that we don't have to inverse-project
- // the surface's clip rect redundantly for every layer. This value is the
- // same as the target surface's clip rect, except that instead of being
- // described in the target surface's target's space, it is described in the
- // current render target's space.
- gfx::Rect clip_rect_of_target_surface_in_target_space;
-
- float accumulated_draw_opacity = layer->opacity();
- if (layer->parent())
- accumulated_draw_opacity *= layer->parent()->draw_opacity();
-
- bool animating_transform_to_screen =
- layer->HasPotentiallyRunningTransformAnimation();
- if (layer->parent()) {
- animating_transform_to_screen |=
- layer->parent()->screen_space_transform_is_animating();
- }
- gfx::Point3F transform_origin = layer->transform_origin();
- gfx::ScrollOffset scroll_offset = GetEffectiveCurrentScrollOffset(layer);
- gfx::PointF position =
- layer->position() - ScrollOffsetToVector2dF(scroll_offset);
- gfx::Transform combined_transform = data_from_ancestor.parent_matrix;
- if (!layer->transform().IsIdentity()) {
- // LT = Tr[origin] * Tr[origin2transformOrigin]
- combined_transform.Translate3d(position.x() + transform_origin.x(),
- position.y() + transform_origin.y(),
- transform_origin.z());
- // LT = Tr[origin] * Tr[origin2origin] * M[layer]
- combined_transform.PreconcatTransform(layer->transform());
- // LT = Tr[origin] * Tr[origin2origin] * M[layer] *
- // Tr[transformOrigin2origin]
- combined_transform.Translate3d(
- -transform_origin.x(), -transform_origin.y(), -transform_origin.z());
- } else {
- combined_transform.Translate(position.x(), position.y());
- }
-
- gfx::Vector2dF effective_scroll_delta = GetEffectiveScrollDelta(layer);
- if (!animating_transform_to_screen && layer->scrollable() &&
- combined_transform.IsScaleOrTranslation()) {
- // Align the scrollable layer's position to screen space pixels to avoid
- // blurriness. To avoid side-effects, do this only if the transform is
- // simple.
- gfx::Vector2dF previous_translation = combined_transform.To2dTranslation();
- combined_transform.RoundTranslationComponents();
- gfx::Vector2dF current_translation = combined_transform.To2dTranslation();
-
- // This rounding changes the scroll delta, and so must be included
- // in the scroll compensation matrix. The scaling converts from physical
- // coordinates to the scroll delta's CSS coordinates (using the parent
- // matrix instead of combined transform since scrolling is applied before
- // the layer's transform). For example, if we have a total scale factor of
- // 3.0, then 1 physical pixel is only 1/3 of a CSS pixel.
- gfx::Vector2dF parent_scales = MathUtil::ComputeTransform2dScaleComponents(
- data_from_ancestor.parent_matrix, 1.f);
- effective_scroll_delta -=
- gfx::ScaleVector2d(current_translation - previous_translation,
- 1.f / parent_scales.x(),
- 1.f / parent_scales.y());
- }
-
- // Apply adjustment from position constraints.
- ApplyPositionAdjustment(layer, data_from_ancestor.fixed_container,
- data_from_ancestor.scroll_compensation_matrix, &combined_transform);
-
- bool combined_is_animating_scale = false;
- float combined_maximum_animation_contents_scale = 0.f;
- float combined_starting_animation_contents_scale = 0.f;
- if (globals.can_adjust_raster_scales) {
- CalculateAnimationContentsScale(
- layer, data_from_ancestor.ancestor_is_animating_scale,
- data_from_ancestor.maximum_animation_contents_scale,
- data_from_ancestor.starting_animation_contents_scale,
- data_from_ancestor.parent_matrix, combined_transform,
- &combined_is_animating_scale,
- &combined_maximum_animation_contents_scale,
- &combined_starting_animation_contents_scale);
- }
- data_for_children.ancestor_is_animating_scale = combined_is_animating_scale;
- data_for_children.maximum_animation_contents_scale =
- combined_maximum_animation_contents_scale;
- data_for_children.starting_animation_contents_scale =
- combined_starting_animation_contents_scale;
-
- // Compute the 2d scale components of the transform hierarchy up to the target
- // surface. From there, we can decide on a contents scale for the layer.
- float layer_scale_factors = globals.device_scale_factor;
- if (data_from_ancestor.in_subtree_of_page_scale_layer)
- layer_scale_factors *= globals.page_scale_factor;
- gfx::Vector2dF combined_transform_scales =
- MathUtil::ComputeTransform2dScaleComponents(
- combined_transform,
- layer_scale_factors);
-
- UpdateLayerScaleDrawProperties(layer,
- combined_maximum_animation_contents_scale,
- combined_starting_animation_contents_scale);
-
- LayerImpl* mask_layer = layer->mask_layer();
- if (mask_layer) {
- UpdateLayerScaleDrawProperties(mask_layer,
- combined_maximum_animation_contents_scale,
- combined_starting_animation_contents_scale);
- }
-
- LayerImpl* replica_mask_layer =
- layer->replica_layer() ? layer->replica_layer()->mask_layer() : NULL;
- if (replica_mask_layer) {
- UpdateLayerScaleDrawProperties(replica_mask_layer,
- combined_maximum_animation_contents_scale,
- combined_starting_animation_contents_scale);
- }
-
- if (layer == globals.page_scale_layer) {
- combined_transform.Scale(globals.page_scale_factor,
- globals.page_scale_factor);
- data_for_children.in_subtree_of_page_scale_layer = true;
- }
-
- // The draw_transform that gets computed below is effectively the layer's
- // draw_transform, unless the layer itself creates a render_surface. In that
- // case, the render_surface re-parents the transforms.
- layer_draw_properties.target_space_transform = combined_transform;
-
- // The layer's screen_space_transform represents the transform between root
- // layer's "screen space" and local content space.
- layer_draw_properties.screen_space_transform =
- data_from_ancestor.full_hierarchy_matrix;
- layer_draw_properties.screen_space_transform.PreconcatTransform
- (layer_draw_properties.target_space_transform);
-
- bool layer_can_use_lcd_text = true;
- bool subtree_can_use_lcd_text = true;
- if (!globals.layers_always_allowed_lcd_text) {
- // To avoid color fringing, LCD text should only be used on opaque layers
- // with just integral translation.
- subtree_can_use_lcd_text = data_from_ancestor.subtree_can_use_lcd_text &&
- accumulated_draw_opacity == 1.f &&
- layer_draw_properties.target_space_transform
- .IsIdentityOrIntegerTranslation();
- // Also disable LCD text locally for non-opaque content.
- layer_can_use_lcd_text = subtree_can_use_lcd_text &&
- layer->contents_opaque();
- }
-
- // full_hierarchy_matrix is the matrix that transforms objects between screen
- // space (except projection matrix) and the most recent RenderSurfaceImpl's
- // space. next_hierarchy_matrix will only change if this layer uses a new
- // RenderSurfaceImpl, otherwise remains the same.
- data_for_children.full_hierarchy_matrix =
- data_from_ancestor.full_hierarchy_matrix;
-
- bool render_to_separate_surface =
- IsRootLayer(layer) ||
- (globals.can_render_to_separate_surface && layer->render_surface());
-
- if (render_to_separate_surface) {
- DCHECK(layer->render_surface());
- // Check back-face visibility before continuing with this surface and its
- // subtree
- RenderSurfaceImpl* render_surface = layer->render_surface();
- if (!layer->double_sided() &&
- IsSurfaceBackFaceVisible(layer, combined_transform)) {
- gfx::Transform draw_transform = combined_transform;
- draw_transform.Scale(1.0 / combined_transform_scales.x(),
- 1.0 / combined_transform_scales.y());
- render_surface->SetDrawTransform(draw_transform);
- return;
- }
-
- if (IsRootLayer(layer)) {
- // The root layer's render surface size is predetermined and so the root
- // layer can't directly support non-identity transforms. It should just
- // forward top-level transforms to the rest of the tree.
- data_for_children.parent_matrix = combined_transform;
- } else {
- // The owning layer's draw transform has a scale from content to layer
- // space which we do not want; so here we use the combined_transform
- // instead of the draw_transform. However, we do need to add a different
- // scale factor that accounts for the surface's pixel dimensions.
- // Remove the combined_transform scale from the draw transform.
- gfx::Transform draw_transform = combined_transform;
- draw_transform.Scale(1.0 / combined_transform_scales.x(),
- 1.0 / combined_transform_scales.y());
- render_surface->SetDrawTransform(draw_transform);
-
- // The owning layer's transform was re-parented by the surface, so the
- // layer's new draw_transform only needs to scale the layer to surface
- // space.
- layer_draw_properties.target_space_transform.MakeIdentity();
- layer_draw_properties.target_space_transform.Scale(
- combined_transform_scales.x(), combined_transform_scales.y());
-
- // Inside the surface's subtree, we scale everything to the owning layer's
- // scale. The sublayer matrix transforms layer rects into target surface
- // content space. Conceptually, all layers in the subtree inherit the
- // scale at the point of the render surface in the transform hierarchy,
- // but we apply it explicitly to the owning layer and the remainder of the
- // subtree independently.
- DCHECK(data_for_children.parent_matrix.IsIdentity());
- data_for_children.parent_matrix.Scale(combined_transform_scales.x(),
- combined_transform_scales.y());
- }
-
- // The opacity value is moved from the layer to its surface, so that the
- // entire subtree properly inherits opacity.
- render_surface->SetDrawOpacity(accumulated_draw_opacity);
- layer_draw_properties.opacity = 1.f;
- DCHECK_EQ(layer->draw_blend_mode(), SkXfermode::kSrcOver_Mode);
-
- layer_draw_properties.screen_space_transform_is_animating =
- animating_transform_to_screen;
-
- // Update the aggregate hierarchy matrix to include the transform of the
- // newly created RenderSurfaceImpl.
- data_for_children.full_hierarchy_matrix.PreconcatTransform(
- render_surface->draw_transform());
-
- // A render surface inherently acts as a flattening point for the content of
- // its descendants.
- data_for_children.full_hierarchy_matrix.FlattenTo2d();
-
- if (layer->mask_layer()) {
- DrawProperties& mask_layer_draw_properties =
- layer->mask_layer()->draw_properties();
- mask_layer_draw_properties.visible_layer_rect =
- gfx::Rect(layer->bounds());
- // Temporarily copy the draw transform of the mask's owning layer into the
- // mask layer draw properties. This won't actually get used for drawing
- // (the render surface uses the mask texture directly), but will get used
- // to get the correct contents scale.
- // TODO(enne): do something similar for property trees.
- mask_layer_draw_properties.target_space_transform =
- layer_draw_properties.target_space_transform;
- }
-
- if (layer->replica_layer() && layer->replica_layer()->mask_layer()) {
- DrawProperties& replica_mask_draw_properties =
- layer->replica_layer()->mask_layer()->draw_properties();
- replica_mask_draw_properties.visible_layer_rect =
- gfx::Rect(layer->bounds());
- replica_mask_draw_properties.target_space_transform =
- layer_draw_properties.target_space_transform;
- }
-
- layer_or_ancestor_clips_descendants = false;
- bool subtree_is_clipped_by_surface_bounds = false;
- // It may be the layer or the surface doing the clipping of the subtree,
- // but in either case, we'll be clipping to the projected clip rect of our
- // ancestor.
- gfx::Transform inverse_surface_draw_transform(
- gfx::Transform::kSkipInitialization);
- if (!render_surface->draw_transform().GetInverse(
- &inverse_surface_draw_transform)) {
- // TODO(shawnsingh): Either we need to handle uninvertible transforms
- // here, or DCHECK that the transform is invertible.
- }
-
- gfx::Rect surface_clip_rect_in_target_space =
- data_from_ancestor.clip_rect_of_target_surface_in_target_space;
- if (ancestor_clips_subtree)
- surface_clip_rect_in_target_space.Intersect(
- ancestor_clip_rect_in_target_space);
- gfx::Rect projected_surface_rect = MathUtil::ProjectEnclosingClippedRect(
- inverse_surface_draw_transform, surface_clip_rect_in_target_space);
- clip_rect_of_target_surface_in_target_space = projected_surface_rect;
-
- if (ancestor_clips_subtree) {
- if (layer_draw_properties.num_unclipped_descendants > 0u) {
- // If we have unclipped descendants, we cannot count on the render
- // surface's bounds clipping our subtree: the unclipped descendants
- // could cause us to expand our bounds. In this case, we must rely on
- // layer clipping for correctess. NB: since we can only encounter
- // translations between a clip child and its clip parent, clipping is
- // guaranteed to be exact in this case.
- layer_or_ancestor_clips_descendants = true;
- clip_rect_in_target_space = projected_surface_rect;
- } else {
- // The new render_surface here will correctly clip the entire subtree.
- // So, we do not need to continue propagating the clipping state further
- // down the tree. This way, we can avoid transforming clip rects from
- // ancestor target surface space to current target surface space that
- // could cause more w < 0 headaches. The render surface clip rect is
- // expressed in the space where this surface draws, i.e. the same space
- // as clip_rect_from_ancestor_in_ancestor_target_space.
- render_surface->SetClipRect(ancestor_clip_rect_in_target_space);
- subtree_is_clipped_by_surface_bounds = true;
- }
- }
-
- DCHECK(layer->render_surface());
- DCHECK(!layer->parent() || layer->parent()->render_target() ==
- accumulated_surface_state->back().render_target);
-
- accumulated_surface_state->push_back(AccumulatedSurfaceState(layer));
-
- render_surface->SetIsClipped(subtree_is_clipped_by_surface_bounds);
- if (!subtree_is_clipped_by_surface_bounds) {
- render_surface->SetClipRect(gfx::Rect());
- }
-
- // If the new render surface is drawn translucent or with a non-integral
- // translation then the subtree that gets drawn on this render surface
- // cannot use LCD text.
- data_for_children.subtree_can_use_lcd_text = subtree_can_use_lcd_text;
-
- } else {
- DCHECK(layer->parent());
-
- // Note: layer_draw_properties.target_space_transform is computed above,
- // before this if-else statement.
- layer_draw_properties.screen_space_transform_is_animating =
- animating_transform_to_screen;
- layer_draw_properties.opacity = accumulated_draw_opacity;
- DCHECK_EQ(layer->draw_blend_mode(), layer->blend_mode());
- data_for_children.parent_matrix = combined_transform;
-
- // Layers without render_surfaces directly inherit the ancestor's clip
- // status.
- layer_or_ancestor_clips_descendants = ancestor_clips_subtree;
- if (ancestor_clips_subtree) {
- clip_rect_in_target_space =
- ancestor_clip_rect_in_target_space;
- }
-
- // The surface's cached clip rect value propagates regardless of what
- // clipping goes on between layers here.
- clip_rect_of_target_surface_in_target_space =
- data_from_ancestor.clip_rect_of_target_surface_in_target_space;
- }
-
- layer_draw_properties.can_use_lcd_text = layer_can_use_lcd_text;
-
- // The layer bounds() includes the layer's bounds_delta() which we want
- // for the clip rect.
- gfx::Rect rect_in_target_space = MathUtil::MapEnclosingClippedRect(
- layer->draw_properties().target_space_transform,
- gfx::Rect(layer->bounds()));
-
- if (LayerClipsSubtree(layer)) {
- layer_or_ancestor_clips_descendants = true;
- if (ancestor_clips_subtree && !render_to_separate_surface) {
- // A layer without render surface shares the same target as its ancestor.
- clip_rect_in_target_space =
- ancestor_clip_rect_in_target_space;
- clip_rect_in_target_space.Intersect(rect_in_target_space);
- } else {
- clip_rect_in_target_space = rect_in_target_space;
- }
- }
-
- // Tell the layer the rect that it's clipped by. In theory we could use a
- // tighter clip rect here (drawable_content_rect), but that actually does not
- // reduce how much would be drawn, and instead it would create unnecessary
- // changes to scissor state affecting GPU performance. Our clip information
- // is used in the recursion below, so we must set it beforehand.
- layer_draw_properties.is_clipped = layer_or_ancestor_clips_descendants;
- if (layer_or_ancestor_clips_descendants) {
- layer_draw_properties.clip_rect = clip_rect_in_target_space;
- } else {
- // Initialize the clip rect to a safe value that will not clip the
- // layer, just in case clipping is still accidentally used.
- layer_draw_properties.clip_rect = rect_in_target_space;
- }
-
- if (!layer->children().empty()) {
- if (layer == globals.elastic_overscroll_application_layer) {
- data_for_children.parent_matrix.Translate(
- -globals.elastic_overscroll.x(), -globals.elastic_overscroll.y());
- }
-
- // Flatten to 2D if the layer doesn't preserve 3D.
- if (layer->should_flatten_transform())
- data_for_children.parent_matrix.FlattenTo2d();
-
- data_for_children.scroll_compensation_matrix =
- ComputeScrollCompensationMatrixForChildren(
- layer,
- data_from_ancestor.parent_matrix,
- data_from_ancestor.scroll_compensation_matrix,
- effective_scroll_delta);
- data_for_children.fixed_container =
- layer->IsContainerForFixedPositionLayers() ?
- layer : data_from_ancestor.fixed_container;
-
- data_for_children.clip_rect_in_target_space = clip_rect_in_target_space;
- data_for_children.clip_rect_of_target_surface_in_target_space =
- clip_rect_of_target_surface_in_target_space;
- data_for_children.ancestor_clips_subtree =
- layer_or_ancestor_clips_descendants;
- data_for_children.subtree_is_visible_from_ancestor = layer_is_drawn;
- }
-
- std::vector<LayerImpl*> sorted_children;
- if (layer_draw_properties.has_child_with_a_scroll_parent)
- SortChildrenForRecursion(&sorted_children, *layer);
-
- for (size_t i = 0; i < layer->children().size(); ++i) {
- // If one of layer's children has a scroll parent, then we may have to
- // visit the children out of order. The new order is stored in
- // sorted_children. Otherwise, we'll grab the child directly from the
- // layer's list of children.
-
- LayerImpl* child =
- layer_draw_properties.has_child_with_a_scroll_parent
- ? sorted_children[i]
- : LayerTreeHostCommon::get_layer_as_raw_ptr(layer->children(), i);
-
- CalculateDrawPropertiesInternal(child, globals, data_for_children,
- accumulated_surface_state);
-
- if (child->layer_or_descendant_is_drawn()) {
- bool layer_or_descendant_is_drawn = true;
- layer->set_layer_or_descendant_is_drawn(layer_or_descendant_is_drawn);
- }
- }
-
- // Compute the total drawable_content_rect for this subtree (the rect is in
- // target surface space).
- gfx::Rect local_drawable_content_rect_of_subtree =
- accumulated_surface_state->back().drawable_content_rect;
- if (render_to_separate_surface) {
- DCHECK(accumulated_surface_state->back().render_target == layer);
- accumulated_surface_state->pop_back();
- }
-
- // Compute the layer's drawable content rect (the rect is in target surface
- // space).
- layer_draw_properties.drawable_content_rect = rect_in_target_space;
- if (layer_or_ancestor_clips_descendants) {
- layer_draw_properties.drawable_content_rect.Intersect(
- clip_rect_in_target_space);
- }
- if (layer->DrawsContent()) {
- local_drawable_content_rect_of_subtree.Union(
- layer_draw_properties.drawable_content_rect);
- }
-
- // Compute the layer's visible content rect (the rect is in content space).
- layer_draw_properties.visible_layer_rect = CalculateVisibleLayerRect(
- layer, clip_rect_of_target_surface_in_target_space, rect_in_target_space);
-
- // Compute the remaining properties for the render surface, if the layer has
- // one.
- if (IsRootLayer(layer)) {
- // The root layer's surface's content_rect is always the entire viewport.
- DCHECK(render_to_separate_surface);
- layer->render_surface()->SetContentRect(
- ancestor_clip_rect_in_target_space);
- } else if (render_to_separate_surface) {
- RenderSurfaceImpl* render_surface = layer->render_surface();
- gfx::Rect clipped_content_rect = local_drawable_content_rect_of_subtree;
-
- // Don't clip if the layer is reflected as the reflection shouldn't be
- // clipped. Also, don't clip if the layer has copy requests.
- if (!layer->replica_layer() && !layer->HasCopyRequest()) {
- // Note, it is correct to use data_from_ancestor.ancestor_clips_subtree
- // here, because we are looking at this layer's render_surface, not the
- // layer itself.
- if (render_surface->is_clipped() && !clipped_content_rect.IsEmpty()) {
- gfx::Rect surface_clip_rect = LayerTreeHostCommon::CalculateVisibleRect(
- render_surface->clip_rect(),
- clipped_content_rect,
- render_surface->draw_transform());
- clipped_content_rect.Intersect(surface_clip_rect);
- }
- }
-
- // The RenderSurfaceImpl backing texture cannot exceed the maximum supported
- // texture size.
- clipped_content_rect.set_width(
- std::min(clipped_content_rect.width(), globals.max_texture_size));
- clipped_content_rect.set_height(
- std::min(clipped_content_rect.height(), globals.max_texture_size));
-
- // Layers having a non-default blend mode will blend with the content
- // inside its parent's render target. This render target should be
- // either root_for_isolated_group, or the root of the layer tree.
- // Otherwise, this layer will use an incomplete backdrop, limited to its
- // render target and the blending result will be incorrect.
- DCHECK(layer->uses_default_blend_mode() || IsRootLayer(layer) ||
- !layer->parent()->render_target() ||
- IsRootLayer(layer->parent()->render_target()) ||
- layer->parent()->render_target()->is_root_for_isolated_group());
-
- render_surface->SetContentRect(clipped_content_rect);
-
- if (clipped_content_rect.IsEmpty()) {
- return;
- }
-
- // The owning layer's screen_space_transform has a scale from content to
- // layer space which we need to undo and replace with a scale from the
- // surface's subtree into layer space.
- gfx::Transform screen_space_transform =
- layer->draw_properties().screen_space_transform;
- screen_space_transform.Scale(1.0 / combined_transform_scales.x(),
- 1.0 / combined_transform_scales.y());
- render_surface->SetScreenSpaceTransform(screen_space_transform);
-
- if (layer->replica_layer()) {
- gfx::Transform surface_origin_to_replica_origin_transform;
- surface_origin_to_replica_origin_transform.Scale(
- combined_transform_scales.x(), combined_transform_scales.y());
- surface_origin_to_replica_origin_transform.Translate(
- layer->replica_layer()->position().x() +
- layer->replica_layer()->transform_origin().x(),
- layer->replica_layer()->position().y() +
- layer->replica_layer()->transform_origin().y());
- surface_origin_to_replica_origin_transform.PreconcatTransform(
- layer->replica_layer()->transform());
- surface_origin_to_replica_origin_transform.Translate(
- -layer->replica_layer()->transform_origin().x(),
- -layer->replica_layer()->transform_origin().y());
- surface_origin_to_replica_origin_transform.Scale(
- 1.0 / combined_transform_scales.x(),
- 1.0 / combined_transform_scales.y());
-
- // Compute the replica's "originTransform" that maps from the replica's
- // origin space to the target surface origin space.
- gfx::Transform replica_origin_transform =
- layer->render_surface()->draw_transform() *
- surface_origin_to_replica_origin_transform;
- render_surface->SetReplicaDrawTransform(replica_origin_transform);
-
- // Compute the replica's "screen_space_transform" that maps from the
- // replica's origin space to the screen's origin space.
- gfx::Transform replica_screen_space_transform =
- layer->render_surface()->screen_space_transform() *
- surface_origin_to_replica_origin_transform;
- render_surface->SetReplicaScreenSpaceTransform(
- replica_screen_space_transform);
- }
- }
-
- SavePaintPropertiesLayer(layer);
-
- UpdateAccumulatedSurfaceState(layer, local_drawable_content_rect_of_subtree,
- accumulated_surface_state);
-} // NOLINT(readability/fn_size)
-
-static void ProcessCalcDrawPropsInputs(
- const LayerTreeHostCommon::CalcDrawPropsImplInputs& inputs,
- SubtreeGlobals* globals,
- DataForRecursion* data_for_recursion) {
- DCHECK(inputs.root_layer);
- DCHECK(IsRootLayer(inputs.root_layer));
- DCHECK(inputs.render_surface_layer_list);
-
- gfx::Transform identity_matrix;
-
- // The root layer's render_surface should receive the device viewport as the
- // initial clip rect.
- gfx::Rect device_viewport_rect(inputs.device_viewport_size);
-
- gfx::Vector2dF device_transform_scale_components =
- MathUtil::ComputeTransform2dScaleComponents(inputs.device_transform, 1.f);
- // Not handling the rare case of different x and y device scale.
- float device_transform_scale =
- std::max(device_transform_scale_components.x(),
- device_transform_scale_components.y());
-
- gfx::Transform scaled_device_transform = inputs.device_transform;
- scaled_device_transform.Scale(inputs.device_scale_factor,
- inputs.device_scale_factor);
-
- globals->max_texture_size = inputs.max_texture_size;
- globals->device_scale_factor =
- inputs.device_scale_factor * device_transform_scale;
- globals->page_scale_factor = inputs.page_scale_factor;
- globals->page_scale_layer = inputs.page_scale_layer;
- globals->elastic_overscroll = inputs.elastic_overscroll;
- globals->elastic_overscroll_application_layer =
- inputs.elastic_overscroll_application_layer;
- globals->can_render_to_separate_surface =
- inputs.can_render_to_separate_surface;
- globals->can_adjust_raster_scales = inputs.can_adjust_raster_scales;
- globals->layers_always_allowed_lcd_text =
- inputs.layers_always_allowed_lcd_text;
-
- data_for_recursion->parent_matrix = scaled_device_transform;
- data_for_recursion->full_hierarchy_matrix = identity_matrix;
- data_for_recursion->scroll_compensation_matrix = identity_matrix;
- data_for_recursion->fixed_container = inputs.root_layer;
- data_for_recursion->clip_rect_in_target_space = device_viewport_rect;
- data_for_recursion->clip_rect_of_target_surface_in_target_space =
- device_viewport_rect;
- data_for_recursion->maximum_animation_contents_scale = 0.f;
- data_for_recursion->starting_animation_contents_scale = 0.f;
- data_for_recursion->ancestor_is_animating_scale = false;
- data_for_recursion->ancestor_clips_subtree = true;
- data_for_recursion->in_subtree_of_page_scale_layer = false;
- data_for_recursion->subtree_can_use_lcd_text = inputs.can_use_lcd_text;
- data_for_recursion->subtree_is_visible_from_ancestor = true;
-}
-
// A layer jitters if its screen space transform is same on two successive
// commits, but has changed in between the commits. CalculateFrameJitter
// computes the jitter in the entire frame.
@@ -2186,139 +1164,6 @@ int LayerTreeHostCommon::CalculateFrameJitter(LayerImpl* layer) {
return jitter;
}
-void VerifyPropertyTreeValuesForSurface(RenderSurfaceImpl* render_surface,
- PropertyTrees* property_trees) {
- RenderSurfaceDrawProperties draw_properties;
- ComputeSurfaceDrawPropertiesUsingPropertyTrees(render_surface, property_trees,
- &draw_properties);
- // TODO(vollick): This tolerance should be lower: crbug.com/471786
- const int tolerance = 1;
-
- // content_rect has to be computed recursively, so is computed separately from
- // other draw properties.
- draw_properties.content_rect =
- render_surface->content_rect_from_property_trees();
-
- const bool render_surface_draw_transforms_match =
- render_surface->draw_transform().ApproximatelyEqual(
- draw_properties.draw_transform);
- CHECK(render_surface_draw_transforms_match)
- << "expected: " << render_surface->draw_transform().ToString()
- << " actual: " << draw_properties.draw_transform.ToString();
-
- const bool render_surface_screen_space_transform_match =
- render_surface->screen_space_transform().ApproximatelyEqual(
- draw_properties.screen_space_transform);
- CHECK(render_surface_screen_space_transform_match)
- << "expected: " << render_surface->screen_space_transform().ToString()
- << " actual: " << draw_properties.screen_space_transform.ToString();
-
- const bool render_surface_replica_draw_transforms_match =
- render_surface->replica_draw_transform().ApproximatelyEqual(
- draw_properties.replica_draw_transform);
- CHECK(render_surface_replica_draw_transforms_match)
- << "expected: " << render_surface->replica_draw_transform().ToString()
- << " actual: " << draw_properties.replica_draw_transform.ToString();
-
- const bool render_surface_replica_screen_space_transforms_match =
- render_surface->replica_screen_space_transform().ApproximatelyEqual(
- draw_properties.replica_screen_space_transform);
- CHECK(render_surface_replica_screen_space_transforms_match)
- << "expected: "
- << render_surface->replica_screen_space_transform().ToString()
- << " actual: "
- << draw_properties.replica_screen_space_transform.ToString();
-
- CHECK_EQ(render_surface->is_clipped(), draw_properties.is_clipped);
-
- const bool render_surface_clip_rects_match =
- render_surface->clip_rect().ApproximatelyEqual(draw_properties.clip_rect,
- tolerance);
- CHECK(render_surface_clip_rects_match)
- << "expected: " << render_surface->clip_rect().ToString()
- << " actual: " << draw_properties.clip_rect.ToString();
-
- CHECK_EQ(render_surface->draw_opacity(), draw_properties.draw_opacity);
-
- const bool render_surface_content_rects_match =
- render_surface->content_rect().ApproximatelyEqual(
- draw_properties.content_rect, tolerance);
- CHECK(render_surface_content_rects_match)
- << "expected: " << render_surface->content_rect().ToString()
- << " actual: " << draw_properties.content_rect.ToString();
-}
-
-void VerifyPropertyTreeValuesForLayer(LayerImpl* current_layer,
- PropertyTrees* property_trees,
- bool layers_always_allowed_lcd_text,
- bool can_use_lcd_text) {
- DrawProperties draw_properties;
- ComputeLayerDrawPropertiesUsingPropertyTrees(
- current_layer, property_trees, layers_always_allowed_lcd_text,
- can_use_lcd_text, &draw_properties);
- // TODO(vollick): This tolerance should be lower: crbug.com/471786
- const int tolerance = 1;
-
- const bool visible_rects_match =
- current_layer->visible_layer_rect().ApproximatelyEqual(
- draw_properties.visible_layer_rect, tolerance);
- CHECK(visible_rects_match)
- << "expected: " << current_layer->visible_layer_rect().ToString()
- << " actual: " << draw_properties.visible_layer_rect.ToString();
-
- const bool draw_transforms_match =
- current_layer->draw_properties()
- .target_space_transform.ApproximatelyEqual(
- draw_properties.target_space_transform);
- CHECK(draw_transforms_match)
- << "expected: "
- << current_layer->draw_properties().target_space_transform.ToString()
- << " actual: " << draw_properties.target_space_transform.ToString();
-
- CHECK_EQ(current_layer->draw_opacity(), draw_properties.opacity);
- CHECK_EQ(current_layer->can_use_lcd_text(), draw_properties.can_use_lcd_text);
- CHECK_EQ(current_layer->is_clipped(), draw_properties.is_clipped);
- CHECK_EQ(current_layer->screen_space_transform_is_animating(),
- draw_properties.screen_space_transform_is_animating);
-
- const bool drawable_content_rects_match =
- current_layer->drawable_content_rect().ApproximatelyEqual(
- draw_properties.drawable_content_rect, tolerance);
- CHECK(drawable_content_rects_match)
- << "expected: " << current_layer->drawable_content_rect().ToString()
- << " actual: " << draw_properties.drawable_content_rect.ToString();
-
- const bool clip_rects_match = current_layer->clip_rect().ApproximatelyEqual(
- draw_properties.clip_rect, tolerance);
- CHECK(clip_rects_match) << "expected: "
- << current_layer->clip_rect().ToString()
- << " actual: "
- << draw_properties.clip_rect.ToString();
-
- CHECK_EQ(current_layer->draw_properties().maximum_animation_contents_scale,
- draw_properties.maximum_animation_contents_scale);
- CHECK_EQ(current_layer->draw_properties().starting_animation_contents_scale,
- draw_properties.starting_animation_contents_scale);
-}
-
-void VerifyPropertyTreeValues(
- LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs) {
- LayerIterator it, end;
- for (it = LayerIterator::Begin(inputs->render_surface_layer_list),
- end = LayerIterator::End(inputs->render_surface_layer_list);
- it != end; ++it) {
- LayerImpl* current_layer = *it;
- if (it.represents_target_render_surface())
- VerifyPropertyTreeValuesForSurface(current_layer->render_surface(),
- inputs->property_trees);
- if (!it.represents_itself() || !current_layer->DrawsContent())
- continue;
- VerifyPropertyTreeValuesForLayer(current_layer, inputs->property_trees,
- inputs->layers_always_allowed_lcd_text,
- inputs->can_use_lcd_text);
- }
-}
-
enum PropertyTreeOption {
BUILD_PROPERTY_TREES_IF_NEEDED,
DONT_BUILD_PROPERTY_TREES
@@ -2327,19 +1172,11 @@ enum PropertyTreeOption {
void CalculateRenderTargetInternal(LayerImpl* layer,
PropertyTrees* property_trees,
bool subtree_visible_from_ancestor,
- bool can_render_to_separate_surface,
- bool use_property_trees) {
+ bool can_render_to_separate_surface) {
bool layer_is_drawn;
- if (use_property_trees) {
- DCHECK_GE(layer->effect_tree_index(), 0);
- layer_is_drawn =
- property_trees->effect_tree.Node(layer->effect_tree_index())
- ->data.is_drawn;
- } else {
- layer_is_drawn =
- (subtree_visible_from_ancestor && layer->EffectiveOpacity() != 0) ||
- layer->HasCopyRequest();
- }
+ DCHECK_GE(layer->effect_tree_index(), 0);
+ layer_is_drawn = property_trees->effect_tree.Node(layer->effect_tree_index())
+ ->data.is_drawn;
// The root layer cannot be skipped.
if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_drawn)) {
@@ -2372,8 +1209,7 @@ void CalculateRenderTargetInternal(LayerImpl* layer,
for (size_t i = 0; i < layer->children().size(); ++i) {
CalculateRenderTargetInternal(
LayerTreeHostCommon::get_layer_as_raw_ptr(layer->children(), i),
- property_trees, layer_is_drawn, can_render_to_separate_surface,
- use_property_trees);
+ property_trees, layer_is_drawn, can_render_to_separate_surface);
}
}
@@ -2386,9 +1222,7 @@ void CalculateRenderSurfaceLayerListInternal(
bool subtree_visible_from_ancestor,
const bool can_render_to_separate_surface,
const int current_render_surface_layer_list_id,
- const int max_texture_size,
- const bool verify_property_trees,
- const bool use_property_trees) {
+ const int max_texture_size) {
// This calculates top level Render Surface Layer List, and Layer List for all
// Render Surfaces.
@@ -2405,16 +1239,9 @@ void CalculateRenderSurfaceLayerListInternal(
// |can_render_to_separate_surface| and |current_render_surface_layer_list_id|
// are settings that should stay the same during recursion.
bool layer_is_drawn = false;
- if (use_property_trees) {
- DCHECK_GE(layer->effect_tree_index(), 0);
- layer_is_drawn =
- property_trees->effect_tree.Node(layer->effect_tree_index())
- ->data.is_drawn;
- } else {
- layer_is_drawn =
- (subtree_visible_from_ancestor && layer->EffectiveOpacity() != 0) ||
- layer->HasCopyRequest();
- }
+ DCHECK_GE(layer->effect_tree_index(), 0);
+ layer_is_drawn = property_trees->effect_tree.Node(layer->effect_tree_index())
+ ->data.is_drawn;
// The root layer cannot be skipped.
if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_drawn)) {
@@ -2430,25 +1257,22 @@ void CalculateRenderSurfaceLayerListInternal(
if (render_to_separate_surface) {
DCHECK(layer->render_surface());
-
- if (use_property_trees) {
- RenderSurfaceDrawProperties draw_properties;
- ComputeSurfaceDrawPropertiesUsingPropertyTrees(
- layer->render_surface(), property_trees, &draw_properties);
- // TODO(ajuma): Once property tree verification is removed, make the above
- // call directly set the surface's properties, so that the copying below
- // is no longer needed.
- layer->render_surface()->SetIsClipped(draw_properties.is_clipped);
- layer->render_surface()->SetDrawOpacity(draw_properties.draw_opacity);
- layer->render_surface()->SetDrawTransform(draw_properties.draw_transform);
- layer->render_surface()->SetScreenSpaceTransform(
- draw_properties.screen_space_transform);
- layer->render_surface()->SetReplicaDrawTransform(
- draw_properties.replica_draw_transform);
- layer->render_surface()->SetReplicaScreenSpaceTransform(
- draw_properties.replica_screen_space_transform);
- layer->render_surface()->SetClipRect(draw_properties.clip_rect);
- }
+ RenderSurfaceDrawProperties draw_properties;
+ ComputeSurfaceDrawPropertiesUsingPropertyTrees(
+ layer->render_surface(), property_trees, &draw_properties);
+ // TODO(ajuma): Once property tree verification is removed, make the above
+ // call directly set the surface's properties, so that the copying below
+ // is no longer needed.
+ layer->render_surface()->SetIsClipped(draw_properties.is_clipped);
+ layer->render_surface()->SetDrawOpacity(draw_properties.draw_opacity);
+ layer->render_surface()->SetDrawTransform(draw_properties.draw_transform);
+ layer->render_surface()->SetScreenSpaceTransform(
+ draw_properties.screen_space_transform);
+ layer->render_surface()->SetReplicaDrawTransform(
+ draw_properties.replica_draw_transform);
+ layer->render_surface()->SetReplicaScreenSpaceTransform(
+ draw_properties.replica_screen_space_transform);
+ layer->render_surface()->SetClipRect(draw_properties.clip_rect);
if (!layer->double_sided() &&
IsSurfaceBackFaceVisible(layer,
@@ -2464,11 +1288,8 @@ void CalculateRenderSurfaceLayerListInternal(
layer->render_surface()->set_contributes_to_drawn_surface(false);
} else {
bool contributes_to_drawn_surface =
- use_property_trees
- ? property_trees->effect_tree.ContributesToDrawnSurface(
- layer->effect_tree_index())
- : subtree_visible_from_ancestor &&
- layer->EffectiveOpacity() != 0.f;
+ property_trees->effect_tree.ContributesToDrawnSurface(
+ layer->effect_tree_index());
layer->render_surface()->set_contributes_to_drawn_surface(
contributes_to_drawn_surface);
}
@@ -2496,19 +1317,17 @@ void CalculateRenderSurfaceLayerListInternal(
size_t descendants_size = descendants->size();
- bool layer_should_be_skipped =
- LayerShouldBeSkipped(layer, layer_is_drawn, use_property_trees,
- property_trees->transform_tree);
+ bool layer_should_be_skipped = LayerShouldBeSkipped(
+ layer, layer_is_drawn, property_trees->transform_tree);
if (!layer_should_be_skipped) {
MarkLayerWithRenderSurfaceLayerListId(layer,
current_render_surface_layer_list_id);
descendants->push_back(layer);
}
- bool compute_content_rects = verify_property_trees || use_property_trees;
// Clear the old accumulated content rect of surface.
- if (compute_content_rects && render_to_separate_surface)
+ if (render_to_separate_surface)
layer->render_surface()->SetAccumulatedContentRect(gfx::Rect());
for (const auto& child_layer : layer->children()) {
@@ -2516,7 +1335,7 @@ void CalculateRenderSurfaceLayerListInternal(
child_layer.get(), property_trees, render_surface_layer_list,
descendants, nearest_occlusion_immune_ancestor, layer_is_drawn,
can_render_to_separate_surface, current_render_surface_layer_list_id,
- max_texture_size, verify_property_trees, use_property_trees);
+ max_texture_size);
// If the child is its own render target, then it has a render surface.
if (child_layer->render_target() == child_layer.get() &&
@@ -2545,73 +1364,63 @@ void CalculateRenderSurfaceLayerListInternal(
// The render surface's content rect is the union of drawable content rects
// of the layers that draw into the surface. If the render surface is clipped,
// it is also intersected with the render's surface clip rect.
- if (compute_content_rects) {
- if (!IsRootLayer(layer)) {
- if (render_to_separate_surface) {
- gfx::Rect surface_content_rect =
- layer->render_surface()->accumulated_content_rect();
- // If the owning layer of a render surface draws content, the content
- // rect of the render surface is expanded to include the drawable
- // content rect of the layer.
- if (layer->DrawsContent())
- surface_content_rect.Union(layer->drawable_content_rect());
-
- if (!layer->replica_layer() && !layer->HasCopyRequest() &&
- layer->render_surface()->is_clipped()) {
- // Here, we clip the render surface's content rect with its clip rect.
- // As the clip rect of render surface is in the surface's target
- // space, we first map the content rect into the target space,
- // intersect it with clip rect and project back the result to the
- // surface space.
- if (!surface_content_rect.IsEmpty()) {
- gfx::Rect surface_clip_rect =
- LayerTreeHostCommon::CalculateVisibleRect(
- layer->render_surface()->clip_rect(), surface_content_rect,
- layer->render_surface()->draw_transform());
- surface_content_rect.Intersect(surface_clip_rect);
- }
- }
- // The RenderSurfaceImpl backing texture cannot exceed the maximum
- // supported texture size.
- surface_content_rect.set_width(
- std::min(surface_content_rect.width(), max_texture_size));
- surface_content_rect.set_height(
- std::min(surface_content_rect.height(), max_texture_size));
- if (use_property_trees)
- layer->render_surface()->SetContentRect(surface_content_rect);
- if (verify_property_trees) {
- layer->render_surface()->SetContentRectFromPropertyTrees(
- surface_content_rect);
+ if (!IsRootLayer(layer)) {
+ if (render_to_separate_surface) {
+ gfx::Rect surface_content_rect =
+ layer->render_surface()->accumulated_content_rect();
+ // If the owning layer of a render surface draws content, the content
+ // rect of the render surface is expanded to include the drawable
+ // content rect of the layer.
+ if (layer->DrawsContent())
+ surface_content_rect.Union(layer->drawable_content_rect());
+
+ if (!layer->replica_layer() && !layer->HasCopyRequest() &&
+ layer->render_surface()->is_clipped()) {
+ // Here, we clip the render surface's content rect with its clip rect.
+ // As the clip rect of render surface is in the surface's target
+ // space, we first map the content rect into the target space,
+ // intersect it with clip rect and project back the result to the
+ // surface space.
+ if (!surface_content_rect.IsEmpty()) {
+ gfx::Rect surface_clip_rect =
+ LayerTreeHostCommon::CalculateVisibleRect(
+ layer->render_surface()->clip_rect(), surface_content_rect,
+ layer->render_surface()->draw_transform());
+ surface_content_rect.Intersect(surface_clip_rect);
}
}
- const LayerImpl* parent_target = layer->parent()->render_target();
- if (!IsRootLayer(parent_target)) {
- gfx::Rect surface_content_rect =
- parent_target->render_surface()->accumulated_content_rect();
- if (render_to_separate_surface) {
- // If the layer owns a surface, then the content rect is in the wrong
- // space. Instead, we will use the surface's DrawableContentRect which
- // is in target space as required. We also need to clip it with the
- // target's clip if the target is clipped.
- surface_content_rect.Union(gfx::ToEnclosedRect(
- layer->render_surface()->DrawableContentRect()));
- if (parent_target->is_clipped())
- surface_content_rect.Intersect(parent_target->clip_rect());
- } else if (layer->DrawsContent()) {
- surface_content_rect.Union(layer->drawable_content_rect());
- }
- parent_target->render_surface()->SetAccumulatedContentRect(
- surface_content_rect);
+ // The RenderSurfaceImpl backing texture cannot exceed the maximum
+ // supported texture size.
+ surface_content_rect.set_width(
+ std::min(surface_content_rect.width(), max_texture_size));
+ surface_content_rect.set_height(
+ std::min(surface_content_rect.height(), max_texture_size));
+ layer->render_surface()->SetContentRect(surface_content_rect);
+ }
+ const LayerImpl* parent_target = layer->parent()->render_target();
+ if (!IsRootLayer(parent_target)) {
+ gfx::Rect surface_content_rect =
+ parent_target->render_surface()->accumulated_content_rect();
+ if (render_to_separate_surface) {
+ // If the layer owns a surface, then the content rect is in the wrong
+ // space. Instead, we will use the surface's DrawableContentRect which
+ // is in target space as required. We also need to clip it with the
+ // target's clip if the target is clipped.
+ surface_content_rect.Union(gfx::ToEnclosedRect(
+ layer->render_surface()->DrawableContentRect()));
+ if (parent_target->is_clipped())
+ surface_content_rect.Intersect(parent_target->clip_rect());
+ } else if (layer->DrawsContent()) {
+ surface_content_rect.Union(layer->drawable_content_rect());
}
- } else {
- // The root layer's surface content rect is always the entire viewport.
- gfx::Rect viewport =
- gfx::ToEnclosingRect(property_trees->clip_tree.ViewportClip());
- if (use_property_trees)
- layer->render_surface()->SetContentRect(viewport);
- if (verify_property_trees)
- layer->render_surface()->SetContentRectFromPropertyTrees(viewport);
+ parent_target->render_surface()->SetAccumulatedContentRect(
+ surface_content_rect);
}
+ } else {
+ // The root layer's surface content rect is always the entire viewport.
+ gfx::Rect viewport =
+ gfx::ToEnclosingRect(property_trees->clip_tree.ViewportClip());
+ layer->render_surface()->SetContentRect(viewport);
}
if (render_to_separate_surface && !IsRootLayer(layer) &&
@@ -2629,10 +1438,8 @@ void CalculateRenderSurfaceLayerListInternal(
void CalculateRenderTarget(
LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs) {
- CalculateRenderTargetInternal(
- inputs->root_layer, inputs->property_trees, true,
- inputs->can_render_to_separate_surface,
- inputs->verify_property_trees || inputs->use_property_trees);
+ CalculateRenderTargetInternal(inputs->root_layer, inputs->property_trees,
+ true, inputs->can_render_to_separate_surface);
}
void CalculateRenderSurfaceLayerList(
@@ -2645,8 +1452,7 @@ void CalculateRenderSurfaceLayerList(
inputs->root_layer, inputs->property_trees,
inputs->render_surface_layer_list, nullptr, nullptr,
subtree_visible_from_ancestor, inputs->can_render_to_separate_surface,
- inputs->current_render_surface_layer_list_id, inputs->max_texture_size,
- inputs->verify_property_trees, inputs->use_property_trees);
+ inputs->current_render_surface_layer_list_id, inputs->max_texture_size);
}
static void ComputeMaskLayerDrawProperties(const LayerImpl* layer,
@@ -2663,7 +1469,7 @@ static void ComputeMaskLayerDrawProperties(const LayerImpl* layer,
layer->draw_properties().starting_animation_contents_scale;
}
-void CalculateDrawPropertiesAndVerify(
+void CalculateDrawPropertiesInternal(
LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs,
PropertyTreeOption property_tree_option) {
inputs->render_surface_layer_list->clear();
@@ -2672,77 +1478,72 @@ void CalculateDrawPropertiesAndVerify(
PreCalculateMetaInformationRecursiveData recursive_data;
PreCalculateMetaInformationInternal(inputs->root_layer, &recursive_data);
const bool should_measure_property_tree_performance =
- inputs->verify_property_trees &&
- (property_tree_option == BUILD_PROPERTY_TREES_IF_NEEDED);
+ property_tree_option == BUILD_PROPERTY_TREES_IF_NEEDED;
LayerImplList visible_layer_list;
- if (inputs->verify_property_trees || inputs->use_property_trees) {
- switch (property_tree_option) {
- case BUILD_PROPERTY_TREES_IF_NEEDED: {
- // The translation from layer to property trees is an intermediate
- // state. We will eventually get these data passed directly to the
- // compositor.
- if (should_measure_property_tree_performance) {
- TRACE_EVENT_BEGIN0(
- TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"),
- "LayerTreeHostCommon::ComputeVisibleRectsWithPropertyTrees");
- }
-
- BuildPropertyTreesAndComputeVisibleRects(
- inputs->root_layer, inputs->page_scale_layer,
- inputs->inner_viewport_scroll_layer,
- inputs->outer_viewport_scroll_layer,
- inputs->elastic_overscroll_application_layer,
- inputs->elastic_overscroll, inputs->page_scale_factor,
- inputs->device_scale_factor,
- gfx::Rect(inputs->device_viewport_size), inputs->device_transform,
- inputs->can_render_to_separate_surface, inputs->property_trees,
- &visible_layer_list);
-
- // Property trees are normally constructed on the main thread and
- // passed to compositor thread. Source to parent updates on them are not
- // allowed in the compositor thread. Some tests build them on the
- // compositor thread, so we need to explicitly disallow source to parent
- // updates when they are built on compositor thread.
- inputs->property_trees->transform_tree
- .set_source_to_parent_updates_allowed(false);
- if (should_measure_property_tree_performance) {
- TRACE_EVENT_END0(
- TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"),
- "LayerTreeHostCommon::ComputeVisibleRectsWithPropertyTrees");
- }
-
- break;
+ switch (property_tree_option) {
+ case BUILD_PROPERTY_TREES_IF_NEEDED: {
+ // The translation from layer to property trees is an intermediate
+ // state. We will eventually get these data passed directly to the
+ // compositor.
+ if (should_measure_property_tree_performance) {
+ TRACE_EVENT_BEGIN0(
+ TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"),
+ "LayerTreeHostCommon::ComputeVisibleRectsWithPropertyTrees");
}
- case DONT_BUILD_PROPERTY_TREES: {
- TRACE_EVENT0(
+
+ BuildPropertyTreesAndComputeVisibleRects(
+ inputs->root_layer, inputs->page_scale_layer,
+ inputs->inner_viewport_scroll_layer,
+ inputs->outer_viewport_scroll_layer,
+ inputs->elastic_overscroll_application_layer,
+ inputs->elastic_overscroll, inputs->page_scale_factor,
+ inputs->device_scale_factor, gfx::Rect(inputs->device_viewport_size),
+ inputs->device_transform, inputs->can_render_to_separate_surface,
+ inputs->property_trees, &visible_layer_list);
+
+ // Property trees are normally constructed on the main thread and
+ // passed to compositor thread. Source to parent updates on them are not
+ // allowed in the compositor thread. Some tests build them on the
+ // compositor thread, so we need to explicitly disallow source to parent
+ // updates when they are built on compositor thread.
+ inputs->property_trees->transform_tree
+ .set_source_to_parent_updates_allowed(false);
+ if (should_measure_property_tree_performance) {
+ TRACE_EVENT_END0(
TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"),
- "LayerTreeHostCommon::ComputeJustVisibleRectsWithPropertyTrees");
- // Since page scale and elastic overscroll are SyncedProperties, changes
- // on the active tree immediately affect the pending tree, so instead of
- // trying to update property trees whenever these values change, we
- // update property trees before using them.
- UpdatePageScaleFactorInPropertyTrees(
- inputs->property_trees, inputs->page_scale_layer,
- inputs->page_scale_factor, inputs->device_scale_factor,
- inputs->device_transform);
- UpdateElasticOverscrollInPropertyTrees(
- inputs->property_trees,
- inputs->elastic_overscroll_application_layer,
- inputs->elastic_overscroll);
- // Similarly, the device viewport and device transform are shared
- // by both trees.
- inputs->property_trees->clip_tree.SetViewportClip(
- gfx::RectF(gfx::SizeF(inputs->device_viewport_size)));
- inputs->property_trees->transform_tree.SetDeviceTransform(
- inputs->device_transform, inputs->root_layer->position());
- inputs->property_trees->transform_tree.SetDeviceTransformScaleFactor(
- inputs->device_transform);
- ComputeVisibleRectsUsingPropertyTrees(
- inputs->root_layer, inputs->property_trees,
- inputs->can_render_to_separate_surface, &visible_layer_list);
- break;
+ "LayerTreeHostCommon::ComputeVisibleRectsWithPropertyTrees");
}
+
+ break;
+ }
+ case DONT_BUILD_PROPERTY_TREES: {
+ TRACE_EVENT0(
+ TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"),
+ "LayerTreeHostCommon::ComputeJustVisibleRectsWithPropertyTrees");
+ // Since page scale and elastic overscroll are SyncedProperties, changes
+ // on the active tree immediately affect the pending tree, so instead of
+ // trying to update property trees whenever these values change, we
+ // update property trees before using them.
+ UpdatePageScaleFactorInPropertyTrees(
+ inputs->property_trees, inputs->page_scale_layer,
+ inputs->page_scale_factor, inputs->device_scale_factor,
+ inputs->device_transform);
+ UpdateElasticOverscrollInPropertyTrees(
+ inputs->property_trees, inputs->elastic_overscroll_application_layer,
+ inputs->elastic_overscroll);
+ // Similarly, the device viewport and device transform are shared
+ // by both trees.
+ inputs->property_trees->clip_tree.SetViewportClip(
+ gfx::RectF(gfx::SizeF(inputs->device_viewport_size)));
+ inputs->property_trees->transform_tree.SetDeviceTransform(
+ inputs->device_transform, inputs->root_layer->position());
+ inputs->property_trees->transform_tree.SetDeviceTransformScaleFactor(
+ inputs->device_transform);
+ ComputeVisibleRectsUsingPropertyTrees(
+ inputs->root_layer, inputs->property_trees,
+ inputs->can_render_to_separate_surface, &visible_layer_list);
+ break;
}
}
@@ -2755,27 +1556,18 @@ void CalculateDrawPropertiesAndVerify(
DCHECK(inputs->can_render_to_separate_surface ==
inputs->property_trees->non_root_surfaces_enabled);
CalculateRenderTarget(inputs);
- if (inputs->use_property_trees) {
- for (LayerImpl* layer : visible_layer_list) {
- ComputeLayerDrawPropertiesUsingPropertyTrees(
- layer, inputs->property_trees, inputs->layers_always_allowed_lcd_text,
- inputs->can_use_lcd_text, &layer->draw_properties());
- if (layer->mask_layer())
- ComputeMaskLayerDrawProperties(layer, layer->mask_layer());
- LayerImpl* replica_mask_layer = layer->replica_layer()
- ? layer->replica_layer()->mask_layer()
- : nullptr;
- if (replica_mask_layer)
- ComputeMaskLayerDrawProperties(layer, replica_mask_layer);
- }
- } else {
- SubtreeGlobals globals;
- DataForRecursion data_for_recursion;
- ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion);
- CalculateDrawPropertiesInternal(inputs->root_layer, globals,
- data_for_recursion,
- &accumulated_surface_state);
+ for (LayerImpl* layer : visible_layer_list) {
+ ComputeLayerDrawPropertiesUsingPropertyTrees(
+ layer, inputs->property_trees, inputs->layers_always_allowed_lcd_text,
+ inputs->can_use_lcd_text, &layer->draw_properties());
+ if (layer->mask_layer())
+ ComputeMaskLayerDrawProperties(layer, layer->mask_layer());
+ LayerImpl* replica_mask_layer =
+ layer->replica_layer() ? layer->replica_layer()->mask_layer() : nullptr;
+ if (replica_mask_layer)
+ ComputeMaskLayerDrawProperties(layer, replica_mask_layer);
}
+
CalculateRenderSurfaceLayerList(inputs);
if (should_measure_property_tree_performance) {
@@ -2783,9 +1575,6 @@ void CalculateDrawPropertiesAndVerify(
"LayerTreeHostCommon::CalculateDrawProperties");
}
- if (inputs->verify_property_trees)
- VerifyPropertyTreeValues(inputs);
-
// A root layer render_surface should always exist after
// CalculateDrawProperties.
DCHECK(inputs->root_layer->render_surface());
@@ -2810,7 +1599,7 @@ void LayerTreeHostCommon::CalculateDrawProperties(
void LayerTreeHostCommon::CalculateDrawProperties(
CalcDrawPropsImplInputs* inputs) {
- CalculateDrawPropertiesAndVerify(inputs, DONT_BUILD_PROPERTY_TREES);
+ CalculateDrawPropertiesInternal(inputs, DONT_BUILD_PROPERTY_TREES);
if (CdpPerfTracingEnabled()) {
LayerTreeImpl* layer_tree_impl = inputs->root_layer->layer_tree_impl();
@@ -2840,7 +1629,7 @@ void LayerTreeHostCommon::CalculateDrawProperties(
void LayerTreeHostCommon::CalculateDrawProperties(
CalcDrawPropsImplInputsForTesting* inputs) {
- CalculateDrawPropertiesAndVerify(inputs, BUILD_PROPERTY_TREES_IF_NEEDED);
+ CalculateDrawPropertiesInternal(inputs, BUILD_PROPERTY_TREES_IF_NEEDED);
}
PropertyTrees* GetPropertyTrees(Layer* layer) {