Commit fa348e7a authored by danakj's avatar danakj Committed by Commit Bot

cc: Additional comments and cleanup of cc::Layer APIs.

The GetTransformNode() method is removed, as it is only safe to use
in certain cases, and just wraps a call to get the node from the
property tree, just do it directly in the callers.

R=weiliangc@chromium.org

Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I6f242f60209c6d9e3d603cfcf60f59ecafc8f523
Reviewed-on: https://chromium-review.googlesource.com/1099765Reviewed-by: default avatarweiliangc <weiliangc@chromium.org>
Commit-Queue: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567386}
parent 692fbed2
...@@ -629,8 +629,10 @@ void Layer::SetPosition(const gfx::PointF& position) { ...@@ -629,8 +629,10 @@ void Layer::SetPosition(const gfx::PointF& position) {
return; return;
SetSubtreePropertyChanged(); SetSubtreePropertyChanged();
TransformNode* transform_node = GetTransformNode(); if (has_transform_node_) {
if (transform_node) { TransformNode* transform_node =
layer_tree_host_->property_trees()->transform_tree.Node(
transform_tree_index_);
transform_node->update_post_local_transform(position, transform_origin()); transform_node->update_post_local_transform(position, transform_origin());
transform_node->needs_local_transform_update = true; transform_node->needs_local_transform_update = true;
transform_node->transform_changed = true; transform_node->transform_changed = true;
...@@ -669,23 +671,21 @@ void Layer::SetTransform(const gfx::Transform& transform) { ...@@ -669,23 +671,21 @@ void Layer::SetTransform(const gfx::Transform& transform) {
SetSubtreePropertyChanged(); SetSubtreePropertyChanged();
if (layer_tree_host_) { if (layer_tree_host_) {
if (has_transform_node_) { if (has_transform_node_) {
PropertyTrees* property_trees = layer_tree_host_->property_trees(); TransformNode* transform_node =
if (TransformNode* transform_node = layer_tree_host_->property_trees()->transform_tree.Node(
property_trees->transform_tree.Node(transform_tree_index())) { transform_tree_index_);
// We need to trigger a rebuild if we could have affected 2d axis // We need to trigger a rebuild if we could have affected 2d axis
// alignment. We'll check to see if transform and inputs_.transform are // alignment. We'll check to see if transform and inputs_.transform are
// axis align with respect to one another. // axis align with respect to one another.
DCHECK_EQ(transform_tree_index(), transform_node->id); DCHECK_EQ(transform_tree_index(), transform_node->id);
bool preserves_2d_axis_alignment = bool preserves_2d_axis_alignment =
Are2dAxisAligned(inputs_.transform, transform); Are2dAxisAligned(inputs_.transform, transform);
transform_node->local = transform; transform_node->local = transform;
transform_node->needs_local_transform_update = true; transform_node->needs_local_transform_update = true;
transform_node->transform_changed = true; transform_node->transform_changed = true;
layer_tree_host_->property_trees()->transform_tree.set_needs_update( layer_tree_host_->property_trees()->transform_tree.set_needs_update(true);
true); if (!preserves_2d_axis_alignment)
if (!preserves_2d_axis_alignment) SetPropertyTreesNeedRebuild();
SetPropertyTreesNeedRebuild();
}
} else { } else {
SetPropertyTreesNeedRebuild(); SetPropertyTreesNeedRebuild();
} }
...@@ -705,8 +705,10 @@ void Layer::SetTransformOrigin(const gfx::Point3F& transform_origin) { ...@@ -705,8 +705,10 @@ void Layer::SetTransformOrigin(const gfx::Point3F& transform_origin) {
return; return;
SetSubtreePropertyChanged(); SetSubtreePropertyChanged();
TransformNode* transform_node = GetTransformNode(); if (has_transform_node_) {
if (transform_node) { TransformNode* transform_node =
layer_tree_host_->property_trees()->transform_tree.Node(
transform_tree_index_);
DCHECK_EQ(transform_tree_index(), transform_node->id); DCHECK_EQ(transform_tree_index(), transform_node->id);
transform_node->update_pre_local_transform(transform_origin); transform_node->update_pre_local_transform(transform_origin);
transform_node->update_post_local_transform(position(), transform_origin); transform_node->update_post_local_transform(position(), transform_origin);
...@@ -1349,13 +1351,6 @@ void Layer::OnOpacityAnimated(float opacity) { ...@@ -1349,13 +1351,6 @@ void Layer::OnOpacityAnimated(float opacity) {
inputs_.opacity = opacity; inputs_.opacity = opacity;
} }
TransformNode* Layer::GetTransformNode() const {
return has_transform_node_
? layer_tree_host_->property_trees()->transform_tree.Node(
transform_tree_index_)
: nullptr;
}
void Layer::OnTransformAnimated(const gfx::Transform& transform) { void Layer::OnTransformAnimated(const gfx::Transform& transform) {
inputs_.transform = transform; inputs_.transform = transform;
} }
......
...@@ -251,6 +251,14 @@ class CC_EXPORT Layer : public base::RefCounted<Layer> { ...@@ -251,6 +251,14 @@ class CC_EXPORT Layer : public base::RefCounted<Layer> {
void SetFilters(const FilterOperations& filters); void SetFilters(const FilterOperations& filters);
const FilterOperations& filters() const { return inputs_.filters; } const FilterOperations& filters() const { return inputs_.filters; }
// Set or get the origin to be used when applying the filters given to
// SetFilters(). By default the origin is at the origin of this layer, but
// may be moved positively or negatively relative to that. The origin effects
// any filters which do not apply uniformly to the entire layer and its
// subtree.
void SetFiltersOrigin(const gfx::PointF& origin);
gfx::PointF filters_origin() const { return inputs_.filters_origin; }
// Set or get the list of filters that should be applied to the content this // Set or get the list of filters that should be applied to the content this
// layer and its subtree will be drawn into. The effect is clipped to only // layer and its subtree will be drawn into. The effect is clipped to only
// apply directly behind this layer and its subtree. // apply directly behind this layer and its subtree.
...@@ -459,8 +467,6 @@ class CC_EXPORT Layer : public base::RefCounted<Layer> { ...@@ -459,8 +467,6 @@ class CC_EXPORT Layer : public base::RefCounted<Layer> {
return inputs_.should_flatten_transform; return inputs_.should_flatten_transform;
} }
bool Is3dSorted() const { return inputs_.sorting_context_id != 0; }
void SetUseParentBackfaceVisibility(bool use); void SetUseParentBackfaceVisibility(bool use);
bool use_parent_backface_visibility() const { bool use_parent_backface_visibility() const {
return inputs_.use_parent_backface_visibility; return inputs_.use_parent_backface_visibility;
...@@ -485,14 +491,19 @@ class CC_EXPORT Layer : public base::RefCounted<Layer> { ...@@ -485,14 +491,19 @@ class CC_EXPORT Layer : public base::RefCounted<Layer> {
// given SetIsDrawable(true). // given SetIsDrawable(true).
bool DrawsContent() const; bool DrawsContent() const;
// Returns the number of layers in this layers subtree (excluding itself) for
// which DrawsContent() is true.
int NumDescendantsThatDrawContent() const;
// Set or get if this layer and its subtree should be part of the compositor's
// output to the screen. When set to true, the layer's subtree does not appear
// to the user, but still remains part of the tree with all its normal drawing
// properties. This can be used to execute a CopyOutputRequest on this layer
// or another in its subtree, since the layers are still able to be drawn by
// the compositor, while not being composed into the result shown to the user.
void SetHideLayerAndSubtree(bool hide); void SetHideLayerAndSubtree(bool hide);
bool hide_layer_and_subtree() const { return inputs_.hide_layer_and_subtree; } bool hide_layer_and_subtree() const { return inputs_.hide_layer_and_subtree; }
void SetFiltersOrigin(const gfx::PointF& origin);
gfx::PointF filters_origin() const { return inputs_.filters_origin; }
int NumDescendantsThatDrawContent() const;
void UpdateDebugInfo(); void UpdateDebugInfo();
void SetLayerClient(base::WeakPtr<LayerClient> client); void SetLayerClient(base::WeakPtr<LayerClient> client);
...@@ -521,6 +532,11 @@ class CC_EXPORT Layer : public base::RefCounted<Layer> { ...@@ -521,6 +532,11 @@ class CC_EXPORT Layer : public base::RefCounted<Layer> {
int effect_tree_index() const; int effect_tree_index() const;
int scroll_tree_index() const; int scroll_tree_index() const;
// While all layers have an index into the transform tree, this value
// indicates whether the transform tree node was created for this layer.
void SetHasTransformNode(bool val) { has_transform_node_ = val; }
bool has_transform_node() { return has_transform_node_; }
void SetOffsetToTransformParent(gfx::Vector2dF offset); void SetOffsetToTransformParent(gfx::Vector2dF offset);
gfx::Vector2dF offset_to_transform_parent() const { gfx::Vector2dF offset_to_transform_parent() const {
return offset_to_transform_parent_; return offset_to_transform_parent_;
...@@ -561,10 +577,6 @@ class CC_EXPORT Layer : public base::RefCounted<Layer> { ...@@ -561,10 +577,6 @@ class CC_EXPORT Layer : public base::RefCounted<Layer> {
// Called on the scroll layer to trigger showing the overlay scrollbars. // Called on the scroll layer to trigger showing the overlay scrollbars.
void ShowScrollbars() { needs_show_scrollbars_ = true; } void ShowScrollbars() { needs_show_scrollbars_ = true; }
bool has_transform_node() { return has_transform_node_; }
void SetHasTransformNode(bool val) { has_transform_node_ = val; }
TransformNode* GetTransformNode() const;
// Internal method to create the compositor thread type for this Layer. // Internal method to create the compositor thread type for this Layer.
// Subclasses should override this method if they want to return their own // Subclasses should override this method if they want to return their own
// subclass of LayerImpl instead. // subclass of LayerImpl instead.
...@@ -852,9 +864,6 @@ class CC_EXPORT Layer : public base::RefCounted<Layer> { ...@@ -852,9 +864,6 @@ class CC_EXPORT Layer : public base::RefCounted<Layer> {
bool subtree_property_changed_ : 1; bool subtree_property_changed_ : 1;
bool may_contain_video_ : 1; bool may_contain_video_ : 1;
bool needs_show_scrollbars_ : 1; bool needs_show_scrollbars_ : 1;
// Whether the nodes referred to by *_tree_index_ "belong" to this
// layer. Only applicable if LayerTreeSettings.use_layer_lists is
// false.
bool has_transform_node_ : 1; bool has_transform_node_ : 1;
// This value is valid only when LayerTreeHost::has_copy_request() is true // This value is valid only when LayerTreeHost::has_copy_request() is true
bool subtree_has_copy_request_ : 1; bool subtree_has_copy_request_ : 1;
......
...@@ -1524,7 +1524,9 @@ void LayerTreeHost::SetElementTransformMutated( ...@@ -1524,7 +1524,9 @@ void LayerTreeHost::SetElementTransformMutated(
DCHECK(layer); DCHECK(layer);
layer->OnTransformAnimated(transform); layer->OnTransformAnimated(transform);
if (TransformNode* node = layer->GetTransformNode()) { if (layer->has_transform_node()) {
TransformNode* node =
property_trees_.transform_tree.Node(layer->transform_tree_index());
if (node->local == transform) if (node->local == transform)
return; return;
......
...@@ -296,7 +296,7 @@ static inline int SortingContextId(LayerImpl* layer) { ...@@ -296,7 +296,7 @@ static inline int SortingContextId(LayerImpl* layer) {
} }
static inline bool Is3dSorted(Layer* layer) { static inline bool Is3dSorted(Layer* layer) {
return layer->Is3dSorted(); return layer->sorting_context_id() != 0;
} }
static inline bool Is3dSorted(LayerImpl* layer) { static inline bool Is3dSorted(LayerImpl* layer) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment