Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(427)

Side by Side Diff: cc/trees/draw_property_utils.cc

Issue 1643053002: cc :: Fix sublayer scale bug when we have scroll parents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/draw_property_utils.h" 5 #include "cc/trees/draw_property_utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // The clip node stores clip rect in its target space. If required, 78 // The clip node stores clip rect in its target space. If required,
79 // this clip rect should be mapped to the current layer's target space. 79 // this clip rect should be mapped to the current layer's target space.
80 gfx::Rect clip_rect_in_target_space; 80 gfx::Rect clip_rect_in_target_space;
81 gfx::Rect combined_clip_rect_in_target_space; 81 gfx::Rect combined_clip_rect_in_target_space;
82 bool success = true; 82 bool success = true;
83 83
84 // When we only have a root surface, the clip node and the layer must 84 // When we only have a root surface, the clip node and the layer must
85 // necessarily have the same target (the root). 85 // necessarily have the same target (the root).
86 if (clip_node->data.target_id != target_node->id && 86 if (clip_node->data.target_id != target_node->id &&
87 non_root_surfaces_enabled) { 87 non_root_surfaces_enabled) {
88 // In this case, layer has a clip parent (or shares the target with an 88 // In this case, layer has a clip parent or scroll parent (or shares the
89 // ancestor layer that has clip parent) and the clip parent's target is 89 // target with an ancestor layer that has clip parent) and the clip
90 // different from the layer's target. As the layer's target has 90 // parent's target is different from the layer's target. As the layer's
91 // unclippped descendants, it is unclippped. 91 // target has unclippped descendants, it is unclippped.
92 if (!clip_node->data.layers_are_clipped) { 92 if (!clip_node->data.layers_are_clipped) {
93 layer->set_visible_rect_from_property_trees(gfx::Rect(layer_bounds)); 93 layer->set_visible_rect_from_property_trees(gfx::Rect(layer_bounds));
94 layer->set_clip_rect_in_target_space_from_property_trees(gfx::Rect()); 94 layer->set_clip_rect_in_target_space_from_property_trees(gfx::Rect());
95 continue; 95 continue;
96 } 96 }
97 gfx::Transform clip_to_target; 97 gfx::Transform clip_to_target;
98 success = transform_tree.ComputeTransform( 98 if (clip_node->data.target_id > target_node->id) {
99 clip_node->data.target_id, target_node->id, &clip_to_target); 99 // In this case, layer has a scroll parent. We need to keep the scale
100 // at the layer's target but remove the scale at the scroll parent's
101 // target.
102 success = transform_tree.ComputeTransformWithDestinationSublayerScale(
103 clip_node->data.target_id, target_node->id, &clip_to_target);
104 const TransformNode* source_node =
105 transform_tree.Node(clip_node->data.target_id);
106 if (source_node->data.sublayer_scale.x() != 0.f &&
107 source_node->data.sublayer_scale.y() != 0.f)
108 clip_to_target.Scale(1.0f / source_node->data.sublayer_scale.x(),
109 1.0f / source_node->data.sublayer_scale.y());
110 } else {
111 success = transform_tree.ComputeTransform(
112 clip_node->data.target_id, target_node->id, &clip_to_target);
113 }
100 if (!success) { 114 if (!success) {
101 // An animated singular transform may become non-singular during the 115 // An animated singular transform may become non-singular during the
102 // animation, so we still need to compute a visible rect. In this 116 // animation, so we still need to compute a visible rect. In this
103 // situation, we treat the entire layer as visible. 117 // situation, we treat the entire layer as visible.
104 layer->set_visible_rect_from_property_trees(gfx::Rect(layer_bounds)); 118 layer->set_visible_rect_from_property_trees(gfx::Rect(layer_bounds));
105 layer->set_clip_rect_in_target_space_from_property_trees(gfx::Rect()); 119 layer->set_clip_rect_in_target_space_from_property_trees(gfx::Rect());
106 continue; 120 continue;
107 } 121 }
108 DCHECK_LT(clip_node->data.target_id, target_node->id);
109 // We use the clip node's clip_in_target_space (and not 122 // We use the clip node's clip_in_target_space (and not
110 // combined_clip_in_target_space) here because we want to clip 123 // combined_clip_in_target_space) here because we want to clip
111 // with respect to clip parent's local clip and not its combined clip as 124 // with respect to clip parent's local clip and not its combined clip as
112 // the combined clip has even the clip parent's target's clip baked into 125 // the combined clip has even the clip parent's target's clip baked into
113 // it and as our target is different, we don't want to use it in our 126 // it and as our target is different, we don't want to use it in our
114 // visible rect computation. 127 // visible rect computation.
115 combined_clip_rect_in_target_space = 128 if (clip_node->data.target_id < target_node->id) {
116 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( 129 combined_clip_rect_in_target_space =
117 clip_to_target, clip_node->data.clip_in_target_space)); 130 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect(
118 clip_rect_in_target_space = 131 clip_to_target, clip_node->data.clip_in_target_space));
119 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( 132 clip_rect_in_target_space =
120 clip_to_target, clip_node->data.clip_in_target_space)); 133 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect(
134 clip_to_target, clip_node->data.clip_in_target_space));
135 } else {
136 combined_clip_rect_in_target_space =
137 gfx::ToEnclosingRect(MathUtil::MapClippedRect(
138 clip_to_target, clip_node->data.clip_in_target_space));
139 clip_rect_in_target_space =
140 gfx::ToEnclosingRect(MathUtil::MapClippedRect(
141 clip_to_target, clip_node->data.clip_in_target_space));
142 }
143
121 } else { 144 } else {
122 clip_rect_in_target_space = 145 clip_rect_in_target_space =
123 gfx::ToEnclosingRect(clip_node->data.clip_in_target_space); 146 gfx::ToEnclosingRect(clip_node->data.clip_in_target_space);
124 if (clip_node->data.target_is_clipped || !non_root_surfaces_enabled) 147 if (clip_node->data.target_is_clipped || !non_root_surfaces_enabled)
125 combined_clip_rect_in_target_space = gfx::ToEnclosingRect( 148 combined_clip_rect_in_target_space = gfx::ToEnclosingRect(
126 clip_node->data.combined_clip_in_target_space); 149 clip_node->data.combined_clip_in_target_space);
127 else 150 else
128 combined_clip_rect_in_target_space = clip_rect_in_target_space; 151 combined_clip_rect_in_target_space = clip_rect_in_target_space;
129 } 152 }
130 153
(...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 1200
1178 void UpdateElasticOverscrollInPropertyTrees( 1201 void UpdateElasticOverscrollInPropertyTrees(
1179 PropertyTrees* property_trees, 1202 PropertyTrees* property_trees,
1180 const Layer* overscroll_elasticity_layer, 1203 const Layer* overscroll_elasticity_layer,
1181 const gfx::Vector2dF& elastic_overscroll) { 1204 const gfx::Vector2dF& elastic_overscroll) {
1182 UpdateElasticOverscrollInPropertyTreesInternal( 1205 UpdateElasticOverscrollInPropertyTreesInternal(
1183 property_trees, overscroll_elasticity_layer, elastic_overscroll); 1206 property_trees, overscroll_elasticity_layer, elastic_overscroll);
1184 } 1207 }
1185 1208
1186 } // namespace cc 1209 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698