| 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 RenderPassDrawQuad. 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 |
| 590 // If the layer clips its descendants but it is not axis-aligned with respect | 603 // If the layer clips its descendants but it is not axis-aligned with respect |
| 591 // to its parent. | 604 // to its parent. |
| 592 bool layer_clips_external_content = | 605 bool layer_clips_external_content = |
| 593 LayerClipsSubtree(layer) || layer->HasDelegatedContent(); | 606 LayerClipsSubtree(layer) || layer->HasDelegatedContent(); |
| 594 if (layer_clips_external_content && !axis_aligned_with_respect_to_parent && | 607 if (layer_clips_external_content && !axis_aligned_with_respect_to_parent && |
| 595 num_descendants_that_draw_content > 0) { | 608 num_descendants_that_draw_content > 0) { |
| 596 TRACE_EVENT_INSTANT0( | 609 TRACE_EVENT_INSTANT0( |
| 597 "cc", | 610 "cc", |
| 598 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface clipping", | 611 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface clipping", |
| 599 TRACE_EVENT_SCOPE_THREAD); | 612 TRACE_EVENT_SCOPE_THREAD); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 622 | 635 |
| 623 // The root layer should always have a render_surface. | 636 // The root layer should always have a render_surface. |
| 624 if (is_root) | 637 if (is_root) |
| 625 return true; | 638 return true; |
| 626 | 639 |
| 627 // | 640 // |
| 628 // These are allowed on the root surface, as they don't require the surface to | 641 // These are allowed on the root surface, as they don't require the surface to |
| 629 // be used as a contributing surface in order to apply correctly. | 642 // be used as a contributing surface in order to apply correctly. |
| 630 // | 643 // |
| 631 | 644 |
| 645 // If the layer has isolation. |
| 646 // TODO(rosca): to be optimized - create separate rendering surface only when |
| 647 // the blending descendants might have access to the content behind this layer |
| 648 // (layer has transparent background or descendants overflow). |
| 649 // https://code.google.com/p/chromium/issues/detail?id=301738 |
| 650 if (layer->is_root_for_isolated_group()) { |
| 651 TRACE_EVENT_INSTANT0( |
| 652 "cc", |
| 653 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface isolation", |
| 654 TRACE_EVENT_SCOPE_THREAD); |
| 655 return true; |
| 656 } |
| 657 |
| 632 // If we force it. | 658 // If we force it. |
| 633 if (layer->force_render_surface()) | 659 if (layer->force_render_surface()) |
| 634 return true; | 660 return true; |
| 635 | 661 |
| 636 // If we'll make a copy of the layer's contents. | 662 // If we'll make a copy of the layer's contents. |
| 637 if (layer->HasCopyRequest()) | 663 if (layer->HasCopyRequest()) |
| 638 return true; | 664 return true; |
| 639 | 665 |
| 640 return false; | 666 return false; |
| 641 } | 667 } |
| (...skipping 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2027 clipped_content_rect.set_width( | 2053 clipped_content_rect.set_width( |
| 2028 std::min(clipped_content_rect.width(), globals.max_texture_size)); | 2054 std::min(clipped_content_rect.width(), globals.max_texture_size)); |
| 2029 clipped_content_rect.set_height( | 2055 clipped_content_rect.set_height( |
| 2030 std::min(clipped_content_rect.height(), globals.max_texture_size)); | 2056 std::min(clipped_content_rect.height(), globals.max_texture_size)); |
| 2031 | 2057 |
| 2032 if (clipped_content_rect.IsEmpty()) { | 2058 if (clipped_content_rect.IsEmpty()) { |
| 2033 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list); | 2059 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list); |
| 2034 return; | 2060 return; |
| 2035 } | 2061 } |
| 2036 | 2062 |
| 2063 // Layers having a non-default blend mode will blend with the content |
| 2064 // inside its parent's render target. This render target should be |
| 2065 // either root_for_isolated_group, or the root of the layer tree. |
| 2066 // Otherwise, this layer will use an incomplete backdrop, limited to its |
| 2067 // render target and the blending result will be incorrect. |
| 2068 DCHECK(layer->uses_default_blend_mode() || IsRootLayer(layer) || |
| 2069 !layer->parent()->render_target() || |
| 2070 IsRootLayer(layer->parent()->render_target()) || |
| 2071 layer->parent()->render_target()->is_root_for_isolated_group()); |
| 2072 |
| 2037 render_surface->SetContentRect(clipped_content_rect); | 2073 render_surface->SetContentRect(clipped_content_rect); |
| 2038 | 2074 |
| 2039 // The owning layer's screen_space_transform has a scale from content to | 2075 // The owning layer's screen_space_transform has a scale from content to |
| 2040 // layer space which we need to undo and replace with a scale from the | 2076 // layer space which we need to undo and replace with a scale from the |
| 2041 // surface's subtree into layer space. | 2077 // surface's subtree into layer space. |
| 2042 gfx::Transform screen_space_transform = layer->screen_space_transform(); | 2078 gfx::Transform screen_space_transform = layer->screen_space_transform(); |
| 2043 screen_space_transform.Scale( | 2079 screen_space_transform.Scale( |
| 2044 layer->contents_scale_x() / render_surface_sublayer_scale.x(), | 2080 layer->contents_scale_x() / render_surface_sublayer_scale.x(), |
| 2045 layer->contents_scale_y() / render_surface_sublayer_scale.y()); | 2081 layer->contents_scale_y() / render_surface_sublayer_scale.y()); |
| 2046 render_surface->SetScreenSpaceTransform(screen_space_transform); | 2082 render_surface->SetScreenSpaceTransform(screen_space_transform); |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2395 // At this point, we think the point does hit the touch event handler region | 2431 // At this point, we think the point does hit the touch event handler region |
| 2396 // on the layer, but we need to walk up the parents to ensure that the layer | 2432 // on the layer, but we need to walk up the parents to ensure that the layer |
| 2397 // was not clipped in such a way that the hit point actually should not hit | 2433 // was not clipped in such a way that the hit point actually should not hit |
| 2398 // the layer. | 2434 // the layer. |
| 2399 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) | 2435 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) |
| 2400 return false; | 2436 return false; |
| 2401 | 2437 |
| 2402 return true; | 2438 return true; |
| 2403 } | 2439 } |
| 2404 } // namespace cc | 2440 } // namespace cc |
| OLD | NEW |