OLD | NEW |
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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 ConcatInverseSurfaceContentsScale(target_effect_node, &target_to_local); | 130 ConcatInverseSurfaceContentsScale(target_effect_node, &target_to_local); |
131 | 131 |
132 if (target_transform_id > local_transform_id) | 132 if (target_transform_id > local_transform_id) |
133 return ConditionalClip{true, // is_clipped. | 133 return ConditionalClip{true, // is_clipped. |
134 MathUtil::MapClippedRect(target_to_local, rect)}; | 134 MathUtil::MapClippedRect(target_to_local, rect)}; |
135 | 135 |
136 return ConditionalClip{true, // is_clipped. | 136 return ConditionalClip{true, // is_clipped. |
137 MathUtil::ProjectClippedRect(target_to_local, rect)}; | 137 MathUtil::ProjectClippedRect(target_to_local, rect)}; |
138 } | 138 } |
139 | 139 |
| 140 static ConditionalClip ConvertRectBetweenSurfaceSpaces( |
| 141 gfx::RectF rect, |
| 142 const PropertyTrees* property_trees, |
| 143 int source_transform_id, |
| 144 int source_effect_id, |
| 145 int dest_transform_id, |
| 146 int dest_effect_id) { |
| 147 gfx::Transform source_to_dest; |
| 148 bool success = property_trees->GetToTarget(source_transform_id, |
| 149 dest_effect_id, &source_to_dest); |
| 150 if (!success) |
| 151 return ConditionalClip{false, gfx::RectF()}; |
| 152 const EffectTree& effect_tree = property_trees->effect_tree; |
| 153 const EffectNode* source_effect_node = effect_tree.Node(source_effect_id); |
| 154 ConcatInverseSurfaceContentsScale(source_effect_node, &source_to_dest); |
| 155 if (source_transform_id > dest_transform_id) { |
| 156 return ConditionalClip{true, // is_clipped |
| 157 MathUtil::MapClippedRect(source_to_dest, rect)}; |
| 158 } |
| 159 return ConditionalClip{true, // is_clipped |
| 160 MathUtil::ProjectClippedRect(source_to_dest, rect)}; |
| 161 } |
| 162 |
140 static ConditionalClip ComputeLocalRectInTargetSpace( | 163 static ConditionalClip ComputeLocalRectInTargetSpace( |
141 gfx::RectF rect, | 164 gfx::RectF rect, |
142 const PropertyTrees* property_trees, | 165 const PropertyTrees* property_trees, |
143 int current_transform_id, | 166 int current_transform_id, |
144 int target_transform_id, | 167 int target_transform_id, |
145 int target_effect_id) { | 168 int target_effect_id) { |
146 gfx::Transform current_to_target; | 169 gfx::Transform current_to_target; |
147 if (!property_trees->GetToTarget(current_transform_id, target_effect_id, | 170 if (!property_trees->GetToTarget(current_transform_id, target_effect_id, |
148 ¤t_to_target)) { | 171 ¤t_to_target)) { |
149 // If transform is not invertible, cannot apply clip. | 172 // If transform is not invertible, cannot apply clip. |
(...skipping 21 matching lines...) Expand all Loading... |
171 gfx::RectF current_clip = clip_node->clip; | 194 gfx::RectF current_clip = clip_node->clip; |
172 gfx::Vector2dF surface_contents_scale = | 195 gfx::Vector2dF surface_contents_scale = |
173 effect_tree.Node(target_effect_id)->surface_contents_scale; | 196 effect_tree.Node(target_effect_id)->surface_contents_scale; |
174 // The viewport clip should not be scaled. | 197 // The viewport clip should not be scaled. |
175 if (surface_contents_scale.x() > 0 && surface_contents_scale.y() > 0 && | 198 if (surface_contents_scale.x() > 0 && surface_contents_scale.y() > 0 && |
176 clip_node->transform_id != TransformTree::kRootNodeId) | 199 clip_node->transform_id != TransformTree::kRootNodeId) |
177 current_clip.Scale(surface_contents_scale.x(), surface_contents_scale.y()); | 200 current_clip.Scale(surface_contents_scale.x(), surface_contents_scale.y()); |
178 return ConditionalClip{true /* is_clipped */, current_clip}; | 201 return ConditionalClip{true /* is_clipped */, current_clip}; |
179 } | 202 } |
180 | 203 |
| 204 static bool ApplyClipNodeToAccumulatedClip(const PropertyTrees* property_trees, |
| 205 bool include_expanding_clips, |
| 206 int target_id, |
| 207 int target_transform_id, |
| 208 const ClipNode* clip_node, |
| 209 gfx::RectF* accumulated_clip) { |
| 210 switch (clip_node->clip_type) { |
| 211 case ClipNode::ClipType::APPLIES_LOCAL_CLIP: { |
| 212 ConditionalClip current_clip = ComputeCurrentClip( |
| 213 clip_node, property_trees, target_transform_id, target_id); |
| 214 |
| 215 // If transform is not invertible, no clip will be applied. |
| 216 if (!current_clip.is_clipped) |
| 217 return false; |
| 218 |
| 219 *accumulated_clip = |
| 220 gfx::IntersectRects(*accumulated_clip, current_clip.clip_rect); |
| 221 return true; |
| 222 } |
| 223 case ClipNode::ClipType::EXPANDS_CLIP: { |
| 224 if (!include_expanding_clips) |
| 225 return true; |
| 226 |
| 227 // Bring the accumulated clip to the space of the expanding effect. |
| 228 const EffectNode* expanding_effect_node = |
| 229 property_trees->effect_tree.Node( |
| 230 clip_node->clip_expander->target_effect_id()); |
| 231 ConditionalClip accumulated_clip_in_expanding_space = |
| 232 ConvertRectBetweenSurfaceSpaces( |
| 233 *accumulated_clip, property_trees, target_transform_id, target_id, |
| 234 expanding_effect_node->transform_id, expanding_effect_node->id); |
| 235 // If transform is not invertible, no clip will be applied. |
| 236 if (!accumulated_clip_in_expanding_space.is_clipped) |
| 237 return false; |
| 238 |
| 239 // Do the expansion. |
| 240 gfx::RectF expanded_clip_in_expanding_space = |
| 241 gfx::RectF(clip_node->clip_expander->MapRectReverse( |
| 242 gfx::ToEnclosingRect( |
| 243 accumulated_clip_in_expanding_space.clip_rect), |
| 244 property_trees)); |
| 245 |
| 246 // Put the expanded clip back into the original target space. |
| 247 ConditionalClip expanded_clip_in_target_space = |
| 248 ConvertRectBetweenSurfaceSpaces( |
| 249 expanded_clip_in_expanding_space, property_trees, |
| 250 expanding_effect_node->transform_id, expanding_effect_node->id, |
| 251 target_transform_id, target_id); |
| 252 // If transform is not invertible, no clip will be applied. |
| 253 if (!expanded_clip_in_target_space.is_clipped) |
| 254 return false; |
| 255 *accumulated_clip = expanded_clip_in_target_space.clip_rect; |
| 256 return true; |
| 257 } |
| 258 case ClipNode::ClipType::NONE: |
| 259 return true; |
| 260 } |
| 261 NOTREACHED(); |
| 262 return true; |
| 263 } |
| 264 |
181 static ConditionalClip ComputeAccumulatedClip( | 265 static ConditionalClip ComputeAccumulatedClip( |
182 const PropertyTrees* property_trees, | 266 const PropertyTrees* property_trees, |
183 bool include_viewport_clip, | 267 bool include_viewport_clip, |
| 268 bool include_expanding_clips, |
184 int local_clip_id, | 269 int local_clip_id, |
185 int target_id) { | 270 int target_id) { |
186 DCHECK(!include_viewport_clip || | 271 DCHECK(!include_viewport_clip || |
187 target_id == EffectTree::kContentsRootNodeId); | 272 target_id == EffectTree::kContentsRootNodeId); |
188 const ClipTree& clip_tree = property_trees->clip_tree; | 273 const ClipTree& clip_tree = property_trees->clip_tree; |
189 const EffectTree& effect_tree = property_trees->effect_tree; | 274 const EffectTree& effect_tree = property_trees->effect_tree; |
190 | 275 |
191 const ClipNode* clip_node = clip_tree.Node(local_clip_id); | 276 const ClipNode* clip_node = clip_tree.Node(local_clip_id); |
192 const EffectNode* target_node = effect_tree.Node(target_id); | 277 const EffectNode* target_node = effect_tree.Node(target_id); |
193 int target_transform_id = target_node->transform_id; | 278 int target_transform_id = target_node->transform_id; |
194 bool is_clipped = false; | |
195 | 279 |
196 // Collect all the clips that need to be accumulated. | 280 // Collect all the clips that need to be accumulated. |
197 std::stack<const ClipNode*> parent_chain; | 281 std::stack<const ClipNode*> parent_chain; |
198 | 282 |
199 // If target is not direct ancestor of clip, this will find least common | 283 // If target is not direct ancestor of clip, this will find least common |
200 // ancestor between the target and the clip. | 284 // ancestor between the target and the clip. |
201 while (target_node->clip_id > clip_node->id || | 285 while (target_node->clip_id > clip_node->id || |
202 target_node->has_unclipped_descendants) { | 286 target_node->has_unclipped_descendants) { |
203 target_node = effect_tree.Node(target_node->target_id); | 287 target_node = effect_tree.Node(target_node->target_id); |
204 } | 288 } |
205 | 289 |
206 // Collect clip nodes up to the least common ancestor. | 290 // Collect clip nodes up to the least common ancestor. |
207 while (target_node->clip_id < clip_node->id) { | 291 while (target_node->clip_id < clip_node->id) { |
208 parent_chain.push(clip_node); | 292 parent_chain.push(clip_node); |
209 clip_node = clip_tree.parent(clip_node); | 293 clip_node = clip_tree.parent(clip_node); |
210 } | 294 } |
211 DCHECK_EQ(target_node->clip_id, clip_node->id); | 295 DCHECK_EQ(target_node->clip_id, clip_node->id); |
212 | 296 |
213 if (!include_viewport_clip && parent_chain.size() == 0) { | 297 if (!include_viewport_clip && parent_chain.size() == 0) { |
214 // There aren't any clips to apply. | 298 // There aren't any clips to apply. |
215 return ConditionalClip{false, gfx::RectF()}; | 299 return ConditionalClip{false, gfx::RectF()}; |
216 } | 300 } |
217 | 301 |
218 if (!include_viewport_clip) { | 302 if (!include_viewport_clip) { |
219 clip_node = parent_chain.top(); | 303 clip_node = parent_chain.top(); |
220 parent_chain.pop(); | 304 parent_chain.pop(); |
221 } | 305 } |
222 | 306 |
223 // TODO(weiliangc): If we don't create clip for render surface, we don't need | 307 // Find the first clip in the chain that we need to apply. |
224 // to check applies_local_clip. | |
225 while (clip_node->clip_type != ClipNode::ClipType::APPLIES_LOCAL_CLIP && | 308 while (clip_node->clip_type != ClipNode::ClipType::APPLIES_LOCAL_CLIP && |
226 parent_chain.size() > 0) { | 309 parent_chain.size() > 0) { |
227 clip_node = parent_chain.top(); | 310 clip_node = parent_chain.top(); |
228 parent_chain.pop(); | 311 parent_chain.pop(); |
229 } | 312 } |
230 | 313 |
231 if (clip_node->clip_type != ClipNode::ClipType::APPLIES_LOCAL_CLIP) | 314 if (clip_node->clip_type != ClipNode::ClipType::APPLIES_LOCAL_CLIP) { |
232 // No clip node applying clip in between. | 315 // No clip node applying clip in between. |
233 return ConditionalClip{false, gfx::RectF()}; | 316 return ConditionalClip{false, gfx::RectF()}; |
| 317 } |
234 | 318 |
235 ConditionalClip current_clip = ComputeCurrentClip( | 319 ConditionalClip current_clip = ComputeCurrentClip( |
236 clip_node, property_trees, target_transform_id, target_id); | 320 clip_node, property_trees, target_transform_id, target_id); |
237 is_clipped = current_clip.is_clipped; | 321 |
| 322 // If transform is not invertible, no clip will be applied. |
| 323 if (!current_clip.is_clipped) |
| 324 return ConditionalClip{false, gfx::RectF()}; |
238 gfx::RectF accumulated_clip = current_clip.clip_rect; | 325 gfx::RectF accumulated_clip = current_clip.clip_rect; |
239 | 326 |
240 while (parent_chain.size() > 0) { | 327 while (parent_chain.size() > 0) { |
241 clip_node = parent_chain.top(); | 328 clip_node = parent_chain.top(); |
242 parent_chain.pop(); | 329 parent_chain.pop(); |
243 if (clip_node->clip_type != ClipNode::ClipType::APPLIES_LOCAL_CLIP) { | 330 bool success = ApplyClipNodeToAccumulatedClip( |
244 continue; | 331 property_trees, include_expanding_clips, target_id, target_transform_id, |
245 } | 332 clip_node, &accumulated_clip); |
246 ConditionalClip current_clip = ComputeCurrentClip( | |
247 clip_node, property_trees, target_transform_id, target_id); | |
248 | 333 |
249 // If transform is not invertible, no clip will be applied. | 334 // Failure to apply the clip means we encountered an uninvertible transform, |
250 if (!current_clip.is_clipped) | 335 // so no clip will be applied. |
251 return ConditionalClip{false, gfx::RectF()}; | 336 if (!success) |
252 | 337 return ConditionalClip{false /* is_clipped */, gfx::RectF()}; |
253 is_clipped = true; | |
254 accumulated_clip = | |
255 gfx::IntersectRects(accumulated_clip, current_clip.clip_rect); | |
256 } | 338 } |
257 | 339 |
258 return ConditionalClip{ | 340 return ConditionalClip{true /* is_clipped */, accumulated_clip.IsEmpty() |
259 is_clipped, accumulated_clip.IsEmpty() ? gfx::RectF() : accumulated_clip}; | 341 ? gfx::RectF() |
| 342 : accumulated_clip}; |
260 } | 343 } |
261 | 344 |
262 static gfx::RectF ComputeAccumulatedClipInRootSpaceForVisibleRect( | 345 static gfx::RectF ComputeAccumulatedClipInRootSpaceForVisibleRect( |
263 const PropertyTrees* property_trees, | 346 const PropertyTrees* property_trees, |
264 int local_clip_id) { | 347 int local_clip_id) { |
265 const int root_effect_id = EffectTree::kContentsRootNodeId; | 348 const int root_effect_id = EffectTree::kContentsRootNodeId; |
266 bool include_viewport_clip = true; | 349 bool include_viewport_clip = true; |
| 350 bool include_expanding_clips = true; |
267 ConditionalClip accumulated_clip = ComputeAccumulatedClip( | 351 ConditionalClip accumulated_clip = ComputeAccumulatedClip( |
268 property_trees, include_viewport_clip, local_clip_id, root_effect_id); | 352 property_trees, include_viewport_clip, include_expanding_clips, |
| 353 local_clip_id, root_effect_id); |
269 DCHECK(accumulated_clip.is_clipped); | 354 DCHECK(accumulated_clip.is_clipped); |
270 return accumulated_clip.clip_rect; | 355 return accumulated_clip.clip_rect; |
271 } | 356 } |
272 | 357 |
273 void CalculateClipRects(const std::vector<LayerImpl*>& visible_layer_list, | 358 void CalculateClipRects(const std::vector<LayerImpl*>& visible_layer_list, |
274 const PropertyTrees* property_trees, | 359 const PropertyTrees* property_trees, |
275 bool non_root_surfaces_enabled) { | 360 bool non_root_surfaces_enabled) { |
276 const ClipTree& clip_tree = property_trees->clip_tree; | 361 const ClipTree& clip_tree = property_trees->clip_tree; |
277 for (auto& layer : visible_layer_list) { | 362 for (auto& layer : visible_layer_list) { |
278 const ClipNode* clip_node = clip_tree.Node(layer->clip_tree_index()); | 363 const ClipNode* clip_node = clip_tree.Node(layer->clip_tree_index()); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 const TransformTree& transform_tree = property_trees->transform_tree; | 416 const TransformTree& transform_tree = property_trees->transform_tree; |
332 const ClipTree& clip_tree = property_trees->clip_tree; | 417 const ClipTree& clip_tree = property_trees->clip_tree; |
333 for (auto& layer : visible_layer_list) { | 418 for (auto& layer : visible_layer_list) { |
334 gfx::Size layer_bounds = layer->bounds(); | 419 gfx::Size layer_bounds = layer->bounds(); |
335 | 420 |
336 int effect_ancestor_with_copy_request = | 421 int effect_ancestor_with_copy_request = |
337 effect_tree.ClosestAncestorWithCopyRequest(layer->effect_tree_index()); | 422 effect_tree.ClosestAncestorWithCopyRequest(layer->effect_tree_index()); |
338 if (effect_ancestor_with_copy_request > 1) { | 423 if (effect_ancestor_with_copy_request > 1) { |
339 // Non root copy request. | 424 // Non root copy request. |
340 bool include_viewport_clip = false; | 425 bool include_viewport_clip = false; |
| 426 bool include_expanding_clips = true; |
341 ConditionalClip accumulated_clip_rect = ComputeAccumulatedClip( | 427 ConditionalClip accumulated_clip_rect = ComputeAccumulatedClip( |
342 property_trees, include_viewport_clip, layer->clip_tree_index(), | 428 property_trees, include_viewport_clip, include_expanding_clips, |
343 effect_ancestor_with_copy_request); | 429 layer->clip_tree_index(), effect_ancestor_with_copy_request); |
344 if (!accumulated_clip_rect.is_clipped) { | 430 if (!accumulated_clip_rect.is_clipped) { |
345 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); | 431 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); |
346 continue; | 432 continue; |
347 } | 433 } |
348 | 434 |
349 gfx::RectF accumulated_clip_in_copy_request_space = | 435 gfx::RectF accumulated_clip_in_copy_request_space = |
350 accumulated_clip_rect.clip_rect; | 436 accumulated_clip_rect.clip_rect; |
351 | 437 |
352 const EffectNode* copy_request_effect_node = | 438 const EffectNode* copy_request_effect_node = |
353 effect_tree.Node(effect_ancestor_with_copy_request); | 439 effect_tree.Node(effect_ancestor_with_copy_request); |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 effect_tree.Node(parent_clip_node->target_effect_id); | 871 effect_tree.Node(parent_clip_node->target_effect_id); |
786 ConcatInverseSurfaceContentsScale(parent_target_effect_node, | 872 ConcatInverseSurfaceContentsScale(parent_target_effect_node, |
787 &parent_to_current); | 873 &parent_to_current); |
788 // If we can't compute a transform, it's because we had to use the inverse | 874 // If we can't compute a transform, it's because we had to use the inverse |
789 // of a singular transform. We won't draw in this case, so there's no need | 875 // of a singular transform. We won't draw in this case, so there's no need |
790 // to compute clips. | 876 // to compute clips. |
791 if (!success) | 877 if (!success) |
792 continue; | 878 continue; |
793 parent_combined_clip_in_target_space = MathUtil::ProjectClippedRect( | 879 parent_combined_clip_in_target_space = MathUtil::ProjectClippedRect( |
794 parent_to_current, parent_clip_node->combined_clip_in_target_space); | 880 parent_to_current, parent_clip_node->combined_clip_in_target_space); |
| 881 if (clip_node->clip_type == ClipNode::ClipType::EXPANDS_CLIP) { |
| 882 parent_combined_clip_in_target_space = |
| 883 gfx::RectF(clip_node->clip_expander->MapRectReverse( |
| 884 gfx::ToEnclosingRect(parent_combined_clip_in_target_space), |
| 885 property_trees)); |
| 886 } |
795 parent_clip_in_target_space = MathUtil::ProjectClippedRect( | 887 parent_clip_in_target_space = MathUtil::ProjectClippedRect( |
796 parent_to_current, parent_clip_node->clip_in_target_space); | 888 parent_to_current, parent_clip_node->clip_in_target_space); |
797 } | 889 } |
798 // Only nodes affected by ancestor clips will have their clip adjusted due | 890 // Only nodes affected by ancestor clips will have their clip adjusted due |
799 // to intersecting with an ancestor clip. But, we still need to propagate | 891 // to intersecting with an ancestor clip. But, we still need to propagate |
800 // the combined clip to our children because if they are clipped, they may | 892 // the combined clip to our children because if they are clipped, they may |
801 // need to clip using our parent clip and if we don't propagate it here, | 893 // need to clip using our parent clip and if we don't propagate it here, |
802 // it will be lost. | 894 // it will be lost. |
803 if (clip_node->resets_clip && non_root_surfaces_enabled) { | 895 if (clip_node->resets_clip && non_root_surfaces_enabled) { |
804 if (clip_node->clip_type == ClipNode::ClipType::APPLIES_LOCAL_CLIP) { | 896 if (clip_node->clip_type == ClipNode::ClipType::APPLIES_LOCAL_CLIP) { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
923 gfx::ToEnclosingRect(clip_tree->Node(root_effect_node->clip_id)->clip); | 1015 gfx::ToEnclosingRect(clip_tree->Node(root_effect_node->clip_id)->clip); |
924 if (root_render_surface->is_clipped()) | 1016 if (root_render_surface->is_clipped()) |
925 DCHECK(root_clip == root_render_surface->clip_rect()) | 1017 DCHECK(root_clip == root_render_surface->clip_rect()) |
926 << "clip on root render surface: " | 1018 << "clip on root render surface: " |
927 << root_render_surface->clip_rect().ToString() | 1019 << root_render_surface->clip_rect().ToString() |
928 << " v.s. root effect node's clip: " << root_clip.ToString(); | 1020 << " v.s. root effect node's clip: " << root_clip.ToString(); |
929 for (int i = 2; i < static_cast<int>(effect_tree->size()); ++i) { | 1021 for (int i = 2; i < static_cast<int>(effect_tree->size()); ++i) { |
930 EffectNode* effect_node = effect_tree->Node(i); | 1022 EffectNode* effect_node = effect_tree->Node(i); |
931 const EffectNode* target_node = effect_tree->Node(effect_node->target_id); | 1023 const EffectNode* target_node = effect_tree->Node(effect_node->target_id); |
932 bool include_viewport_clip = false; | 1024 bool include_viewport_clip = false; |
933 ConditionalClip accumulated_clip_rect = | 1025 bool include_expanding_clips = false; |
934 ComputeAccumulatedClip(property_trees, include_viewport_clip, | 1026 ConditionalClip accumulated_clip_rect = ComputeAccumulatedClip( |
935 effect_node->clip_id, target_node->id); | 1027 property_trees, include_viewport_clip, include_expanding_clips, |
| 1028 effect_node->clip_id, target_node->id); |
936 gfx::RectF accumulated_clip = accumulated_clip_rect.clip_rect; | 1029 gfx::RectF accumulated_clip = accumulated_clip_rect.clip_rect; |
937 const RenderSurfaceImpl* render_surface = effect_node->render_surface; | 1030 const RenderSurfaceImpl* render_surface = effect_node->render_surface; |
938 if (render_surface && render_surface->is_clipped()) { | 1031 if (render_surface && render_surface->is_clipped()) { |
939 DCHECK(gfx::ToEnclosingRect(accumulated_clip) == | 1032 DCHECK(gfx::ToEnclosingRect(accumulated_clip) == |
940 render_surface->clip_rect()) | 1033 render_surface->clip_rect()) |
941 << " render surface's clip rect: " | 1034 << " render surface's clip rect: " |
942 << render_surface->clip_rect().ToString() | 1035 << render_surface->clip_rect().ToString() |
943 << " v.s. accumulated clip: " | 1036 << " v.s. accumulated clip: " |
944 << gfx::ToEnclosingRect(accumulated_clip).ToString(); | 1037 << gfx::ToEnclosingRect(accumulated_clip).ToString(); |
945 } | 1038 } |
(...skipping 10 matching lines...) Expand all Loading... |
956 effect_node->has_render_surface | 1049 effect_node->has_render_surface |
957 ? effect_node | 1050 ? effect_node |
958 : effect_tree->Node(effect_node->target_id); | 1051 : effect_tree->Node(effect_node->target_id); |
959 // TODO(weiliangc): When effect node has up to date render surface info on | 1052 // TODO(weiliangc): When effect node has up to date render surface info on |
960 // compositor thread, no need to check for resourceless draw mode | 1053 // compositor thread, no need to check for resourceless draw mode |
961 if (!property_trees->non_root_surfaces_enabled) { | 1054 if (!property_trees->non_root_surfaces_enabled) { |
962 target_node = effect_tree->Node(1); | 1055 target_node = effect_tree->Node(1); |
963 } | 1056 } |
964 | 1057 |
965 bool include_viewport_clip = false; | 1058 bool include_viewport_clip = false; |
966 ConditionalClip accumulated_clip_rect = | 1059 bool include_expanding_clips = false; |
967 ComputeAccumulatedClip(property_trees, include_viewport_clip, | 1060 ConditionalClip accumulated_clip_rect = ComputeAccumulatedClip( |
968 layer->clip_tree_index(), target_node->id); | 1061 property_trees, include_viewport_clip, include_expanding_clips, |
| 1062 layer->clip_tree_index(), target_node->id); |
969 | 1063 |
970 bool is_clipped_from_clip_tree = | 1064 bool is_clipped_from_clip_tree = |
971 property_trees->non_root_surfaces_enabled | 1065 property_trees->non_root_surfaces_enabled |
972 ? clip_node->layers_are_clipped | 1066 ? clip_node->layers_are_clipped |
973 : clip_node->layers_are_clipped_when_surfaces_disabled; | 1067 : clip_node->layers_are_clipped_when_surfaces_disabled; |
974 DCHECK_EQ(is_clipped_from_clip_tree, accumulated_clip_rect.is_clipped); | 1068 DCHECK_EQ(is_clipped_from_clip_tree, accumulated_clip_rect.is_clipped); |
975 | 1069 |
976 gfx::RectF accumulated_clip = accumulated_clip_rect.clip_rect; | 1070 gfx::RectF accumulated_clip = accumulated_clip_rect.clip_rect; |
977 | 1071 |
978 DCHECK(layer->clip_rect() == gfx::ToEnclosingRect(accumulated_clip)) | 1072 DCHECK(layer->clip_rect() == gfx::ToEnclosingRect(accumulated_clip)) |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 const LayerImpl* layer) { | 1185 const LayerImpl* layer) { |
1092 int effect_ancestor_with_copy_request = | 1186 int effect_ancestor_with_copy_request = |
1093 property_trees->effect_tree.ClosestAncestorWithCopyRequest( | 1187 property_trees->effect_tree.ClosestAncestorWithCopyRequest( |
1094 layer->effect_tree_index()); | 1188 layer->effect_tree_index()); |
1095 bool non_root_copy_request = | 1189 bool non_root_copy_request = |
1096 effect_ancestor_with_copy_request > EffectTree::kContentsRootNodeId; | 1190 effect_ancestor_with_copy_request > EffectTree::kContentsRootNodeId; |
1097 gfx::Rect layer_content_rect = gfx::Rect(layer->bounds()); | 1191 gfx::Rect layer_content_rect = gfx::Rect(layer->bounds()); |
1098 gfx::RectF accumulated_clip_in_root_space; | 1192 gfx::RectF accumulated_clip_in_root_space; |
1099 if (non_root_copy_request) { | 1193 if (non_root_copy_request) { |
1100 bool include_viewport_clip = false; | 1194 bool include_viewport_clip = false; |
| 1195 bool include_expanding_clips = true; |
1101 ConditionalClip accumulated_clip = ComputeAccumulatedClip( | 1196 ConditionalClip accumulated_clip = ComputeAccumulatedClip( |
1102 property_trees, include_viewport_clip, layer->clip_tree_index(), | 1197 property_trees, include_viewport_clip, include_expanding_clips, |
1103 effect_ancestor_with_copy_request); | 1198 layer->clip_tree_index(), effect_ancestor_with_copy_request); |
1104 if (!accumulated_clip.is_clipped) | 1199 if (!accumulated_clip.is_clipped) |
1105 return layer_content_rect; | 1200 return layer_content_rect; |
1106 accumulated_clip_in_root_space = accumulated_clip.clip_rect; | 1201 accumulated_clip_in_root_space = accumulated_clip.clip_rect; |
1107 } else { | 1202 } else { |
1108 accumulated_clip_in_root_space = | 1203 accumulated_clip_in_root_space = |
1109 ComputeAccumulatedClipInRootSpaceForVisibleRect( | 1204 ComputeAccumulatedClipInRootSpaceForVisibleRect( |
1110 property_trees, layer->clip_tree_index()); | 1205 property_trees, layer->clip_tree_index()); |
1111 } | 1206 } |
1112 | 1207 |
1113 const EffectNode* root_effect_node = | 1208 const EffectNode* root_effect_node = |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1462 void UpdateElasticOverscroll(PropertyTrees* property_trees, | 1557 void UpdateElasticOverscroll(PropertyTrees* property_trees, |
1463 const Layer* overscroll_elasticity_layer, | 1558 const Layer* overscroll_elasticity_layer, |
1464 const gfx::Vector2dF& elastic_overscroll) { | 1559 const gfx::Vector2dF& elastic_overscroll) { |
1465 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, | 1560 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, |
1466 elastic_overscroll); | 1561 elastic_overscroll); |
1467 } | 1562 } |
1468 | 1563 |
1469 } // namespace draw_property_utils | 1564 } // namespace draw_property_utils |
1470 | 1565 |
1471 } // namespace cc | 1566 } // namespace cc |
OLD | NEW |