Index: cc/trees/draw_property_utils.cc |
diff --git a/cc/trees/draw_property_utils.cc b/cc/trees/draw_property_utils.cc |
index 2481e2dc14bfc69580acbdcfabac8f012e1aab22..3f9c1206f2f657eaf4a69d9780c33c946cf6da89 100644 |
--- a/cc/trees/draw_property_utils.cc |
+++ b/cc/trees/draw_property_utils.cc |
@@ -627,9 +627,7 @@ void ComputeVisibleRectsUsingPropertyTrees(LayerImpl* root_layer, |
template <typename LayerType> |
gfx::Transform DrawTransformFromPropertyTreesInternal( |
const LayerType* layer, |
- const TransformTree& tree) { |
- const TransformNode* node = tree.Node(layer->transform_tree_index()); |
- |
+ const TransformNode* node) { |
gfx::Transform xform; |
const bool owns_non_root_surface = |
layer->parent() && layer->has_render_surface(); |
@@ -650,17 +648,18 @@ gfx::Transform DrawTransformFromPropertyTreesInternal( |
gfx::Transform DrawTransformFromPropertyTrees(const Layer* layer, |
const TransformTree& tree) { |
- return DrawTransformFromPropertyTreesInternal(layer, tree); |
+ return DrawTransformFromPropertyTreesInternal( |
+ layer, tree.Node(layer->transform_tree_index())); |
} |
gfx::Transform DrawTransformFromPropertyTrees(const LayerImpl* layer, |
const TransformTree& tree) { |
- return DrawTransformFromPropertyTreesInternal(layer, tree); |
+ return DrawTransformFromPropertyTreesInternal( |
+ layer, tree.Node(layer->transform_tree_index())); |
} |
-gfx::Transform DrawTransformOfRenderSurfaceFromPropertyTrees( |
- const RenderSurfaceImpl* render_surface, |
- const TransformTree& tree) { |
+gfx::Transform SurfaceDrawTransform(const RenderSurfaceImpl* render_surface, |
+ const TransformTree& tree) { |
const TransformNode* node = tree.Node(render_surface->TransformTreeIndex()); |
gfx::Transform render_surface_transform; |
// The draw transform of root render surface is identity tranform. |
@@ -678,28 +677,24 @@ gfx::Transform DrawTransformOfRenderSurfaceFromPropertyTrees( |
return render_surface_transform; |
} |
-bool RenderSurfaceIsClippedFromPropertyTrees( |
- const RenderSurfaceImpl* render_surface, |
- const ClipTree& tree) { |
- const ClipNode* node = tree.Node(render_surface->ClipTreeIndex()); |
+bool SurfaceIsClipped(const RenderSurfaceImpl* render_surface, |
+ const ClipNode* clip_node) { |
// If the render surface's owning layer doesn't form a clip node, it is not |
// clipped. |
- if (render_surface->OwningLayerId() != node->owner_id) |
+ if (render_surface->OwningLayerId() != clip_node->owner_id) |
return false; |
- return node->data.render_surface_is_clipped; |
+ return clip_node->data.render_surface_is_clipped; |
} |
-gfx::Rect ClipRectOfRenderSurfaceFromPropertyTrees( |
- const RenderSurfaceImpl* render_surface, |
- const ClipTree& clip_tree) { |
- if (!RenderSurfaceIsClippedFromPropertyTrees(render_surface, clip_tree)) |
+gfx::Rect SurfaceClipRect(const RenderSurfaceImpl* render_surface, |
+ const ClipNode* parent_clip_node, |
+ bool is_clipped) { |
+ if (!is_clipped) |
return gfx::Rect(); |
- const ClipNode* clip_node = clip_tree.Node(render_surface->ClipTreeIndex()); |
- const ClipNode* parent_clip_node = clip_tree.parent(clip_node); |
return gfx::ToEnclosingRect(parent_clip_node->data.clip_in_target_space); |
} |
-gfx::Transform ScreenSpaceTransformOfRenderSurfaceFromPropertyTrees( |
+gfx::Transform SurfaceScreenSpaceTransform( |
const RenderSurfaceImpl* render_surface, |
const TransformTree& tree) { |
const TransformNode* node = tree.Node(render_surface->TransformTreeIndex()); |
@@ -718,75 +713,31 @@ gfx::Transform ScreenSpaceTransformOfRenderSurfaceFromPropertyTrees( |
template <typename LayerType> |
gfx::Transform ScreenSpaceTransformFromPropertyTreesInternal( |
LayerType* layer, |
- const TransformTree& tree) { |
+ const TransformNode* node) { |
gfx::Transform xform(1, 0, 0, 1, layer->offset_to_transform_parent().x(), |
layer->offset_to_transform_parent().y()); |
- if (layer->transform_tree_index() >= 0) { |
- gfx::Transform ssxform = |
- tree.Node(layer->transform_tree_index())->data.to_screen; |
- xform.ConcatTransform(ssxform); |
- if (layer->should_flatten_transform_from_property_tree()) |
- xform.FlattenTo2d(); |
- } |
+ gfx::Transform ssxform = node->data.to_screen; |
+ xform.ConcatTransform(ssxform); |
+ if (layer->should_flatten_transform_from_property_tree()) |
+ xform.FlattenTo2d(); |
return xform; |
} |
gfx::Transform ScreenSpaceTransformFromPropertyTrees( |
const Layer* layer, |
const TransformTree& tree) { |
- return ScreenSpaceTransformFromPropertyTreesInternal(layer, tree); |
+ return ScreenSpaceTransformFromPropertyTreesInternal( |
+ layer, tree.Node(layer->transform_tree_index())); |
} |
gfx::Transform ScreenSpaceTransformFromPropertyTrees( |
const LayerImpl* layer, |
const TransformTree& tree) { |
- return ScreenSpaceTransformFromPropertyTreesInternal(layer, tree); |
-} |
- |
-template <typename LayerType> |
-bool ScreenSpaceTransformIsAnimatingFromPropertyTreesInternal( |
- LayerType* layer, |
- const TransformTree& tree) { |
- return tree.Node(layer->transform_tree_index())->data.to_screen_is_animated; |
-} |
- |
-bool ScreenSpaceTransformIsAnimatingFromPropertyTrees( |
- const Layer* layer, |
- const TransformTree& tree) { |
- return ScreenSpaceTransformIsAnimatingFromPropertyTreesInternal(layer, tree); |
-} |
- |
-bool ScreenSpaceTransformIsAnimatingFromPropertyTrees( |
- const LayerImpl* layer, |
- const TransformTree& tree) { |
- return ScreenSpaceTransformIsAnimatingFromPropertyTreesInternal(layer, tree); |
+ return ScreenSpaceTransformFromPropertyTreesInternal( |
+ layer, tree.Node(layer->transform_tree_index())); |
} |
-float MaximumAnimationTargetScaleFromPropertyTrees(const LayerImpl* layer, |
- const TransformTree& tree) { |
- if (!layer->layer_tree_impl() |
- ->settings() |
- .layer_transforms_should_scale_layer_contents) |
- return 0.f; |
- |
- return tree.Node(layer->transform_tree_index()) |
- ->data.combined_maximum_animation_target_scale; |
-} |
- |
-float StartingAnimationScaleFromPropertyTrees(const LayerImpl* layer, |
- const TransformTree& tree) { |
- if (!layer->layer_tree_impl() |
- ->settings() |
- .layer_transforms_should_scale_layer_contents) |
- return 0.f; |
- |
- return tree.Node(layer->transform_tree_index()) |
- ->data.combined_starting_animation_scale; |
-} |
- |
-template <typename LayerType> |
-float DrawOpacityFromPropertyTreesInternal(LayerType layer, |
- const EffectTree& tree) { |
+float LayerDrawOpacity(const LayerImpl* layer, const EffectTree& tree) { |
if (!layer->render_target()) |
return 0.f; |
@@ -804,18 +755,8 @@ float DrawOpacityFromPropertyTreesInternal(LayerType layer, |
return draw_opacity; |
} |
-float DrawOpacityFromPropertyTrees(const Layer* layer, const EffectTree& tree) { |
- return DrawOpacityFromPropertyTreesInternal(layer, tree); |
-} |
- |
-float DrawOpacityFromPropertyTrees(const LayerImpl* layer, |
- const EffectTree& tree) { |
- return DrawOpacityFromPropertyTreesInternal(layer, tree); |
-} |
- |
-float DrawOpacityOfRenderSurfaceFromPropertyTrees( |
- RenderSurfaceImpl* render_surface, |
- const EffectTree& tree) { |
+float SurfaceDrawOpacity(RenderSurfaceImpl* render_surface, |
+ const EffectTree& tree) { |
const EffectNode* node = tree.Node(render_surface->EffectTreeIndex()); |
float target_opacity_tree_index = render_surface->TargetEffectTreeIndex(); |
if (target_opacity_tree_index < 0) |
@@ -829,25 +770,20 @@ float DrawOpacityOfRenderSurfaceFromPropertyTrees( |
return draw_opacity; |
} |
-bool CanUseLcdTextFromPropertyTrees(const LayerImpl* layer, |
- bool layers_always_allowed_lcd_text, |
- bool can_use_lcd_text, |
- PropertyTrees* property_trees) { |
+bool LayerCanUseLcdText(const LayerImpl* layer, |
+ bool layers_always_allowed_lcd_text, |
+ bool can_use_lcd_text, |
+ const TransformNode* transform_node, |
+ const EffectNode* effect_node) { |
if (layers_always_allowed_lcd_text) |
return true; |
if (!can_use_lcd_text) |
return false; |
if (!layer->contents_opaque()) |
return false; |
- DCHECK(!property_trees->transform_tree.needs_update()); |
- DCHECK(!property_trees->effect_tree.needs_update()); |
- const EffectNode* opacity_node = |
- property_trees->effect_tree.Node(layer->effect_tree_index()); |
- if (opacity_node->data.screen_space_opacity != 1.f) |
+ if (effect_node->data.screen_space_opacity != 1.f) |
return false; |
- const TransformNode* transform_node = |
- property_trees->transform_tree.Node(layer->transform_tree_index()); |
if (!transform_node->data.node_and_ancestors_have_only_integer_translation) |
return false; |
if (static_cast<int>(layer->offset_to_transform_parent().x()) != |
@@ -859,47 +795,28 @@ bool CanUseLcdTextFromPropertyTrees(const LayerImpl* layer, |
return true; |
} |
-gfx::Rect DrawableContentRectOfSurfaceFromPropertyTrees( |
- const RenderSurfaceImpl* render_surface, |
- const TransformTree& transform_tree) { |
+gfx::Rect DrawableContentRectOfSurface( |
+ const RenderSurfaceImpl* render_surface) { |
gfx::Rect drawable_content_rect = |
gfx::ToEnclosingRect(MathUtil::MapClippedRect( |
- DrawTransformOfRenderSurfaceFromPropertyTrees(render_surface, |
- transform_tree), |
+ render_surface->draw_transform(), |
render_surface->content_rect_from_property_trees())); |
if (render_surface->HasReplica()) { |
drawable_content_rect.Union(gfx::ToEnclosingRect(MathUtil::MapClippedRect( |
- DrawTransformOfRenderSurfaceReplicaFromPropertyTrees(render_surface, |
- transform_tree), |
+ render_surface->replica_draw_transform(), |
render_surface->content_rect_from_property_trees()))); |
} |
return drawable_content_rect; |
} |
-gfx::Rect DrawableContentRectFromPropertyTrees( |
+gfx::Rect LayerDrawableContentRect( |
const LayerImpl* layer, |
- const TransformTree& transform_tree) { |
- gfx::Rect drawable_content_rect = MathUtil::MapEnclosingClippedRect( |
- DrawTransformFromPropertyTrees(layer, transform_tree), |
- gfx::Rect(layer->bounds())); |
- if (layer->is_clipped() && layer->clip_tree_index() > 0) { |
- drawable_content_rect.Intersect( |
- layer->clip_rect_in_target_space_from_property_trees()); |
- } |
- return drawable_content_rect; |
-} |
- |
-gfx::Rect ClipRectFromPropertyTrees(const LayerImpl* layer, |
- const TransformTree& transform_tree) { |
+ const gfx::Rect& layer_bounds_in_target_space, |
+ const gfx::Rect& clip_rect) { |
if (layer->is_clipped() && layer->clip_tree_index() > 0) |
- return layer->clip_rect_in_target_space_from_property_trees(); |
- return MathUtil::MapEnclosingClippedRect( |
- DrawTransformFromPropertyTrees(layer, transform_tree), |
- gfx::Rect(layer->bounds())); |
-} |
+ return IntersectRects(layer_bounds_in_target_space, clip_rect); |
-gfx::Rect ViewportRectFromPropertyTrees(const ClipTree& tree) { |
- return gfx::ToEnclosingRect(tree.Node(1)->data.clip); |
+ return layer_bounds_in_target_space; |
} |
gfx::Transform ReplicaToSurfaceTransform( |
@@ -929,23 +846,98 @@ gfx::Transform ReplicaToSurfaceTransform( |
return replica_to_surface; |
} |
-gfx::Transform DrawTransformOfRenderSurfaceReplicaFromPropertyTrees( |
- const RenderSurfaceImpl* render_surface, |
- const TransformTree& tree) { |
- if (!render_surface->HasReplica()) |
- return gfx::Transform(); |
- return DrawTransformOfRenderSurfaceFromPropertyTrees(render_surface, tree) * |
- ReplicaToSurfaceTransform(render_surface, tree); |
+gfx::Rect LayerClipRect(const LayerImpl* layer, |
+ const gfx::Rect& layer_bounds_in_target_space) { |
+ if (layer->is_clipped() && layer->clip_tree_index() > 0) |
+ return layer->clip_rect_in_target_space_from_property_trees(); |
+ |
+ return layer_bounds_in_target_space; |
} |
-gfx::Transform ScreenSpaceTransformOfRenderSurfaceReplicaFromPropertyTrees( |
- const RenderSurfaceImpl* render_surface, |
- const TransformTree& tree) { |
- if (!render_surface->HasReplica()) |
- return gfx::Transform(); |
- return ScreenSpaceTransformOfRenderSurfaceFromPropertyTrees(render_surface, |
- tree) * |
- ReplicaToSurfaceTransform(render_surface, tree); |
+gfx::Rect ViewportRectFromPropertyTrees(const ClipTree& tree) { |
+ return gfx::ToEnclosingRect(tree.Node(1)->data.clip); |
+} |
+ |
+void ComputeLayerDrawPropertiesUsingPropertyTrees( |
+ const LayerImpl* layer, |
+ const PropertyTrees* property_trees, |
+ bool layers_always_allowed_lcd_text, |
+ bool can_use_lcd_text, |
+ DrawProperties<LayerImpl>* draw_properties) { |
+ draw_properties->visible_layer_rect = |
+ layer->visible_rect_from_property_trees(); |
+ |
+ const TransformNode* transform_node = |
+ property_trees->transform_tree.Node(layer->transform_tree_index()); |
+ const EffectNode* effect_node = |
+ property_trees->effect_tree.Node(layer->effect_tree_index()); |
+ |
+ draw_properties->target_space_transform = |
+ DrawTransformFromPropertyTreesInternal(layer, transform_node); |
+ draw_properties->screen_space_transform = |
+ ScreenSpaceTransformFromPropertyTreesInternal(layer, transform_node); |
+ draw_properties->screen_space_transform_is_animating = |
+ transform_node->data.to_screen_is_animated; |
+ if (layer->layer_tree_impl() |
+ ->settings() |
+ .layer_transforms_should_scale_layer_contents) { |
+ draw_properties->maximum_animation_contents_scale = |
+ transform_node->data.combined_maximum_animation_target_scale; |
+ draw_properties->starting_animation_contents_scale = |
+ transform_node->data.combined_starting_animation_scale; |
+ } else { |
+ draw_properties->maximum_animation_contents_scale = 0.f; |
+ draw_properties->starting_animation_contents_scale = 0.f; |
+ } |
+ |
+ draw_properties->opacity = |
+ LayerDrawOpacity(layer, property_trees->effect_tree); |
+ draw_properties->can_use_lcd_text = |
+ LayerCanUseLcdText(layer, layers_always_allowed_lcd_text, |
+ can_use_lcd_text, transform_node, effect_node); |
+ |
+ gfx::Rect bounds_in_target_space = MathUtil::MapEnclosingClippedRect( |
+ draw_properties->target_space_transform, gfx::Rect(layer->bounds())); |
+ draw_properties->clip_rect = LayerClipRect(layer, bounds_in_target_space); |
+ draw_properties->drawable_content_rect = LayerDrawableContentRect( |
+ layer, bounds_in_target_space, draw_properties->clip_rect); |
+} |
+ |
+SurfaceDrawProperties::SurfaceDrawProperties() |
+ : is_clipped(false), draw_opacity(0.f) {} |
+ |
+SurfaceDrawProperties::~SurfaceDrawProperties() {} |
+ |
+void ComputeSurfaceDrawPropertiesUsingPropertyTrees( |
+ RenderSurfaceImpl* render_surface, |
+ const PropertyTrees* property_trees, |
+ SurfaceDrawProperties* draw_properties) { |
+ const ClipNode* clip_node = |
+ property_trees->clip_tree.Node(render_surface->ClipTreeIndex()); |
+ |
+ draw_properties->is_clipped = SurfaceIsClipped(render_surface, clip_node); |
+ draw_properties->draw_opacity = |
+ SurfaceDrawOpacity(render_surface, property_trees->effect_tree); |
+ draw_properties->draw_transform = |
+ SurfaceDrawTransform(render_surface, property_trees->transform_tree); |
+ draw_properties->screen_space_transform = SurfaceScreenSpaceTransform( |
+ render_surface, property_trees->transform_tree); |
+ |
+ if (render_surface->HasReplica()) { |
+ gfx::Transform replica_to_surface = ReplicaToSurfaceTransform( |
+ render_surface, property_trees->transform_tree); |
+ draw_properties->replica_draw_transform = |
+ draw_properties->draw_transform * replica_to_surface; |
+ draw_properties->replica_screen_space_transform = |
+ draw_properties->screen_space_transform * replica_to_surface; |
+ } else { |
+ draw_properties->replica_draw_transform.MakeIdentity(); |
+ draw_properties->replica_screen_space_transform.MakeIdentity(); |
+ } |
+ |
+ draw_properties->clip_rect = SurfaceClipRect( |
+ render_surface, property_trees->clip_tree.parent(clip_node), |
+ draw_properties->is_clipped); |
} |
} // namespace cc |