| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 const EffectTree& effect_tree) { | 75 const EffectTree& effect_tree) { |
| 76 const EffectNode* effect_node = effect_tree.Node(effect_tree_index); | 76 const EffectNode* effect_node = effect_tree.Node(effect_tree_index); |
| 77 return effect_node->has_render_surface | 77 return effect_node->has_render_surface |
| 78 ? effect_node | 78 ? effect_node |
| 79 : effect_tree.Node(effect_node->target_id); | 79 : effect_tree.Node(effect_node->target_id); |
| 80 } | 80 } |
| 81 | 81 |
| 82 template <typename LayerType> | 82 template <typename LayerType> |
| 83 bool ComputeClipRectInTargetSpace(const LayerType* layer, | 83 bool ComputeClipRectInTargetSpace(const LayerType* layer, |
| 84 const ClipNode* clip_node, | 84 const ClipNode* clip_node, |
| 85 const TransformTree& transform_tree, | 85 const PropertyTrees* property_trees, |
| 86 const EffectTree& effect_tree, | |
| 87 int target_node_id, | 86 int target_node_id, |
| 88 gfx::RectF* clip_rect_in_target_space) { | 87 gfx::RectF* clip_rect_in_target_space) { |
| 89 DCHECK(layer->clip_tree_index() == clip_node->id); | 88 DCHECK(layer->clip_tree_index() == clip_node->id); |
| 90 DCHECK(clip_node->target_transform_id != target_node_id); | 89 DCHECK(clip_node->target_transform_id != target_node_id); |
| 91 | 90 |
| 91 const EffectTree& effect_tree = property_trees->effect_tree; |
| 92 const EffectNode* target_effect_node = |
| 93 ContentsTargetEffectNode(layer->effect_tree_index(), effect_tree); |
| 92 gfx::Transform clip_to_target; | 94 gfx::Transform clip_to_target; |
| 93 if (clip_node->target_transform_id > target_node_id) { | 95 if (clip_node->target_transform_id > target_node_id) { |
| 94 // In this case, layer has a scroll parent. We need to keep the scale | 96 // In this case, layer has a scroll parent. We need to keep the scale |
| 95 // at the layer's target but remove the scale at the scroll parent's | 97 // at the layer's target but remove the scale at the scroll parent's |
| 96 // target. | 98 // target. |
| 97 if (transform_tree.ComputeTransform(clip_node->target_transform_id, | 99 if (property_trees->ComputeTransformToTarget(clip_node->target_transform_id, |
| 98 target_node_id, &clip_to_target)) { | 100 target_effect_node->id, |
| 101 &clip_to_target)) { |
| 99 // We don't have to apply surface contents scale when target is root. | 102 // We don't have to apply surface contents scale when target is root. |
| 100 if (target_node_id != 0) { | 103 if (target_node_id != 0) { |
| 101 const EffectNode* target_effect_node = | |
| 102 ContentsTargetEffectNode(layer->effect_tree_index(), effect_tree); | |
| 103 PostConcatSurfaceContentsScale(target_effect_node, &clip_to_target); | 104 PostConcatSurfaceContentsScale(target_effect_node, &clip_to_target); |
| 104 #if DCHECK_IS_ON() | 105 #if DCHECK_IS_ON() |
| 106 const TransformTree& transform_tree = property_trees->transform_tree; |
| 105 VerifySurfaceContentsScalesMatch(layer->effect_tree_index(), | 107 VerifySurfaceContentsScalesMatch(layer->effect_tree_index(), |
| 106 target_node_id, effect_tree, | 108 target_node_id, effect_tree, |
| 107 transform_tree); | 109 transform_tree); |
| 108 #endif | 110 #endif |
| 109 } | 111 } |
| 110 | 112 |
| 111 const EffectNode* source_node = | 113 const EffectNode* source_node = |
| 112 effect_tree.Node(clip_node->target_effect_id); | 114 effect_tree.Node(clip_node->target_effect_id); |
| 113 ConcatInverseSurfaceContentsScale(source_node, &clip_to_target); | 115 ConcatInverseSurfaceContentsScale(source_node, &clip_to_target); |
| 114 #if DCHECK_IS_ON() | 116 #if DCHECK_IS_ON() |
| 117 const TransformTree& transform_tree = property_trees->transform_tree; |
| 115 VerifySurfaceContentsScalesMatch(clip_node->target_effect_id, | 118 VerifySurfaceContentsScalesMatch(clip_node->target_effect_id, |
| 116 clip_node->target_transform_id, | 119 clip_node->target_transform_id, |
| 117 effect_tree, transform_tree); | 120 effect_tree, transform_tree); |
| 118 #endif | 121 #endif |
| 119 *clip_rect_in_target_space = MathUtil::MapClippedRect( | 122 *clip_rect_in_target_space = MathUtil::MapClippedRect( |
| 120 clip_to_target, clip_node->clip_in_target_space); | 123 clip_to_target, clip_node->clip_in_target_space); |
| 121 } else { | 124 } else { |
| 122 return false; | 125 return false; |
| 123 } | 126 } |
| 124 } else { | 127 } else { |
| 125 if (transform_tree.ComputeTransform(clip_node->target_transform_id, | 128 if (property_trees->ComputeTransformToTarget(clip_node->target_transform_id, |
| 126 target_node_id, &clip_to_target)) { | 129 target_effect_node->id, |
| 130 &clip_to_target)) { |
| 127 *clip_rect_in_target_space = MathUtil::ProjectClippedRect( | 131 *clip_rect_in_target_space = MathUtil::ProjectClippedRect( |
| 128 clip_to_target, clip_node->clip_in_target_space); | 132 clip_to_target, clip_node->clip_in_target_space); |
| 129 } else { | 133 } else { |
| 130 return false; | 134 return false; |
| 131 } | 135 } |
| 132 } | 136 } |
| 133 return true; | 137 return true; |
| 134 } | 138 } |
| 135 | 139 |
| 136 struct ConditionalClip { | 140 struct ConditionalClip { |
| 137 bool is_clipped; | 141 bool is_clipped; |
| 138 gfx::RectF clip_rect; | 142 gfx::RectF clip_rect; |
| 139 }; | 143 }; |
| 140 | 144 |
| 141 static ConditionalClip ComputeTargetRectInLocalSpace( | 145 static ConditionalClip ComputeTargetRectInLocalSpace( |
| 142 gfx::RectF rect, | 146 gfx::RectF rect, |
| 143 const TransformTree& transform_tree, | 147 const PropertyTrees* property_trees, |
| 144 const EffectTree& effect_tree, | |
| 145 int current_transform_id, | 148 int current_transform_id, |
| 146 int target_transform_id, | 149 int target_transform_id, |
| 147 const int current_effect_id) { | 150 const int current_effect_id) { |
| 151 const TransformTree& transform_tree = property_trees->transform_tree; |
| 152 const EffectTree& effect_tree = property_trees->effect_tree; |
| 148 gfx::Transform current_to_target; | 153 gfx::Transform current_to_target; |
| 149 bool success = transform_tree.ComputeTransform( | 154 bool success = transform_tree.ComputeTransform( |
| 150 current_transform_id, target_transform_id, ¤t_to_target); | 155 current_transform_id, target_transform_id, ¤t_to_target); |
| 151 if (!success) | 156 if (!success) |
| 152 // If transform is not invertible, cannot apply clip. | 157 // If transform is not invertible, cannot apply clip. |
| 153 return ConditionalClip{false, gfx::RectF()}; | 158 return ConditionalClip{false, gfx::RectF()}; |
| 154 const EffectNode* current_effect_node = effect_tree.Node(current_effect_id); | 159 const EffectNode* current_effect_node = effect_tree.Node(current_effect_id); |
| 155 ConcatInverseSurfaceContentsScale(current_effect_node, ¤t_to_target); | 160 ConcatInverseSurfaceContentsScale(current_effect_node, ¤t_to_target); |
| 156 | 161 |
| 157 if (current_transform_id > target_transform_id) | 162 if (current_transform_id > target_transform_id) |
| 158 return ConditionalClip{true, // is_clipped. | 163 return ConditionalClip{true, // is_clipped. |
| 159 MathUtil::MapClippedRect(current_to_target, rect)}; | 164 MathUtil::MapClippedRect(current_to_target, rect)}; |
| 160 | 165 |
| 161 return ConditionalClip{true, // is_clipped. | 166 return ConditionalClip{true, // is_clipped. |
| 162 MathUtil::ProjectClippedRect(current_to_target, rect)}; | 167 MathUtil::ProjectClippedRect(current_to_target, rect)}; |
| 163 } | 168 } |
| 164 | 169 |
| 165 static ConditionalClip ComputeLocalRectInTargetSpace( | 170 static ConditionalClip ComputeLocalRectInTargetSpace( |
| 166 gfx::RectF rect, | 171 gfx::RectF rect, |
| 167 const TransformTree& transform_tree, | 172 const PropertyTrees* property_trees, |
| 168 const EffectTree& effect_tree, | |
| 169 int current_transform_id, | 173 int current_transform_id, |
| 170 int target_transform_id, | 174 int target_transform_id, |
| 171 int target_effect_id) { | 175 int target_effect_id) { |
| 172 gfx::Transform current_to_target; | 176 gfx::Transform current_to_target; |
| 173 if (!transform_tree.ComputeTransform(current_transform_id, | 177 if (!property_trees->ComputeTransformToTarget( |
| 174 target_transform_id, ¤t_to_target)) | 178 current_transform_id, target_effect_id, ¤t_to_target)) |
| 175 // If transform is not invertible, cannot apply clip. | 179 // If transform is not invertible, cannot apply clip. |
| 176 return ConditionalClip{false, gfx::RectF()}; | 180 return ConditionalClip{false, gfx::RectF()}; |
| 177 // We don't have to apply surface contents scale when target is root. | 181 // We don't have to apply surface contents scale when target is root. |
| 178 if (target_transform_id != 0) { | 182 if (target_transform_id != 0) { |
| 183 const EffectTree& effect_tree = property_trees->effect_tree; |
| 179 const EffectNode* target_effect_node = effect_tree.Node(target_effect_id); | 184 const EffectNode* target_effect_node = effect_tree.Node(target_effect_id); |
| 180 PostConcatSurfaceContentsScale(target_effect_node, ¤t_to_target); | 185 PostConcatSurfaceContentsScale(target_effect_node, ¤t_to_target); |
| 181 #if DCHECK_IS_ON() | 186 #if DCHECK_IS_ON() |
| 187 const TransformTree& transform_tree = property_trees->transform_tree; |
| 182 VerifySurfaceContentsScalesMatch(target_effect_id, target_transform_id, | 188 VerifySurfaceContentsScalesMatch(target_effect_id, target_transform_id, |
| 183 effect_tree, transform_tree); | 189 effect_tree, transform_tree); |
| 184 #endif | 190 #endif |
| 185 } | 191 } |
| 186 | 192 |
| 187 if (current_transform_id > target_transform_id) | 193 if (current_transform_id > target_transform_id) |
| 188 return ConditionalClip{true, // is_clipped. | 194 return ConditionalClip{true, // is_clipped. |
| 189 MathUtil::MapClippedRect(current_to_target, rect)}; | 195 MathUtil::MapClippedRect(current_to_target, rect)}; |
| 190 | 196 |
| 191 return ConditionalClip{true, // is_clipped. | 197 return ConditionalClip{true, // is_clipped. |
| 192 MathUtil::ProjectClippedRect(current_to_target, rect)}; | 198 MathUtil::ProjectClippedRect(current_to_target, rect)}; |
| 193 } | 199 } |
| 194 | 200 |
| 195 static ConditionalClip ComputeCurrentClip(const ClipNode* clip_node, | 201 static ConditionalClip ComputeCurrentClip(const ClipNode* clip_node, |
| 196 const TransformTree& transform_tree, | 202 const PropertyTrees* property_trees, |
| 197 const EffectTree& effect_tree, | |
| 198 int target_transform_id, | 203 int target_transform_id, |
| 199 int target_effect_id) { | 204 int target_effect_id) { |
| 200 if (clip_node->transform_id != target_transform_id) | 205 if (clip_node->transform_id != target_transform_id) |
| 201 return ComputeLocalRectInTargetSpace(clip_node->clip, transform_tree, | 206 return ComputeLocalRectInTargetSpace(clip_node->clip, property_trees, |
| 202 effect_tree, clip_node->transform_id, | 207 clip_node->transform_id, |
| 203 target_transform_id, target_effect_id); | 208 target_transform_id, target_effect_id); |
| 204 | 209 |
| 210 const EffectTree& effect_tree = property_trees->effect_tree; |
| 205 gfx::RectF current_clip = clip_node->clip; | 211 gfx::RectF current_clip = clip_node->clip; |
| 206 gfx::Vector2dF surface_contents_scale = | 212 gfx::Vector2dF surface_contents_scale = |
| 207 effect_tree.Node(target_effect_id)->surface_contents_scale; | 213 effect_tree.Node(target_effect_id)->surface_contents_scale; |
| 208 if (surface_contents_scale.x() > 0 && surface_contents_scale.y() > 0) | 214 if (surface_contents_scale.x() > 0 && surface_contents_scale.y() > 0) |
| 209 current_clip.Scale(surface_contents_scale.x(), surface_contents_scale.y()); | 215 current_clip.Scale(surface_contents_scale.x(), surface_contents_scale.y()); |
| 210 return ConditionalClip{true /* is_clipped */, current_clip}; | 216 return ConditionalClip{true /* is_clipped */, current_clip}; |
| 211 } | 217 } |
| 212 | 218 |
| 213 static ConditionalClip ComputeAccumulatedClip( | 219 static ConditionalClip ComputeAccumulatedClip( |
| 214 const ClipTree& clip_tree, | 220 const PropertyTrees* property_trees, |
| 215 int local_clip_id, | 221 int local_clip_id, |
| 216 const EffectTree& effect_tree, | 222 int target_id) { |
| 217 int target_id, | 223 const ClipTree& clip_tree = property_trees->clip_tree; |
| 218 const TransformTree& transform_tree) { | 224 const EffectTree& effect_tree = property_trees->effect_tree; |
| 225 |
| 219 const ClipNode* clip_node = clip_tree.Node(local_clip_id); | 226 const ClipNode* clip_node = clip_tree.Node(local_clip_id); |
| 220 const EffectNode* target_node = effect_tree.Node(target_id); | 227 const EffectNode* target_node = effect_tree.Node(target_id); |
| 221 int target_transform_id = target_node->transform_id; | 228 int target_transform_id = target_node->transform_id; |
| 222 bool is_clipped = false; | 229 bool is_clipped = false; |
| 223 | 230 |
| 224 // Collect all the clips that need to be accumulated. | 231 // Collect all the clips that need to be accumulated. |
| 225 std::stack<const ClipNode*> parent_chain; | 232 std::stack<const ClipNode*> parent_chain; |
| 226 | 233 |
| 227 // If target is not direct ancestor of clip, this will find least common | 234 // If target is not direct ancestor of clip, this will find least common |
| 228 // ancestor between the target and the clip. | 235 // ancestor between the target and the clip. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 252 while (!clip_node->applies_local_clip && parent_chain.size() > 0) { | 259 while (!clip_node->applies_local_clip && parent_chain.size() > 0) { |
| 253 clip_node = parent_chain.top(); | 260 clip_node = parent_chain.top(); |
| 254 parent_chain.pop(); | 261 parent_chain.pop(); |
| 255 } | 262 } |
| 256 | 263 |
| 257 if (!clip_node->applies_local_clip) | 264 if (!clip_node->applies_local_clip) |
| 258 // No clip node applying clip in between. | 265 // No clip node applying clip in between. |
| 259 return ConditionalClip{false, gfx::RectF()}; | 266 return ConditionalClip{false, gfx::RectF()}; |
| 260 | 267 |
| 261 ConditionalClip current_clip = ComputeCurrentClip( | 268 ConditionalClip current_clip = ComputeCurrentClip( |
| 262 clip_node, transform_tree, effect_tree, target_transform_id, target_id); | 269 clip_node, property_trees, target_transform_id, target_id); |
| 263 is_clipped = current_clip.is_clipped; | 270 is_clipped = current_clip.is_clipped; |
| 264 gfx::RectF accumulated_clip = current_clip.clip_rect; | 271 gfx::RectF accumulated_clip = current_clip.clip_rect; |
| 265 | 272 |
| 266 while (parent_chain.size() > 0) { | 273 while (parent_chain.size() > 0) { |
| 267 clip_node = parent_chain.top(); | 274 clip_node = parent_chain.top(); |
| 268 parent_chain.pop(); | 275 parent_chain.pop(); |
| 269 if (!clip_node->applies_local_clip) { | 276 if (!clip_node->applies_local_clip) { |
| 270 continue; | 277 continue; |
| 271 } | 278 } |
| 272 ConditionalClip current_clip = ComputeCurrentClip( | 279 ConditionalClip current_clip = ComputeCurrentClip( |
| 273 clip_node, transform_tree, effect_tree, target_transform_id, target_id); | 280 clip_node, property_trees, target_transform_id, target_id); |
| 274 | 281 |
| 275 // If transform is not invertible, no clip will be applied. | 282 // If transform is not invertible, no clip will be applied. |
| 276 if (!current_clip.is_clipped) | 283 if (!current_clip.is_clipped) |
| 277 return ConditionalClip{false, gfx::RectF()}; | 284 return ConditionalClip{false, gfx::RectF()}; |
| 278 | 285 |
| 279 is_clipped = true; | 286 is_clipped = true; |
| 280 accumulated_clip = | 287 accumulated_clip = |
| 281 gfx::IntersectRects(accumulated_clip, current_clip.clip_rect); | 288 gfx::IntersectRects(accumulated_clip, current_clip.clip_rect); |
| 282 } | 289 } |
| 283 | 290 |
| 284 return ConditionalClip{ | 291 return ConditionalClip{ |
| 285 is_clipped, accumulated_clip.IsEmpty() ? gfx::RectF() : accumulated_clip}; | 292 is_clipped, accumulated_clip.IsEmpty() ? gfx::RectF() : accumulated_clip}; |
| 286 } | 293 } |
| 287 | 294 |
| 288 template <typename LayerType> | 295 template <typename LayerType> |
| 289 void CalculateClipRects( | 296 void CalculateClipRects( |
| 290 const typename LayerType::LayerListType& visible_layer_list, | 297 const typename LayerType::LayerListType& visible_layer_list, |
| 291 const ClipTree& clip_tree, | 298 const PropertyTrees* property_trees, |
| 292 const TransformTree& transform_tree, | |
| 293 const EffectTree& effect_tree, | |
| 294 bool non_root_surfaces_enabled) { | 299 bool non_root_surfaces_enabled) { |
| 300 const ClipTree& clip_tree = property_trees->clip_tree; |
| 295 for (auto& layer : visible_layer_list) { | 301 for (auto& layer : visible_layer_list) { |
| 296 const ClipNode* clip_node = clip_tree.Node(layer->clip_tree_index()); | 302 const ClipNode* clip_node = clip_tree.Node(layer->clip_tree_index()); |
| 297 if (!non_root_surfaces_enabled) { | 303 if (!non_root_surfaces_enabled) { |
| 298 layer->set_clip_rect( | 304 layer->set_clip_rect( |
| 299 gfx::ToEnclosingRect(clip_node->clip_in_target_space)); | 305 gfx::ToEnclosingRect(clip_node->clip_in_target_space)); |
| 300 continue; | 306 continue; |
| 301 } | 307 } |
| 302 | 308 |
| 303 // When both the layer and the target are unclipped, the entire layer | 309 // When both the layer and the target are unclipped, the entire layer |
| 304 // content rect is visible. | 310 // content rect is visible. |
| 305 const bool fully_visible = | 311 const bool fully_visible = |
| 306 !clip_node->layers_are_clipped && !clip_node->target_is_clipped; | 312 !clip_node->layers_are_clipped && !clip_node->target_is_clipped; |
| 307 | 313 |
| 308 if (!fully_visible) { | 314 if (!fully_visible) { |
| 315 const TransformTree& transform_tree = property_trees->transform_tree; |
| 309 const TransformNode* transform_node = | 316 const TransformNode* transform_node = |
| 310 transform_tree.Node(layer->transform_tree_index()); | 317 transform_tree.Node(layer->transform_tree_index()); |
| 311 int target_node_id = transform_tree.ContentTargetId(transform_node->id); | 318 int target_node_id = transform_tree.ContentTargetId(transform_node->id); |
| 312 | 319 |
| 313 // The clip node stores clip rect in its target space. | 320 // The clip node stores clip rect in its target space. |
| 314 gfx::RectF clip_rect_in_target_space = clip_node->clip_in_target_space; | 321 gfx::RectF clip_rect_in_target_space = clip_node->clip_in_target_space; |
| 315 | 322 |
| 316 // If required, this clip rect should be mapped to the current layer's | 323 // If required, this clip rect should be mapped to the current layer's |
| 317 // target space. | 324 // target space. |
| 318 if (clip_node->target_transform_id != target_node_id) { | 325 if (clip_node->target_transform_id != target_node_id) { |
| 319 // In this case, layer has a clip parent or scroll parent (or shares the | 326 // In this case, layer has a clip parent or scroll parent (or shares the |
| 320 // target with an ancestor layer that has clip parent) and the clip | 327 // target with an ancestor layer that has clip parent) and the clip |
| 321 // parent's target is different from the layer's target. As the layer's | 328 // parent's target is different from the layer's target. As the layer's |
| 322 // target has unclippped descendants, it is unclippped. | 329 // target has unclippped descendants, it is unclippped. |
| 323 if (!clip_node->layers_are_clipped) | 330 if (!clip_node->layers_are_clipped) |
| 324 continue; | 331 continue; |
| 325 | 332 |
| 326 // Compute the clip rect in target space and store it. | 333 // Compute the clip rect in target space and store it. |
| 327 if (!ComputeClipRectInTargetSpace(layer, clip_node, transform_tree, | 334 if (!ComputeClipRectInTargetSpace(layer, clip_node, property_trees, |
| 328 effect_tree, target_node_id, | 335 target_node_id, |
| 329 &clip_rect_in_target_space)) | 336 &clip_rect_in_target_space)) |
| 330 continue; | 337 continue; |
| 331 } | 338 } |
| 332 | 339 |
| 333 if (!clip_rect_in_target_space.IsEmpty()) { | 340 if (!clip_rect_in_target_space.IsEmpty()) { |
| 334 layer->set_clip_rect(gfx::ToEnclosingRect(clip_rect_in_target_space)); | 341 layer->set_clip_rect(gfx::ToEnclosingRect(clip_rect_in_target_space)); |
| 335 } else { | 342 } else { |
| 336 layer->set_clip_rect(gfx::Rect()); | 343 layer->set_clip_rect(gfx::Rect()); |
| 337 } | 344 } |
| 338 } | 345 } |
| 339 } | 346 } |
| 340 } | 347 } |
| 341 | 348 |
| 342 bool GetLayerClipRect(const scoped_refptr<Layer> layer, | 349 bool GetLayerClipRect(const scoped_refptr<Layer> layer, |
| 343 const ClipNode* clip_node, | 350 const ClipNode* clip_node, |
| 344 const TransformTree& transform_tree, | 351 const PropertyTrees* property_trees, |
| 345 const EffectTree& effect_tree, | |
| 346 int target_node_id, | 352 int target_node_id, |
| 347 gfx::RectF* clip_rect_in_target_space) { | 353 gfx::RectF* clip_rect_in_target_space) { |
| 348 return ComputeClipRectInTargetSpace(layer.get(), clip_node, transform_tree, | 354 return ComputeClipRectInTargetSpace(layer.get(), clip_node, property_trees, |
| 349 effect_tree, target_node_id, | 355 target_node_id, |
| 350 clip_rect_in_target_space); | 356 clip_rect_in_target_space); |
| 351 } | 357 } |
| 352 | 358 |
| 353 bool GetLayerClipRect(const LayerImpl* layer, | 359 bool GetLayerClipRect(const LayerImpl* layer, |
| 354 const ClipNode* clip_node, | 360 const ClipNode* clip_node, |
| 355 const TransformTree& transform_tree, | 361 const PropertyTrees* property_trees, |
| 356 const EffectTree& effect_tree, | |
| 357 int target_node_id, | 362 int target_node_id, |
| 358 gfx::RectF* clip_rect_in_target_space) { | 363 gfx::RectF* clip_rect_in_target_space) { |
| 359 // This is equivalent of calling ComputeClipRectInTargetSpace. | 364 // This is equivalent of calling ComputeClipRectInTargetSpace. |
| 360 *clip_rect_in_target_space = gfx::RectF(layer->clip_rect()); | 365 *clip_rect_in_target_space = gfx::RectF(layer->clip_rect()); |
| 361 return transform_tree.Node(target_node_id)->ancestors_are_invertible; | 366 return property_trees->transform_tree.Node(target_node_id) |
| 367 ->ancestors_are_invertible; |
| 362 } | 368 } |
| 363 | 369 |
| 364 template <typename LayerType> | 370 template <typename LayerType> |
| 365 void CalculateVisibleRects( | 371 void CalculateVisibleRects( |
| 366 const typename LayerType::LayerListType& visible_layer_list, | 372 const typename LayerType::LayerListType& visible_layer_list, |
| 367 const ClipTree& clip_tree, | 373 const PropertyTrees* property_trees, |
| 368 const TransformTree& transform_tree, | |
| 369 const EffectTree& effect_tree, | |
| 370 bool non_root_surfaces_enabled) { | 374 bool non_root_surfaces_enabled) { |
| 375 const EffectTree& effect_tree = property_trees->effect_tree; |
| 376 const TransformTree& transform_tree = property_trees->transform_tree; |
| 377 const ClipTree& clip_tree = property_trees->clip_tree; |
| 371 for (auto& layer : visible_layer_list) { | 378 for (auto& layer : visible_layer_list) { |
| 372 gfx::Size layer_bounds = layer->bounds(); | 379 gfx::Size layer_bounds = layer->bounds(); |
| 373 | 380 |
| 374 int effect_ancestor_with_copy_request = | 381 int effect_ancestor_with_copy_request = |
| 375 effect_tree.ClosestAncestorWithCopyRequest(layer->effect_tree_index()); | 382 effect_tree.ClosestAncestorWithCopyRequest(layer->effect_tree_index()); |
| 376 if (effect_ancestor_with_copy_request > 1) { | 383 if (effect_ancestor_with_copy_request > 1) { |
| 377 // Non root copy request. | 384 // Non root copy request. |
| 378 ConditionalClip accumulated_clip_rect = ComputeAccumulatedClip( | 385 ConditionalClip accumulated_clip_rect = |
| 379 clip_tree, layer->clip_tree_index(), effect_tree, | 386 ComputeAccumulatedClip(property_trees, layer->clip_tree_index(), |
| 380 effect_ancestor_with_copy_request, transform_tree); | 387 effect_ancestor_with_copy_request); |
| 381 if (!accumulated_clip_rect.is_clipped) { | 388 if (!accumulated_clip_rect.is_clipped) { |
| 382 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); | 389 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); |
| 383 continue; | 390 continue; |
| 384 } | 391 } |
| 385 | 392 |
| 386 gfx::RectF accumulated_clip_in_copy_request_space = | 393 gfx::RectF accumulated_clip_in_copy_request_space = |
| 387 accumulated_clip_rect.clip_rect; | 394 accumulated_clip_rect.clip_rect; |
| 388 | 395 |
| 389 const EffectNode* copy_request_effect_node = | 396 const EffectNode* copy_request_effect_node = |
| 390 effect_tree.Node(effect_ancestor_with_copy_request); | 397 effect_tree.Node(effect_ancestor_with_copy_request); |
| 391 ConditionalClip clip_in_layer_space = ComputeTargetRectInLocalSpace( | 398 ConditionalClip clip_in_layer_space = ComputeTargetRectInLocalSpace( |
| 392 accumulated_clip_in_copy_request_space, transform_tree, effect_tree, | 399 accumulated_clip_in_copy_request_space, property_trees, |
| 393 copy_request_effect_node->transform_id, layer->transform_tree_index(), | 400 copy_request_effect_node->transform_id, layer->transform_tree_index(), |
| 394 copy_request_effect_node->id); | 401 copy_request_effect_node->id); |
| 395 | 402 |
| 396 if (clip_in_layer_space.is_clipped) { | 403 if (clip_in_layer_space.is_clipped) { |
| 397 gfx::RectF clip_rect = clip_in_layer_space.clip_rect; | 404 gfx::RectF clip_rect = clip_in_layer_space.clip_rect; |
| 398 clip_rect.Offset(-layer->offset_to_transform_parent()); | 405 clip_rect.Offset(-layer->offset_to_transform_parent()); |
| 399 gfx::Rect visible_rect = gfx::ToEnclosingRect(clip_rect); | 406 gfx::Rect visible_rect = gfx::ToEnclosingRect(clip_rect); |
| 400 visible_rect.Intersect(gfx::Rect(layer_bounds)); | 407 visible_rect.Intersect(gfx::Rect(layer_bounds)); |
| 401 layer->set_visible_layer_rect(visible_rect); | 408 layer->set_visible_layer_rect(visible_rect); |
| 402 } else { | 409 } else { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); | 463 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); |
| 457 continue; | 464 continue; |
| 458 } | 465 } |
| 459 | 466 |
| 460 // We use the clip node's clip_in_target_space (and not | 467 // We use the clip node's clip_in_target_space (and not |
| 461 // combined_clip_in_target_space) here because we want to clip | 468 // combined_clip_in_target_space) here because we want to clip |
| 462 // with respect to clip parent's local clip and not its combined clip as | 469 // with respect to clip parent's local clip and not its combined clip as |
| 463 // the combined clip has even the clip parent's target's clip baked into | 470 // the combined clip has even the clip parent's target's clip baked into |
| 464 // it and as our target is different, we don't want to use it in our | 471 // it and as our target is different, we don't want to use it in our |
| 465 // visible rect computation. | 472 // visible rect computation. |
| 466 if (!GetLayerClipRect(layer, clip_node, transform_tree, effect_tree, | 473 if (!GetLayerClipRect(layer, clip_node, property_trees, target_node_id, |
| 467 target_node_id, | |
| 468 &combined_clip_rect_in_target_space)) { | 474 &combined_clip_rect_in_target_space)) { |
| 469 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); | 475 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); |
| 470 continue; | 476 continue; |
| 471 } | 477 } |
| 472 } else { | 478 } else { |
| 473 if (clip_node->target_is_clipped) { | 479 if (clip_node->target_is_clipped) { |
| 474 combined_clip_rect_in_target_space = | 480 combined_clip_rect_in_target_space = |
| 475 clip_node->combined_clip_in_target_space; | 481 clip_node->combined_clip_in_target_space; |
| 476 } else { | 482 } else { |
| 477 combined_clip_rect_in_target_space = clip_node->clip_in_target_space; | 483 combined_clip_rect_in_target_space = clip_node->clip_in_target_space; |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 | 739 |
| 734 void ConcatInverseSurfaceContentsScale(const EffectNode* effect_node, | 740 void ConcatInverseSurfaceContentsScale(const EffectNode* effect_node, |
| 735 gfx::Transform* transform) { | 741 gfx::Transform* transform) { |
| 736 DCHECK(effect_node->has_render_surface); | 742 DCHECK(effect_node->has_render_surface); |
| 737 if (effect_node->surface_contents_scale.x() != 0.0 && | 743 if (effect_node->surface_contents_scale.x() != 0.0 && |
| 738 effect_node->surface_contents_scale.y() != 0.0) | 744 effect_node->surface_contents_scale.y() != 0.0) |
| 739 transform->Scale(1.0 / effect_node->surface_contents_scale.x(), | 745 transform->Scale(1.0 / effect_node->surface_contents_scale.x(), |
| 740 1.0 / effect_node->surface_contents_scale.y()); | 746 1.0 / effect_node->surface_contents_scale.y()); |
| 741 } | 747 } |
| 742 | 748 |
| 743 void ComputeClips(ClipTree* clip_tree, | 749 void ComputeClips(PropertyTrees* property_trees, |
| 744 const TransformTree& transform_tree, | |
| 745 const EffectTree& effect_tree, | |
| 746 bool non_root_surfaces_enabled) { | 750 bool non_root_surfaces_enabled) { |
| 751 ClipTree* clip_tree = &property_trees->clip_tree; |
| 747 if (!clip_tree->needs_update()) | 752 if (!clip_tree->needs_update()) |
| 748 return; | 753 return; |
| 749 for (int i = 1; i < static_cast<int>(clip_tree->size()); ++i) { | 754 for (int i = 1; i < static_cast<int>(clip_tree->size()); ++i) { |
| 750 ClipNode* clip_node = clip_tree->Node(i); | 755 ClipNode* clip_node = clip_tree->Node(i); |
| 751 | 756 |
| 752 if (clip_node->id == 1) { | 757 if (clip_node->id == 1) { |
| 753 ResetIfHasNanCoordinate(&clip_node->clip); | 758 ResetIfHasNanCoordinate(&clip_node->clip); |
| 754 clip_node->clip_in_target_space = clip_node->clip; | 759 clip_node->clip_in_target_space = clip_node->clip; |
| 755 clip_node->combined_clip_in_target_space = clip_node->clip; | 760 clip_node->combined_clip_in_target_space = clip_node->clip; |
| 756 continue; | 761 continue; |
| 757 } | 762 } |
| 763 const TransformTree& transform_tree = property_trees->transform_tree; |
| 764 const EffectTree& effect_tree = property_trees->effect_tree; |
| 758 const TransformNode* transform_node = | 765 const TransformNode* transform_node = |
| 759 transform_tree.Node(clip_node->transform_id); | 766 transform_tree.Node(clip_node->transform_id); |
| 760 ClipNode* parent_clip_node = clip_tree->parent(clip_node); | 767 ClipNode* parent_clip_node = clip_tree->parent(clip_node); |
| 761 | 768 |
| 762 gfx::Transform parent_to_current; | 769 gfx::Transform parent_to_current; |
| 763 const TransformNode* parent_target_transform_node = | 770 const TransformNode* parent_target_transform_node = |
| 764 transform_tree.Node(parent_clip_node->target_transform_id); | 771 transform_tree.Node(parent_clip_node->target_transform_id); |
| 765 bool success = true; | 772 bool success = true; |
| 766 | 773 |
| 767 // Clips must be combined in target space. We cannot, for example, combine | 774 // Clips must be combined in target space. We cannot, for example, combine |
| 768 // clips in the space of the child clip. The reason is non-affine | 775 // clips in the space of the child clip. The reason is non-affine |
| 769 // transforms. Say we have the following tree T->A->B->C, and B clips C, but | 776 // transforms. Say we have the following tree T->A->B->C, and B clips C, but |
| 770 // draw into target T. It may be the case that A applies a perspective | 777 // draw into target T. It may be the case that A applies a perspective |
| 771 // transform, and B and C are at different z positions. When projected into | 778 // transform, and B and C are at different z positions. When projected into |
| 772 // target space, the relative sizes and positions of B and C can shift. | 779 // target space, the relative sizes and positions of B and C can shift. |
| 773 // Since it's the relationship in target space that matters, that's where we | 780 // Since it's the relationship in target space that matters, that's where we |
| 774 // must combine clips. For each clip node, we save the clip rects in its | 781 // must combine clips. For each clip node, we save the clip rects in its |
| 775 // target space. So, we need to get the ancestor clip rect in the current | 782 // target space. So, we need to get the ancestor clip rect in the current |
| 776 // clip node's target space. | 783 // clip node's target space. |
| 777 gfx::RectF parent_combined_clip_in_target_space = | 784 gfx::RectF parent_combined_clip_in_target_space = |
| 778 parent_clip_node->combined_clip_in_target_space; | 785 parent_clip_node->combined_clip_in_target_space; |
| 779 gfx::RectF parent_clip_in_target_space = | 786 gfx::RectF parent_clip_in_target_space = |
| 780 parent_clip_node->clip_in_target_space; | 787 parent_clip_node->clip_in_target_space; |
| 781 if (parent_target_transform_node && | 788 if (parent_target_transform_node && |
| 782 parent_target_transform_node->id != clip_node->target_transform_id && | 789 parent_target_transform_node->id != clip_node->target_transform_id && |
| 783 non_root_surfaces_enabled) { | 790 non_root_surfaces_enabled) { |
| 784 success &= transform_tree.ComputeTransform( | 791 success &= property_trees->ComputeTransformToTarget( |
| 785 parent_target_transform_node->id, clip_node->target_transform_id, | 792 parent_target_transform_node->id, clip_node->target_effect_id, |
| 786 &parent_to_current); | 793 &parent_to_current); |
| 787 // We don't have to apply surface contents scale when target is root. | 794 // We don't have to apply surface contents scale when target is root. |
| 788 if (clip_node->target_transform_id != 0) { | 795 if (clip_node->target_transform_id != 0) { |
| 789 const EffectNode* target_effect_node = | 796 const EffectNode* target_effect_node = |
| 790 effect_tree.Node(clip_node->target_effect_id); | 797 effect_tree.Node(clip_node->target_effect_id); |
| 791 PostConcatSurfaceContentsScale(target_effect_node, &parent_to_current); | 798 PostConcatSurfaceContentsScale(target_effect_node, &parent_to_current); |
| 792 #if DCHECK_IS_ON() | 799 #if DCHECK_IS_ON() |
| 793 VerifySurfaceContentsScalesMatch(clip_node->target_effect_id, | 800 VerifySurfaceContentsScalesMatch(clip_node->target_effect_id, |
| 794 clip_node->target_transform_id, | 801 clip_node->target_transform_id, |
| 795 effect_tree, transform_tree); | 802 effect_tree, transform_tree); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 } | 862 } |
| 856 } else { | 863 } else { |
| 857 gfx::Transform source_to_target; | 864 gfx::Transform source_to_target; |
| 858 | 865 |
| 859 if (!non_root_surfaces_enabled) { | 866 if (!non_root_surfaces_enabled) { |
| 860 source_to_target = transform_tree.ToScreen(clip_node->transform_id); | 867 source_to_target = transform_tree.ToScreen(clip_node->transform_id); |
| 861 } else if (transform_tree.ContentTargetId(transform_node->id) == | 868 } else if (transform_tree.ContentTargetId(transform_node->id) == |
| 862 clip_node->target_transform_id) { | 869 clip_node->target_transform_id) { |
| 863 source_to_target = transform_tree.ToTarget(clip_node->transform_id); | 870 source_to_target = transform_tree.ToTarget(clip_node->transform_id); |
| 864 } else { | 871 } else { |
| 865 success = transform_tree.ComputeTransform( | 872 success = property_trees->ComputeTransformToTarget( |
| 866 transform_node->id, clip_node->target_transform_id, | 873 transform_node->id, clip_node->target_effect_id, &source_to_target); |
| 867 &source_to_target); | |
| 868 // We don't have to apply surface contents scale when target is root. | 874 // We don't have to apply surface contents scale when target is root. |
| 869 if (clip_node->target_transform_id != 0) { | 875 if (clip_node->target_transform_id != 0) { |
| 870 const EffectNode* target_effect_node = | 876 const EffectNode* target_effect_node = |
| 871 effect_tree.Node(clip_node->target_effect_id); | 877 effect_tree.Node(clip_node->target_effect_id); |
| 872 PostConcatSurfaceContentsScale(target_effect_node, &source_to_target); | 878 PostConcatSurfaceContentsScale(target_effect_node, &source_to_target); |
| 873 #if DCHECK_IS_ON() | 879 #if DCHECK_IS_ON() |
| 874 VerifySurfaceContentsScalesMatch(clip_node->target_effect_id, | 880 VerifySurfaceContentsScalesMatch(clip_node->target_effect_id, |
| 875 clip_node->target_transform_id, | 881 clip_node->target_transform_id, |
| 876 effect_tree, transform_tree); | 882 effect_tree, transform_tree); |
| 877 #endif | 883 #endif |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 if (!effect_tree->needs_update()) | 942 if (!effect_tree->needs_update()) |
| 937 return; | 943 return; |
| 938 for (int i = 1; i < static_cast<int>(effect_tree->size()); ++i) | 944 for (int i = 1; i < static_cast<int>(effect_tree->size()); ++i) |
| 939 effect_tree->UpdateEffects(i); | 945 effect_tree->UpdateEffects(i); |
| 940 effect_tree->set_needs_update(false); | 946 effect_tree->set_needs_update(false); |
| 941 } | 947 } |
| 942 | 948 |
| 943 static void ComputeClipsWithEffectTree(PropertyTrees* property_trees) { | 949 static void ComputeClipsWithEffectTree(PropertyTrees* property_trees) { |
| 944 EffectTree* effect_tree = &property_trees->effect_tree; | 950 EffectTree* effect_tree = &property_trees->effect_tree; |
| 945 const ClipTree* clip_tree = &property_trees->clip_tree; | 951 const ClipTree* clip_tree = &property_trees->clip_tree; |
| 946 const TransformTree* transform_tree = &property_trees->transform_tree; | |
| 947 EffectNode* root_effect_node = effect_tree->Node(1); | 952 EffectNode* root_effect_node = effect_tree->Node(1); |
| 948 const RenderSurfaceImpl* root_render_surface = | 953 const RenderSurfaceImpl* root_render_surface = |
| 949 root_effect_node->render_surface; | 954 root_effect_node->render_surface; |
| 950 gfx::Rect root_clip = | 955 gfx::Rect root_clip = |
| 951 gfx::ToEnclosingRect(clip_tree->Node(root_effect_node->clip_id)->clip); | 956 gfx::ToEnclosingRect(clip_tree->Node(root_effect_node->clip_id)->clip); |
| 952 if (root_render_surface->is_clipped()) | 957 if (root_render_surface->is_clipped()) |
| 953 DCHECK(root_clip == root_render_surface->clip_rect()) | 958 DCHECK(root_clip == root_render_surface->clip_rect()) |
| 954 << "clip on root render surface: " | 959 << "clip on root render surface: " |
| 955 << root_render_surface->clip_rect().ToString() | 960 << root_render_surface->clip_rect().ToString() |
| 956 << " v.s. root effect node's clip: " << root_clip.ToString(); | 961 << " v.s. root effect node's clip: " << root_clip.ToString(); |
| 957 for (int i = 2; i < static_cast<int>(effect_tree->size()); ++i) { | 962 for (int i = 2; i < static_cast<int>(effect_tree->size()); ++i) { |
| 958 EffectNode* effect_node = effect_tree->Node(i); | 963 EffectNode* effect_node = effect_tree->Node(i); |
| 959 const EffectNode* target_node = effect_tree->Node(effect_node->target_id); | 964 const EffectNode* target_node = effect_tree->Node(effect_node->target_id); |
| 960 ConditionalClip accumulated_clip_rect = | 965 ConditionalClip accumulated_clip_rect = ComputeAccumulatedClip( |
| 961 ComputeAccumulatedClip(*clip_tree, effect_node->clip_id, *effect_tree, | 966 property_trees, effect_node->clip_id, target_node->id); |
| 962 target_node->id, *transform_tree); | |
| 963 gfx::RectF accumulated_clip = accumulated_clip_rect.clip_rect; | 967 gfx::RectF accumulated_clip = accumulated_clip_rect.clip_rect; |
| 964 const RenderSurfaceImpl* render_surface = effect_node->render_surface; | 968 const RenderSurfaceImpl* render_surface = effect_node->render_surface; |
| 965 if (render_surface && render_surface->is_clipped()) { | 969 if (render_surface && render_surface->is_clipped()) { |
| 966 DCHECK(gfx::ToEnclosingRect(accumulated_clip) == | 970 DCHECK(gfx::ToEnclosingRect(accumulated_clip) == |
| 967 render_surface->clip_rect()) | 971 render_surface->clip_rect()) |
| 968 << " render surface's clip rect: " | 972 << " render surface's clip rect: " |
| 969 << render_surface->clip_rect().ToString() | 973 << render_surface->clip_rect().ToString() |
| 970 << " v.s. accumulated clip: " | 974 << " v.s. accumulated clip: " |
| 971 << gfx::ToEnclosingRect(accumulated_clip).ToString(); | 975 << gfx::ToEnclosingRect(accumulated_clip).ToString(); |
| 972 } | 976 } |
| 973 } | 977 } |
| 974 } | 978 } |
| 975 | 979 |
| 976 static void ComputeLayerClipRect(const PropertyTrees* property_trees, | 980 static void ComputeLayerClipRect(const PropertyTrees* property_trees, |
| 977 const LayerImpl* layer) { | 981 const LayerImpl* layer) { |
| 978 const EffectTree* effect_tree = &property_trees->effect_tree; | 982 const EffectTree* effect_tree = &property_trees->effect_tree; |
| 979 const ClipTree* clip_tree = &property_trees->clip_tree; | 983 const ClipTree* clip_tree = &property_trees->clip_tree; |
| 980 const TransformTree* transform_tree = &property_trees->transform_tree; | |
| 981 const EffectNode* effect_node = effect_tree->Node(layer->effect_tree_index()); | 984 const EffectNode* effect_node = effect_tree->Node(layer->effect_tree_index()); |
| 982 const EffectNode* target_node = | 985 const EffectNode* target_node = |
| 983 effect_node->has_render_surface | 986 effect_node->has_render_surface |
| 984 ? effect_node | 987 ? effect_node |
| 985 : effect_tree->Node(effect_node->target_id); | 988 : effect_tree->Node(effect_node->target_id); |
| 986 // TODO(weiliangc): When effect node has up to date render surface info on | 989 // TODO(weiliangc): When effect node has up to date render surface info on |
| 987 // compositor thread, no need to check for resourceless draw mode | 990 // compositor thread, no need to check for resourceless draw mode |
| 988 if (!property_trees->non_root_surfaces_enabled) { | 991 if (!property_trees->non_root_surfaces_enabled) { |
| 989 target_node = effect_tree->Node(1); | 992 target_node = effect_tree->Node(1); |
| 990 } | 993 } |
| 991 | 994 |
| 992 ConditionalClip accumulated_clip_rect = | 995 ConditionalClip accumulated_clip_rect = ComputeAccumulatedClip( |
| 993 ComputeAccumulatedClip(*clip_tree, layer->clip_tree_index(), *effect_tree, | 996 property_trees, layer->clip_tree_index(), target_node->id); |
| 994 target_node->id, *transform_tree); | |
| 995 | 997 |
| 996 gfx::RectF accumulated_clip = accumulated_clip_rect.clip_rect; | 998 gfx::RectF accumulated_clip = accumulated_clip_rect.clip_rect; |
| 997 | 999 |
| 998 if ((!property_trees->non_root_surfaces_enabled && | 1000 if ((!property_trees->non_root_surfaces_enabled && |
| 999 clip_tree->Node(layer->clip_tree_index()) | 1001 clip_tree->Node(layer->clip_tree_index()) |
| 1000 ->layers_are_clipped_when_surfaces_disabled) || | 1002 ->layers_are_clipped_when_surfaces_disabled) || |
| 1001 clip_tree->Node(layer->clip_tree_index())->layers_are_clipped) { | 1003 clip_tree->Node(layer->clip_tree_index())->layers_are_clipped) { |
| 1002 DCHECK(layer->clip_rect() == gfx::ToEnclosingRect(accumulated_clip)) | 1004 DCHECK(layer->clip_rect() == gfx::ToEnclosingRect(accumulated_clip)) |
| 1003 << " layer: " << layer->id() << " clip id: " << layer->clip_tree_index() | 1005 << " layer: " << layer->id() << " clip id: " << layer->clip_tree_index() |
| 1004 << " layer clip: " << layer->clip_rect().ToString() << " v.s. " | 1006 << " layer clip: " << layer->clip_rect().ToString() << " v.s. " |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1018 return node->transform_id; | 1020 return node->transform_id; |
| 1019 node = effect_tree.Node(node->target_id); | 1021 node = effect_tree.Node(node->target_id); |
| 1020 return node->transform_id; | 1022 return node->transform_id; |
| 1021 } | 1023 } |
| 1022 | 1024 |
| 1023 static void VerifyDrawTransformsMatch(LayerImpl* layer, | 1025 static void VerifyDrawTransformsMatch(LayerImpl* layer, |
| 1024 PropertyTrees* property_trees) { | 1026 PropertyTrees* property_trees) { |
| 1025 const int source_id = layer->transform_tree_index(); | 1027 const int source_id = layer->transform_tree_index(); |
| 1026 int destination_id = FindTargetTransformTreeIndexFromEffectTree( | 1028 int destination_id = FindTargetTransformTreeIndexFromEffectTree( |
| 1027 property_trees->effect_tree, layer->effect_tree_index()); | 1029 property_trees->effect_tree, layer->effect_tree_index()); |
| 1030 const EffectNode* target_effect_node = ContentsTargetEffectNode( |
| 1031 layer->effect_tree_index(), property_trees->effect_tree); |
| 1028 gfx::Transform draw_transform; | 1032 gfx::Transform draw_transform; |
| 1029 property_trees->transform_tree.ComputeTransform(source_id, destination_id, | 1033 property_trees->ComputeTransformToTarget(source_id, target_effect_node->id, |
| 1030 &draw_transform); | 1034 &draw_transform); |
| 1031 // We don't have to apply surface contents scale when target is root. | 1035 // We don't have to apply surface contents scale when target is root. |
| 1032 if (destination_id != 0) { | 1036 if (destination_id != 0) { |
| 1033 const EffectNode* target_effect_node = ContentsTargetEffectNode( | |
| 1034 layer->effect_tree_index(), property_trees->effect_tree); | |
| 1035 PostConcatSurfaceContentsScale(target_effect_node, &draw_transform); | 1037 PostConcatSurfaceContentsScale(target_effect_node, &draw_transform); |
| 1036 #if DCHECK_IS_ON() | 1038 #if DCHECK_IS_ON() |
| 1037 VerifySurfaceContentsScalesMatch(layer->effect_tree_index(), destination_id, | 1039 VerifySurfaceContentsScalesMatch(layer->effect_tree_index(), destination_id, |
| 1038 property_trees->effect_tree, | 1040 property_trees->effect_tree, |
| 1039 property_trees->transform_tree); | 1041 property_trees->transform_tree); |
| 1040 #endif | 1042 #endif |
| 1041 } | 1043 } |
| 1042 if (layer->should_flatten_transform_from_property_tree()) | 1044 if (layer->should_flatten_transform_from_property_tree()) |
| 1043 draw_transform.FlattenTo2d(); | 1045 draw_transform.FlattenTo2d(); |
| 1044 draw_transform.Translate(layer->offset_to_transform_parent().x(), | 1046 draw_transform.Translate(layer->offset_to_transform_parent().x(), |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1067 if (property_trees->transform_tree.needs_update()) { | 1069 if (property_trees->transform_tree.needs_update()) { |
| 1068 property_trees->clip_tree.set_needs_update(true); | 1070 property_trees->clip_tree.set_needs_update(true); |
| 1069 property_trees->effect_tree.set_needs_update(true); | 1071 property_trees->effect_tree.set_needs_update(true); |
| 1070 } | 1072 } |
| 1071 UpdateRenderTarget(&property_trees->effect_tree, | 1073 UpdateRenderTarget(&property_trees->effect_tree, |
| 1072 property_trees->non_root_surfaces_enabled); | 1074 property_trees->non_root_surfaces_enabled); |
| 1073 ComputeTransforms(&property_trees->transform_tree); | 1075 ComputeTransforms(&property_trees->transform_tree); |
| 1074 // Computation of clips uses surface contents scale which is updated while | 1076 // Computation of clips uses surface contents scale which is updated while |
| 1075 // computing effects. So, ComputeEffects should be before ComputeClips. | 1077 // computing effects. So, ComputeEffects should be before ComputeClips. |
| 1076 ComputeEffects(&property_trees->effect_tree); | 1078 ComputeEffects(&property_trees->effect_tree); |
| 1077 ComputeClips(&property_trees->clip_tree, property_trees->transform_tree, | 1079 ComputeClips(property_trees, can_render_to_separate_surface); |
| 1078 property_trees->effect_tree, can_render_to_separate_surface); | |
| 1079 | 1080 |
| 1080 FindLayersThatNeedUpdates(root_layer->layer_tree_impl(), | 1081 FindLayersThatNeedUpdates(root_layer->layer_tree_impl(), |
| 1081 property_trees->transform_tree, | 1082 property_trees->transform_tree, |
| 1082 property_trees->effect_tree, visible_layer_list); | 1083 property_trees->effect_tree, visible_layer_list); |
| 1083 CalculateClipRects<LayerImpl>(*visible_layer_list, property_trees->clip_tree, | 1084 CalculateClipRects<LayerImpl>(*visible_layer_list, property_trees, |
| 1084 property_trees->transform_tree, | |
| 1085 property_trees->effect_tree, | |
| 1086 can_render_to_separate_surface); | 1085 can_render_to_separate_surface); |
| 1087 CalculateVisibleRects<LayerImpl>( | 1086 CalculateVisibleRects<LayerImpl>(*visible_layer_list, property_trees, |
| 1088 *visible_layer_list, property_trees->clip_tree, | 1087 can_render_to_separate_surface); |
| 1089 property_trees->transform_tree, property_trees->effect_tree, | |
| 1090 can_render_to_separate_surface); | |
| 1091 } | 1088 } |
| 1092 | 1089 |
| 1093 void UpdatePropertyTrees(PropertyTrees* property_trees, | 1090 void UpdatePropertyTrees(PropertyTrees* property_trees, |
| 1094 bool can_render_to_separate_surface) { | 1091 bool can_render_to_separate_surface) { |
| 1095 if (property_trees->non_root_surfaces_enabled != | 1092 if (property_trees->non_root_surfaces_enabled != |
| 1096 can_render_to_separate_surface) { | 1093 can_render_to_separate_surface) { |
| 1097 property_trees->non_root_surfaces_enabled = can_render_to_separate_surface; | 1094 property_trees->non_root_surfaces_enabled = can_render_to_separate_surface; |
| 1098 property_trees->transform_tree.set_needs_update(true); | 1095 property_trees->transform_tree.set_needs_update(true); |
| 1099 } | 1096 } |
| 1100 if (property_trees->transform_tree.needs_update()) { | 1097 if (property_trees->transform_tree.needs_update()) { |
| 1101 property_trees->clip_tree.set_needs_update(true); | 1098 property_trees->clip_tree.set_needs_update(true); |
| 1102 property_trees->effect_tree.set_needs_update(true); | 1099 property_trees->effect_tree.set_needs_update(true); |
| 1103 } | 1100 } |
| 1104 ComputeTransforms(&property_trees->transform_tree); | 1101 ComputeTransforms(&property_trees->transform_tree); |
| 1105 // Computation of clips uses surface contents scale which is updated while | 1102 // Computation of clips uses surface contents scale which is updated while |
| 1106 // computing effects. So, ComputeEffects should be before ComputeClips. | 1103 // computing effects. So, ComputeEffects should be before ComputeClips. |
| 1107 ComputeEffects(&property_trees->effect_tree); | 1104 ComputeEffects(&property_trees->effect_tree); |
| 1108 ComputeClips(&property_trees->clip_tree, property_trees->transform_tree, | 1105 ComputeClips(property_trees, can_render_to_separate_surface); |
| 1109 property_trees->effect_tree, can_render_to_separate_surface); | |
| 1110 } | 1106 } |
| 1111 | 1107 |
| 1112 void ComputeVisibleRectsForTesting(PropertyTrees* property_trees, | 1108 void ComputeVisibleRectsForTesting(PropertyTrees* property_trees, |
| 1113 bool can_render_to_separate_surface, | 1109 bool can_render_to_separate_surface, |
| 1114 LayerList* update_layer_list) { | 1110 LayerList* update_layer_list) { |
| 1115 CalculateVisibleRects<Layer>(*update_layer_list, property_trees->clip_tree, | 1111 CalculateVisibleRects<Layer>(*update_layer_list, property_trees, |
| 1116 property_trees->transform_tree, | |
| 1117 property_trees->effect_tree, | |
| 1118 can_render_to_separate_surface); | 1112 can_render_to_separate_surface); |
| 1119 } | 1113 } |
| 1120 | 1114 |
| 1121 void BuildPropertyTreesAndComputeVisibleRects( | 1115 void BuildPropertyTreesAndComputeVisibleRects( |
| 1122 LayerImpl* root_layer, | 1116 LayerImpl* root_layer, |
| 1123 const LayerImpl* page_scale_layer, | 1117 const LayerImpl* page_scale_layer, |
| 1124 const LayerImpl* inner_viewport_scroll_layer, | 1118 const LayerImpl* inner_viewport_scroll_layer, |
| 1125 const LayerImpl* outer_viewport_scroll_layer, | 1119 const LayerImpl* outer_viewport_scroll_layer, |
| 1126 const LayerImpl* overscroll_elasticity_layer, | 1120 const LayerImpl* overscroll_elasticity_layer, |
| 1127 const gfx::Vector2dF& elastic_overscroll, | 1121 const gfx::Vector2dF& elastic_overscroll, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1211 effect_node->surface_contents_scale.y()); | 1205 effect_node->surface_contents_scale.y()); |
| 1212 #if DCHECK_IS_ON() | 1206 #if DCHECK_IS_ON() |
| 1213 VerifySurfaceContentsScalesMatch(layer->effect_tree_index(), | 1207 VerifySurfaceContentsScalesMatch(layer->effect_tree_index(), |
| 1214 layer->transform_tree_index(), effect_tree, | 1208 layer->transform_tree_index(), effect_tree, |
| 1215 transform_tree); | 1209 transform_tree); |
| 1216 #endif | 1210 #endif |
| 1217 } | 1211 } |
| 1218 return xform; | 1212 return xform; |
| 1219 } | 1213 } |
| 1220 | 1214 |
| 1221 static void SetSurfaceDrawTransform(const TransformTree& transform_tree, | 1215 static void SetSurfaceDrawTransform(const PropertyTrees* property_trees, |
| 1222 const EffectTree& effect_tree, | |
| 1223 RenderSurfaceImpl* render_surface) { | 1216 RenderSurfaceImpl* render_surface) { |
| 1217 const TransformTree& transform_tree = property_trees->transform_tree; |
| 1218 const EffectTree& effect_tree = property_trees->effect_tree; |
| 1224 const TransformNode* transform_node = | 1219 const TransformNode* transform_node = |
| 1225 transform_tree.Node(render_surface->TransformTreeIndex()); | 1220 transform_tree.Node(render_surface->TransformTreeIndex()); |
| 1226 const EffectNode* effect_node = | 1221 const EffectNode* effect_node = |
| 1227 effect_tree.Node(render_surface->EffectTreeIndex()); | 1222 effect_tree.Node(render_surface->EffectTreeIndex()); |
| 1228 // The draw transform of root render surface is identity tranform. | 1223 // The draw transform of root render surface is identity tranform. |
| 1229 if (transform_node->id == 1) { | 1224 if (transform_node->id == 1) { |
| 1230 render_surface->SetDrawTransform(gfx::Transform()); | 1225 render_surface->SetDrawTransform(gfx::Transform()); |
| 1231 return; | 1226 return; |
| 1232 } | 1227 } |
| 1233 | 1228 |
| 1234 gfx::Transform render_surface_transform; | 1229 gfx::Transform render_surface_transform; |
| 1235 const TransformNode* target_transform_node = | 1230 const TransformNode* target_transform_node = |
| 1236 transform_tree.Node(transform_tree.TargetId(transform_node->id)); | 1231 transform_tree.Node(transform_tree.TargetId(transform_node->id)); |
| 1237 transform_tree.ComputeTransform(transform_node->id, target_transform_node->id, | 1232 const EffectNode* target_effect_node = |
| 1238 &render_surface_transform); | 1233 effect_tree.Node(effect_node->target_id); |
| 1234 property_trees->ComputeTransformToTarget( |
| 1235 transform_node->id, target_effect_node->id, &render_surface_transform); |
| 1239 // We don't have to apply surface contents scale when target is root. | 1236 // We don't have to apply surface contents scale when target is root. |
| 1240 if (target_transform_node->id != 0) { | 1237 if (target_transform_node->id != 0) { |
| 1241 const EffectNode* target_effect_node = | |
| 1242 effect_tree.Node(effect_node->target_id); | |
| 1243 PostConcatSurfaceContentsScale(target_effect_node, | 1238 PostConcatSurfaceContentsScale(target_effect_node, |
| 1244 &render_surface_transform); | 1239 &render_surface_transform); |
| 1245 #if DCHECK_IS_ON() | 1240 #if DCHECK_IS_ON() |
| 1246 VerifySurfaceContentsScalesMatch(effect_node->target_id, | 1241 VerifySurfaceContentsScalesMatch(effect_node->target_id, |
| 1247 target_transform_node->id, effect_tree, | 1242 target_transform_node->id, effect_tree, |
| 1248 transform_tree); | 1243 transform_tree); |
| 1249 #endif | 1244 #endif |
| 1250 } | 1245 } |
| 1251 | 1246 |
| 1252 ConcatInverseSurfaceContentsScale(effect_node, &render_surface_transform); | 1247 ConcatInverseSurfaceContentsScale(effect_node, &render_surface_transform); |
| 1253 #if DCHECK_IS_ON() | 1248 #if DCHECK_IS_ON() |
| 1254 VerifySurfaceContentsScalesMatch(effect_node->id, transform_node->id, | 1249 VerifySurfaceContentsScalesMatch(effect_node->id, transform_node->id, |
| 1255 effect_tree, transform_tree); | 1250 effect_tree, transform_tree); |
| 1256 #endif | 1251 #endif |
| 1257 render_surface->SetDrawTransform(render_surface_transform); | 1252 render_surface->SetDrawTransform(render_surface_transform); |
| 1258 } | 1253 } |
| 1259 | 1254 |
| 1260 static void SetSurfaceIsClipped(const ClipNode* clip_node, | 1255 static void SetSurfaceIsClipped(const ClipNode* clip_node, |
| 1261 RenderSurfaceImpl* render_surface) { | 1256 RenderSurfaceImpl* render_surface) { |
| 1262 DCHECK(render_surface->OwningLayerId() == clip_node->owner_id) | 1257 DCHECK(render_surface->OwningLayerId() == clip_node->owner_id) |
| 1263 << "we now create clip node for every render surface"; | 1258 << "we now create clip node for every render surface"; |
| 1264 | 1259 |
| 1265 render_surface->SetIsClipped(clip_node->target_is_clipped); | 1260 render_surface->SetIsClipped(clip_node->target_is_clipped); |
| 1266 } | 1261 } |
| 1267 | 1262 |
| 1268 static void SetSurfaceClipRect(const ClipNode* parent_clip_node, | 1263 static void SetSurfaceClipRect(const ClipNode* parent_clip_node, |
| 1269 const TransformTree& transform_tree, | 1264 const PropertyTrees* property_trees, |
| 1270 const EffectTree& effect_tree, | |
| 1271 RenderSurfaceImpl* render_surface) { | 1265 RenderSurfaceImpl* render_surface) { |
| 1272 if (!render_surface->is_clipped()) { | 1266 if (!render_surface->is_clipped()) { |
| 1273 render_surface->SetClipRect(gfx::Rect()); | 1267 render_surface->SetClipRect(gfx::Rect()); |
| 1274 return; | 1268 return; |
| 1275 } | 1269 } |
| 1276 | 1270 |
| 1271 const EffectTree& effect_tree = property_trees->effect_tree; |
| 1272 const TransformTree& transform_tree = property_trees->transform_tree; |
| 1277 const TransformNode* transform_node = | 1273 const TransformNode* transform_node = |
| 1278 transform_tree.Node(render_surface->TransformTreeIndex()); | 1274 transform_tree.Node(render_surface->TransformTreeIndex()); |
| 1279 if (transform_tree.TargetId(transform_node->id) == | 1275 if (transform_tree.TargetId(transform_node->id) == |
| 1280 parent_clip_node->target_transform_id) { | 1276 parent_clip_node->target_transform_id) { |
| 1281 render_surface->SetClipRect( | 1277 render_surface->SetClipRect( |
| 1282 gfx::ToEnclosingRect(parent_clip_node->clip_in_target_space)); | 1278 gfx::ToEnclosingRect(parent_clip_node->clip_in_target_space)); |
| 1283 return; | 1279 return; |
| 1284 } | 1280 } |
| 1285 | 1281 |
| 1286 // In this case, the clip child has reset the clip node for subtree and hence | 1282 // In this case, the clip child has reset the clip node for subtree and hence |
| 1287 // the parent clip node's clip rect is in clip parent's target space and not | 1283 // the parent clip node's clip rect is in clip parent's target space and not |
| 1288 // our target space. We need to transform it to our target space. | 1284 // our target space. We need to transform it to our target space. |
| 1289 gfx::Transform clip_parent_target_to_target; | 1285 gfx::Transform clip_parent_target_to_target; |
| 1290 const bool success = transform_tree.ComputeTransform( | 1286 const EffectNode* effect_node = |
| 1291 parent_clip_node->target_transform_id, | 1287 effect_tree.Node(render_surface->EffectTreeIndex()); |
| 1292 transform_tree.TargetId(transform_node->id), | 1288 int target_effect_id = effect_node->target_id; |
| 1289 const bool success = property_trees->ComputeTransformToTarget( |
| 1290 parent_clip_node->target_transform_id, target_effect_id, |
| 1293 &clip_parent_target_to_target); | 1291 &clip_parent_target_to_target); |
| 1294 | 1292 |
| 1295 if (!success) { | 1293 if (!success) { |
| 1296 render_surface->SetClipRect(gfx::Rect()); | 1294 render_surface->SetClipRect(gfx::Rect()); |
| 1297 return; | 1295 return; |
| 1298 } | 1296 } |
| 1299 | 1297 |
| 1300 // We don't have to apply surface contents scale when target is root. | 1298 // We don't have to apply surface contents scale when target is root. |
| 1301 if (transform_tree.TargetId(transform_node->id) != 0) { | 1299 if (transform_tree.TargetId(transform_node->id) != 0) { |
| 1302 const EffectNode* effect_node = | 1300 const EffectNode* effect_node = |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1374 const gfx::Rect& layer_bounds_in_target_space, | 1372 const gfx::Rect& layer_bounds_in_target_space, |
| 1375 const gfx::Rect& clip_rect) { | 1373 const gfx::Rect& clip_rect) { |
| 1376 if (layer->is_clipped()) | 1374 if (layer->is_clipped()) |
| 1377 return IntersectRects(layer_bounds_in_target_space, clip_rect); | 1375 return IntersectRects(layer_bounds_in_target_space, clip_rect); |
| 1378 | 1376 |
| 1379 return layer_bounds_in_target_space; | 1377 return layer_bounds_in_target_space; |
| 1380 } | 1378 } |
| 1381 | 1379 |
| 1382 static gfx::Transform ReplicaToSurfaceTransform( | 1380 static gfx::Transform ReplicaToSurfaceTransform( |
| 1383 const RenderSurfaceImpl* render_surface, | 1381 const RenderSurfaceImpl* render_surface, |
| 1384 const TransformTree& transform_tree, | 1382 const PropertyTrees* property_trees) { |
| 1385 const EffectTree& effect_tree) { | |
| 1386 gfx::Transform replica_to_surface; | 1383 gfx::Transform replica_to_surface; |
| 1387 if (!render_surface->HasReplica()) | 1384 if (!render_surface->HasReplica()) |
| 1388 return replica_to_surface; | 1385 return replica_to_surface; |
| 1389 const LayerImpl* replica_layer = render_surface->ReplicaLayer(); | 1386 const LayerImpl* replica_layer = render_surface->ReplicaLayer(); |
| 1387 const EffectTree& effect_tree = property_trees->effect_tree; |
| 1390 const EffectNode* surface_effect_node = | 1388 const EffectNode* surface_effect_node = |
| 1391 effect_tree.Node(render_surface->EffectTreeIndex()); | 1389 effect_tree.Node(render_surface->EffectTreeIndex()); |
| 1392 if (render_surface->TransformTreeIndex() != 0) { | 1390 if (render_surface->TransformTreeIndex() != 0) { |
| 1393 replica_to_surface.Scale(surface_effect_node->surface_contents_scale.x(), | 1391 replica_to_surface.Scale(surface_effect_node->surface_contents_scale.x(), |
| 1394 surface_effect_node->surface_contents_scale.y()); | 1392 surface_effect_node->surface_contents_scale.y()); |
| 1395 #if DCHECK_IS_ON() | 1393 #if DCHECK_IS_ON() |
| 1394 const TransformTree& transform_tree = property_trees->transform_tree; |
| 1396 VerifySurfaceContentsScalesMatch(render_surface->EffectTreeIndex(), | 1395 VerifySurfaceContentsScalesMatch(render_surface->EffectTreeIndex(), |
| 1397 render_surface->TransformTreeIndex(), | 1396 render_surface->TransformTreeIndex(), |
| 1398 effect_tree, transform_tree); | 1397 effect_tree, transform_tree); |
| 1399 #endif | 1398 #endif |
| 1400 } | 1399 } |
| 1401 replica_to_surface.Translate(replica_layer->offset_to_transform_parent().x(), | 1400 replica_to_surface.Translate(replica_layer->offset_to_transform_parent().x(), |
| 1402 replica_layer->offset_to_transform_parent().y()); | 1401 replica_layer->offset_to_transform_parent().y()); |
| 1403 gfx::Transform replica_transform_node_to_surface; | 1402 gfx::Transform replica_transform_node_to_surface; |
| 1404 transform_tree.ComputeTransform(replica_layer->transform_tree_index(), | 1403 property_trees->ComputeTransformToTarget( |
| 1405 render_surface->TransformTreeIndex(), | 1404 replica_layer->transform_tree_index(), render_surface->EffectTreeIndex(), |
| 1406 &replica_transform_node_to_surface); | 1405 &replica_transform_node_to_surface); |
| 1407 replica_to_surface.PreconcatTransform(replica_transform_node_to_surface); | 1406 replica_to_surface.PreconcatTransform(replica_transform_node_to_surface); |
| 1408 if (surface_effect_node->surface_contents_scale.x() != 0 && | 1407 if (surface_effect_node->surface_contents_scale.x() != 0 && |
| 1409 surface_effect_node->surface_contents_scale.y() != 0) { | 1408 surface_effect_node->surface_contents_scale.y() != 0) { |
| 1410 replica_to_surface.Scale( | 1409 replica_to_surface.Scale( |
| 1411 1.0 / surface_effect_node->surface_contents_scale.x(), | 1410 1.0 / surface_effect_node->surface_contents_scale.x(), |
| 1412 1.0 / surface_effect_node->surface_contents_scale.y()); | 1411 1.0 / surface_effect_node->surface_contents_scale.y()); |
| 1413 } | 1412 } |
| 1414 return replica_to_surface; | 1413 return replica_to_surface; |
| 1415 } | 1414 } |
| 1416 | 1415 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1460 gfx::Rect(mask_layer->bounds()); | 1459 gfx::Rect(mask_layer->bounds()); |
| 1461 } | 1460 } |
| 1462 | 1461 |
| 1463 void ComputeSurfaceDrawProperties(const PropertyTrees* property_trees, | 1462 void ComputeSurfaceDrawProperties(const PropertyTrees* property_trees, |
| 1464 RenderSurfaceImpl* render_surface) { | 1463 RenderSurfaceImpl* render_surface) { |
| 1465 const ClipNode* clip_node = | 1464 const ClipNode* clip_node = |
| 1466 property_trees->clip_tree.Node(render_surface->ClipTreeIndex()); | 1465 property_trees->clip_tree.Node(render_surface->ClipTreeIndex()); |
| 1467 | 1466 |
| 1468 SetSurfaceIsClipped(clip_node, render_surface); | 1467 SetSurfaceIsClipped(clip_node, render_surface); |
| 1469 SetSurfaceDrawOpacity(property_trees->effect_tree, render_surface); | 1468 SetSurfaceDrawOpacity(property_trees->effect_tree, render_surface); |
| 1470 SetSurfaceDrawTransform(property_trees->transform_tree, | 1469 SetSurfaceDrawTransform(property_trees, render_surface); |
| 1471 property_trees->effect_tree, render_surface); | |
| 1472 render_surface->SetScreenSpaceTransform( | 1470 render_surface->SetScreenSpaceTransform( |
| 1473 property_trees->ToScreenSpaceTransformWithoutSurfaceContentsScale( | 1471 property_trees->ToScreenSpaceTransformWithoutSurfaceContentsScale( |
| 1474 render_surface->TransformTreeIndex(), | 1472 render_surface->TransformTreeIndex(), |
| 1475 render_surface->EffectTreeIndex())); | 1473 render_surface->EffectTreeIndex())); |
| 1476 | 1474 |
| 1477 if (render_surface->HasReplica()) { | 1475 if (render_surface->HasReplica()) { |
| 1478 gfx::Transform replica_to_surface = ReplicaToSurfaceTransform( | 1476 gfx::Transform replica_to_surface = |
| 1479 render_surface, property_trees->transform_tree, | 1477 ReplicaToSurfaceTransform(render_surface, property_trees); |
| 1480 property_trees->effect_tree); | |
| 1481 render_surface->SetReplicaDrawTransform(render_surface->draw_transform() * | 1478 render_surface->SetReplicaDrawTransform(render_surface->draw_transform() * |
| 1482 replica_to_surface); | 1479 replica_to_surface); |
| 1483 render_surface->SetReplicaScreenSpaceTransform( | 1480 render_surface->SetReplicaScreenSpaceTransform( |
| 1484 render_surface->screen_space_transform() * replica_to_surface); | 1481 render_surface->screen_space_transform() * replica_to_surface); |
| 1485 } else { | 1482 } else { |
| 1486 render_surface->SetReplicaDrawTransform(gfx::Transform()); | 1483 render_surface->SetReplicaDrawTransform(gfx::Transform()); |
| 1487 render_surface->SetReplicaScreenSpaceTransform(gfx::Transform()); | 1484 render_surface->SetReplicaScreenSpaceTransform(gfx::Transform()); |
| 1488 } | 1485 } |
| 1489 | 1486 |
| 1490 SetSurfaceClipRect(property_trees->clip_tree.parent(clip_node), | 1487 SetSurfaceClipRect(property_trees->clip_tree.parent(clip_node), |
| 1491 property_trees->transform_tree, | 1488 property_trees, render_surface); |
| 1492 property_trees->effect_tree, render_surface); | |
| 1493 } | 1489 } |
| 1494 | 1490 |
| 1495 #if DCHECK_IS_ON() | 1491 #if DCHECK_IS_ON() |
| 1496 static void ValidatePageScaleLayer(const Layer* page_scale_layer) { | 1492 static void ValidatePageScaleLayer(const Layer* page_scale_layer) { |
| 1497 DCHECK_EQ(page_scale_layer->position().ToString(), gfx::PointF().ToString()); | 1493 DCHECK_EQ(page_scale_layer->position().ToString(), gfx::PointF().ToString()); |
| 1498 DCHECK_EQ(page_scale_layer->transform_origin().ToString(), | 1494 DCHECK_EQ(page_scale_layer->transform_origin().ToString(), |
| 1499 gfx::Point3F().ToString()); | 1495 gfx::Point3F().ToString()); |
| 1500 } | 1496 } |
| 1501 | 1497 |
| 1502 static void ValidatePageScaleLayer(const LayerImpl* page_scale_layer) {} | 1498 static void ValidatePageScaleLayer(const LayerImpl* page_scale_layer) {} |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1587 void UpdateElasticOverscroll(PropertyTrees* property_trees, | 1583 void UpdateElasticOverscroll(PropertyTrees* property_trees, |
| 1588 const Layer* overscroll_elasticity_layer, | 1584 const Layer* overscroll_elasticity_layer, |
| 1589 const gfx::Vector2dF& elastic_overscroll) { | 1585 const gfx::Vector2dF& elastic_overscroll) { |
| 1590 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, | 1586 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, |
| 1591 elastic_overscroll); | 1587 elastic_overscroll); |
| 1592 } | 1588 } |
| 1593 | 1589 |
| 1594 } // namespace draw_property_utils | 1590 } // namespace draw_property_utils |
| 1595 | 1591 |
| 1596 } // namespace cc | 1592 } // namespace cc |
| OLD | NEW |