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

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

Issue 12967018: cc: Avoid pointless gfx::Point/Size contructors when making Rects. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: RectFs as well Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « cc/trees/damage_tracker_unittest.cc ('k') | cc/trees/layer_tree_host_common_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_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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 // be cached instead of computing it redundantly for every layer. 163 // be cached instead of computing it redundantly for every layer.
164 visible_rect_in_target_surface_space.Intersect( 164 visible_rect_in_target_surface_space.Intersect(
165 ancestor_clip_rect_in_descendant_surface_space); 165 ancestor_clip_rect_in_descendant_surface_space);
166 } 166 }
167 167
168 if (visible_rect_in_target_surface_space.IsEmpty()) 168 if (visible_rect_in_target_surface_space.IsEmpty())
169 return gfx::Rect(); 169 return gfx::Rect();
170 170
171 return CalculateVisibleRectWithCachedLayerRect( 171 return CalculateVisibleRectWithCachedLayerRect(
172 visible_rect_in_target_surface_space, 172 visible_rect_in_target_surface_space,
173 gfx::Rect(gfx::Point(), layer->content_bounds()), 173 gfx::Rect(layer->content_bounds()),
174 layer_rect_in_target_space, 174 layer_rect_in_target_space,
175 layer->draw_transform()); 175 layer->draw_transform());
176 } 176 }
177 177
178 static inline bool TransformToParentIsKnown(LayerImpl* layer) { return true; } 178 static inline bool TransformToParentIsKnown(LayerImpl* layer) { return true; }
179 179
180 static inline bool TransformToParentIsKnown(Layer* layer) { 180 static inline bool TransformToParentIsKnown(Layer* layer) {
181 181
182 return !layer->TransformIsAnimating(); 182 return !layer->TransformIsAnimating();
183 } 183 }
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 // causes jank. 880 // causes jank.
881 bool adjust_text_aa = 881 bool adjust_text_aa =
882 !animating_opacity_to_screen && !animating_transform_to_screen; 882 !animating_opacity_to_screen && !animating_transform_to_screen;
883 // To avoid color fringing, LCD text should only be used on opaque layers with 883 // To avoid color fringing, LCD text should only be used on opaque layers with
884 // just integral translation. 884 // just integral translation.
885 bool layer_can_use_lcd_text = 885 bool layer_can_use_lcd_text =
886 subtree_can_use_lcd_text && (accumulated_draw_opacity == 1.f) && 886 subtree_can_use_lcd_text && (accumulated_draw_opacity == 1.f) &&
887 layer_draw_properties.target_space_transform. 887 layer_draw_properties.target_space_transform.
888 IsIdentityOrIntegerTranslation(); 888 IsIdentityOrIntegerTranslation();
889 889
890 gfx::RectF content_rect(gfx::PointF(), layer->content_bounds()); 890 gfx::RectF content_rect(layer->content_bounds());
891 891
892 // full_hierarchy_matrix is the matrix that transforms objects between screen 892 // full_hierarchy_matrix is the matrix that transforms objects between screen
893 // space (except projection matrix) and the most recent RenderSurfaceImpl's 893 // space (except projection matrix) and the most recent RenderSurfaceImpl's
894 // space. next_hierarchy_matrix will only change if this layer uses a new 894 // space. next_hierarchy_matrix will only change if this layer uses a new
895 // RenderSurfaceImpl, otherwise remains the same. 895 // RenderSurfaceImpl, otherwise remains the same.
896 gfx::Transform next_hierarchy_matrix = full_hierarchy_matrix; 896 gfx::Transform next_hierarchy_matrix = full_hierarchy_matrix;
897 gfx::Transform sublayer_matrix; 897 gfx::Transform sublayer_matrix;
898 898
899 gfx::Vector2dF render_surface_sublayer_scale = 899 gfx::Vector2dF render_surface_sublayer_scale =
900 MathUtil::ComputeTransform2dScaleComponents( 900 MathUtil::ComputeTransform2dScaleComponents(
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 // the tree. This way, we can avoid transforming clip rects from ancestor 966 // the tree. This way, we can avoid transforming clip rects from ancestor
967 // target surface space to current target surface space that could cause 967 // target surface space to current target surface space that could cause
968 // more w < 0 headaches. 968 // more w < 0 headaches.
969 subtree_should_be_clipped = false; 969 subtree_should_be_clipped = false;
970 970
971 if (layer->mask_layer()) { 971 if (layer->mask_layer()) {
972 DrawProperties<LayerType, RenderSurfaceType>& mask_layer_draw_properties = 972 DrawProperties<LayerType, RenderSurfaceType>& mask_layer_draw_properties =
973 layer->mask_layer()->draw_properties(); 973 layer->mask_layer()->draw_properties();
974 mask_layer_draw_properties.render_target = layer; 974 mask_layer_draw_properties.render_target = layer;
975 mask_layer_draw_properties.visible_content_rect = 975 mask_layer_draw_properties.visible_content_rect =
976 gfx::Rect(gfx::Point(), layer->content_bounds()); 976 gfx::Rect(layer->content_bounds());
977 } 977 }
978 978
979 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) { 979 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) {
980 DrawProperties<LayerType, RenderSurfaceType>& 980 DrawProperties<LayerType, RenderSurfaceType>&
981 replica_mask_draw_properties = 981 replica_mask_draw_properties =
982 layer->replica_layer()->mask_layer()->draw_properties(); 982 layer->replica_layer()->mask_layer()->draw_properties();
983 replica_mask_draw_properties.render_target = layer; 983 replica_mask_draw_properties.render_target = layer;
984 replica_mask_draw_properties.visible_content_rect = 984 replica_mask_draw_properties.visible_content_rect =
985 gfx::Rect(gfx::Point(), layer->content_bounds()); 985 gfx::Rect(layer->content_bounds());
986 } 986 }
987 987
988 // TODO(senorblanco): make this smarter for the SkImageFilter case (check 988 // TODO(senorblanco): make this smarter for the SkImageFilter case (check
989 // for pixel-moving filters) 989 // for pixel-moving filters)
990 if (layer->filters().hasFilterThatMovesPixels() || layer->filter()) 990 if (layer->filters().hasFilterThatMovesPixels() || layer->filter())
991 nearest_ancestor_that_moves_pixels = render_surface; 991 nearest_ancestor_that_moves_pixels = render_surface;
992 992
993 // The render surface clip rect is expressed in the space where this surface 993 // The render surface clip rect is expressed in the space where this surface
994 // draws, i.e. the same space as clip_rect_from_ancestor. 994 // draws, i.e. the same space as clip_rect_from_ancestor.
995 render_surface->SetIsClipped(ancestor_clips_subtree); 995 render_surface->SetIsClipped(ancestor_clips_subtree);
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 std::vector<scoped_refptr<Layer> >* render_surface_layer_list) { 1295 std::vector<scoped_refptr<Layer> >* render_surface_layer_list) {
1296 gfx::Rect total_drawable_content_rect; 1296 gfx::Rect total_drawable_content_rect;
1297 gfx::Transform identity_matrix; 1297 gfx::Transform identity_matrix;
1298 gfx::Transform device_scale_transform; 1298 gfx::Transform device_scale_transform;
1299 device_scale_transform.Scale(device_scale_factor, device_scale_factor); 1299 device_scale_transform.Scale(device_scale_factor, device_scale_factor);
1300 std::vector<scoped_refptr<Layer> > dummy_layer_list; 1300 std::vector<scoped_refptr<Layer> > dummy_layer_list;
1301 1301
1302 // The root layer's render_surface should receive the device viewport as the 1302 // The root layer's render_surface should receive the device viewport as the
1303 // initial clip rect. 1303 // initial clip rect.
1304 bool subtree_should_be_clipped = true; 1304 bool subtree_should_be_clipped = true;
1305 gfx::Rect device_viewport_rect(gfx::Point(), device_viewport_size); 1305 gfx::Rect device_viewport_rect(device_viewport_size);
1306 bool update_tile_priorities = false; 1306 bool update_tile_priorities = false;
1307 1307
1308 // This function should have received a root layer. 1308 // This function should have received a root layer.
1309 DCHECK(IsRootLayer(root_layer)); 1309 DCHECK(IsRootLayer(root_layer));
1310 1310
1311 PreCalculateMetaInformation<Layer>(root_layer); 1311 PreCalculateMetaInformation<Layer>(root_layer);
1312 CalculateDrawPropertiesInternal<Layer, 1312 CalculateDrawPropertiesInternal<Layer,
1313 std::vector<scoped_refptr<Layer> >, 1313 std::vector<scoped_refptr<Layer> >,
1314 RenderSurface>(root_layer, 1314 RenderSurface>(root_layer,
1315 device_scale_transform, 1315 device_scale_transform,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1348 gfx::Rect total_drawable_content_rect; 1348 gfx::Rect total_drawable_content_rect;
1349 gfx::Transform identity_matrix; 1349 gfx::Transform identity_matrix;
1350 gfx::Transform device_scale_transform; 1350 gfx::Transform device_scale_transform;
1351 device_scale_transform.Scale(device_scale_factor, device_scale_factor); 1351 device_scale_transform.Scale(device_scale_factor, device_scale_factor);
1352 std::vector<LayerImpl*> dummy_layer_list; 1352 std::vector<LayerImpl*> dummy_layer_list;
1353 LayerSorter layer_sorter; 1353 LayerSorter layer_sorter;
1354 1354
1355 // The root layer's render_surface should receive the device viewport as the 1355 // The root layer's render_surface should receive the device viewport as the
1356 // initial clip rect. 1356 // initial clip rect.
1357 bool subtree_should_be_clipped = true; 1357 bool subtree_should_be_clipped = true;
1358 gfx::Rect device_viewport_rect(gfx::Point(), device_viewport_size); 1358 gfx::Rect device_viewport_rect(device_viewport_size);
1359 1359
1360 // This function should have received a root layer. 1360 // This function should have received a root layer.
1361 DCHECK(IsRootLayer(root_layer)); 1361 DCHECK(IsRootLayer(root_layer));
1362 1362
1363 PreCalculateMetaInformation<LayerImpl>(root_layer); 1363 PreCalculateMetaInformation<LayerImpl>(root_layer);
1364 CalculateDrawPropertiesInternal<LayerImpl, 1364 CalculateDrawPropertiesInternal<LayerImpl,
1365 std::vector<LayerImpl*>, 1365 std::vector<LayerImpl*>,
1366 RenderSurfaceImpl>( 1366 RenderSurfaceImpl>(
1367 root_layer, 1367 root_layer,
1368 device_scale_transform, 1368 device_scale_transform,
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 for (LayerIteratorType 1493 for (LayerIteratorType
1494 it = LayerIteratorType::Begin(&render_surface_layer_list); 1494 it = LayerIteratorType::Begin(&render_surface_layer_list);
1495 it != end; 1495 it != end;
1496 ++it) { 1496 ++it) {
1497 // We don't want to consider render_surfaces for hit testing. 1497 // We don't want to consider render_surfaces for hit testing.
1498 if (!it.represents_itself()) 1498 if (!it.represents_itself())
1499 continue; 1499 continue;
1500 1500
1501 LayerImpl* current_layer = (*it); 1501 LayerImpl* current_layer = (*it);
1502 1502
1503 gfx::RectF content_rect(gfx::PointF(), current_layer->content_bounds()); 1503 gfx::RectF content_rect(current_layer->content_bounds());
1504 if (!PointHitsRect(screen_space_point, 1504 if (!PointHitsRect(screen_space_point,
1505 current_layer->screen_space_transform(), 1505 current_layer->screen_space_transform(),
1506 content_rect)) 1506 content_rect))
1507 continue; 1507 continue;
1508 1508
1509 // At this point, we think the point does hit the layer, but we need to walk 1509 // At this point, we think the point does hit the layer, but we need to walk
1510 // up the parents to ensure that the layer was not clipped in such a way 1510 // up the parents to ensure that the layer was not clipped in such a way
1511 // that the hit point actually should not hit the layer. 1511 // that the hit point actually should not hit the layer.
1512 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, current_layer)) 1512 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, current_layer))
1513 continue; 1513 continue;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 // At this point, we think the point does hit the touch event handler region 1574 // 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 1575 // 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 1576 // was not clipped in such a way that the hit point actually should not hit
1577 // the layer. 1577 // the layer.
1578 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) 1578 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl))
1579 return false; 1579 return false;
1580 1580
1581 return true; 1581 return true;
1582 } 1582 }
1583 } // namespace cc 1583 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/damage_tracker_unittest.cc ('k') | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698