| 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 |
| 11 #include "cc/base/math_util.h" | 11 #include "cc/base/math_util.h" |
| 12 #include "cc/layers/draw_properties.h" | 12 #include "cc/layers/draw_properties.h" |
| 13 #include "cc/layers/layer.h" | 13 #include "cc/layers/layer.h" |
| 14 #include "cc/layers/layer_impl.h" | 14 #include "cc/layers/layer_impl.h" |
| 15 #include "cc/trees/clip_node.h" |
| 16 #include "cc/trees/effect_node.h" |
| 15 #include "cc/trees/layer_tree_host.h" | 17 #include "cc/trees/layer_tree_host.h" |
| 16 #include "cc/trees/layer_tree_impl.h" | 18 #include "cc/trees/layer_tree_impl.h" |
| 17 #include "cc/trees/property_tree.h" | 19 #include "cc/trees/property_tree.h" |
| 18 #include "cc/trees/property_tree_builder.h" | 20 #include "cc/trees/property_tree_builder.h" |
| 21 #include "cc/trees/transform_node.h" |
| 19 #include "ui/gfx/geometry/rect_conversions.h" | 22 #include "ui/gfx/geometry/rect_conversions.h" |
| 20 | 23 |
| 21 namespace cc { | 24 namespace cc { |
| 22 | 25 |
| 23 namespace draw_property_utils { | 26 namespace draw_property_utils { |
| 24 | 27 |
| 25 namespace { | 28 namespace { |
| 26 | 29 |
| 27 static bool IsRootLayer(const Layer* layer) { | 30 static bool IsRootLayer(const Layer* layer) { |
| 28 return !layer->parent(); | 31 return !layer->parent(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 39 if (layer->has_render_surface()) | 42 if (layer->has_render_surface()) |
| 40 return; | 43 return; |
| 41 | 44 |
| 42 DCHECK(layer->filters().IsEmpty()) << "layer: " << layer->id(); | 45 DCHECK(layer->filters().IsEmpty()) << "layer: " << layer->id(); |
| 43 DCHECK(!IsRootLayer(layer)) << "layer: " << layer->id(); | 46 DCHECK(!IsRootLayer(layer)) << "layer: " << layer->id(); |
| 44 EffectNode* effect_node = | 47 EffectNode* effect_node = |
| 45 layer->layer_tree_impl()->property_trees()->effect_tree.Node( | 48 layer->layer_tree_impl()->property_trees()->effect_tree.Node( |
| 46 layer->effect_tree_index()); | 49 layer->effect_tree_index()); |
| 47 if (effect_node->owner_id != layer->id()) | 50 if (effect_node->owner_id != layer->id()) |
| 48 return; | 51 return; |
| 49 DCHECK_EQ(effect_node->data.mask_layer_id, -1) << "layer: " << layer->id(); | 52 DCHECK_EQ(effect_node->mask_layer_id, -1) << "layer: " << layer->id(); |
| 50 DCHECK_EQ(effect_node->data.replica_layer_id, -1) << "layer: " << layer->id(); | 53 DCHECK_EQ(effect_node->replica_layer_id, -1) << "layer: " << layer->id(); |
| 51 DCHECK(effect_node->data.background_filters.IsEmpty()); | 54 DCHECK(effect_node->background_filters.IsEmpty()); |
| 52 } | 55 } |
| 53 | 56 |
| 54 #endif | 57 #endif |
| 55 | 58 |
| 56 template <typename LayerType> | 59 template <typename LayerType> |
| 57 bool ComputeClipRectInTargetSpace(const LayerType* layer, | 60 bool ComputeClipRectInTargetSpace(const LayerType* layer, |
| 58 const ClipNode* clip_node, | 61 const ClipNode* clip_node, |
| 59 const TransformTree& transform_tree, | 62 const TransformTree& transform_tree, |
| 60 int target_node_id, | 63 int target_node_id, |
| 61 gfx::RectF* clip_rect_in_target_space) { | 64 gfx::RectF* clip_rect_in_target_space) { |
| 62 DCHECK(layer->clip_tree_index() == clip_node->id); | 65 DCHECK(layer->clip_tree_index() == clip_node->id); |
| 63 DCHECK(clip_node->data.target_id != target_node_id); | 66 DCHECK(clip_node->target_id != target_node_id); |
| 64 | 67 |
| 65 gfx::Transform clip_to_target; | 68 gfx::Transform clip_to_target; |
| 66 if (clip_node->data.target_id > target_node_id) { | 69 if (clip_node->target_id > target_node_id) { |
| 67 // In this case, layer has a scroll parent. We need to keep the scale | 70 // In this case, layer has a scroll parent. We need to keep the scale |
| 68 // at the layer's target but remove the scale at the scroll parent's | 71 // at the layer's target but remove the scale at the scroll parent's |
| 69 // target. | 72 // target. |
| 70 if (transform_tree.ComputeTransformWithDestinationSublayerScale( | 73 if (transform_tree.ComputeTransformWithDestinationSublayerScale( |
| 71 clip_node->data.target_id, target_node_id, &clip_to_target)) { | 74 clip_node->target_id, target_node_id, &clip_to_target)) { |
| 72 const TransformNode* source_node = | 75 const TransformNode* source_node = |
| 73 transform_tree.Node(clip_node->data.target_id); | 76 transform_tree.Node(clip_node->target_id); |
| 74 if (source_node->data.sublayer_scale.x() != 0.f && | 77 if (source_node->sublayer_scale.x() != 0.f && |
| 75 source_node->data.sublayer_scale.y() != 0.f) | 78 source_node->sublayer_scale.y() != 0.f) |
| 76 clip_to_target.Scale(1.0f / source_node->data.sublayer_scale.x(), | 79 clip_to_target.Scale(1.0f / source_node->sublayer_scale.x(), |
| 77 1.0f / source_node->data.sublayer_scale.y()); | 80 1.0f / source_node->sublayer_scale.y()); |
| 78 *clip_rect_in_target_space = MathUtil::MapClippedRect( | 81 *clip_rect_in_target_space = MathUtil::MapClippedRect( |
| 79 clip_to_target, clip_node->data.clip_in_target_space); | 82 clip_to_target, clip_node->clip_in_target_space); |
| 80 } else { | 83 } else { |
| 81 return false; | 84 return false; |
| 82 } | 85 } |
| 83 } else { | 86 } else { |
| 84 if (transform_tree.ComputeTransform(clip_node->data.target_id, | 87 if (transform_tree.ComputeTransform(clip_node->target_id, target_node_id, |
| 85 target_node_id, &clip_to_target)) { | 88 &clip_to_target)) { |
| 86 *clip_rect_in_target_space = MathUtil::ProjectClippedRect( | 89 *clip_rect_in_target_space = MathUtil::ProjectClippedRect( |
| 87 clip_to_target, clip_node->data.clip_in_target_space); | 90 clip_to_target, clip_node->clip_in_target_space); |
| 88 } else { | 91 } else { |
| 89 return false; | 92 return false; |
| 90 } | 93 } |
| 91 } | 94 } |
| 92 return true; | 95 return true; |
| 93 } | 96 } |
| 94 | 97 |
| 95 struct ConditionalClip { | 98 struct ConditionalClip { |
| 96 bool is_clipped; | 99 bool is_clipped; |
| 97 gfx::RectF clip_rect; | 100 gfx::RectF clip_rect; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 111 return ConditionalClip{true, // is_clipped. | 114 return ConditionalClip{true, // is_clipped. |
| 112 MathUtil::MapClippedRect(current_to_target, rect)}; | 115 MathUtil::MapClippedRect(current_to_target, rect)}; |
| 113 | 116 |
| 114 return ConditionalClip{true, // is_clipped. | 117 return ConditionalClip{true, // is_clipped. |
| 115 MathUtil::ProjectClippedRect(current_to_target, rect)}; | 118 MathUtil::ProjectClippedRect(current_to_target, rect)}; |
| 116 } | 119 } |
| 117 | 120 |
| 118 static ConditionalClip ComputeCurrentClip(const ClipNode* clip_node, | 121 static ConditionalClip ComputeCurrentClip(const ClipNode* clip_node, |
| 119 const TransformTree& transform_tree, | 122 const TransformTree& transform_tree, |
| 120 int target_transform_id) { | 123 int target_transform_id) { |
| 121 if (clip_node->data.transform_id != target_transform_id) | 124 if (clip_node->transform_id != target_transform_id) |
| 122 return ComputeRectInTargetSpace(clip_node->data.clip, transform_tree, | 125 return ComputeRectInTargetSpace(clip_node->clip, transform_tree, |
| 123 clip_node->data.transform_id, | 126 clip_node->transform_id, |
| 124 target_transform_id); | 127 target_transform_id); |
| 125 | 128 |
| 126 gfx::RectF current_clip = clip_node->data.clip; | 129 gfx::RectF current_clip = clip_node->clip; |
| 127 gfx::Vector2dF sublayer_scale = | 130 gfx::Vector2dF sublayer_scale = |
| 128 transform_tree.Node(target_transform_id)->data.sublayer_scale; | 131 transform_tree.Node(target_transform_id)->sublayer_scale; |
| 129 if (sublayer_scale.x() > 0 && sublayer_scale.y() > 0) | 132 if (sublayer_scale.x() > 0 && sublayer_scale.y() > 0) |
| 130 current_clip.Scale(sublayer_scale.x(), sublayer_scale.y()); | 133 current_clip.Scale(sublayer_scale.x(), sublayer_scale.y()); |
| 131 return ConditionalClip{true /* is_clipped */, current_clip}; | 134 return ConditionalClip{true /* is_clipped */, current_clip}; |
| 132 } | 135 } |
| 133 | 136 |
| 134 static ConditionalClip ComputeAccumulatedClip( | 137 static ConditionalClip ComputeAccumulatedClip( |
| 135 const ClipTree& clip_tree, | 138 const ClipTree& clip_tree, |
| 136 int local_clip_id, | 139 int local_clip_id, |
| 137 const EffectTree& effect_tree, | 140 const EffectTree& effect_tree, |
| 138 int target_id, | 141 int target_id, |
| 139 const TransformTree& transform_tree) { | 142 const TransformTree& transform_tree) { |
| 140 const ClipNode* clip_node = clip_tree.Node(local_clip_id); | 143 const ClipNode* clip_node = clip_tree.Node(local_clip_id); |
| 141 const EffectNode* target_node = effect_tree.Node(target_id); | 144 const EffectNode* target_node = effect_tree.Node(target_id); |
| 142 int target_transform_id = target_node->data.transform_id; | 145 int target_transform_id = target_node->transform_id; |
| 143 bool is_clipped = false; | 146 bool is_clipped = false; |
| 144 | 147 |
| 145 // Collect all the clips that need to be accumulated. | 148 // Collect all the clips that need to be accumulated. |
| 146 std::stack<const ClipNode*> parent_chain; | 149 std::stack<const ClipNode*> parent_chain; |
| 147 | 150 |
| 148 // If target is not direct ancestor of clip, this will find least common | 151 // If target is not direct ancestor of clip, this will find least common |
| 149 // ancestor between the target and the clip. | 152 // ancestor between the target and the clip. |
| 150 while (target_node->id >= 0 && clip_node->id >= 0) { | 153 while (target_node->id >= 0 && clip_node->id >= 0) { |
| 151 while (target_node->data.clip_id > clip_node->id || | 154 while (target_node->clip_id > clip_node->id || |
| 152 target_node->data.has_unclipped_descendants) { | 155 target_node->has_unclipped_descendants) { |
| 153 target_node = effect_tree.Node(target_node->data.target_id); | 156 target_node = effect_tree.Node(target_node->target_id); |
| 154 } | 157 } |
| 155 if (target_node->data.clip_id == clip_node->id) | 158 if (target_node->clip_id == clip_node->id) |
| 156 break; | 159 break; |
| 157 while (target_node->data.clip_id < clip_node->id) { | 160 while (target_node->clip_id < clip_node->id) { |
| 158 parent_chain.push(clip_node); | 161 parent_chain.push(clip_node); |
| 159 clip_node = clip_tree.parent(clip_node); | 162 clip_node = clip_tree.parent(clip_node); |
| 160 } | 163 } |
| 161 if (target_node->data.clip_id == clip_node->id) { | 164 if (target_node->clip_id == clip_node->id) { |
| 162 // Target is responsible for applying this clip_node (id equals to | 165 // Target is responsible for applying this clip_node (id equals to |
| 163 // target_node's clip id), no need to accumulate this as part of clip | 166 // target_node's clip id), no need to accumulate this as part of clip |
| 164 // rect. | 167 // rect. |
| 165 clip_node = parent_chain.top(); | 168 clip_node = parent_chain.top(); |
| 166 parent_chain.pop(); | 169 parent_chain.pop(); |
| 167 break; | 170 break; |
| 168 } | 171 } |
| 169 } | 172 } |
| 170 | 173 |
| 171 // TODO(weiliangc): If we don't create clip for render surface, we don't need | 174 // TODO(weiliangc): If we don't create clip for render surface, we don't need |
| 172 // to check applies_local_clip. | 175 // to check applies_local_clip. |
| 173 while (!clip_node->data.applies_local_clip && parent_chain.size() > 0) { | 176 while (!clip_node->applies_local_clip && parent_chain.size() > 0) { |
| 174 clip_node = parent_chain.top(); | 177 clip_node = parent_chain.top(); |
| 175 parent_chain.pop(); | 178 parent_chain.pop(); |
| 176 } | 179 } |
| 177 | 180 |
| 178 if (!clip_node->data.applies_local_clip) | 181 if (!clip_node->applies_local_clip) |
| 179 // No clip node applying clip in between. | 182 // No clip node applying clip in between. |
| 180 return ConditionalClip{false, gfx::RectF()}; | 183 return ConditionalClip{false, gfx::RectF()}; |
| 181 | 184 |
| 182 ConditionalClip current_clip = | 185 ConditionalClip current_clip = |
| 183 ComputeCurrentClip(clip_node, transform_tree, target_transform_id); | 186 ComputeCurrentClip(clip_node, transform_tree, target_transform_id); |
| 184 is_clipped = current_clip.is_clipped; | 187 is_clipped = current_clip.is_clipped; |
| 185 gfx::RectF accumulated_clip = current_clip.clip_rect; | 188 gfx::RectF accumulated_clip = current_clip.clip_rect; |
| 186 | 189 |
| 187 while (parent_chain.size() > 0) { | 190 while (parent_chain.size() > 0) { |
| 188 clip_node = parent_chain.top(); | 191 clip_node = parent_chain.top(); |
| 189 parent_chain.pop(); | 192 parent_chain.pop(); |
| 190 if (!clip_node->data.applies_local_clip) { | 193 if (!clip_node->applies_local_clip) { |
| 191 continue; | 194 continue; |
| 192 } | 195 } |
| 193 ConditionalClip current_clip = | 196 ConditionalClip current_clip = |
| 194 ComputeCurrentClip(clip_node, transform_tree, target_transform_id); | 197 ComputeCurrentClip(clip_node, transform_tree, target_transform_id); |
| 195 | 198 |
| 196 // If transform is not invertible, no clip will be applied. | 199 // If transform is not invertible, no clip will be applied. |
| 197 if (!current_clip.is_clipped) | 200 if (!current_clip.is_clipped) |
| 198 return ConditionalClip{false, gfx::RectF()}; | 201 return ConditionalClip{false, gfx::RectF()}; |
| 199 | 202 |
| 200 is_clipped = true; | 203 is_clipped = true; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 211 const typename LayerType::LayerListType& visible_layer_list, | 214 const typename LayerType::LayerListType& visible_layer_list, |
| 212 const ClipTree& clip_tree, | 215 const ClipTree& clip_tree, |
| 213 const TransformTree& transform_tree, | 216 const TransformTree& transform_tree, |
| 214 const EffectTree& effect_tree, | 217 const EffectTree& effect_tree, |
| 215 bool non_root_surfaces_enabled) { | 218 bool non_root_surfaces_enabled) { |
| 216 for (auto& layer : visible_layer_list) { | 219 for (auto& layer : visible_layer_list) { |
| 217 const ClipNode* clip_node = clip_tree.Node(layer->clip_tree_index()); | 220 const ClipNode* clip_node = clip_tree.Node(layer->clip_tree_index()); |
| 218 // The entire layer is visible if it has copy requests. | 221 // The entire layer is visible if it has copy requests. |
| 219 const EffectNode* effect_node = | 222 const EffectNode* effect_node = |
| 220 effect_tree.Node(layer->effect_tree_index()); | 223 effect_tree.Node(layer->effect_tree_index()); |
| 221 if (effect_node->data.has_copy_request && | 224 if (effect_node->has_copy_request && effect_node->owner_id == layer->id()) |
| 222 effect_node->owner_id == layer->id()) | |
| 223 continue; | 225 continue; |
| 224 | 226 |
| 225 if (!non_root_surfaces_enabled) { | 227 if (!non_root_surfaces_enabled) { |
| 226 layer->set_clip_rect( | 228 layer->set_clip_rect( |
| 227 gfx::ToEnclosingRect(clip_node->data.clip_in_target_space)); | 229 gfx::ToEnclosingRect(clip_node->clip_in_target_space)); |
| 228 continue; | 230 continue; |
| 229 } | 231 } |
| 230 | 232 |
| 231 // When both the layer and the target are unclipped, the entire layer | 233 // When both the layer and the target are unclipped, the entire layer |
| 232 // content rect is visible. | 234 // content rect is visible. |
| 233 const bool fully_visible = !clip_node->data.layers_are_clipped && | 235 const bool fully_visible = |
| 234 !clip_node->data.target_is_clipped; | 236 !clip_node->layers_are_clipped && !clip_node->target_is_clipped; |
| 235 | 237 |
| 236 if (!fully_visible) { | 238 if (!fully_visible) { |
| 237 const TransformNode* transform_node = | 239 const TransformNode* transform_node = |
| 238 transform_tree.Node(layer->transform_tree_index()); | 240 transform_tree.Node(layer->transform_tree_index()); |
| 239 int target_node_id = transform_tree.ContentTargetId(transform_node->id); | 241 int target_node_id = transform_tree.ContentTargetId(transform_node->id); |
| 240 | 242 |
| 241 // The clip node stores clip rect in its target space. | 243 // The clip node stores clip rect in its target space. |
| 242 gfx::RectF clip_rect_in_target_space = | 244 gfx::RectF clip_rect_in_target_space = clip_node->clip_in_target_space; |
| 243 clip_node->data.clip_in_target_space; | |
| 244 | 245 |
| 245 // If required, this clip rect should be mapped to the current layer's | 246 // If required, this clip rect should be mapped to the current layer's |
| 246 // target space. | 247 // target space. |
| 247 if (clip_node->data.target_id != target_node_id) { | 248 if (clip_node->target_id != target_node_id) { |
| 248 // In this case, layer has a clip parent or scroll parent (or shares the | 249 // In this case, layer has a clip parent or scroll parent (or shares the |
| 249 // target with an ancestor layer that has clip parent) and the clip | 250 // target with an ancestor layer that has clip parent) and the clip |
| 250 // parent's target is different from the layer's target. As the layer's | 251 // parent's target is different from the layer's target. As the layer's |
| 251 // target has unclippped descendants, it is unclippped. | 252 // target has unclippped descendants, it is unclippped. |
| 252 if (!clip_node->data.layers_are_clipped) | 253 if (!clip_node->layers_are_clipped) |
| 253 continue; | 254 continue; |
| 254 | 255 |
| 255 // Compute the clip rect in target space and store it. | 256 // Compute the clip rect in target space and store it. |
| 256 if (!ComputeClipRectInTargetSpace(layer, clip_node, transform_tree, | 257 if (!ComputeClipRectInTargetSpace(layer, clip_node, transform_tree, |
| 257 target_node_id, | 258 target_node_id, |
| 258 &clip_rect_in_target_space)) | 259 &clip_rect_in_target_space)) |
| 259 continue; | 260 continue; |
| 260 } | 261 } |
| 261 | 262 |
| 262 if (!clip_rect_in_target_space.IsEmpty()) { | 263 if (!clip_rect_in_target_space.IsEmpty()) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 278 clip_rect_in_target_space); | 279 clip_rect_in_target_space); |
| 279 } | 280 } |
| 280 | 281 |
| 281 bool GetLayerClipRect(const LayerImpl* layer, | 282 bool GetLayerClipRect(const LayerImpl* layer, |
| 282 const ClipNode* clip_node, | 283 const ClipNode* clip_node, |
| 283 const TransformTree& transform_tree, | 284 const TransformTree& transform_tree, |
| 284 int target_node_id, | 285 int target_node_id, |
| 285 gfx::RectF* clip_rect_in_target_space) { | 286 gfx::RectF* clip_rect_in_target_space) { |
| 286 // This is equivalent of calling ComputeClipRectInTargetSpace. | 287 // This is equivalent of calling ComputeClipRectInTargetSpace. |
| 287 *clip_rect_in_target_space = gfx::RectF(layer->clip_rect()); | 288 *clip_rect_in_target_space = gfx::RectF(layer->clip_rect()); |
| 288 return transform_tree.Node(target_node_id)->data.ancestors_are_invertible; | 289 return transform_tree.Node(target_node_id)->ancestors_are_invertible; |
| 289 } | 290 } |
| 290 | 291 |
| 291 template <typename LayerType> | 292 template <typename LayerType> |
| 292 void CalculateVisibleRects( | 293 void CalculateVisibleRects( |
| 293 const typename LayerType::LayerListType& visible_layer_list, | 294 const typename LayerType::LayerListType& visible_layer_list, |
| 294 const ClipTree& clip_tree, | 295 const ClipTree& clip_tree, |
| 295 const TransformTree& transform_tree, | 296 const TransformTree& transform_tree, |
| 296 const EffectTree& effect_tree, | 297 const EffectTree& effect_tree, |
| 297 bool non_root_surfaces_enabled) { | 298 bool non_root_surfaces_enabled) { |
| 298 for (auto& layer : visible_layer_list) { | 299 for (auto& layer : visible_layer_list) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 310 continue; | 311 continue; |
| 311 } | 312 } |
| 312 | 313 |
| 313 gfx::RectF accumulated_clip_in_copy_request_space = | 314 gfx::RectF accumulated_clip_in_copy_request_space = |
| 314 accumulated_clip_rect.clip_rect; | 315 accumulated_clip_rect.clip_rect; |
| 315 | 316 |
| 316 const EffectNode* copy_request_effect_node = | 317 const EffectNode* copy_request_effect_node = |
| 317 effect_tree.Node(effect_ancestor_with_copy_request); | 318 effect_tree.Node(effect_ancestor_with_copy_request); |
| 318 ConditionalClip clip_in_layer_space = ComputeRectInTargetSpace( | 319 ConditionalClip clip_in_layer_space = ComputeRectInTargetSpace( |
| 319 accumulated_clip_in_copy_request_space, transform_tree, | 320 accumulated_clip_in_copy_request_space, transform_tree, |
| 320 copy_request_effect_node->data.transform_id, | 321 copy_request_effect_node->transform_id, |
| 321 layer->transform_tree_index()); | 322 layer->transform_tree_index()); |
| 322 if (clip_in_layer_space.is_clipped) { | 323 if (clip_in_layer_space.is_clipped) { |
| 323 gfx::RectF clip_rect = clip_in_layer_space.clip_rect; | 324 gfx::RectF clip_rect = clip_in_layer_space.clip_rect; |
| 324 clip_rect.Offset(-layer->offset_to_transform_parent()); | 325 clip_rect.Offset(-layer->offset_to_transform_parent()); |
| 325 gfx::Rect visible_rect = gfx::ToEnclosingRect(clip_rect); | 326 gfx::Rect visible_rect = gfx::ToEnclosingRect(clip_rect); |
| 326 visible_rect.Intersect(gfx::Rect(layer_bounds)); | 327 visible_rect.Intersect(gfx::Rect(layer_bounds)); |
| 327 layer->set_visible_layer_rect(visible_rect); | 328 layer->set_visible_layer_rect(visible_rect); |
| 328 } else { | 329 } else { |
| 329 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); | 330 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); |
| 330 } | 331 } |
| 331 continue; | 332 continue; |
| 332 } | 333 } |
| 333 | 334 |
| 334 const ClipNode* clip_node = clip_tree.Node(layer->clip_tree_index()); | 335 const ClipNode* clip_node = clip_tree.Node(layer->clip_tree_index()); |
| 335 const TransformNode* transform_node = | 336 const TransformNode* transform_node = |
| 336 transform_tree.Node(layer->transform_tree_index()); | 337 transform_tree.Node(layer->transform_tree_index()); |
| 337 if (!non_root_surfaces_enabled) { | 338 if (!non_root_surfaces_enabled) { |
| 338 // When we only have a root surface, the clip node and the layer must | 339 // When we only have a root surface, the clip node and the layer must |
| 339 // necessarily have the same target (the root). | 340 // necessarily have the same target (the root). |
| 340 if (transform_node->data.ancestors_are_invertible) { | 341 if (transform_node->ancestors_are_invertible) { |
| 341 gfx::RectF combined_clip_rect_in_target_space = | 342 gfx::RectF combined_clip_rect_in_target_space = |
| 342 clip_node->data.combined_clip_in_target_space; | 343 clip_node->combined_clip_in_target_space; |
| 343 gfx::Transform target_to_content; | 344 gfx::Transform target_to_content; |
| 344 target_to_content.Translate(-layer->offset_to_transform_parent().x(), | 345 target_to_content.Translate(-layer->offset_to_transform_parent().x(), |
| 345 -layer->offset_to_transform_parent().y()); | 346 -layer->offset_to_transform_parent().y()); |
| 346 target_to_content.PreconcatTransform( | 347 target_to_content.PreconcatTransform( |
| 347 transform_tree.FromScreen(transform_node->id)); | 348 transform_tree.FromScreen(transform_node->id)); |
| 348 | 349 |
| 349 gfx::Rect visible_rect = | 350 gfx::Rect visible_rect = |
| 350 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( | 351 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( |
| 351 target_to_content, combined_clip_rect_in_target_space)); | 352 target_to_content, combined_clip_rect_in_target_space)); |
| 352 visible_rect.Intersect(gfx::Rect(layer_bounds)); | 353 visible_rect.Intersect(gfx::Rect(layer_bounds)); |
| 353 layer->set_visible_layer_rect(visible_rect); | 354 layer->set_visible_layer_rect(visible_rect); |
| 354 } else { | 355 } else { |
| 355 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); | 356 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); |
| 356 } | 357 } |
| 357 continue; | 358 continue; |
| 358 } | 359 } |
| 359 | 360 |
| 360 // When both the layer and the target are unclipped, the entire layer | 361 // When both the layer and the target are unclipped, the entire layer |
| 361 // content rect is visible. | 362 // content rect is visible. |
| 362 const bool fully_visible = !clip_node->data.layers_are_clipped && | 363 const bool fully_visible = |
| 363 !clip_node->data.target_is_clipped; | 364 !clip_node->layers_are_clipped && !clip_node->target_is_clipped; |
| 364 | 365 |
| 365 if (fully_visible) { | 366 if (fully_visible) { |
| 366 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); | 367 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); |
| 367 continue; | 368 continue; |
| 368 } | 369 } |
| 369 | 370 |
| 370 int target_node_id = transform_tree.ContentTargetId(transform_node->id); | 371 int target_node_id = transform_tree.ContentTargetId(transform_node->id); |
| 371 | 372 |
| 372 // The clip node stores clip rect in its target space. If required, | 373 // The clip node stores clip rect in its target space. If required, |
| 373 // this clip rect should be mapped to the current layer's target space. | 374 // this clip rect should be mapped to the current layer's target space. |
| 374 gfx::RectF combined_clip_rect_in_target_space; | 375 gfx::RectF combined_clip_rect_in_target_space; |
| 375 | 376 |
| 376 if (clip_node->data.target_id != target_node_id) { | 377 if (clip_node->target_id != target_node_id) { |
| 377 // In this case, layer has a clip parent or scroll parent (or shares the | 378 // In this case, layer has a clip parent or scroll parent (or shares the |
| 378 // target with an ancestor layer that has clip parent) and the clip | 379 // target with an ancestor layer that has clip parent) and the clip |
| 379 // parent's target is different from the layer's target. As the layer's | 380 // parent's target is different from the layer's target. As the layer's |
| 380 // target has unclippped descendants, it is unclippped. | 381 // target has unclippped descendants, it is unclippped. |
| 381 if (!clip_node->data.layers_are_clipped) { | 382 if (!clip_node->layers_are_clipped) { |
| 382 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); | 383 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); |
| 383 continue; | 384 continue; |
| 384 } | 385 } |
| 385 | 386 |
| 386 // We use the clip node's clip_in_target_space (and not | 387 // We use the clip node's clip_in_target_space (and not |
| 387 // combined_clip_in_target_space) here because we want to clip | 388 // combined_clip_in_target_space) here because we want to clip |
| 388 // with respect to clip parent's local clip and not its combined clip as | 389 // with respect to clip parent's local clip and not its combined clip as |
| 389 // the combined clip has even the clip parent's target's clip baked into | 390 // the combined clip has even the clip parent's target's clip baked into |
| 390 // it and as our target is different, we don't want to use it in our | 391 // it and as our target is different, we don't want to use it in our |
| 391 // visible rect computation. | 392 // visible rect computation. |
| 392 if (!GetLayerClipRect(layer, clip_node, transform_tree, target_node_id, | 393 if (!GetLayerClipRect(layer, clip_node, transform_tree, target_node_id, |
| 393 &combined_clip_rect_in_target_space)) { | 394 &combined_clip_rect_in_target_space)) { |
| 394 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); | 395 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); |
| 395 continue; | 396 continue; |
| 396 } | 397 } |
| 397 } else { | 398 } else { |
| 398 if (clip_node->data.target_is_clipped) { | 399 if (clip_node->target_is_clipped) { |
| 399 combined_clip_rect_in_target_space = | 400 combined_clip_rect_in_target_space = |
| 400 clip_node->data.combined_clip_in_target_space; | 401 clip_node->combined_clip_in_target_space; |
| 401 } else { | 402 } else { |
| 402 combined_clip_rect_in_target_space = | 403 combined_clip_rect_in_target_space = clip_node->clip_in_target_space; |
| 403 clip_node->data.clip_in_target_space; | |
| 404 } | 404 } |
| 405 } | 405 } |
| 406 | 406 |
| 407 // The clip rect should be intersected with layer rect in target space. | 407 // The clip rect should be intersected with layer rect in target space. |
| 408 gfx::Transform content_to_target = | 408 gfx::Transform content_to_target = |
| 409 transform_tree.ToTarget(transform_node->id); | 409 transform_tree.ToTarget(transform_node->id); |
| 410 content_to_target.Translate(layer->offset_to_transform_parent().x(), | 410 content_to_target.Translate(layer->offset_to_transform_parent().x(), |
| 411 layer->offset_to_transform_parent().y()); | 411 layer->offset_to_transform_parent().y()); |
| 412 gfx::Rect layer_content_rect = gfx::Rect(layer_bounds); | 412 gfx::Rect layer_content_rect = gfx::Rect(layer_bounds); |
| 413 gfx::RectF layer_content_bounds_in_target_space = MathUtil::MapClippedRect( | 413 gfx::RectF layer_content_bounds_in_target_space = MathUtil::MapClippedRect( |
| 414 content_to_target, gfx::RectF(layer_content_rect)); | 414 content_to_target, gfx::RectF(layer_content_rect)); |
| 415 // If the layer is fully contained within the clip, treat it as fully | 415 // If the layer is fully contained within the clip, treat it as fully |
| 416 // visible. | 416 // visible. |
| 417 if (!layer_content_bounds_in_target_space.IsEmpty() && | 417 if (!layer_content_bounds_in_target_space.IsEmpty() && |
| 418 combined_clip_rect_in_target_space.Contains( | 418 combined_clip_rect_in_target_space.Contains( |
| 419 layer_content_bounds_in_target_space)) { | 419 layer_content_bounds_in_target_space)) { |
| 420 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); | 420 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); |
| 421 continue; | 421 continue; |
| 422 } | 422 } |
| 423 | 423 |
| 424 combined_clip_rect_in_target_space.Intersect( | 424 combined_clip_rect_in_target_space.Intersect( |
| 425 layer_content_bounds_in_target_space); | 425 layer_content_bounds_in_target_space); |
| 426 if (combined_clip_rect_in_target_space.IsEmpty()) { | 426 if (combined_clip_rect_in_target_space.IsEmpty()) { |
| 427 layer->set_visible_layer_rect(gfx::Rect()); | 427 layer->set_visible_layer_rect(gfx::Rect()); |
| 428 continue; | 428 continue; |
| 429 } | 429 } |
| 430 | 430 |
| 431 gfx::Transform target_to_layer; | 431 gfx::Transform target_to_layer; |
| 432 if (transform_node->data.ancestors_are_invertible) { | 432 if (transform_node->ancestors_are_invertible) { |
| 433 target_to_layer = transform_tree.FromTarget(transform_node->id); | 433 target_to_layer = transform_tree.FromTarget(transform_node->id); |
| 434 } else { | 434 } else { |
| 435 if (!transform_tree.ComputeTransformWithSourceSublayerScale( | 435 if (!transform_tree.ComputeTransformWithSourceSublayerScale( |
| 436 target_node_id, transform_node->id, &target_to_layer)) { | 436 target_node_id, transform_node->id, &target_to_layer)) { |
| 437 // An animated singular transform may become non-singular during the | 437 // An animated singular transform may become non-singular during the |
| 438 // animation, so we still need to compute a visible rect. In this | 438 // animation, so we still need to compute a visible rect. In this |
| 439 // situation, we treat the entire layer as visible. | 439 // situation, we treat the entire layer as visible. |
| 440 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); | 440 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); |
| 441 continue; | 441 continue; |
| 442 } | 442 } |
| 443 } | 443 } |
| 444 | 444 |
| 445 gfx::Transform target_to_content; | 445 gfx::Transform target_to_content; |
| 446 target_to_content.Translate(-layer->offset_to_transform_parent().x(), | 446 target_to_content.Translate(-layer->offset_to_transform_parent().x(), |
| 447 -layer->offset_to_transform_parent().y()); | 447 -layer->offset_to_transform_parent().y()); |
| 448 target_to_content.PreconcatTransform(target_to_layer); | 448 target_to_content.PreconcatTransform(target_to_layer); |
| 449 | 449 |
| 450 gfx::Rect visible_rect = gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( | 450 gfx::Rect visible_rect = gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( |
| 451 target_to_content, combined_clip_rect_in_target_space)); | 451 target_to_content, combined_clip_rect_in_target_space)); |
| 452 visible_rect.Intersect(gfx::Rect(layer_bounds)); | 452 visible_rect.Intersect(gfx::Rect(layer_bounds)); |
| 453 layer->set_visible_layer_rect(visible_rect); | 453 layer->set_visible_layer_rect(visible_rect); |
| 454 } | 454 } |
| 455 } | 455 } |
| 456 | 456 |
| 457 static bool HasSingularTransform(int transform_tree_index, | 457 static bool HasSingularTransform(int transform_tree_index, |
| 458 const TransformTree& tree) { | 458 const TransformTree& tree) { |
| 459 const TransformNode* node = tree.Node(transform_tree_index); | 459 const TransformNode* node = tree.Node(transform_tree_index); |
| 460 return !node->data.is_invertible || !node->data.ancestors_are_invertible; | 460 return !node->is_invertible || !node->ancestors_are_invertible; |
| 461 } | 461 } |
| 462 | 462 |
| 463 template <typename LayerType> | 463 template <typename LayerType> |
| 464 static int TransformTreeIndexForBackfaceVisibility(LayerType* layer, | 464 static int TransformTreeIndexForBackfaceVisibility(LayerType* layer, |
| 465 const TransformTree& tree) { | 465 const TransformTree& tree) { |
| 466 if (!layer->use_parent_backface_visibility()) | 466 if (!layer->use_parent_backface_visibility()) |
| 467 return layer->transform_tree_index(); | 467 return layer->transform_tree_index(); |
| 468 const TransformNode* node = tree.Node(layer->transform_tree_index()); | 468 const TransformNode* node = tree.Node(layer->transform_tree_index()); |
| 469 return layer->id() == node->owner_id ? tree.parent(node)->id : node->id; | 469 return layer->id() == node->owner_id ? tree.parent(node)->id : node->id; |
| 470 } | 470 } |
| 471 | 471 |
| 472 template <typename LayerType> | 472 template <typename LayerType> |
| 473 static bool IsLayerBackFaceVisible(LayerType* layer, | 473 static bool IsLayerBackFaceVisible(LayerType* layer, |
| 474 int transform_tree_index, | 474 int transform_tree_index, |
| 475 const TransformTree& tree) { | 475 const TransformTree& tree) { |
| 476 const TransformNode* node = tree.Node(transform_tree_index); | 476 const TransformNode* node = tree.Node(transform_tree_index); |
| 477 return layer->use_local_transform_for_backface_visibility() | 477 return layer->use_local_transform_for_backface_visibility() |
| 478 ? node->data.local.IsBackFaceVisible() | 478 ? node->local.IsBackFaceVisible() |
| 479 : tree.ToTarget(transform_tree_index).IsBackFaceVisible(); | 479 : tree.ToTarget(transform_tree_index).IsBackFaceVisible(); |
| 480 } | 480 } |
| 481 | 481 |
| 482 static inline bool TransformToScreenIsKnown(Layer* layer, | 482 static inline bool TransformToScreenIsKnown(Layer* layer, |
| 483 int transform_tree_index, | 483 int transform_tree_index, |
| 484 const TransformTree& tree) { | 484 const TransformTree& tree) { |
| 485 const TransformNode* node = tree.Node(transform_tree_index); | 485 const TransformNode* node = tree.Node(transform_tree_index); |
| 486 return !node->data.to_screen_is_potentially_animated; | 486 return !node->to_screen_is_potentially_animated; |
| 487 } | 487 } |
| 488 | 488 |
| 489 static inline bool TransformToScreenIsKnown(LayerImpl* layer, | 489 static inline bool TransformToScreenIsKnown(LayerImpl* layer, |
| 490 int transform_tree_index, | 490 int transform_tree_index, |
| 491 const TransformTree& tree) { | 491 const TransformTree& tree) { |
| 492 return true; | 492 return true; |
| 493 } | 493 } |
| 494 | 494 |
| 495 template <typename LayerType> | 495 template <typename LayerType> |
| 496 static bool LayerNeedsUpdateInternal(LayerType* layer, | 496 static bool LayerNeedsUpdateInternal(LayerType* layer, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 | 533 |
| 534 return true; | 534 return true; |
| 535 } | 535 } |
| 536 | 536 |
| 537 void FindLayersThatNeedUpdates(LayerTreeImpl* layer_tree_impl, | 537 void FindLayersThatNeedUpdates(LayerTreeImpl* layer_tree_impl, |
| 538 const TransformTree& transform_tree, | 538 const TransformTree& transform_tree, |
| 539 const EffectTree& effect_tree, | 539 const EffectTree& effect_tree, |
| 540 std::vector<LayerImpl*>* visible_layer_list) { | 540 std::vector<LayerImpl*>* visible_layer_list) { |
| 541 for (auto* layer_impl : *layer_tree_impl) { | 541 for (auto* layer_impl : *layer_tree_impl) { |
| 542 bool layer_is_drawn = | 542 bool layer_is_drawn = |
| 543 effect_tree.Node(layer_impl->effect_tree_index())->data.is_drawn; | 543 effect_tree.Node(layer_impl->effect_tree_index())->is_drawn; |
| 544 | 544 |
| 545 if (!IsRootLayer(layer_impl) && | 545 if (!IsRootLayer(layer_impl) && |
| 546 LayerShouldBeSkipped(layer_impl, layer_is_drawn, transform_tree, | 546 LayerShouldBeSkipped(layer_impl, layer_is_drawn, transform_tree, |
| 547 effect_tree)) | 547 effect_tree)) |
| 548 continue; | 548 continue; |
| 549 | 549 |
| 550 if (LayerNeedsUpdate(layer_impl, layer_is_drawn, transform_tree)) | 550 if (LayerNeedsUpdate(layer_impl, layer_is_drawn, transform_tree)) |
| 551 visible_layer_list->push_back(layer_impl); | 551 visible_layer_list->push_back(layer_impl); |
| 552 } | 552 } |
| 553 } | 553 } |
| 554 | 554 |
| 555 void UpdateRenderSurfaceForLayer(EffectTree* effect_tree, | 555 void UpdateRenderSurfaceForLayer(EffectTree* effect_tree, |
| 556 bool non_root_surfaces_enabled, | 556 bool non_root_surfaces_enabled, |
| 557 LayerImpl* layer) { | 557 LayerImpl* layer) { |
| 558 if (!non_root_surfaces_enabled) { | 558 if (!non_root_surfaces_enabled) { |
| 559 layer->SetHasRenderSurface(IsRootLayer(layer)); | 559 layer->SetHasRenderSurface(IsRootLayer(layer)); |
| 560 return; | 560 return; |
| 561 } | 561 } |
| 562 | 562 |
| 563 EffectNode* node = effect_tree->Node(layer->effect_tree_index()); | 563 EffectNode* node = effect_tree->Node(layer->effect_tree_index()); |
| 564 | 564 |
| 565 if (node->owner_id == layer->id() && node->data.has_render_surface) | 565 if (node->owner_id == layer->id() && node->has_render_surface) |
| 566 layer->SetHasRenderSurface(true); | 566 layer->SetHasRenderSurface(true); |
| 567 else | 567 else |
| 568 layer->SetHasRenderSurface(false); | 568 layer->SetHasRenderSurface(false); |
| 569 } | 569 } |
| 570 } // namespace | 570 } // namespace |
| 571 | 571 |
| 572 template <typename LayerType> | 572 template <typename LayerType> |
| 573 static inline bool LayerShouldBeSkippedInternal( | 573 static inline bool LayerShouldBeSkippedInternal( |
| 574 LayerType* layer, | 574 LayerType* layer, |
| 575 bool layer_is_drawn, | 575 bool layer_is_drawn, |
| 576 const TransformTree& transform_tree, | 576 const TransformTree& transform_tree, |
| 577 const EffectTree& effect_tree) { | 577 const EffectTree& effect_tree) { |
| 578 const TransformNode* transform_node = | 578 const TransformNode* transform_node = |
| 579 transform_tree.Node(layer->transform_tree_index()); | 579 transform_tree.Node(layer->transform_tree_index()); |
| 580 const EffectNode* effect_node = effect_tree.Node(layer->effect_tree_index()); | 580 const EffectNode* effect_node = effect_tree.Node(layer->effect_tree_index()); |
| 581 | 581 |
| 582 if (effect_node->data.has_render_surface && | 582 if (effect_node->has_render_surface && |
| 583 effect_node->data.num_copy_requests_in_subtree > 0) | 583 effect_node->num_copy_requests_in_subtree > 0) |
| 584 return false; | 584 return false; |
| 585 // If the layer transform is not invertible, it should be skipped. | 585 // If the layer transform is not invertible, it should be skipped. |
| 586 // TODO(ajuma): Correctly process subtrees with singular transform for the | 586 // TODO(ajuma): Correctly process subtrees with singular transform for the |
| 587 // case where we may animate to a non-singular transform and wish to | 587 // case where we may animate to a non-singular transform and wish to |
| 588 // pre-raster. | 588 // pre-raster. |
| 589 return !transform_node->data.node_and_ancestors_are_animated_or_invertible || | 589 return !transform_node->node_and_ancestors_are_animated_or_invertible || |
| 590 effect_node->data.hidden_by_backface_visibility || | 590 effect_node->hidden_by_backface_visibility || !effect_node->is_drawn; |
| 591 !effect_node->data.is_drawn; | |
| 592 } | 591 } |
| 593 | 592 |
| 594 bool LayerShouldBeSkipped(LayerImpl* layer, | 593 bool LayerShouldBeSkipped(LayerImpl* layer, |
| 595 bool layer_is_drawn, | 594 bool layer_is_drawn, |
| 596 const TransformTree& transform_tree, | 595 const TransformTree& transform_tree, |
| 597 const EffectTree& effect_tree) { | 596 const EffectTree& effect_tree) { |
| 598 return LayerShouldBeSkippedInternal(layer, layer_is_drawn, transform_tree, | 597 return LayerShouldBeSkippedInternal(layer, layer_is_drawn, transform_tree, |
| 599 effect_tree); | 598 effect_tree); |
| 600 } | 599 } |
| 601 | 600 |
| 602 bool LayerShouldBeSkipped(Layer* layer, | 601 bool LayerShouldBeSkipped(Layer* layer, |
| 603 bool layer_is_drawn, | 602 bool layer_is_drawn, |
| 604 const TransformTree& transform_tree, | 603 const TransformTree& transform_tree, |
| 605 const EffectTree& effect_tree) { | 604 const EffectTree& effect_tree) { |
| 606 return LayerShouldBeSkippedInternal(layer, layer_is_drawn, transform_tree, | 605 return LayerShouldBeSkippedInternal(layer, layer_is_drawn, transform_tree, |
| 607 effect_tree); | 606 effect_tree); |
| 608 } | 607 } |
| 609 | 608 |
| 610 void FindLayersThatNeedUpdates(LayerTreeHost* layer_tree_host, | 609 void FindLayersThatNeedUpdates(LayerTreeHost* layer_tree_host, |
| 611 const TransformTree& transform_tree, | 610 const TransformTree& transform_tree, |
| 612 const EffectTree& effect_tree, | 611 const EffectTree& effect_tree, |
| 613 LayerList* update_layer_list) { | 612 LayerList* update_layer_list) { |
| 614 for (auto* layer : *layer_tree_host) { | 613 for (auto* layer : *layer_tree_host) { |
| 615 bool layer_is_drawn = | 614 bool layer_is_drawn = |
| 616 effect_tree.Node(layer->effect_tree_index())->data.is_drawn; | 615 effect_tree.Node(layer->effect_tree_index())->is_drawn; |
| 617 | 616 |
| 618 if (!IsRootLayer(layer) && | 617 if (!IsRootLayer(layer) && |
| 619 LayerShouldBeSkipped(layer, layer_is_drawn, transform_tree, | 618 LayerShouldBeSkipped(layer, layer_is_drawn, transform_tree, |
| 620 effect_tree)) | 619 effect_tree)) |
| 621 continue; | 620 continue; |
| 622 | 621 |
| 623 if (LayerNeedsUpdate(layer, layer_is_drawn, transform_tree)) { | 622 if (LayerNeedsUpdate(layer, layer_is_drawn, transform_tree)) { |
| 624 update_layer_list->push_back(layer); | 623 update_layer_list->push_back(layer); |
| 625 } | 624 } |
| 626 | 625 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 644 | 643 |
| 645 void ComputeClips(ClipTree* clip_tree, | 644 void ComputeClips(ClipTree* clip_tree, |
| 646 const TransformTree& transform_tree, | 645 const TransformTree& transform_tree, |
| 647 bool non_root_surfaces_enabled) { | 646 bool non_root_surfaces_enabled) { |
| 648 if (!clip_tree->needs_update()) | 647 if (!clip_tree->needs_update()) |
| 649 return; | 648 return; |
| 650 for (int i = 1; i < static_cast<int>(clip_tree->size()); ++i) { | 649 for (int i = 1; i < static_cast<int>(clip_tree->size()); ++i) { |
| 651 ClipNode* clip_node = clip_tree->Node(i); | 650 ClipNode* clip_node = clip_tree->Node(i); |
| 652 | 651 |
| 653 if (clip_node->id == 1) { | 652 if (clip_node->id == 1) { |
| 654 ResetIfHasNanCoordinate(&clip_node->data.clip); | 653 ResetIfHasNanCoordinate(&clip_node->clip); |
| 655 clip_node->data.clip_in_target_space = clip_node->data.clip; | 654 clip_node->clip_in_target_space = clip_node->clip; |
| 656 clip_node->data.combined_clip_in_target_space = clip_node->data.clip; | 655 clip_node->combined_clip_in_target_space = clip_node->clip; |
| 657 continue; | 656 continue; |
| 658 } | 657 } |
| 659 const TransformNode* transform_node = | 658 const TransformNode* transform_node = |
| 660 transform_tree.Node(clip_node->data.transform_id); | 659 transform_tree.Node(clip_node->transform_id); |
| 661 ClipNode* parent_clip_node = clip_tree->parent(clip_node); | 660 ClipNode* parent_clip_node = clip_tree->parent(clip_node); |
| 662 | 661 |
| 663 gfx::Transform parent_to_current; | 662 gfx::Transform parent_to_current; |
| 664 const TransformNode* parent_target_transform_node = | 663 const TransformNode* parent_target_transform_node = |
| 665 transform_tree.Node(parent_clip_node->data.target_id); | 664 transform_tree.Node(parent_clip_node->target_id); |
| 666 bool success = true; | 665 bool success = true; |
| 667 | 666 |
| 668 // Clips must be combined in target space. We cannot, for example, combine | 667 // Clips must be combined in target space. We cannot, for example, combine |
| 669 // clips in the space of the child clip. The reason is non-affine | 668 // clips in the space of the child clip. The reason is non-affine |
| 670 // transforms. Say we have the following tree T->A->B->C, and B clips C, but | 669 // transforms. Say we have the following tree T->A->B->C, and B clips C, but |
| 671 // draw into target T. It may be the case that A applies a perspective | 670 // draw into target T. It may be the case that A applies a perspective |
| 672 // transform, and B and C are at different z positions. When projected into | 671 // transform, and B and C are at different z positions. When projected into |
| 673 // target space, the relative sizes and positions of B and C can shift. | 672 // target space, the relative sizes and positions of B and C can shift. |
| 674 // Since it's the relationship in target space that matters, that's where we | 673 // Since it's the relationship in target space that matters, that's where we |
| 675 // must combine clips. For each clip node, we save the clip rects in its | 674 // must combine clips. For each clip node, we save the clip rects in its |
| 676 // target space. So, we need to get the ancestor clip rect in the current | 675 // target space. So, we need to get the ancestor clip rect in the current |
| 677 // clip node's target space. | 676 // clip node's target space. |
| 678 gfx::RectF parent_combined_clip_in_target_space = | 677 gfx::RectF parent_combined_clip_in_target_space = |
| 679 parent_clip_node->data.combined_clip_in_target_space; | 678 parent_clip_node->combined_clip_in_target_space; |
| 680 gfx::RectF parent_clip_in_target_space = | 679 gfx::RectF parent_clip_in_target_space = |
| 681 parent_clip_node->data.clip_in_target_space; | 680 parent_clip_node->clip_in_target_space; |
| 682 if (parent_target_transform_node && | 681 if (parent_target_transform_node && |
| 683 parent_target_transform_node->id != clip_node->data.target_id && | 682 parent_target_transform_node->id != clip_node->target_id && |
| 684 non_root_surfaces_enabled) { | 683 non_root_surfaces_enabled) { |
| 685 success &= transform_tree.ComputeTransformWithDestinationSublayerScale( | 684 success &= transform_tree.ComputeTransformWithDestinationSublayerScale( |
| 686 parent_target_transform_node->id, clip_node->data.target_id, | 685 parent_target_transform_node->id, clip_node->target_id, |
| 687 &parent_to_current); | 686 &parent_to_current); |
| 688 if (parent_target_transform_node->data.sublayer_scale.x() > 0 && | 687 if (parent_target_transform_node->sublayer_scale.x() > 0 && |
| 689 parent_target_transform_node->data.sublayer_scale.y() > 0) | 688 parent_target_transform_node->sublayer_scale.y() > 0) |
| 690 parent_to_current.Scale( | 689 parent_to_current.Scale( |
| 691 1.f / parent_target_transform_node->data.sublayer_scale.x(), | 690 1.f / parent_target_transform_node->sublayer_scale.x(), |
| 692 1.f / parent_target_transform_node->data.sublayer_scale.y()); | 691 1.f / parent_target_transform_node->sublayer_scale.y()); |
| 693 // If we can't compute a transform, it's because we had to use the inverse | 692 // If we can't compute a transform, it's because we had to use the inverse |
| 694 // of a singular transform. We won't draw in this case, so there's no need | 693 // of a singular transform. We won't draw in this case, so there's no need |
| 695 // to compute clips. | 694 // to compute clips. |
| 696 if (!success) | 695 if (!success) |
| 697 continue; | 696 continue; |
| 698 parent_combined_clip_in_target_space = MathUtil::ProjectClippedRect( | 697 parent_combined_clip_in_target_space = MathUtil::ProjectClippedRect( |
| 699 parent_to_current, | 698 parent_to_current, parent_clip_node->combined_clip_in_target_space); |
| 700 parent_clip_node->data.combined_clip_in_target_space); | |
| 701 parent_clip_in_target_space = MathUtil::ProjectClippedRect( | 699 parent_clip_in_target_space = MathUtil::ProjectClippedRect( |
| 702 parent_to_current, parent_clip_node->data.clip_in_target_space); | 700 parent_to_current, parent_clip_node->clip_in_target_space); |
| 703 } | 701 } |
| 704 // Only nodes affected by ancestor clips will have their clip adjusted due | 702 // Only nodes affected by ancestor clips will have their clip adjusted due |
| 705 // to intersecting with an ancestor clip. But, we still need to propagate | 703 // to intersecting with an ancestor clip. But, we still need to propagate |
| 706 // the combined clip to our children because if they are clipped, they may | 704 // the combined clip to our children because if they are clipped, they may |
| 707 // need to clip using our parent clip and if we don't propagate it here, | 705 // need to clip using our parent clip and if we don't propagate it here, |
| 708 // it will be lost. | 706 // it will be lost. |
| 709 if (clip_node->data.resets_clip && non_root_surfaces_enabled) { | 707 if (clip_node->resets_clip && non_root_surfaces_enabled) { |
| 710 if (clip_node->data.applies_local_clip) { | 708 if (clip_node->applies_local_clip) { |
| 711 clip_node->data.clip_in_target_space = MathUtil::MapClippedRect( | 709 clip_node->clip_in_target_space = MathUtil::MapClippedRect( |
| 712 transform_tree.ToTarget(clip_node->data.transform_id), | 710 transform_tree.ToTarget(clip_node->transform_id), clip_node->clip); |
| 713 clip_node->data.clip); | 711 ResetIfHasNanCoordinate(&clip_node->clip_in_target_space); |
| 714 ResetIfHasNanCoordinate(&clip_node->data.clip_in_target_space); | 712 clip_node->combined_clip_in_target_space = |
| 715 clip_node->data.combined_clip_in_target_space = | 713 gfx::IntersectRects(clip_node->clip_in_target_space, |
| 716 gfx::IntersectRects(clip_node->data.clip_in_target_space, | |
| 717 parent_combined_clip_in_target_space); | 714 parent_combined_clip_in_target_space); |
| 718 } else { | 715 } else { |
| 719 DCHECK(!clip_node->data.target_is_clipped); | 716 DCHECK(!clip_node->target_is_clipped); |
| 720 DCHECK(!clip_node->data.layers_are_clipped); | 717 DCHECK(!clip_node->layers_are_clipped); |
| 721 clip_node->data.combined_clip_in_target_space = | 718 clip_node->combined_clip_in_target_space = |
| 722 parent_combined_clip_in_target_space; | 719 parent_combined_clip_in_target_space; |
| 723 } | 720 } |
| 724 ResetIfHasNanCoordinate(&clip_node->data.combined_clip_in_target_space); | 721 ResetIfHasNanCoordinate(&clip_node->combined_clip_in_target_space); |
| 725 continue; | 722 continue; |
| 726 } | 723 } |
| 727 bool use_only_parent_clip = !clip_node->data.applies_local_clip; | 724 bool use_only_parent_clip = !clip_node->applies_local_clip; |
| 728 if (use_only_parent_clip) { | 725 if (use_only_parent_clip) { |
| 729 clip_node->data.combined_clip_in_target_space = | 726 clip_node->combined_clip_in_target_space = |
| 730 parent_combined_clip_in_target_space; | 727 parent_combined_clip_in_target_space; |
| 731 if (!non_root_surfaces_enabled) { | 728 if (!non_root_surfaces_enabled) { |
| 732 clip_node->data.clip_in_target_space = | 729 clip_node->clip_in_target_space = |
| 733 parent_clip_node->data.clip_in_target_space; | 730 parent_clip_node->clip_in_target_space; |
| 734 } else if (!clip_node->data.target_is_clipped) { | 731 } else if (!clip_node->target_is_clipped) { |
| 735 clip_node->data.clip_in_target_space = parent_clip_in_target_space; | 732 clip_node->clip_in_target_space = parent_clip_in_target_space; |
| 736 } else { | 733 } else { |
| 737 // Render Surface applies clip and the owning layer itself applies | 734 // Render Surface applies clip and the owning layer itself applies |
| 738 // no clip. So, clip_in_target_space is not used and hence we can set | 735 // no clip. So, clip_in_target_space is not used and hence we can set |
| 739 // it to an empty rect. | 736 // it to an empty rect. |
| 740 clip_node->data.clip_in_target_space = gfx::RectF(); | 737 clip_node->clip_in_target_space = gfx::RectF(); |
| 741 } | 738 } |
| 742 } else { | 739 } else { |
| 743 gfx::Transform source_to_target; | 740 gfx::Transform source_to_target; |
| 744 | 741 |
| 745 if (!non_root_surfaces_enabled) { | 742 if (!non_root_surfaces_enabled) { |
| 746 source_to_target = | 743 source_to_target = transform_tree.ToScreen(clip_node->transform_id); |
| 747 transform_tree.ToScreen(clip_node->data.transform_id); | |
| 748 } else if (transform_tree.ContentTargetId(transform_node->id) == | 744 } else if (transform_tree.ContentTargetId(transform_node->id) == |
| 749 clip_node->data.target_id) { | 745 clip_node->target_id) { |
| 750 source_to_target = | 746 source_to_target = transform_tree.ToTarget(clip_node->transform_id); |
| 751 transform_tree.ToTarget(clip_node->data.transform_id); | |
| 752 } else { | 747 } else { |
| 753 success = transform_tree.ComputeTransformWithDestinationSublayerScale( | 748 success = transform_tree.ComputeTransformWithDestinationSublayerScale( |
| 754 transform_node->id, clip_node->data.target_id, &source_to_target); | 749 transform_node->id, clip_node->target_id, &source_to_target); |
| 755 // source_to_target computation should be successful as target is an | 750 // source_to_target computation should be successful as target is an |
| 756 // ancestor of the transform node. | 751 // ancestor of the transform node. |
| 757 DCHECK(success); | 752 DCHECK(success); |
| 758 } | 753 } |
| 759 | 754 |
| 760 gfx::RectF source_clip_in_target_space = | 755 gfx::RectF source_clip_in_target_space = |
| 761 MathUtil::MapClippedRect(source_to_target, clip_node->data.clip); | 756 MathUtil::MapClippedRect(source_to_target, clip_node->clip); |
| 762 | 757 |
| 763 // With surfaces disabled, the only case where we use only the local clip | 758 // With surfaces disabled, the only case where we use only the local clip |
| 764 // for layer clipping is the case where no non-viewport ancestor node | 759 // for layer clipping is the case where no non-viewport ancestor node |
| 765 // applies a local clip. | 760 // applies a local clip. |
| 766 bool layer_clipping_uses_only_local_clip = | 761 bool layer_clipping_uses_only_local_clip = |
| 767 non_root_surfaces_enabled | 762 non_root_surfaces_enabled |
| 768 ? clip_node->data.layer_clipping_uses_only_local_clip | 763 ? clip_node->layer_clipping_uses_only_local_clip |
| 769 : !parent_clip_node->data | 764 : !parent_clip_node->layers_are_clipped_when_surfaces_disabled; |
| 770 .layers_are_clipped_when_surfaces_disabled; | |
| 771 if (!layer_clipping_uses_only_local_clip) { | 765 if (!layer_clipping_uses_only_local_clip) { |
| 772 clip_node->data.clip_in_target_space = gfx::IntersectRects( | 766 clip_node->clip_in_target_space = gfx::IntersectRects( |
| 773 parent_clip_in_target_space, source_clip_in_target_space); | 767 parent_clip_in_target_space, source_clip_in_target_space); |
| 774 } else { | 768 } else { |
| 775 clip_node->data.clip_in_target_space = source_clip_in_target_space; | 769 clip_node->clip_in_target_space = source_clip_in_target_space; |
| 776 } | 770 } |
| 777 | 771 |
| 778 clip_node->data.combined_clip_in_target_space = gfx::IntersectRects( | 772 clip_node->combined_clip_in_target_space = gfx::IntersectRects( |
| 779 parent_combined_clip_in_target_space, source_clip_in_target_space); | 773 parent_combined_clip_in_target_space, source_clip_in_target_space); |
| 780 } | 774 } |
| 781 ResetIfHasNanCoordinate(&clip_node->data.clip_in_target_space); | 775 ResetIfHasNanCoordinate(&clip_node->clip_in_target_space); |
| 782 ResetIfHasNanCoordinate(&clip_node->data.combined_clip_in_target_space); | 776 ResetIfHasNanCoordinate(&clip_node->combined_clip_in_target_space); |
| 783 } | 777 } |
| 784 clip_tree->set_needs_update(false); | 778 clip_tree->set_needs_update(false); |
| 785 } | 779 } |
| 786 | 780 |
| 787 void ComputeTransforms(TransformTree* transform_tree) { | 781 void ComputeTransforms(TransformTree* transform_tree) { |
| 788 if (!transform_tree->needs_update()) | 782 if (!transform_tree->needs_update()) |
| 789 return; | 783 return; |
| 790 for (int i = 1; i < static_cast<int>(transform_tree->size()); ++i) | 784 for (int i = 1; i < static_cast<int>(transform_tree->size()); ++i) |
| 791 transform_tree->UpdateTransforms(i); | 785 transform_tree->UpdateTransforms(i); |
| 792 transform_tree->set_needs_update(false); | 786 transform_tree->set_needs_update(false); |
| 793 } | 787 } |
| 794 | 788 |
| 795 void UpdateRenderTarget(EffectTree* effect_tree, | 789 void UpdateRenderTarget(EffectTree* effect_tree, |
| 796 bool can_render_to_separate_surface) { | 790 bool can_render_to_separate_surface) { |
| 797 for (int i = 1; i < static_cast<int>(effect_tree->size()); ++i) { | 791 for (int i = 1; i < static_cast<int>(effect_tree->size()); ++i) { |
| 798 EffectNode* node = effect_tree->Node(i); | 792 EffectNode* node = effect_tree->Node(i); |
| 799 if (i == 1) { | 793 if (i == 1) { |
| 800 // Render target on the first effect node is root. | 794 // Render target on the first effect node is root. |
| 801 node->data.target_id = 0; | 795 node->target_id = 0; |
| 802 } else if (!can_render_to_separate_surface) { | 796 } else if (!can_render_to_separate_surface) { |
| 803 node->data.target_id = 1; | 797 node->target_id = 1; |
| 804 } else if (effect_tree->parent(node)->data.has_render_surface) { | 798 } else if (effect_tree->parent(node)->has_render_surface) { |
| 805 node->data.target_id = node->parent_id; | 799 node->target_id = node->parent_id; |
| 806 } else { | 800 } else { |
| 807 node->data.target_id = effect_tree->parent(node)->data.target_id; | 801 node->target_id = effect_tree->parent(node)->target_id; |
| 808 } | 802 } |
| 809 } | 803 } |
| 810 } | 804 } |
| 811 | 805 |
| 812 void ComputeEffects(EffectTree* effect_tree) { | 806 void ComputeEffects(EffectTree* effect_tree) { |
| 813 if (!effect_tree->needs_update()) | 807 if (!effect_tree->needs_update()) |
| 814 return; | 808 return; |
| 815 for (int i = 1; i < static_cast<int>(effect_tree->size()); ++i) | 809 for (int i = 1; i < static_cast<int>(effect_tree->size()); ++i) |
| 816 effect_tree->UpdateEffects(i); | 810 effect_tree->UpdateEffects(i); |
| 817 effect_tree->set_needs_update(false); | 811 effect_tree->set_needs_update(false); |
| 818 } | 812 } |
| 819 | 813 |
| 820 static void ComputeClipsWithEffectTree(PropertyTrees* property_trees) { | 814 static void ComputeClipsWithEffectTree(PropertyTrees* property_trees) { |
| 821 EffectTree* effect_tree = &property_trees->effect_tree; | 815 EffectTree* effect_tree = &property_trees->effect_tree; |
| 822 const ClipTree* clip_tree = &property_trees->clip_tree; | 816 const ClipTree* clip_tree = &property_trees->clip_tree; |
| 823 const TransformTree* transform_tree = &property_trees->transform_tree; | 817 const TransformTree* transform_tree = &property_trees->transform_tree; |
| 824 EffectNode* root_effect_node = effect_tree->Node(1); | 818 EffectNode* root_effect_node = effect_tree->Node(1); |
| 825 const RenderSurfaceImpl* root_render_surface = | 819 const RenderSurfaceImpl* root_render_surface = |
| 826 root_effect_node->data.render_surface; | 820 root_effect_node->render_surface; |
| 827 gfx::Rect root_clip = gfx::ToEnclosingRect( | 821 gfx::Rect root_clip = |
| 828 clip_tree->Node(root_effect_node->data.clip_id)->data.clip); | 822 gfx::ToEnclosingRect(clip_tree->Node(root_effect_node->clip_id)->clip); |
| 829 if (root_render_surface->is_clipped()) | 823 if (root_render_surface->is_clipped()) |
| 830 DCHECK(root_clip == root_render_surface->clip_rect()) | 824 DCHECK(root_clip == root_render_surface->clip_rect()) |
| 831 << "clip on root render surface: " | 825 << "clip on root render surface: " |
| 832 << root_render_surface->clip_rect().ToString() | 826 << root_render_surface->clip_rect().ToString() |
| 833 << " v.s. root effect node's clip: " << root_clip.ToString(); | 827 << " v.s. root effect node's clip: " << root_clip.ToString(); |
| 834 for (int i = 2; i < static_cast<int>(effect_tree->size()); ++i) { | 828 for (int i = 2; i < static_cast<int>(effect_tree->size()); ++i) { |
| 835 EffectNode* effect_node = effect_tree->Node(i); | 829 EffectNode* effect_node = effect_tree->Node(i); |
| 836 const EffectNode* target_node = | 830 const EffectNode* target_node = effect_tree->Node(effect_node->target_id); |
| 837 effect_tree->Node(effect_node->data.target_id); | |
| 838 ConditionalClip accumulated_clip_rect = | 831 ConditionalClip accumulated_clip_rect = |
| 839 ComputeAccumulatedClip(*clip_tree, effect_node->data.clip_id, | 832 ComputeAccumulatedClip(*clip_tree, effect_node->clip_id, *effect_tree, |
| 840 *effect_tree, target_node->id, *transform_tree); | 833 target_node->id, *transform_tree); |
| 841 gfx::RectF accumulated_clip = accumulated_clip_rect.clip_rect; | 834 gfx::RectF accumulated_clip = accumulated_clip_rect.clip_rect; |
| 842 const RenderSurfaceImpl* render_surface = effect_node->data.render_surface; | 835 const RenderSurfaceImpl* render_surface = effect_node->render_surface; |
| 843 if (render_surface && render_surface->is_clipped()) { | 836 if (render_surface && render_surface->is_clipped()) { |
| 844 DCHECK(gfx::ToEnclosingRect(accumulated_clip) == | 837 DCHECK(gfx::ToEnclosingRect(accumulated_clip) == |
| 845 render_surface->clip_rect()) | 838 render_surface->clip_rect()) |
| 846 << " render surface's clip rect: " | 839 << " render surface's clip rect: " |
| 847 << render_surface->clip_rect().ToString() | 840 << render_surface->clip_rect().ToString() |
| 848 << " v.s. accumulated clip: " | 841 << " v.s. accumulated clip: " |
| 849 << gfx::ToEnclosingRect(accumulated_clip).ToString(); | 842 << gfx::ToEnclosingRect(accumulated_clip).ToString(); |
| 850 } | 843 } |
| 851 } | 844 } |
| 852 } | 845 } |
| 853 | 846 |
| 854 static void ComputeLayerClipRect(const PropertyTrees* property_trees, | 847 static void ComputeLayerClipRect(const PropertyTrees* property_trees, |
| 855 const LayerImpl* layer) { | 848 const LayerImpl* layer) { |
| 856 const EffectTree* effect_tree = &property_trees->effect_tree; | 849 const EffectTree* effect_tree = &property_trees->effect_tree; |
| 857 const ClipTree* clip_tree = &property_trees->clip_tree; | 850 const ClipTree* clip_tree = &property_trees->clip_tree; |
| 858 const TransformTree* transform_tree = &property_trees->transform_tree; | 851 const TransformTree* transform_tree = &property_trees->transform_tree; |
| 859 const EffectNode* effect_node = effect_tree->Node(layer->effect_tree_index()); | 852 const EffectNode* effect_node = effect_tree->Node(layer->effect_tree_index()); |
| 860 const EffectNode* target_node = | 853 const EffectNode* target_node = |
| 861 effect_node->data.has_render_surface | 854 effect_node->has_render_surface |
| 862 ? effect_node | 855 ? effect_node |
| 863 : effect_tree->Node(effect_node->data.target_id); | 856 : effect_tree->Node(effect_node->target_id); |
| 864 // TODO(weiliangc): When effect node has up to date render surface info on | 857 // TODO(weiliangc): When effect node has up to date render surface info on |
| 865 // compositor thread, no need to check for resourceless draw mode | 858 // compositor thread, no need to check for resourceless draw mode |
| 866 if (!property_trees->non_root_surfaces_enabled) { | 859 if (!property_trees->non_root_surfaces_enabled) { |
| 867 target_node = effect_tree->Node(1); | 860 target_node = effect_tree->Node(1); |
| 868 } | 861 } |
| 869 | 862 |
| 870 ConditionalClip accumulated_clip_rect = | 863 ConditionalClip accumulated_clip_rect = |
| 871 ComputeAccumulatedClip(*clip_tree, layer->clip_tree_index(), *effect_tree, | 864 ComputeAccumulatedClip(*clip_tree, layer->clip_tree_index(), *effect_tree, |
| 872 target_node->id, *transform_tree); | 865 target_node->id, *transform_tree); |
| 873 | 866 |
| 874 gfx::RectF accumulated_clip = accumulated_clip_rect.clip_rect; | 867 gfx::RectF accumulated_clip = accumulated_clip_rect.clip_rect; |
| 875 | 868 |
| 876 if ((!property_trees->non_root_surfaces_enabled && | 869 if ((!property_trees->non_root_surfaces_enabled && |
| 877 clip_tree->Node(layer->clip_tree_index()) | 870 clip_tree->Node(layer->clip_tree_index()) |
| 878 ->data.layers_are_clipped_when_surfaces_disabled) || | 871 ->layers_are_clipped_when_surfaces_disabled) || |
| 879 clip_tree->Node(layer->clip_tree_index())->data.layers_are_clipped) { | 872 clip_tree->Node(layer->clip_tree_index())->layers_are_clipped) { |
| 880 DCHECK(layer->clip_rect() == gfx::ToEnclosingRect(accumulated_clip)) | 873 DCHECK(layer->clip_rect() == gfx::ToEnclosingRect(accumulated_clip)) |
| 881 << " layer: " << layer->id() << " clip id: " << layer->clip_tree_index() | 874 << " layer: " << layer->id() << " clip id: " << layer->clip_tree_index() |
| 882 << " layer clip: " << layer->clip_rect().ToString() << " v.s. " | 875 << " layer clip: " << layer->clip_rect().ToString() << " v.s. " |
| 883 << gfx::ToEnclosingRect(accumulated_clip).ToString() | 876 << gfx::ToEnclosingRect(accumulated_clip).ToString() |
| 884 << " and clip node clip: " | 877 << " and clip node clip: " |
| 885 << gfx::ToEnclosingRect(clip_tree->Node(layer->clip_tree_index()) | 878 << gfx::ToEnclosingRect( |
| 886 ->data.clip_in_target_space) | 879 clip_tree->Node(layer->clip_tree_index())->clip_in_target_space) |
| 887 .ToString(); | 880 .ToString(); |
| 888 } | 881 } |
| 889 } | 882 } |
| 890 | 883 |
| 891 static int FindTargetTransformTreeIndexFromEffectTree( | 884 static int FindTargetTransformTreeIndexFromEffectTree( |
| 892 const EffectTree& effect_tree, | 885 const EffectTree& effect_tree, |
| 893 const int effect_tree_index) { | 886 const int effect_tree_index) { |
| 894 const EffectNode* node = effect_tree.Node(effect_tree_index); | 887 const EffectNode* node = effect_tree.Node(effect_tree_index); |
| 895 if (node->data.has_render_surface) | 888 if (node->has_render_surface) |
| 896 return node->data.transform_id; | 889 return node->transform_id; |
| 897 node = effect_tree.Node(node->data.target_id); | 890 node = effect_tree.Node(node->target_id); |
| 898 return node->data.transform_id; | 891 return node->transform_id; |
| 899 } | 892 } |
| 900 | 893 |
| 901 static void VerifyDrawTransformsMatch(LayerImpl* layer, | 894 static void VerifyDrawTransformsMatch(LayerImpl* layer, |
| 902 PropertyTrees* property_trees) { | 895 PropertyTrees* property_trees) { |
| 903 const int source_id = layer->transform_tree_index(); | 896 const int source_id = layer->transform_tree_index(); |
| 904 int destination_id = FindTargetTransformTreeIndexFromEffectTree( | 897 int destination_id = FindTargetTransformTreeIndexFromEffectTree( |
| 905 property_trees->effect_tree, layer->effect_tree_index()); | 898 property_trees->effect_tree, layer->effect_tree_index()); |
| 906 // TODO(jaydasika) : Remove this after sorting out how sublayer scale works | 899 // TODO(jaydasika) : Remove this after sorting out how sublayer scale works |
| 907 // for these ids. | 900 // for these ids. |
| 908 if (destination_id == 0 || destination_id == 1) | 901 if (destination_id == 0 || destination_id == 1) |
| 909 return; | 902 return; |
| 910 gfx::Transform draw_transform; | 903 gfx::Transform draw_transform; |
| 911 property_trees->transform_tree.ComputeTransform(source_id, destination_id, | 904 property_trees->transform_tree.ComputeTransform(source_id, destination_id, |
| 912 &draw_transform); | 905 &draw_transform); |
| 913 TransformNode* target_node = | 906 TransformNode* target_node = |
| 914 property_trees->transform_tree.Node(destination_id); | 907 property_trees->transform_tree.Node(destination_id); |
| 915 draw_transform.matrix().postScale(target_node->data.sublayer_scale.x(), | 908 draw_transform.matrix().postScale(target_node->sublayer_scale.x(), |
| 916 target_node->data.sublayer_scale.y(), 1.f); | 909 target_node->sublayer_scale.y(), 1.f); |
| 917 if (layer->should_flatten_transform_from_property_tree()) | 910 if (layer->should_flatten_transform_from_property_tree()) |
| 918 draw_transform.FlattenTo2d(); | 911 draw_transform.FlattenTo2d(); |
| 919 draw_transform.Translate(layer->offset_to_transform_parent().x(), | 912 draw_transform.Translate(layer->offset_to_transform_parent().x(), |
| 920 layer->offset_to_transform_parent().y()); | 913 layer->offset_to_transform_parent().y()); |
| 921 DCHECK(draw_transform.ApproximatelyEqual( | 914 DCHECK(draw_transform.ApproximatelyEqual( |
| 922 DrawTransform(layer, property_trees->transform_tree))) | 915 DrawTransform(layer, property_trees->transform_tree))) |
| 923 << " layer: " << layer->id() << " source transform id: " << source_id | 916 << " layer: " << layer->id() << " source transform id: " << source_id |
| 924 << " destination transform id: " << destination_id | 917 << " destination transform id: " << destination_id |
| 925 << " draw transform from transform tree: " | 918 << " draw transform from transform tree: " |
| 926 << DrawTransform(layer, property_trees->transform_tree).ToString() | 919 << DrawTransform(layer, property_trees->transform_tree).ToString() |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1028 void ComputeVisibleRects(LayerImpl* root_layer, | 1021 void ComputeVisibleRects(LayerImpl* root_layer, |
| 1029 PropertyTrees* property_trees, | 1022 PropertyTrees* property_trees, |
| 1030 bool can_render_to_separate_surface, | 1023 bool can_render_to_separate_surface, |
| 1031 LayerImplList* visible_layer_list) { | 1024 LayerImplList* visible_layer_list) { |
| 1032 for (auto* layer : *root_layer->layer_tree_impl()) { | 1025 for (auto* layer : *root_layer->layer_tree_impl()) { |
| 1033 UpdateRenderSurfaceForLayer(&property_trees->effect_tree, | 1026 UpdateRenderSurfaceForLayer(&property_trees->effect_tree, |
| 1034 can_render_to_separate_surface, layer); | 1027 can_render_to_separate_surface, layer); |
| 1035 EffectNode* node = | 1028 EffectNode* node = |
| 1036 property_trees->effect_tree.Node(layer->effect_tree_index()); | 1029 property_trees->effect_tree.Node(layer->effect_tree_index()); |
| 1037 if (node->owner_id == layer->id()) | 1030 if (node->owner_id == layer->id()) |
| 1038 node->data.render_surface = layer->render_surface(); | 1031 node->render_surface = layer->render_surface(); |
| 1039 #if DCHECK_IS_ON() | 1032 #if DCHECK_IS_ON() |
| 1040 if (can_render_to_separate_surface) | 1033 if (can_render_to_separate_surface) |
| 1041 ValidateRenderSurfaceForLayer(layer); | 1034 ValidateRenderSurfaceForLayer(layer); |
| 1042 #endif | 1035 #endif |
| 1043 } | 1036 } |
| 1044 ComputeVisibleRectsInternal(root_layer, property_trees, | 1037 ComputeVisibleRectsInternal(root_layer, property_trees, |
| 1045 can_render_to_separate_surface, | 1038 can_render_to_separate_surface, |
| 1046 visible_layer_list); | 1039 visible_layer_list); |
| 1047 } | 1040 } |
| 1048 | 1041 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1067 if (!owns_non_root_surface) { | 1060 if (!owns_non_root_surface) { |
| 1068 // If you're not the root, or you don't own a surface, you need to apply | 1061 // If you're not the root, or you don't own a surface, you need to apply |
| 1069 // your local offset. | 1062 // your local offset. |
| 1070 xform = tree.ToTarget(layer->transform_tree_index()); | 1063 xform = tree.ToTarget(layer->transform_tree_index()); |
| 1071 if (layer->should_flatten_transform_from_property_tree()) | 1064 if (layer->should_flatten_transform_from_property_tree()) |
| 1072 xform.FlattenTo2d(); | 1065 xform.FlattenTo2d(); |
| 1073 xform.Translate(layer->offset_to_transform_parent().x(), | 1066 xform.Translate(layer->offset_to_transform_parent().x(), |
| 1074 layer->offset_to_transform_parent().y()); | 1067 layer->offset_to_transform_parent().y()); |
| 1075 } else { | 1068 } else { |
| 1076 // Surfaces need to apply their sublayer scale. | 1069 // Surfaces need to apply their sublayer scale. |
| 1077 xform.Scale(node->data.sublayer_scale.x(), node->data.sublayer_scale.y()); | 1070 xform.Scale(node->sublayer_scale.x(), node->sublayer_scale.y()); |
| 1078 } | 1071 } |
| 1079 return xform; | 1072 return xform; |
| 1080 } | 1073 } |
| 1081 | 1074 |
| 1082 static void SetSurfaceDrawTransform(const TransformTree& tree, | 1075 static void SetSurfaceDrawTransform(const TransformTree& tree, |
| 1083 RenderSurfaceImpl* render_surface) { | 1076 RenderSurfaceImpl* render_surface) { |
| 1084 const TransformNode* node = tree.Node(render_surface->TransformTreeIndex()); | 1077 const TransformNode* node = tree.Node(render_surface->TransformTreeIndex()); |
| 1085 // The draw transform of root render surface is identity tranform. | 1078 // The draw transform of root render surface is identity tranform. |
| 1086 if (node->id == 1) { | 1079 if (node->id == 1) { |
| 1087 render_surface->SetDrawTransform(gfx::Transform()); | 1080 render_surface->SetDrawTransform(gfx::Transform()); |
| 1088 return; | 1081 return; |
| 1089 } | 1082 } |
| 1090 | 1083 |
| 1091 gfx::Transform render_surface_transform; | 1084 gfx::Transform render_surface_transform; |
| 1092 const TransformNode* target_node = tree.Node(tree.TargetId(node->id)); | 1085 const TransformNode* target_node = tree.Node(tree.TargetId(node->id)); |
| 1093 tree.ComputeTransformWithDestinationSublayerScale(node->id, target_node->id, | 1086 tree.ComputeTransformWithDestinationSublayerScale(node->id, target_node->id, |
| 1094 &render_surface_transform); | 1087 &render_surface_transform); |
| 1095 if (node->data.sublayer_scale.x() != 0.0 && | 1088 if (node->sublayer_scale.x() != 0.0 && node->sublayer_scale.y() != 0.0) |
| 1096 node->data.sublayer_scale.y() != 0.0) | 1089 render_surface_transform.Scale(1.0 / node->sublayer_scale.x(), |
| 1097 render_surface_transform.Scale(1.0 / node->data.sublayer_scale.x(), | 1090 1.0 / node->sublayer_scale.y()); |
| 1098 1.0 / node->data.sublayer_scale.y()); | |
| 1099 render_surface->SetDrawTransform(render_surface_transform); | 1091 render_surface->SetDrawTransform(render_surface_transform); |
| 1100 } | 1092 } |
| 1101 | 1093 |
| 1102 static void SetSurfaceIsClipped(const ClipNode* clip_node, | 1094 static void SetSurfaceIsClipped(const ClipNode* clip_node, |
| 1103 RenderSurfaceImpl* render_surface) { | 1095 RenderSurfaceImpl* render_surface) { |
| 1104 DCHECK(render_surface->OwningLayerId() == clip_node->owner_id) | 1096 DCHECK(render_surface->OwningLayerId() == clip_node->owner_id) |
| 1105 << "we now create clip node for every render surface"; | 1097 << "we now create clip node for every render surface"; |
| 1106 | 1098 |
| 1107 render_surface->SetIsClipped(clip_node->data.target_is_clipped); | 1099 render_surface->SetIsClipped(clip_node->target_is_clipped); |
| 1108 } | 1100 } |
| 1109 | 1101 |
| 1110 static void SetSurfaceClipRect(const ClipNode* parent_clip_node, | 1102 static void SetSurfaceClipRect(const ClipNode* parent_clip_node, |
| 1111 const TransformTree& transform_tree, | 1103 const TransformTree& transform_tree, |
| 1112 RenderSurfaceImpl* render_surface) { | 1104 RenderSurfaceImpl* render_surface) { |
| 1113 if (!render_surface->is_clipped()) { | 1105 if (!render_surface->is_clipped()) { |
| 1114 render_surface->SetClipRect(gfx::Rect()); | 1106 render_surface->SetClipRect(gfx::Rect()); |
| 1115 return; | 1107 return; |
| 1116 } | 1108 } |
| 1117 | 1109 |
| 1118 const TransformNode* transform_node = | 1110 const TransformNode* transform_node = |
| 1119 transform_tree.Node(render_surface->TransformTreeIndex()); | 1111 transform_tree.Node(render_surface->TransformTreeIndex()); |
| 1120 if (transform_tree.TargetId(transform_node->id) == | 1112 if (transform_tree.TargetId(transform_node->id) == |
| 1121 parent_clip_node->data.target_id) { | 1113 parent_clip_node->target_id) { |
| 1122 render_surface->SetClipRect( | 1114 render_surface->SetClipRect( |
| 1123 gfx::ToEnclosingRect(parent_clip_node->data.clip_in_target_space)); | 1115 gfx::ToEnclosingRect(parent_clip_node->clip_in_target_space)); |
| 1124 return; | 1116 return; |
| 1125 } | 1117 } |
| 1126 | 1118 |
| 1127 // In this case, the clip child has reset the clip node for subtree and hence | 1119 // In this case, the clip child has reset the clip node for subtree and hence |
| 1128 // the parent clip node's clip rect is in clip parent's target space and not | 1120 // the parent clip node's clip rect is in clip parent's target space and not |
| 1129 // our target space. We need to transform it to our target space. | 1121 // our target space. We need to transform it to our target space. |
| 1130 gfx::Transform clip_parent_target_to_target; | 1122 gfx::Transform clip_parent_target_to_target; |
| 1131 const bool success = | 1123 const bool success = |
| 1132 transform_tree.ComputeTransformWithDestinationSublayerScale( | 1124 transform_tree.ComputeTransformWithDestinationSublayerScale( |
| 1133 parent_clip_node->data.target_id, | 1125 parent_clip_node->target_id, |
| 1134 transform_tree.TargetId(transform_node->id), | 1126 transform_tree.TargetId(transform_node->id), |
| 1135 &clip_parent_target_to_target); | 1127 &clip_parent_target_to_target); |
| 1136 | 1128 |
| 1137 if (!success) { | 1129 if (!success) { |
| 1138 render_surface->SetClipRect(gfx::Rect()); | 1130 render_surface->SetClipRect(gfx::Rect()); |
| 1139 return; | 1131 return; |
| 1140 } | 1132 } |
| 1141 | 1133 |
| 1142 DCHECK_LT(parent_clip_node->data.target_id, | 1134 DCHECK_LT(parent_clip_node->target_id, |
| 1143 transform_tree.TargetId(transform_node->id)); | 1135 transform_tree.TargetId(transform_node->id)); |
| 1144 render_surface->SetClipRect(gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( | 1136 render_surface->SetClipRect(gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( |
| 1145 clip_parent_target_to_target, | 1137 clip_parent_target_to_target, parent_clip_node->clip_in_target_space))); |
| 1146 parent_clip_node->data.clip_in_target_space))); | |
| 1147 } | 1138 } |
| 1148 | 1139 |
| 1149 template <typename LayerType> | 1140 template <typename LayerType> |
| 1150 static gfx::Transform ScreenSpaceTransformInternal(LayerType* layer, | 1141 static gfx::Transform ScreenSpaceTransformInternal(LayerType* layer, |
| 1151 const TransformTree& tree) { | 1142 const TransformTree& tree) { |
| 1152 gfx::Transform xform(1, 0, 0, 1, layer->offset_to_transform_parent().x(), | 1143 gfx::Transform xform(1, 0, 0, 1, layer->offset_to_transform_parent().x(), |
| 1153 layer->offset_to_transform_parent().y()); | 1144 layer->offset_to_transform_parent().y()); |
| 1154 gfx::Transform ssxform = tree.ToScreen(layer->transform_tree_index()); | 1145 gfx::Transform ssxform = tree.ToScreen(layer->transform_tree_index()); |
| 1155 xform.ConcatTransform(ssxform); | 1146 xform.ConcatTransform(ssxform); |
| 1156 if (layer->should_flatten_transform_from_property_tree()) | 1147 if (layer->should_flatten_transform_from_property_tree()) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1185 } | 1176 } |
| 1186 return draw_opacity; | 1177 return draw_opacity; |
| 1187 } | 1178 } |
| 1188 | 1179 |
| 1189 static void SetSurfaceDrawOpacity(const EffectTree& tree, | 1180 static void SetSurfaceDrawOpacity(const EffectTree& tree, |
| 1190 RenderSurfaceImpl* render_surface) { | 1181 RenderSurfaceImpl* render_surface) { |
| 1191 // Draw opacity of a surface is the product of opacities between the surface | 1182 // Draw opacity of a surface is the product of opacities between the surface |
| 1192 // (included) and its target surface (excluded). | 1183 // (included) and its target surface (excluded). |
| 1193 const EffectNode* node = tree.Node(render_surface->EffectTreeIndex()); | 1184 const EffectNode* node = tree.Node(render_surface->EffectTreeIndex()); |
| 1194 float draw_opacity = tree.EffectiveOpacity(node); | 1185 float draw_opacity = tree.EffectiveOpacity(node); |
| 1195 for (node = tree.parent(node); node && !node->data.has_render_surface; | 1186 for (node = tree.parent(node); node && !node->has_render_surface; |
| 1196 node = tree.parent(node)) { | 1187 node = tree.parent(node)) { |
| 1197 draw_opacity *= tree.EffectiveOpacity(node); | 1188 draw_opacity *= tree.EffectiveOpacity(node); |
| 1198 } | 1189 } |
| 1199 render_surface->SetDrawOpacity(draw_opacity); | 1190 render_surface->SetDrawOpacity(draw_opacity); |
| 1200 } | 1191 } |
| 1201 | 1192 |
| 1202 static gfx::Rect LayerDrawableContentRect( | 1193 static gfx::Rect LayerDrawableContentRect( |
| 1203 const LayerImpl* layer, | 1194 const LayerImpl* layer, |
| 1204 const gfx::Rect& layer_bounds_in_target_space, | 1195 const gfx::Rect& layer_bounds_in_target_space, |
| 1205 const gfx::Rect& clip_rect) { | 1196 const gfx::Rect& clip_rect) { |
| 1206 if (layer->is_clipped()) | 1197 if (layer->is_clipped()) |
| 1207 return IntersectRects(layer_bounds_in_target_space, clip_rect); | 1198 return IntersectRects(layer_bounds_in_target_space, clip_rect); |
| 1208 | 1199 |
| 1209 return layer_bounds_in_target_space; | 1200 return layer_bounds_in_target_space; |
| 1210 } | 1201 } |
| 1211 | 1202 |
| 1212 static gfx::Transform ReplicaToSurfaceTransform( | 1203 static gfx::Transform ReplicaToSurfaceTransform( |
| 1213 const RenderSurfaceImpl* render_surface, | 1204 const RenderSurfaceImpl* render_surface, |
| 1214 const TransformTree& tree) { | 1205 const TransformTree& tree) { |
| 1215 gfx::Transform replica_to_surface; | 1206 gfx::Transform replica_to_surface; |
| 1216 if (!render_surface->HasReplica()) | 1207 if (!render_surface->HasReplica()) |
| 1217 return replica_to_surface; | 1208 return replica_to_surface; |
| 1218 const LayerImpl* replica_layer = render_surface->ReplicaLayer(); | 1209 const LayerImpl* replica_layer = render_surface->ReplicaLayer(); |
| 1219 const TransformNode* surface_transform_node = | 1210 const TransformNode* surface_transform_node = |
| 1220 tree.Node(render_surface->TransformTreeIndex()); | 1211 tree.Node(render_surface->TransformTreeIndex()); |
| 1221 replica_to_surface.Scale(surface_transform_node->data.sublayer_scale.x(), | 1212 replica_to_surface.Scale(surface_transform_node->sublayer_scale.x(), |
| 1222 surface_transform_node->data.sublayer_scale.y()); | 1213 surface_transform_node->sublayer_scale.y()); |
| 1223 replica_to_surface.Translate(replica_layer->offset_to_transform_parent().x(), | 1214 replica_to_surface.Translate(replica_layer->offset_to_transform_parent().x(), |
| 1224 replica_layer->offset_to_transform_parent().y()); | 1215 replica_layer->offset_to_transform_parent().y()); |
| 1225 gfx::Transform replica_transform_node_to_surface; | 1216 gfx::Transform replica_transform_node_to_surface; |
| 1226 tree.ComputeTransform(replica_layer->transform_tree_index(), | 1217 tree.ComputeTransform(replica_layer->transform_tree_index(), |
| 1227 render_surface->TransformTreeIndex(), | 1218 render_surface->TransformTreeIndex(), |
| 1228 &replica_transform_node_to_surface); | 1219 &replica_transform_node_to_surface); |
| 1229 replica_to_surface.PreconcatTransform(replica_transform_node_to_surface); | 1220 replica_to_surface.PreconcatTransform(replica_transform_node_to_surface); |
| 1230 if (surface_transform_node->data.sublayer_scale.x() != 0 && | 1221 if (surface_transform_node->sublayer_scale.x() != 0 && |
| 1231 surface_transform_node->data.sublayer_scale.y() != 0) { | 1222 surface_transform_node->sublayer_scale.y() != 0) { |
| 1232 replica_to_surface.Scale( | 1223 replica_to_surface.Scale(1.0 / surface_transform_node->sublayer_scale.x(), |
| 1233 1.0 / surface_transform_node->data.sublayer_scale.x(), | 1224 1.0 / surface_transform_node->sublayer_scale.y()); |
| 1234 1.0 / surface_transform_node->data.sublayer_scale.y()); | |
| 1235 } | 1225 } |
| 1236 return replica_to_surface; | 1226 return replica_to_surface; |
| 1237 } | 1227 } |
| 1238 | 1228 |
| 1239 void ComputeLayerDrawProperties(LayerImpl* layer, | 1229 void ComputeLayerDrawProperties(LayerImpl* layer, |
| 1240 const PropertyTrees* property_trees) { | 1230 const PropertyTrees* property_trees) { |
| 1241 const TransformNode* transform_node = | 1231 const TransformNode* transform_node = |
| 1242 property_trees->transform_tree.Node(layer->transform_tree_index()); | 1232 property_trees->transform_tree.Node(layer->transform_tree_index()); |
| 1243 const ClipNode* clip_node = | 1233 const ClipNode* clip_node = |
| 1244 property_trees->clip_tree.Node(layer->clip_tree_index()); | 1234 property_trees->clip_tree.Node(layer->clip_tree_index()); |
| 1245 | 1235 |
| 1246 layer->draw_properties().screen_space_transform = | 1236 layer->draw_properties().screen_space_transform = |
| 1247 ScreenSpaceTransformInternal(layer, property_trees->transform_tree); | 1237 ScreenSpaceTransformInternal(layer, property_trees->transform_tree); |
| 1248 if (property_trees->non_root_surfaces_enabled) { | 1238 if (property_trees->non_root_surfaces_enabled) { |
| 1249 layer->draw_properties().target_space_transform = | 1239 layer->draw_properties().target_space_transform = |
| 1250 DrawTransform(layer, property_trees->transform_tree); | 1240 DrawTransform(layer, property_trees->transform_tree); |
| 1251 } else { | 1241 } else { |
| 1252 layer->draw_properties().target_space_transform = | 1242 layer->draw_properties().target_space_transform = |
| 1253 layer->draw_properties().screen_space_transform; | 1243 layer->draw_properties().screen_space_transform; |
| 1254 } | 1244 } |
| 1255 layer->draw_properties().screen_space_transform_is_animating = | 1245 layer->draw_properties().screen_space_transform_is_animating = |
| 1256 transform_node->data.to_screen_is_potentially_animated; | 1246 transform_node->to_screen_is_potentially_animated; |
| 1257 | 1247 |
| 1258 layer->draw_properties().opacity = | 1248 layer->draw_properties().opacity = |
| 1259 LayerDrawOpacity(layer, property_trees->effect_tree); | 1249 LayerDrawOpacity(layer, property_trees->effect_tree); |
| 1260 if (property_trees->non_root_surfaces_enabled) { | 1250 if (property_trees->non_root_surfaces_enabled) { |
| 1261 layer->draw_properties().is_clipped = clip_node->data.layers_are_clipped; | 1251 layer->draw_properties().is_clipped = clip_node->layers_are_clipped; |
| 1262 } else { | 1252 } else { |
| 1263 layer->draw_properties().is_clipped = | 1253 layer->draw_properties().is_clipped = |
| 1264 clip_node->data.layers_are_clipped_when_surfaces_disabled; | 1254 clip_node->layers_are_clipped_when_surfaces_disabled; |
| 1265 } | 1255 } |
| 1266 | 1256 |
| 1267 gfx::Rect bounds_in_target_space = MathUtil::MapEnclosingClippedRect( | 1257 gfx::Rect bounds_in_target_space = MathUtil::MapEnclosingClippedRect( |
| 1268 layer->draw_properties().target_space_transform, | 1258 layer->draw_properties().target_space_transform, |
| 1269 gfx::Rect(layer->bounds())); | 1259 gfx::Rect(layer->bounds())); |
| 1270 layer->draw_properties().drawable_content_rect = LayerDrawableContentRect( | 1260 layer->draw_properties().drawable_content_rect = LayerDrawableContentRect( |
| 1271 layer, bounds_in_target_space, layer->draw_properties().clip_rect); | 1261 layer, bounds_in_target_space, layer->draw_properties().clip_rect); |
| 1272 } | 1262 } |
| 1273 | 1263 |
| 1274 void ComputeMaskDrawProperties(LayerImpl* mask_layer, | 1264 void ComputeMaskDrawProperties(LayerImpl* mask_layer, |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1337 // TODO(enne): property trees can't ask the layer these things, but | 1327 // TODO(enne): property trees can't ask the layer these things, but |
| 1338 // the page scale layer should *just* be the page scale. | 1328 // the page scale layer should *just* be the page scale. |
| 1339 #if DCHECK_IS_ON() | 1329 #if DCHECK_IS_ON() |
| 1340 ValidatePageScaleLayer(page_scale_layer); | 1330 ValidatePageScaleLayer(page_scale_layer); |
| 1341 #endif | 1331 #endif |
| 1342 | 1332 |
| 1343 if (IsRootLayer(page_scale_layer)) { | 1333 if (IsRootLayer(page_scale_layer)) { |
| 1344 // When the page scale layer is also the root layer, the node should also | 1334 // When the page scale layer is also the root layer, the node should also |
| 1345 // store the combined scale factor and not just the page scale factor. | 1335 // store the combined scale factor and not just the page scale factor. |
| 1346 float post_local_scale_factor = page_scale_factor * device_scale_factor; | 1336 float post_local_scale_factor = page_scale_factor * device_scale_factor; |
| 1347 node->data.post_local_scale_factor = post_local_scale_factor; | 1337 node->post_local_scale_factor = post_local_scale_factor; |
| 1348 node->data.post_local = device_transform; | 1338 node->post_local = device_transform; |
| 1349 node->data.post_local.Scale(post_local_scale_factor, | 1339 node->post_local.Scale(post_local_scale_factor, post_local_scale_factor); |
| 1350 post_local_scale_factor); | |
| 1351 } else { | 1340 } else { |
| 1352 node->data.post_local_scale_factor = page_scale_factor; | 1341 node->post_local_scale_factor = page_scale_factor; |
| 1353 node->data.update_post_local_transform(gfx::PointF(), gfx::Point3F()); | 1342 node->update_post_local_transform(gfx::PointF(), gfx::Point3F()); |
| 1354 } | 1343 } |
| 1355 node->data.needs_local_transform_update = true; | 1344 node->needs_local_transform_update = true; |
| 1356 property_trees->transform_tree.set_needs_update(true); | 1345 property_trees->transform_tree.set_needs_update(true); |
| 1357 } | 1346 } |
| 1358 | 1347 |
| 1359 void UpdatePageScaleFactor(PropertyTrees* property_trees, | 1348 void UpdatePageScaleFactor(PropertyTrees* property_trees, |
| 1360 const LayerImpl* page_scale_layer, | 1349 const LayerImpl* page_scale_layer, |
| 1361 float page_scale_factor, | 1350 float page_scale_factor, |
| 1362 float device_scale_factor, | 1351 float device_scale_factor, |
| 1363 const gfx::Transform device_transform) { | 1352 const gfx::Transform device_transform) { |
| 1364 UpdatePageScaleFactorInternal(property_trees, page_scale_layer, | 1353 UpdatePageScaleFactorInternal(property_trees, page_scale_layer, |
| 1365 page_scale_factor, device_scale_factor, | 1354 page_scale_factor, device_scale_factor, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1381 PropertyTrees* property_trees, | 1370 PropertyTrees* property_trees, |
| 1382 const LayerType* overscroll_elasticity_layer, | 1371 const LayerType* overscroll_elasticity_layer, |
| 1383 const gfx::Vector2dF& elastic_overscroll) { | 1372 const gfx::Vector2dF& elastic_overscroll) { |
| 1384 if (!overscroll_elasticity_layer) { | 1373 if (!overscroll_elasticity_layer) { |
| 1385 DCHECK(elastic_overscroll.IsZero()); | 1374 DCHECK(elastic_overscroll.IsZero()); |
| 1386 return; | 1375 return; |
| 1387 } | 1376 } |
| 1388 | 1377 |
| 1389 TransformNode* node = property_trees->transform_tree.Node( | 1378 TransformNode* node = property_trees->transform_tree.Node( |
| 1390 overscroll_elasticity_layer->transform_tree_index()); | 1379 overscroll_elasticity_layer->transform_tree_index()); |
| 1391 if (node->data.scroll_offset == gfx::ScrollOffset(elastic_overscroll)) | 1380 if (node->scroll_offset == gfx::ScrollOffset(elastic_overscroll)) |
| 1392 return; | 1381 return; |
| 1393 | 1382 |
| 1394 node->data.scroll_offset = gfx::ScrollOffset(elastic_overscroll); | 1383 node->scroll_offset = gfx::ScrollOffset(elastic_overscroll); |
| 1395 node->data.needs_local_transform_update = true; | 1384 node->needs_local_transform_update = true; |
| 1396 property_trees->transform_tree.set_needs_update(true); | 1385 property_trees->transform_tree.set_needs_update(true); |
| 1397 } | 1386 } |
| 1398 | 1387 |
| 1399 void UpdateElasticOverscroll(PropertyTrees* property_trees, | 1388 void UpdateElasticOverscroll(PropertyTrees* property_trees, |
| 1400 const LayerImpl* overscroll_elasticity_layer, | 1389 const LayerImpl* overscroll_elasticity_layer, |
| 1401 const gfx::Vector2dF& elastic_overscroll) { | 1390 const gfx::Vector2dF& elastic_overscroll) { |
| 1402 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, | 1391 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, |
| 1403 elastic_overscroll); | 1392 elastic_overscroll); |
| 1404 } | 1393 } |
| 1405 | 1394 |
| 1406 void UpdateElasticOverscroll(PropertyTrees* property_trees, | 1395 void UpdateElasticOverscroll(PropertyTrees* property_trees, |
| 1407 const Layer* overscroll_elasticity_layer, | 1396 const Layer* overscroll_elasticity_layer, |
| 1408 const gfx::Vector2dF& elastic_overscroll) { | 1397 const gfx::Vector2dF& elastic_overscroll) { |
| 1409 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, | 1398 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, |
| 1410 elastic_overscroll); | 1399 elastic_overscroll); |
| 1411 } | 1400 } |
| 1412 | 1401 |
| 1413 } // namespace draw_property_utils | 1402 } // namespace draw_property_utils |
| 1414 | 1403 |
| 1415 } // namespace cc | 1404 } // namespace cc |
| OLD | NEW |