Lines Matching refs:layer

12 #include "cc/layers/layer.h"
45 static gfx::Vector2dF GetEffectiveScrollDelta(LayerType* layer) {
46 gfx::Vector2dF scroll_delta = layer->ScrollDelta();
48 // compositor thread since the commit for this layer tree's source frame.
51 if (layer->scroll_parent())
52 scroll_delta += layer->scroll_parent()->ScrollDelta();
57 static gfx::Vector2dF GetEffectiveTotalScrollOffset(LayerType* layer) {
58 gfx::Vector2dF offset = layer->TotalScrollOffset();
61 // scroll children's positions by the main thread layer positioning code.
62 if (layer->scroll_parent())
63 offset += layer->scroll_parent()->ScrollDelta();
75 // Is this layer fully contained within the target surface?
79 // If the layer doesn't fill up the entire surface, then find the part of
80 // the surface rect where the layer could be visible. This avoids trying to
88 // Project the corners of the target surface rect into the layer space.
96 // the layer is visible, we must conservatively assume the full layer is
118 static LayerType* NextTargetSurface(LayerType* layer) {
119 return layer->parent() ? layer->parent()->render_target() : 0;
168 // Attempts to update the clip rects for the given layer. If the layer has a
172 const LayerType* layer,
175 // If the layer has no clip_parent, or the ancestor is the same as its actual
178 const LayerType* clip_parent = layer->scroll_parent();
181 clip_parent = layer->clip_parent();
183 if (!clip_parent || clip_parent == layer->parent())
186 // The root layer is never a clip child.
187 DCHECK(layer->parent());
199 if (clip_parent == layer->clip_parent()) {
202 *layer->parent(),
211 TranslateRectToTargetSpace<LayerType>(*layer->parent(),
219 // Typically, a layer will contribute to only one surface, the surface
224 // NB: we accumulate the layer's *clipped* drawable content rect.
243 LayerType* layer,
247 if (IsRootLayer(layer))
257 LayerType* render_target = layer->clip_parent()
258 ? layer->clip_parent()->render_target()
259 : layer->parent()->render_target();
261 // If the layer owns a surface, then the content rect is in the wrong space.
265 if (layer->render_surface()) {
267 gfx::ToEnclosedRect(layer->render_surface()->DrawableContentRect());
272 // If the layer has a clip parent, the clip rect may be in the wrong space,
274 if (layer->clip_parent()) {
276 *layer->clip_parent(),
277 *layer,
326 template <typename LayerType> static inline bool IsRootLayer(LayerType* layer) {
327 return !layer->parent();
331 static inline bool LayerIsInExisting3DRenderingContext(LayerType* layer) {
332 return layer->Is3dSorted() && layer->parent() &&
333 layer->parent()->Is3dSorted();
337 static bool IsRootLayerOfNewRenderingContext(LayerType* layer) {
338 if (layer->parent())
339 return !layer->parent()->Is3dSorted() && layer->Is3dSorted();
341 return layer->Is3dSorted();
345 static bool IsLayerBackFaceVisible(LayerType* layer) {
347 // be determined differently depending on whether the layer is in a "3d
351 if (LayerIsInExisting3DRenderingContext(layer))
352 return layer->draw_transform().IsBackFaceVisible();
354 // In this case, either the layer establishes a new 3d rendering context, or
356 return layer->transform().IsBackFaceVisible();
360 static bool IsSurfaceBackFaceVisible(LayerType* layer,
362 if (LayerIsInExisting3DRenderingContext(layer))
365 if (IsRootLayerOfNewRenderingContext(layer))
366 return layer->transform().IsBackFaceVisible();
375 static inline bool LayerClipsSubtree(LayerType* layer) {
376 return layer->masks_to_bounds() || layer->mask_layer();
381 LayerType* layer,
384 DCHECK(layer->render_target());
386 // Nothing is visible if the layer bounds are empty.
387 if (!layer->DrawsContent() || layer->content_bounds().IsEmpty() ||
388 layer->drawable_content_rect().IsEmpty())
393 layer->drawable_content_rect();
395 if (layer->render_target()->render_surface()->is_clipped()) {
396 // The |layer| L has a target T which owns a surface Ts. The surface Ts
399 // In this case the target surface Ts does clip the layer L that contributes
404 // layer.
414 gfx::Rect(layer->content_bounds()),
416 layer->draw_transform());
419 static inline bool TransformToParentIsKnown(LayerImpl* layer) { return true; }
421 static inline bool TransformToParentIsKnown(Layer* layer) {
422 return !layer->TransformIsAnimating();
425 static inline bool TransformToScreenIsKnown(LayerImpl* layer) { return true; }
427 static inline bool TransformToScreenIsKnown(Layer* layer) {
428 return !layer->screen_space_transform_is_animating();
432 static bool LayerShouldBeSkipped(LayerType* layer, bool layer_is_drawn) {
439 // - the layer is not double-sided, but its back face is visible.
443 // - the intersection of render_surface content and layer clip_rect is empty
446 // Note, if the layer should not have been drawn due to being fully
453 if (!layer->DrawsContent() || layer->bounds().IsEmpty())
456 LayerType* backface_test_layer = layer;
457 if (layer->use_parent_backface_visibility()) {
458 DCHECK(layer->parent());
459 DCHECK(!layer->parent()->use_parent_backface_visibility());
460 backface_test_layer = layer->parent();
463 // The layer should not be drawn if (1) it is not double-sided and (2) the
464 // back of the layer is known to be facing the screen.
474 static bool HasInvertibleOrAnimatedTransform(LayerType* layer) {
475 return layer->transform_is_invertible() || layer->TransformIsAnimating();
478 static inline bool SubtreeShouldBeSkipped(LayerImpl* layer,
480 // If the layer transform is not invertible, it should not be drawn.
484 if (!HasInvertibleOrAnimatedTransform(layer))
487 // When we need to do a readback/copy of a layer's output, we can not skip
489 if (layer->draw_properties().layer_or_descendant_has_copy_request)
494 if (layer->draw_properties().layer_or_descendant_has_input_handler)
497 // If the layer is not drawn, then skip it and its subtree.
501 // If layer is on the pending tree and opacity is being animated then
503 // include tiles for this layer when deciding if tree can be activated.
504 if (layer->layer_tree_impl()->IsPendingTree() && layer->OpacityIsAnimating())
507 // The opacity of a layer always applies to its children (either implicitly
509 // entire subtree can be skipped if this layer is fully transparent.
510 return !layer->opacity();
513 static inline bool SubtreeShouldBeSkipped(Layer* layer, bool layer_is_drawn) {
514 // If the layer transform is not invertible, it should not be drawn.
515 if (!layer->transform_is_invertible() && !layer->TransformIsAnimating())
518 // When we need to do a readback/copy of a layer's output, we can not skip
520 if (layer->draw_properties().layer_or_descendant_has_copy_request)
525 if (layer->draw_properties().layer_or_descendant_has_input_handler)
528 // If the layer is not drawn, then skip it and its subtree.
538 return !layer->opacity() && !layer->OpacityIsAnimating() &&
539 !layer->OpacityCanAnimateOnImplThread();
542 static inline void SavePaintPropertiesLayer(LayerImpl* layer) {}
544 static inline void SavePaintPropertiesLayer(Layer* layer) {
545 layer->SavePaintProperties();
547 if (layer->mask_layer())
548 layer->mask_layer()->SavePaintProperties();
549 if (layer->replica_layer() && layer->replica_layer()->mask_layer())
550 layer->replica_layer()->mask_layer()->SavePaintProperties();
555 LayerType* layer,
558 // A layer and its descendants should render onto a new RenderSurfaceImpl if
562 // The root layer owns a render surface, but it never acts as a contributing
564 // a contributing surface can not be applied to the root layer. In order to
566 // in order to act as a contributing surface to the root layer's surface.
567 bool is_root = IsRootLayer(layer);
569 // If the layer uses a mask.
570 if (layer->mask_layer()) {
575 // If the layer has a reflection.
576 if (layer->replica_layer()) {
581 // If the layer uses a CSS filter.
582 if (!layer->filters().IsEmpty() || !layer->background_filters().IsEmpty()) {
588 layer->NumDescendantsThatDrawContent();
590 // If the layer flattens its subtree, but it is treated as a 3D object by its
592 if (LayerIsInExisting3DRenderingContext(layer) &&
593 layer->should_flatten_transform() &&
603 // If the layer has blending.
607 if (!layer->uses_default_blend_mode()) {
616 // If the layer clips its descendants but it is not axis-aligned with respect
619 LayerClipsSubtree(layer) || layer->HasDelegatedContent();
630 // If the layer has some translucency and does not have a preserves-3d
632 // layers in the subtree overlap. But checking layer overlaps is unnecessarily
637 (layer->DrawsContent() || num_descendants_that_draw_content > 1);
639 if (layer->opacity() != 1.f && layer->should_flatten_transform() &&
649 // The root layer should always have a render_surface.
658 // If the layer has isolation.
660 // the blending descendants might have access to the content behind this layer
661 // (layer has transparent background or descendants overflow).
663 if (layer->is_root_for_isolated_group()) {
672 if (layer->force_render_surface())
675 // If we'll make a copy of the layer's contents.
676 if (layer->HasCopyRequest())
683 // that's in the layer's target surface coordinate, while the position offset is
684 // specified in some ancestor layer's coordinate.
686 LayerImpl* layer,
691 // To apply a translate in the container's layer space,
696 // container's layer space
703 for (LayerImpl* current_target_surface = NextTargetSurface(layer);
722 // the container render surface to the container layer.
735 // projection. For example ScaleZ(0) is non-invertible but the layer is
751 Layer* layer,
756 LayerImpl* layer,
760 if (!layer->position_constraint().is_fixed_position())
763 // Special case: this layer is a composited fixed-position layer; we need to
765 // this layer fixed correctly.
771 // the layer should relocate itself if the container changes its size.
773 layer->position_constraint().is_fixed_to_right_edge();
775 layer->position_constraint().is_fixed_to_bottom_edge();
785 ComputeSizeDeltaCompensation(layer, container, position_offset));
792 // For every layer that has non-zero scroll_delta, we have to compute a
794 // want this matrix to premultiply a fixed-position layer's parent_matrix, so
807 // space. So this matrix can pre-multiply any fixed-position layer's
809 // layer is fixed onto the same render_target as this scrolling_layer.
838 LayerImpl* layer,
843 // scroll_delta translations that occurred since the nearest container layer,
848 // - A layer that is both a fixed-position and container should not be its
851 // - A layer that is a fixed-position container and has a render_surface
854 // - A layer that does not have an explicit container is simply fixed to the
856 // - If the fixed-position layer has its own render_surface, then the
864 // - the current layer is a container for fixed-position descendants
865 // - the current layer is fixed-position itself, so any fixed-position
866 // descendants are positioned with respect to this layer. Thus, any
868 // that occur below this layer.
870 layer->IsContainerForFixedPositionLayers() ||
871 layer->position_constraint().is_fixed_position();
877 scroll_delta.IsZero() && !layer->render_surface())
883 // If this layer does not reset scroll compensation, then it inherits the
888 // If the current layer has a non-zero scroll_delta, then we should compute
894 layer, parent_matrix, scroll_delta);
899 // If the layer created its own render_surface, we have to adjust
906 if (layer->render_surface() &&
910 if (!layer->render_surface()->draw_transform().GetInverse(
917 layer->render_surface()->draw_transform();
925 LayerType* layer,
930 layer->draw_properties().ideal_contents_scale = ideal_contents_scale;
931 layer->draw_properties().maximum_animation_contents_scale =
933 layer->draw_properties().page_scale_factor = page_scale_factor;
934 layer->draw_properties().device_scale_factor = device_scale_factor;
937 static inline void CalculateContentsScale(LayerImpl* layer,
943 static inline void CalculateContentsScale(Layer* layer, float contents_scale) {
944 layer->CalculateContentsScale(contents_scale,
945 &layer->draw_properties().contents_scale_x,
946 &layer->draw_properties().contents_scale_y,
947 &layer->draw_properties().content_bounds);
949 Layer* mask_layer = layer->mask_layer();
959 layer->replica_layer() ? layer->replica_layer()->mask_layer() : NULL;
970 LayerImpl* layer,
976 CalculateContentsScale(layer, ideal_contents_scale);
980 Layer* layer,
990 bool need_to_set_raster_scale = layer->raster_scale_is_unknown();
994 if (!need_to_set_raster_scale && layer->raster_scale() != 1.f &&
995 ideal_raster_scale != layer->raster_scale()) {
1004 layer->set_raster_scale(ideal_raster_scale);
1009 if (!layer->raster_scale_is_unknown())
1010 raster_scale = layer->raster_scale();
1012 gfx::Size old_content_bounds = layer->content_bounds();
1013 float old_contents_scale_x = layer->contents_scale_x();
1014 float old_contents_scale_y = layer->contents_scale_y();
1017 CalculateContentsScale(layer, contents_scale);
1019 if (layer->content_bounds() != old_content_bounds ||
1020 layer->contents_scale_x() != old_contents_scale_x ||
1021 layer->contents_scale_y() != old_contents_scale_y)
1022 layer->SetNeedsPushProperties();
1026 Layer* layer,
1038 LayerImpl* layer,
1067 !layer->layer_animation_controller()->HasOnlyTranslationTransforms();
1086 // At this point, we know either the layer or an ancestor, but not both,
1091 MathUtil::ComputeTransform2dScaleComponents(layer->transform(), 0.f);
1099 if (!layer->layer_animation_controller()->MaximumTargetScale(
1113 LayerType* layer) {
1114 if (!layer->render_surface()) {
1115 layer->CreateRenderSurface();
1116 return layer->render_surface();
1119 layer->render_surface()->ClearLayerLists();
1120 return layer->render_surface();
1125 LayerTypePtr layer,
1127 layer->draw_properties().last_drawn_render_surface_layer_list_id =
1133 LayerTypePtr layer,
1135 if (layer->mask_layer()) {
1136 MarkLayerWithRenderSurfaceLayerListId(layer->mask_layer(),
1139 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) {
1140 MarkLayerWithRenderSurfaceLayerListId(layer->replica_layer()->mask_layer(),
1164 // Technically, we know that the layer we want to remove should be
1206 // Recursively walks the layer tree to compute any information that is needed
1210 LayerType* layer,
1213 layer->draw_properties().sorted_for_recursion = false;
1214 layer->draw_properties().has_child_with_a_scroll_parent = false;
1216 if (!HasInvertibleOrAnimatedTransform(layer)) {
1222 if (layer->clip_parent())
1225 for (size_t i = 0; i < layer->children().size(); ++i) {
1227 LayerTreeHostCommon::get_layer_as_raw_ptr(layer->children(), i);
1233 layer->draw_properties().has_child_with_a_scroll_parent = true;
1237 if (layer->clip_children()) {
1238 int num_clip_children = layer->clip_children()->size();
1243 if (layer->HasCopyRequest())
1246 if (!layer->touch_event_handler_region().IsEmpty() ||
1247 layer->have_wheel_event_handlers())
1250 layer->draw_properties().num_unclipped_descendants =
1252 layer->draw_properties().layer_or_descendant_has_copy_request =
1254 layer->draw_properties().layer_or_descendant_has_input_handler =
1276 // The accumulated sequence of transforms a layer will use to determine its
1280 // The accumulated sequence of transforms a layer will use to determine its
1285 // fixed-position layer and its container, so that the layer actually does
1296 // When the layer's children want to compute their visible content rect, they
1301 // this value redundantly for each child layer, it is computed only once
1302 // while dealing with the parent layer, and then this precomputed value is
1306 // The maximum amount by which this layer will be scaled during the lifetime
1321 LayerType* layer) {
1322 for (LayerType* ancestor = layer; ancestor; ancestor = ancestor->parent()) {
1333 LayerType* layer) {
1339 // Take for example this layer tree:
1358 // So our first task at this step of the recursion is to determine the layer
1360 // containing |layer|.
1361 LayerType* child = GetChildContainingLayer(parent, layer);
1394 static void GetNewDescendantsStartIndexAndCount(LayerType* layer,
1397 *start_index = layer->draw_properties().index_of_first_descendants_addition;
1398 *count = layer->draw_properties().num_descendants_added;
1402 static void GetNewRenderSurfacesStartIndexAndCount(LayerType* layer,
1405 *start_index = layer->draw_properties()
1407 *count = layer->draw_properties().num_render_surfaces_added;
1445 // Recursively walks the layer tree starting at the given node and computes all
1449 LayerType* layer,
1457 // layer and all its descendants. It also computes the appropriate render
1464 // 1. In our terminology, the "layer origin" refers to the top-left corner of
1465 // a layer, and the positive Y-axis points downwards. This interpretation is
1470 // layer space", where the bounds of the layer map to [0, 1]. However, as a
1471 // Transform object, the transform to the anchor point is specified in "layer
1472 // space", where the bounds of the layer map to [bounds.width(),
1483 // this layer's origin.
1485 // Tr[origin2anchor] is the translation from the layer's origin to its
1488 // Tr[origin2center] is the translation from the layer's origin to its
1491 // M[layer] is the layer's matrix (applied at the anchor point)
1493 // S[layer2content] is the ratio of a layer's content_bounds() to its
1498 // composite_layer_transform = Tr[origin2anchor] * M[layer] *
1501 // 4. When a layer (or render surface) is drawn, it is drawn into a "target
1503 // transform from screen space to local layer space. Instead, the draw
1505 // local layer space. Note that render surfaces, except for the root, also
1512 // The draw transform for the layer is:
1514 // S[layer2content] = M[parent] * Tr[layer->position() + anchor] *
1515 // M[layer] * Tr[anchor2origin] * S[layer2content]
1518 // layer's render surface to the origin of the layer in content space.
1523 // = M[root] * Tr[layer->position() + anchor] * M[layer]
1527 // render surface's content space to the origin of the layer in content
1534 // = M[parent] * Tr[layer->position() + anchor] *
1535 // M[layer] * Tr[anchor2origin]
1540 // Finally, note that the final matrix used by the shader for the layer is P *
1544 // layer's size)
1546 // When a render surface has a replica layer, that layer's transform is used
1549 // replica layer.
1572 // which layer roots the subtree the scale is applied to.
1591 !layer->hide_layer_and_subtree();
1592 const bool layer_is_drawn = layer_is_visible || layer->HasCopyRequest();
1594 // The root layer cannot skip CalcDrawProperties.
1595 if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_drawn)) {
1596 if (layer->render_surface())
1597 layer->ClearRenderSurfaceLayerList();
1604 // separate the clipping hierarchy from the layer hierarchy.
1613 layer, &ancestor_clip_rect_in_target_space, &ancestor_clips_subtree);
1616 // layer that actually get computed. To avoid unnecessary copies
1619 DrawProperties<LayerType>& layer_draw_properties = layer->draw_properties();
1625 // the surface's clip rect redundantly for every layer. This value is the
1631 float accumulated_draw_opacity = layer->opacity();
1632 bool animating_opacity_to_target = layer->OpacityIsAnimating();
1634 if (layer->parent()) {
1635 accumulated_draw_opacity *= layer->parent()->draw_opacity();
1636 animating_opacity_to_target |= layer->parent()->draw_opacity_is_animating();
1638 layer->parent()->screen_space_opacity_is_animating();
1641 bool animating_transform_to_target = layer->TransformIsAnimating();
1643 if (layer->parent()) {
1645 layer->parent()->draw_transform_is_animating();
1647 layer->parent()->screen_space_transform_is_animating();
1649 gfx::Point3F transform_origin = layer->transform_origin();
1650 gfx::Vector2dF scroll_offset = GetEffectiveTotalScrollOffset(layer);
1651 gfx::PointF position = layer->position() - scroll_offset;
1653 if (!layer->transform().IsIdentity()) {
1658 // LT = Tr[origin] * Tr[origin2origin] * M[layer]
1659 combined_transform.PreconcatTransform(layer->transform());
1660 // LT = Tr[origin] * Tr[origin2origin] * M[layer] *
1668 gfx::Vector2dF effective_scroll_delta = GetEffectiveScrollDelta(layer);
1669 if (!animating_transform_to_target && layer->scrollable() &&
1671 // Align the scrollable layer's position to screen space pixels to avoid
1682 // the layer's transform). For example, if we have a total scale factor of
1693 ApplyPositionAdjustment(layer, data_from_ancestor.fixed_container,
1700 layer,
1713 // surface. From there, we can decide on a contents scale for the layer.
1728 layer,
1738 layer,
1746 LayerType* mask_layer = layer->mask_layer();
1759 layer->replica_layer() ? layer->replica_layer()->mask_layer() : NULL;
1771 // The draw_transform that gets computed below is effectively the layer's
1772 // draw_transform, unless the layer itself creates a render_surface. In that
1777 SK_MScalar1 / layer->contents_scale_x(),
1778 SK_MScalar1 / layer->contents_scale_y());
1780 // The layer's screen_space_transform represents the transform between root
1781 // layer's "screen space" and local content space.
1784 if (layer->should_flatten_transform())
1801 gfx::Rect content_rect(layer->content_bounds());
1805 // space. next_hierarchy_matrix will only change if this layer uses a new
1810 // If the subtree will scale layer contents by the transform hierarchy, then
1821 layer, combined_transform.Preserves2dAxisAlignment());
1823 render_to_separate_surface = IsRootLayer(layer);
1828 if (!layer->double_sided() && TransformToParentIsKnown(layer) &&
1829 IsSurfaceBackFaceVisible(layer, combined_transform)) {
1830 layer->ClearRenderSurfaceLayerList();
1835 CreateOrReuseRenderSurface(layer);
1837 if (IsRootLayer(layer)) {
1838 // The root layer's render surface size is predetermined and so the root
1839 // layer can't directly support non-identity transforms. It should just
1845 layer->render_surface()->set_contributes_to_drawn_surface(false);
1847 // The owning layer's draw transform has a scale from content to layer
1855 // The owning layer's transform was re-parented by the surface, so the
1856 // layer's new draw_transform only needs to scale the layer to surface
1860 Scale(render_surface_sublayer_scale.x() / layer->contents_scale_x(),
1861 render_surface_sublayer_scale.y() / layer->contents_scale_y());
1863 // Inside the surface's subtree, we scale everything to the owning layer's
1864 // scale. The sublayer matrix transforms layer rects into target surface
1867 // but we apply it explicitly to the owning layer and the remainder of the
1875 layer->render_surface()->set_contributes_to_drawn_surface(
1879 // The opacity value is moved from the layer to its surface, so that the
1904 if (layer->mask_layer()) {
1906 layer->mask_layer()->draw_properties();
1907 mask_layer_draw_properties.render_target = layer;
1909 gfx::Rect(layer->content_bounds());
1912 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) {
1914 layer->replica_layer()->mask_layer()->draw_properties();
1915 replica_mask_draw_properties.render_target = layer;
1917 gfx::Rect(layer->content_bounds());
1923 // where both layer and the replica are occluded, but this seems like an
1927 if (layer->HasCopyRequest() ||
1928 layer->has_replica() ||
1929 layer->filters().HasReferenceFilter() ||
1930 layer->filters().HasFilterThatMovesPixels()) {
1939 // It may be the layer or the surface doing the clipping of the subtree,
1960 // layer clipping for correctess. NB: since we can only encounter
1979 DCHECK(layer->render_surface());
1980 DCHECK(!layer->parent() || layer->parent()->render_target() ==
1984 AccumulatedSurfaceState<LayerType>(layer));
1998 render_surface_layer_list->push_back(layer);
2000 DCHECK(layer->parent());
2014 layer->ClearRenderSurface();
2031 layer_draw_properties.render_target = layer->parent()->render_target();
2038 MathUtil::MapEnclosingClippedRect(layer->draw_transform(), content_rect);
2040 if (LayerClipsSubtree(layer)) {
2042 if (ancestor_clips_subtree && !layer->render_surface()) {
2043 // A layer without render surface shares the same target as its ancestor.
2052 // Tell the layer the rect that it's clipped by. In theory we could use a
2062 // layer, just in case clipping is still accidentally used.
2067 (layer->render_surface() ? layer->render_surface()->layer_list()
2070 // Any layers that are appended after this point are in the layer's subtree
2074 if (!LayerShouldBeSkipped(layer, layer_is_drawn)) {
2075 MarkLayerWithRenderSurfaceLayerListId(layer,
2077 descendants.push_back(layer);
2086 if (!layer->children().empty()) {
2087 if (layer == globals.page_scale_application_layer) {
2094 // Flatten to 2D if the layer doesn't preserve 3D.
2095 if (layer->should_flatten_transform())
2100 layer,
2105 layer->IsContainerForFixedPositionLayers() ?
2106 layer : data_from_ancestor.fixed_container;
2121 child_order_changed = SortChildrenForRecursion(&sorted_children, *layer);
2123 for (size_t i = 0; i < layer->children().size(); ++i) {
2124 // If one of layer's children has a scroll parent, then we may have to
2127 // layer's list of children.
2131 : LayerTreeHostCommon::get_layer_as_raw_ptr(layer->children(), i);
2150 // we need to mark just the mask layer (and replica mask layer)
2166 // Add the unsorted layer list contributions, if necessary.
2169 *layer,
2175 *layer,
2185 if (layer->render_surface()) {
2186 DCHECK(accumulated_surface_state->back().render_target == layer);
2190 if (layer->render_surface() && !IsRootLayer(layer) &&
2191 layer->render_surface()->layer_list().empty()) {
2192 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list);
2196 // Compute the layer's drawable content rect (the rect is in target surface
2203 if (layer->DrawsContent()) {
2208 // Compute the layer's visible content rect (the rect is in content space).
2210 layer, clip_rect_of_target_surface_in_target_space, rect_in_target_space);
2212 // Compute the remaining properties for the render surface, if the layer has
2214 if (IsRootLayer(layer)) {
2215 // The root layer's surface's content_rect is always the entire viewport.
2216 DCHECK(layer->render_surface());
2217 layer->render_surface()->SetContentRect(
2219 } else if (layer->render_surface()) {
2221 layer->render_surface();
2224 // Don't clip if the layer is reflected as the reflection shouldn't be
2225 // clipped. If the layer is animating, then the surface's transform to
2228 if (!layer->replica_layer() && TransformToParentIsKnown(layer)) {
2230 // here, because we are looking at this layer's render_surface, not the
2231 // layer itself.
2249 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list);
2255 // either root_for_isolated_group, or the root of the layer tree.
2256 // Otherwise, this layer will use an incomplete backdrop, limited to its
2258 DCHECK(layer->uses_default_blend_mode() || IsRootLayer(layer) ||
2259 !layer->parent()->render_target() ||
2260 IsRootLayer(layer->parent()->render_target()) ||
2261 layer->parent()->render_target()->is_root_for_isolated_group());
2265 // The owning layer's screen_space_transform has a scale from content to
2266 // layer space which we need to undo and replace with a scale from the
2267 // surface's subtree into layer space.
2268 gfx::Transform screen_space_transform = layer->screen_space_transform();
2270 layer->contents_scale_x() / render_surface_sublayer_scale.x(),
2271 layer->contents_scale_y() / render_surface_sublayer_scale.y());
2274 if (layer->replica_layer()) {
2279 layer->replica_layer()->position().x() +
2280 layer->replica_layer()->transform_origin().x(),
2281 layer->replica_layer()->position().y() +
2282 layer->replica_layer()->transform_origin().y());
2284 layer->replica_layer()->transform());
2286 -layer->replica_layer()->transform_origin().x(),
2287 -layer->replica_layer()->transform_origin().y());
2295 layer->render_surface()->draw_transform() *
2302 layer->render_surface()->screen_space_transform() *
2309 SavePaintPropertiesLayer(layer);
2311 // If neither this layer nor any of its children were added, early out.
2313 DCHECK(!layer->render_surface() || IsRootLayer(layer));
2321 if (globals.layer_sorter && descendants.size() && layer->Is3dSorted() &&
2322 !LayerIsInExisting3DRenderingContext(layer)) {
2329 layer, local_drawable_content_rect_of_subtree, accumulated_surface_state);
2331 if (layer->HasContributingDelegatedRenderPasses()) {
2332 layer->render_target()->render_surface()->
2333 AddContributingDelegatedRenderPassLayer(layer);
2350 // The root layer's render_surface should receive the device viewport as the
2410 // The dummy layer list should not have been used.
2412 // A root layer render_surface should always exist after
2440 // The dummy layer list should not have been used.
2442 // A root layer render_surface should always exist after