Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(572)

Side by Side Diff: cc/trees/layer_tree_impl.cc

Issue 2639723002: [NOT FOR REVIEW]
Patch Set: . Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_impl.h ('k') | cc/trees/layer_tree_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_impl.h" 5 #include "cc/trees/layer_tree_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 layer->SetElementId(LayerIdToElementIdForTesting(layer->id())); 953 layer->SetElementId(LayerIdToElementIdForTesting(layer->id()));
954 } 954 }
955 955
956 void LayerTreeImpl::SetElementIdsForTesting() { 956 void LayerTreeImpl::SetElementIdsForTesting() {
957 LayerListIterator<LayerImpl> it(root_layer_for_testing_); 957 LayerListIterator<LayerImpl> it(root_layer_for_testing_);
958 for (; it != LayerListIterator<LayerImpl>(nullptr); ++it) { 958 for (; it != LayerListIterator<LayerImpl>(nullptr); ++it) {
959 SetElementIdForTesting(*it); 959 SetElementIdForTesting(*it);
960 } 960 }
961 } 961 }
962 962
963 bool LayerTreeImpl::UpdateDrawProperties( 963 bool LayerTreeImpl::UpdateDrawProperties(bool update_lcd_text) {
964 bool update_lcd_text,
965 bool force_skip_verify_visible_rect_calculations) {
966 if (!needs_update_draw_properties_) 964 if (!needs_update_draw_properties_)
967 return true; 965 return true;
968 966
969 // Calling UpdateDrawProperties must clear this flag, so there can be no 967 // Calling UpdateDrawProperties must clear this flag, so there can be no
970 // early outs before this. 968 // early outs before this.
971 needs_update_draw_properties_ = false; 969 needs_update_draw_properties_ = false;
972 970
973 // For max_texture_size. When a new output surface is received the needs 971 // For max_texture_size. When a new output surface is received the needs
974 // update draw properties flag is set again. 972 // update draw properties flag is set again.
975 if (!layer_tree_host_impl_->compositor_frame_sink()) 973 if (!layer_tree_host_impl_->compositor_frame_sink())
(...skipping 10 matching lines...) Expand all
986 base::ElapsedTimer timer; 984 base::ElapsedTimer timer;
987 TRACE_EVENT2( 985 TRACE_EVENT2(
988 "cc", "LayerTreeImpl::UpdateDrawProperties::CalculateDrawProperties", 986 "cc", "LayerTreeImpl::UpdateDrawProperties::CalculateDrawProperties",
989 "IsActive", IsActiveTree(), "SourceFrameNumber", source_frame_number_); 987 "IsActive", IsActiveTree(), "SourceFrameNumber", source_frame_number_);
990 bool can_render_to_separate_surface = 988 bool can_render_to_separate_surface =
991 (!is_in_resourceless_software_draw_mode()); 989 (!is_in_resourceless_software_draw_mode());
992 990
993 // We verify visible rect calculations whenever we verify clip tree 991 // We verify visible rect calculations whenever we verify clip tree
994 // calculations except when this function is explicitly passed a flag asking 992 // calculations except when this function is explicitly passed a flag asking
995 // us to skip it. 993 // us to skip it.
996 bool verify_visible_rect_calculations =
997 force_skip_verify_visible_rect_calculations
998 ? false
999 : settings().verify_clip_tree_calculations;
1000 LayerTreeHostCommon::CalcDrawPropsImplInputs inputs( 994 LayerTreeHostCommon::CalcDrawPropsImplInputs inputs(
1001 layer_list_[0], DrawViewportSize(), 995 layer_list_[0], DrawViewportSize(),
1002 layer_tree_host_impl_->DrawTransform(), device_scale_factor(), 996 layer_tree_host_impl_->DrawTransform(), device_scale_factor(),
1003 current_page_scale_factor(), PageScaleLayer(), 997 current_page_scale_factor(), PageScaleLayer(),
1004 InnerViewportScrollLayer(), OuterViewportScrollLayer(), 998 InnerViewportScrollLayer(), OuterViewportScrollLayer(),
1005 elastic_overscroll()->Current(IsActiveTree()), 999 elastic_overscroll()->Current(IsActiveTree()),
1006 OverscrollElasticityLayer(), resource_provider()->max_texture_size(), 1000 OverscrollElasticityLayer(), resource_provider()->max_texture_size(),
1007 can_render_to_separate_surface, 1001 can_render_to_separate_surface,
1008 settings().layer_transforms_should_scale_layer_contents, 1002 settings().layer_transforms_should_scale_layer_contents,
1009 settings().verify_clip_tree_calculations,
1010 verify_visible_rect_calculations,
1011 &render_surface_layer_list_, &property_trees_); 1003 &render_surface_layer_list_, &property_trees_);
1012 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 1004 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
1013 if (const char* client_name = GetClientNameForMetrics()) { 1005 if (const char* client_name = GetClientNameForMetrics()) {
1014 UMA_HISTOGRAM_COUNTS( 1006 UMA_HISTOGRAM_COUNTS(
1015 base::StringPrintf( 1007 base::StringPrintf(
1016 "Compositing.%s.LayerTreeImpl.CalculateDrawPropertiesUs", 1008 "Compositing.%s.LayerTreeImpl.CalculateDrawPropertiesUs",
1017 client_name), 1009 client_name),
1018 timer.Elapsed().InMicroseconds()); 1010 timer.Elapsed().InMicroseconds());
1019 UMA_HISTOGRAM_COUNTS_100( 1011 UMA_HISTOGRAM_COUNTS_100(
1020 base::StringPrintf("Compositing.%s.NumRenderSurfaces", client_name), 1012 base::StringPrintf("Compositing.%s.NumRenderSurfaces", client_name),
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
1781 const gfx::PointF& screen_space_point, 1773 const gfx::PointF& screen_space_point,
1782 const LayerImpl* layer) { 1774 const LayerImpl* layer) {
1783 // We need to visit all ancestor clip nodes to check this. Checking with just 1775 // We need to visit all ancestor clip nodes to check this. Checking with just
1784 // the combined clip stored at a clip node is not enough because parent 1776 // the combined clip stored at a clip node is not enough because parent
1785 // combined clip can sometimes be smaller than current combined clip. This can 1777 // combined clip can sometimes be smaller than current combined clip. This can
1786 // happen when we have transforms like rotation that inflate the combined 1778 // happen when we have transforms like rotation that inflate the combined
1787 // clip's bounds. Also, the point can be clipped by the content rect of an 1779 // clip's bounds. Also, the point can be clipped by the content rect of an
1788 // ancestor render surface. 1780 // ancestor render surface.
1789 1781
1790 // We first check if the point is clipped by viewport. 1782 // We first check if the point is clipped by viewport.
1791 const PropertyTrees* property_trees = 1783 PropertyTrees* property_trees = layer->layer_tree_impl()->property_trees();
1792 layer->layer_tree_impl()->property_trees();
1793 const ClipTree& clip_tree = property_trees->clip_tree; 1784 const ClipTree& clip_tree = property_trees->clip_tree;
1794 const TransformTree& transform_tree = property_trees->transform_tree; 1785 const TransformTree& transform_tree = property_trees->transform_tree;
1795 const ClipNode* clip_node = clip_tree.Node(1); 1786 const ClipNode* clip_node = clip_tree.Node(1);
1796 gfx::Rect combined_clip_in_target_space = 1787 gfx::Rect clip = gfx::ToEnclosingRect(clip_node->clip);
1797 gfx::ToEnclosingRect(clip_node->combined_clip_in_target_space); 1788 if (!PointHitsRect(screen_space_point, gfx::Transform(), clip, NULL))
1798 if (!PointHitsRect(screen_space_point, gfx::Transform(),
1799 combined_clip_in_target_space, NULL))
1800 return true; 1789 return true;
1801 1790
1802 for (const ClipNode* clip_node = clip_tree.Node(layer->clip_tree_index()); 1791 for (const ClipNode* clip_node = clip_tree.Node(layer->clip_tree_index());
1803 clip_node->id > ClipTree::kViewportNodeId; 1792 clip_node->id > ClipTree::kViewportNodeId;
1804 clip_node = clip_tree.parent(clip_node)) { 1793 clip_node = clip_tree.parent(clip_node)) {
1805 if (clip_node->clip_type == ClipNode::ClipType::APPLIES_LOCAL_CLIP) { 1794 if (clip_node->clip_type == ClipNode::ClipType::APPLIES_LOCAL_CLIP) {
1806 const TransformNode* transform_node = 1795 gfx::Rect clip = gfx::ToEnclosingRect(clip_node->clip);
1807 transform_tree.Node(clip_node->target_transform_id);
1808 gfx::Rect combined_clip_in_target_space =
1809 gfx::ToEnclosingRect(clip_node->combined_clip_in_target_space);
1810 1796
1811 const LayerImpl* target_layer = 1797 gfx::Transform screen_space_transform =
1812 layer->layer_tree_impl()->LayerById(transform_node->owning_layer_id); 1798 transform_tree.ToScreen(clip_node->transform_id);
1813 DCHECK(transform_node->id == TransformTree::kRootNodeId || 1799 if (!PointHitsRect(screen_space_point, screen_space_transform, clip,
1814 target_layer->render_surface() || 1800 NULL)) {
1815 layer->layer_tree_impl()->is_in_resourceless_software_draw_mode());
1816 gfx::Transform surface_screen_space_transform =
1817 transform_node->id == TransformTree::kRootNodeId ||
1818 (layer->layer_tree_impl()
1819 ->is_in_resourceless_software_draw_mode())
1820 ? gfx::Transform()
1821 : SurfaceScreenSpaceTransform(target_layer);
1822 if (!PointHitsRect(screen_space_point, surface_screen_space_transform,
1823 combined_clip_in_target_space, NULL)) {
1824 return true; 1801 return true;
1825 } 1802 }
1826 } 1803 }
1827 const LayerImpl* clip_node_owner = 1804 const LayerImpl* clip_node_owner =
1828 layer->layer_tree_impl()->LayerById(clip_node->owning_layer_id); 1805 layer->layer_tree_impl()->LayerById(clip_node->owning_layer_id);
1829 if (clip_node_owner->render_surface() && 1806 if (clip_node_owner->render_surface() &&
1830 !PointHitsRect( 1807 !PointHitsRect(
1831 screen_space_point, SurfaceScreenSpaceTransform(clip_node_owner), 1808 screen_space_point, SurfaceScreenSpaceTransform(clip_node_owner),
1832 clip_node_owner->render_surface()->content_rect(), NULL)) { 1809 clip_node_owner->render_surface()->content_rect(), NULL)) {
1833 return true; 1810 return true;
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
2102 2079
2103 void LayerTreeImpl::ResetAllChangeTracking() { 2080 void LayerTreeImpl::ResetAllChangeTracking() {
2104 layers_that_should_push_properties_.clear(); 2081 layers_that_should_push_properties_.clear();
2105 // Iterate over all layers, including masks. 2082 // Iterate over all layers, including masks.
2106 for (auto& layer : *layers_) 2083 for (auto& layer : *layers_)
2107 layer->ResetChangeTracking(); 2084 layer->ResetChangeTracking();
2108 property_trees_.ResetAllChangeTracking(); 2085 property_trees_.ResetAllChangeTracking();
2109 } 2086 }
2110 2087
2111 } // namespace cc 2088 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_impl.h ('k') | cc/trees/layer_tree_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698