OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/layer_tree_host_common.h" | 5 #include "cc/trees/layer_tree_host_common.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 | 291 |
292 int num_descendants_that_draw_content = | 292 int num_descendants_that_draw_content = |
293 layer->draw_properties().num_descendants_that_draw_content; | 293 layer->draw_properties().num_descendants_that_draw_content; |
294 | 294 |
295 // If the layer flattens its subtree (i.e. the layer doesn't preserve-3d), but | 295 // If the layer flattens its subtree (i.e. the layer doesn't preserve-3d), but |
296 // it is treated as a 3D object by its parent (i.e. parent does preserve-3d). | 296 // it is treated as a 3D object by its parent (i.e. parent does preserve-3d). |
297 if (LayerIsInExisting3DRenderingContext(layer) && !layer->preserves_3d() && | 297 if (LayerIsInExisting3DRenderingContext(layer) && !layer->preserves_3d() && |
298 num_descendants_that_draw_content > 0) { | 298 num_descendants_that_draw_content > 0) { |
299 TRACE_EVENT_INSTANT0( | 299 TRACE_EVENT_INSTANT0( |
300 "cc", | 300 "cc", |
301 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface flattening"); | 301 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface flattening", |
| 302 TRACE_EVENT_SCOPE_THREAD); |
302 return true; | 303 return true; |
303 } | 304 } |
304 | 305 |
305 // If the layer clips its descendants but it is not axis-aligned with respect | 306 // If the layer clips its descendants but it is not axis-aligned with respect |
306 // to its parent. | 307 // to its parent. |
307 bool layer_clips_external_content = | 308 bool layer_clips_external_content = |
308 LayerClipsSubtree(layer) || layer->HasDelegatedContent(); | 309 LayerClipsSubtree(layer) || layer->HasDelegatedContent(); |
309 if (layer_clips_external_content && !axis_aligned_with_respect_to_parent && | 310 if (layer_clips_external_content && !axis_aligned_with_respect_to_parent && |
310 !layer->draw_properties().descendants_can_clip_selves) { | 311 !layer->draw_properties().descendants_can_clip_selves) { |
311 TRACE_EVENT_INSTANT0( | 312 TRACE_EVENT_INSTANT0( |
312 "cc", | 313 "cc", |
313 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface clipping"); | 314 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface clipping", |
| 315 TRACE_EVENT_SCOPE_THREAD); |
314 return true; | 316 return true; |
315 } | 317 } |
316 | 318 |
317 // If the layer has some translucency and does not have a preserves-3d | 319 // If the layer has some translucency and does not have a preserves-3d |
318 // transform style. This condition only needs a render surface if two or more | 320 // transform style. This condition only needs a render surface if two or more |
319 // layers in the subtree overlap. But checking layer overlaps is unnecessarily | 321 // layers in the subtree overlap. But checking layer overlaps is unnecessarily |
320 // costly so instead we conservatively create a surface whenever at least two | 322 // costly so instead we conservatively create a surface whenever at least two |
321 // layers draw content for this subtree. | 323 // layers draw content for this subtree. |
322 bool at_least_two_layers_in_subtree_draw_content = | 324 bool at_least_two_layers_in_subtree_draw_content = |
323 num_descendants_that_draw_content > 0 && | 325 num_descendants_that_draw_content > 0 && |
324 (layer->DrawsContent() || num_descendants_that_draw_content > 1); | 326 (layer->DrawsContent() || num_descendants_that_draw_content > 1); |
325 | 327 |
326 if (layer->opacity() != 1.f && !layer->preserves_3d() && | 328 if (layer->opacity() != 1.f && !layer->preserves_3d() && |
327 at_least_two_layers_in_subtree_draw_content) { | 329 at_least_two_layers_in_subtree_draw_content) { |
328 TRACE_EVENT_INSTANT0( | 330 TRACE_EVENT_INSTANT0( |
329 "cc", | 331 "cc", |
330 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface opacity"); | 332 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface opacity", |
| 333 TRACE_EVENT_SCOPE_THREAD); |
331 return true; | 334 return true; |
332 } | 335 } |
333 | 336 |
334 return false; | 337 return false; |
335 } | 338 } |
336 | 339 |
337 gfx::Transform ComputeScrollCompensationForThisLayer( | 340 gfx::Transform ComputeScrollCompensationForThisLayer( |
338 LayerImpl* scrolling_layer, | 341 LayerImpl* scrolling_layer, |
339 const gfx::Transform& parent_matrix) { | 342 const gfx::Transform& parent_matrix) { |
340 // For every layer that has non-zero scroll_delta, we have to compute a | 343 // For every layer that has non-zero scroll_delta, we have to compute a |
(...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1574 // At this point, we think the point does hit the touch event handler region | 1577 // At this point, we think the point does hit the touch event handler region |
1575 // on the layer, but we need to walk up the parents to ensure that the layer | 1578 // on the layer, but we need to walk up the parents to ensure that the layer |
1576 // was not clipped in such a way that the hit point actually should not hit | 1579 // was not clipped in such a way that the hit point actually should not hit |
1577 // the layer. | 1580 // the layer. |
1578 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) | 1581 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) |
1579 return false; | 1582 return false; |
1580 | 1583 |
1581 return true; | 1584 return true; |
1582 } | 1585 } |
1583 } // namespace cc | 1586 } // namespace cc |
OLD | NEW |