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); |
| 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 1423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2023 clipped_content_rect.set_width( | 2050 clipped_content_rect.set_width( |
2024 std::min(clipped_content_rect.width(), globals.max_texture_size)); | 2051 std::min(clipped_content_rect.width(), globals.max_texture_size)); |
2025 clipped_content_rect.set_height( | 2052 clipped_content_rect.set_height( |
2026 std::min(clipped_content_rect.height(), globals.max_texture_size)); | 2053 std::min(clipped_content_rect.height(), globals.max_texture_size)); |
2027 | 2054 |
2028 if (clipped_content_rect.IsEmpty()) { | 2055 if (clipped_content_rect.IsEmpty()) { |
2029 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list); | 2056 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list); |
2030 return; | 2057 return; |
2031 } | 2058 } |
2032 | 2059 |
| 2060 // Layers having a non-default blend mode will blend with the content |
| 2061 // inside its parent's render target. This render target should be |
| 2062 // either root_for_isolated_group, or the root of the layer tree. |
| 2063 // Otherwise, this layer will use an incomplete backdrop, limited to its |
| 2064 // render target and the blending result will be incorrect. |
| 2065 DCHECK(layer->uses_default_blend_mode() || !layer->parent() || |
| 2066 !layer->parent()->render_target() || |
| 2067 IsRootLayer(layer->parent()->render_target()) || |
| 2068 layer->parent()->render_target()->is_root_for_isolated_group()); |
| 2069 |
2033 render_surface->SetContentRect(clipped_content_rect); | 2070 render_surface->SetContentRect(clipped_content_rect); |
2034 | 2071 |
2035 // The owning layer's screen_space_transform has a scale from content to | 2072 // The owning layer's screen_space_transform has a scale from content to |
2036 // layer space which we need to undo and replace with a scale from the | 2073 // layer space which we need to undo and replace with a scale from the |
2037 // surface's subtree into layer space. | 2074 // surface's subtree into layer space. |
2038 gfx::Transform screen_space_transform = layer->screen_space_transform(); | 2075 gfx::Transform screen_space_transform = layer->screen_space_transform(); |
2039 screen_space_transform.Scale( | 2076 screen_space_transform.Scale( |
2040 layer->contents_scale_x() / render_surface_sublayer_scale.x(), | 2077 layer->contents_scale_x() / render_surface_sublayer_scale.x(), |
2041 layer->contents_scale_y() / render_surface_sublayer_scale.y()); | 2078 layer->contents_scale_y() / render_surface_sublayer_scale.y()); |
2042 render_surface->SetScreenSpaceTransform(screen_space_transform); | 2079 render_surface->SetScreenSpaceTransform(screen_space_transform); |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2391 // At this point, we think the point does hit the touch event handler region | 2428 // At this point, we think the point does hit the touch event handler region |
2392 // on the layer, but we need to walk up the parents to ensure that the layer | 2429 // on the layer, but we need to walk up the parents to ensure that the layer |
2393 // was not clipped in such a way that the hit point actually should not hit | 2430 // was not clipped in such a way that the hit point actually should not hit |
2394 // the layer. | 2431 // the layer. |
2395 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) | 2432 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) |
2396 return false; | 2433 return false; |
2397 | 2434 |
2398 return true; | 2435 return true; |
2399 } | 2436 } |
2400 } // namespace cc | 2437 } // namespace cc |
OLD | NEW |