return layer_bound_rect;
}
- gfx::Rect layer_rect = gfx::ToEnclosingRect(MathUtil::ProjectClippedRect(
- surface_to_layer, gfx::RectF(minimal_surface_rect)));
+ gfx::Rect layer_rect = MathUtil::ProjectEnclosingClippedRect(
+ surface_to_layer, minimal_surface_rect);
layer_rect.Intersect(layer_bound_rect);
return layer_rect;
}
const gfx::Rect& layer_bound_rect,
const gfx::Transform& transform) {
gfx::Rect layer_in_surface_space =
- MathUtil::MapClippedRect(transform, layer_bound_rect);
+ MathUtil::MapEnclosingClippedRect(transform, layer_bound_rect);
return CalculateVisibleRectWithCachedLayerRect(
target_surface_rect, layer_bound_rect, layer_in_surface_space, transform);
}
template <typename LayerType>
static inline bool LayerIsInExisting3DRenderingContext(LayerType* layer) {
- // According to current W3C spec on CSS transforms, a layer is part of an
- // established 3d rendering context if its parent has transform-style of
- // preserves-3d.
- return layer->parent() && layer->parent()->preserves_3d();
+ return layer->is_3d_sorted() && layer->parent() &&
+ layer->parent()->is_3d_sorted();
}
template <typename LayerType>
static bool IsRootLayerOfNewRenderingContext(LayerType* layer) {
- // According to current W3C spec on CSS transforms (Section 6.1), a layer is
- // the beginning of 3d rendering context if its parent does not have
- // transform-style: preserve-3d, but this layer itself does.
if (layer->parent())
- return !layer->parent()->preserves_3d() && layer->preserves_3d();
+ return !layer->parent()->is_3d_sorted() && layer->is_3d_sorted();
- return layer->preserves_3d();
+ return layer->is_3d_sorted();
}
template <typename LayerType>
}
template <typename LayerType>
-static bool LayerShouldBeSkipped(LayerType* layer,
- bool layer_is_visible) {
+static bool LayerShouldBeSkipped(LayerType* layer, bool layer_is_drawn) {
// Layers can be skipped if any of these conditions are met.
- // - is not visible due to it or one of its ancestors being hidden.
+ // - is not drawn due to it or one of its ancestors being hidden (or having
+ // no copy requests).
// - has empty bounds
// - the layer is not double-sided, but its back face is visible.
// - is transparent
// transparent, we would have skipped the entire subtree and never made it
// into this function, so it is safe to omit this check here.
- if (!layer_is_visible)
+ if (!layer_is_drawn)
return true;
if (layer->bounds().IsEmpty())
}
static inline bool SubtreeShouldBeSkipped(LayerImpl* layer,
- bool layer_is_visible) {
+ bool layer_is_drawn) {
// When we need to do a readback/copy of a layer's output, we can not skip
// it or any of its ancestors.
if (layer->draw_properties().layer_or_descendant_has_copy_request)
return false;
- // If the layer is not visible, then skip it and its subtree.
- if (!layer_is_visible)
+ // If the layer is not drawn, then skip it and its subtree.
+ if (!layer_is_drawn)
return true;
// If layer is on the pending tree and opacity is being animated then
return !layer->opacity();
}
-static inline bool SubtreeShouldBeSkipped(Layer* layer,
- bool layer_is_visible) {
+static inline bool SubtreeShouldBeSkipped(Layer* layer, bool layer_is_drawn) {
// When we need to do a readback/copy of a layer's output, we can not skip
// it or any of its ancestors.
if (layer->draw_properties().layer_or_descendant_has_copy_request)
return false;
- // If the layer is not visible, then skip it and its subtree.
- if (!layer_is_visible)
+ // If the layer is not drawn, then skip it and its subtree.
+ if (!layer_is_drawn)
return true;
// If the opacity is being animated then the opacity on the main thread is
int num_descendants_that_draw_content =
layer->draw_properties().num_descendants_that_draw_content;
- // If the layer flattens its subtree (i.e. the layer doesn't preserve-3d), but
- // it is treated as a 3D object by its parent (i.e. parent does preserve-3d).
- if (LayerIsInExisting3DRenderingContext(layer) && !layer->preserves_3d() &&
+ // If the layer flattens its subtree, but it is treated as a 3D object by its
+ // parent (i.e. parent participates in a 3D rendering context).
+ if (LayerIsInExisting3DRenderingContext(layer) &&
+ layer->should_flatten_transform() &&
num_descendants_that_draw_content > 0) {
TRACE_EVENT_INSTANT0(
"cc",
num_descendants_that_draw_content > 0 &&
(layer->DrawsContent() || num_descendants_that_draw_content > 1);
- if (layer->opacity() != 1.f && !layer->preserves_3d() &&
+ if (layer->opacity() != 1.f && layer->should_flatten_transform() &&
at_least_two_layers_in_subtree_draw_content) {
TRACE_EVENT_INSTANT0(
"cc",
layer->position_constraint().is_fixed_to_right_edge();
bool fixed_to_bottom_edge =
layer->position_constraint().is_fixed_to_bottom_edge();
- gfx::Vector2dF position_offset = container->fixed_container_size_delta();
+ gfx::Vector2dF position_offset = container->FixedContainerSizeDelta();
position_offset.set_x(fixed_to_right_edge ? position_offset.x() : 0);
position_offset.set_y(fixed_to_bottom_edge ? position_offset.y() : 0);
if (position_offset.IsZero())
//
// M[layer] is the layer's matrix (applied at the anchor point)
//
- // M[sublayer] is the layer's sublayer transform (also applied at the
- // layer's anchor point)
- //
// S[layer2content] is the ratio of a layer's content_bounds() to its
// Bounds().
//
// composite_layer_transform = Tr[origin2anchor] * M[layer] *
// Tr[origin2anchor].inverse()
//
- // composite_sublayer_transform = Tr[origin2anchor] * M[sublayer] *
- // 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
// 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 * composite_sublayer_transform
+ // composite_layer_transform
// = M[parent] * Tr[layer->position() + anchor] *
- // M[layer] * Tr[anchor2origin] *
- // composite_sublayer_transform
+ // M[layer] * Tr[anchor2origin]
//
// and a similar matrix for the full hierarchy with respect to the
// root.
data_for_children.subtree_can_use_lcd_text =
data_from_ancestor.subtree_can_use_lcd_text;
- // Layers with a copy request are always visible, as well as un-hiding their
- // subtree. Otherise, layers that are marked as hidden will hide themselves
- // and their subtree.
- bool layer_is_visible =
+ // 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->hide_layer_and_subtree();
- if (layer->HasCopyRequest())
- layer_is_visible = true;
+ const bool layer_is_drawn = layer_is_visible || layer->HasCopyRequest();
// The root layer cannot skip CalcDrawProperties.
- if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_visible)) {
+ if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_drawn)) {
if (layer->render_surface())
layer->ClearRenderSurface();
return;
// layer's "screen space" and local content space.
layer_draw_properties.screen_space_transform =
data_from_ancestor.full_hierarchy_matrix;
- if (!layer->preserves_3d())
+ if (layer->should_flatten_transform())
layer_draw_properties.screen_space_transform.FlattenTo2d();
layer_draw_properties.screen_space_transform.PreconcatTransform
(layer_draw_properties.target_space_transform);
data_for_children.parent_matrix.Scale(render_surface_sublayer_scale.x(),
render_surface_sublayer_scale.y());
+ // Even if the |layer_is_drawn|, it only contributes to a drawn surface
+ // when the |layer_is_visible|.
layer->render_surface()->set_contributes_to_drawn_surface(
- data_from_ancestor.subtree_is_visible_from_ancestor &&
layer_is_visible);
}
// here, or DCHECK that the transform is invertible.
}
- gfx::Rect projected_surface_rect = gfx::ToEnclosingRect(
- MathUtil::ProjectClippedRect(inverse_surface_draw_transform,
- ancestor_clip_rect_in_target_space));
+ gfx::Rect projected_surface_rect = MathUtil::ProjectEnclosingClippedRect(
+ inverse_surface_draw_transform, ancestor_clip_rect_in_target_space);
if (layer_draw_properties.num_unclipped_descendants > 0) {
// If we have unclipped descendants, we cannot count on the render
// and should be included in the sorting process.
size_t sorting_start_index = descendants.size();
- if (!LayerShouldBeSkipped(layer, layer_is_visible))
+ if (!LayerShouldBeSkipped(layer, layer_is_drawn))
descendants.push_back(layer);
// Any layers that are appended after this point may need to be sorted if we
}
// Flatten to 2D if the layer doesn't preserve 3D.
- if (!layer->preserves_3d())
+ if (layer->should_flatten_transform())
data_for_children.parent_matrix.FlattenTo2d();
- // Apply the sublayer transform at the anchor point of the layer.
- if (!layer->sublayer_transform().IsIdentity()) {
- data_for_children.parent_matrix.Translate(
- layer->anchor_point().x() * bounds.width(),
- layer->anchor_point().y() * bounds.height());
- data_for_children.parent_matrix.PreconcatTransform(
- layer->sublayer_transform());
- data_for_children.parent_matrix.Translate(
- -layer->anchor_point().x() * bounds.width(),
- -layer->anchor_point().y() * bounds.height());
- }
-
data_for_children.scroll_compensation_matrix =
ComputeScrollCompensationMatrixForChildren(
layer,
layer_or_ancestor_clips_descendants;
data_for_children.nearest_occlusion_immune_ancestor_surface =
nearest_occlusion_immune_ancestor_surface;
- data_for_children.subtree_is_visible_from_ancestor = layer_is_visible;
+ data_for_children.subtree_is_visible_from_ancestor = layer_is_drawn;
}
std::vector<LayerType*> sorted_children;
// drawn from back to front. If the preserves-3d property is also set on the
// parent then skip the sorting as the parent will sort all the descendants
// anyway.
- if (globals.layer_sorter && descendants.size() && layer->preserves_3d() &&
- (!layer->parent() || !layer->parent()->preserves_3d())) {
+ if (globals.layer_sorter && descendants.size() && layer->is_3d_sorted() &&
+ !LayerIsInExisting3DRenderingContext(layer)) {
SortLayers(descendants.begin() + sorting_start_index,
descendants.end(),
globals.layer_sorter);
const LayerImplList& render_surface_layer_list) {
LayerImpl* found_layer = NULL;
- typedef LayerIterator<LayerImpl,
- LayerImplList,
- RenderSurfaceImpl,
- LayerIteratorActions::FrontToBack> LayerIteratorType;
+ typedef LayerIterator<LayerImpl> LayerIteratorType;
LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list);
-
for (LayerIteratorType
it = LayerIteratorType::Begin(&render_surface_layer_list);
it != end;