Chromium Code Reviews| 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 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 580 if (LayerIsInExisting3DRenderingContext(layer) && !layer->preserves_3d() && | 580 if (LayerIsInExisting3DRenderingContext(layer) && !layer->preserves_3d() && |
| 581 num_descendants_that_draw_content > 0) { | 581 num_descendants_that_draw_content > 0) { |
| 582 TRACE_EVENT_INSTANT0( | 582 TRACE_EVENT_INSTANT0( |
| 583 "cc", | 583 "cc", |
| 584 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface flattening", | 584 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface flattening", |
| 585 TRACE_EVENT_SCOPE_THREAD); | 585 TRACE_EVENT_SCOPE_THREAD); |
| 586 DCHECK(!is_root); | 586 DCHECK(!is_root); |
| 587 return true; | 587 return true; |
| 588 } | 588 } |
| 589 | 589 |
| 590 // If the layer has blending. | |
| 591 // TODO(rosca): this is temporary, until blending is implemented for other | |
| 592 // types of quads than RenderPassQuad. Layers having descendants that draw | |
| 593 // content will still create a separate rendering surface. | |
| 594 if (!layer->uses_default_blend_mode()) { | |
| 595 TRACE_EVENT_INSTANT0( | |
| 596 "cc", | |
| 597 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface blending", | |
| 598 TRACE_EVENT_SCOPE_THREAD); | |
| 599 DCHECK(!is_root); | |
| 600 return true; | |
| 601 } | |
| 602 | |
| 603 // If the layer has isolation. | |
| 604 // TODO(rosca): to be optimized - create separate rendering surface only when | |
| 605 // the blending descendants might have access to the content behind this layer | |
| 606 // (layer has transparent background or descendants overflow) | |
| 607 // https://code.google.com/p/chromium/issues/detail?id=301738 | |
| 608 if (layer->is_root_for_isolated_group()) { | |
| 609 TRACE_EVENT_INSTANT0( | |
| 610 "cc", | |
| 611 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface isolation", | |
| 612 TRACE_EVENT_SCOPE_THREAD); | |
| 613 DCHECK(!is_root); | |
|
enne (OOO)
2013/11/06 22:40:19
Why can't this be the root? In the cases above, we
rosca
2013/11/07 01:58:16
Agree. Done.
| |
| 614 return true; | |
| 615 } | |
| 616 | |
| 590 // If the layer clips its descendants but it is not axis-aligned with respect | 617 // If the layer clips its descendants but it is not axis-aligned with respect |
| 591 // to its parent. | 618 // to its parent. |
| 592 bool layer_clips_external_content = | 619 bool layer_clips_external_content = |
| 593 LayerClipsSubtree(layer) || layer->HasDelegatedContent(); | 620 LayerClipsSubtree(layer) || layer->HasDelegatedContent(); |
| 594 if (layer_clips_external_content && !axis_aligned_with_respect_to_parent && | 621 if (layer_clips_external_content && !axis_aligned_with_respect_to_parent && |
| 595 num_descendants_that_draw_content > 0) { | 622 num_descendants_that_draw_content > 0) { |
| 596 TRACE_EVENT_INSTANT0( | 623 TRACE_EVENT_INSTANT0( |
| 597 "cc", | 624 "cc", |
| 598 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface clipping", | 625 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface clipping", |
| 599 TRACE_EVENT_SCOPE_THREAD); | 626 TRACE_EVENT_SCOPE_THREAD); |
| (...skipping 1441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2041 clipped_content_rect.set_width( | 2068 clipped_content_rect.set_width( |
| 2042 std::min(clipped_content_rect.width(), globals.max_texture_size)); | 2069 std::min(clipped_content_rect.width(), globals.max_texture_size)); |
| 2043 clipped_content_rect.set_height( | 2070 clipped_content_rect.set_height( |
| 2044 std::min(clipped_content_rect.height(), globals.max_texture_size)); | 2071 std::min(clipped_content_rect.height(), globals.max_texture_size)); |
| 2045 | 2072 |
| 2046 if (clipped_content_rect.IsEmpty()) { | 2073 if (clipped_content_rect.IsEmpty()) { |
| 2047 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list); | 2074 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list); |
| 2048 return; | 2075 return; |
| 2049 } | 2076 } |
| 2050 | 2077 |
| 2078 // Layers having a non-default blend mode will blend with the content | |
| 2079 // inside its parent's render target. This render target should be | |
| 2080 // either root_for_isolated_group, or the root of the layer tree. | |
| 2081 // Otherwise, this layer will use an incomplete backdrop, limited to its | |
| 2082 // render target and the blending result will be incorrect. | |
| 2083 DCHECK(layer->uses_default_blend_mode() || !layer->parent() || | |
| 2084 !layer->parent()->render_target() || | |
| 2085 IsRootLayer(layer->parent()->render_target()) || | |
| 2086 layer->parent()->render_target()->is_root_for_isolated_group()); | |
| 2087 | |
| 2051 render_surface->SetContentRect(clipped_content_rect); | 2088 render_surface->SetContentRect(clipped_content_rect); |
| 2052 | 2089 |
| 2053 // The owning layer's screen_space_transform has a scale from content to | 2090 // The owning layer's screen_space_transform has a scale from content to |
| 2054 // layer space which we need to undo and replace with a scale from the | 2091 // layer space which we need to undo and replace with a scale from the |
| 2055 // surface's subtree into layer space. | 2092 // surface's subtree into layer space. |
| 2056 gfx::Transform screen_space_transform = layer->screen_space_transform(); | 2093 gfx::Transform screen_space_transform = layer->screen_space_transform(); |
| 2057 screen_space_transform.Scale( | 2094 screen_space_transform.Scale( |
| 2058 layer->contents_scale_x() / render_surface_sublayer_scale.x(), | 2095 layer->contents_scale_x() / render_surface_sublayer_scale.x(), |
| 2059 layer->contents_scale_y() / render_surface_sublayer_scale.y()); | 2096 layer->contents_scale_y() / render_surface_sublayer_scale.y()); |
| 2060 render_surface->SetScreenSpaceTransform(screen_space_transform); | 2097 render_surface->SetScreenSpaceTransform(screen_space_transform); |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2415 // At this point, we think the point does hit the touch event handler region | 2452 // At this point, we think the point does hit the touch event handler region |
| 2416 // on the layer, but we need to walk up the parents to ensure that the layer | 2453 // on the layer, but we need to walk up the parents to ensure that the layer |
| 2417 // was not clipped in such a way that the hit point actually should not hit | 2454 // was not clipped in such a way that the hit point actually should not hit |
| 2418 // the layer. | 2455 // the layer. |
| 2419 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) | 2456 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) |
| 2420 return false; | 2457 return false; |
| 2421 | 2458 |
| 2422 return true; | 2459 return true; |
| 2423 } | 2460 } |
| 2424 } // namespace cc | 2461 } // namespace cc |
| OLD | NEW |