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

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

Issue 1314943008: cc: Remove implicit conversions from Rect to RectF in src/cc/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
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 <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 10
(...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 } 1224 }
1225 1225
1226 template <typename LayerType> 1226 template <typename LayerType>
1227 static inline bool LayerClipsSubtree(LayerType* layer) { 1227 static inline bool LayerClipsSubtree(LayerType* layer) {
1228 return layer->masks_to_bounds() || layer->mask_layer(); 1228 return layer->masks_to_bounds() || layer->mask_layer();
1229 } 1229 }
1230 1230
1231 static bool PointHitsRect( 1231 static bool PointHitsRect(
1232 const gfx::PointF& screen_space_point, 1232 const gfx::PointF& screen_space_point,
1233 const gfx::Transform& local_space_to_screen_space_transform, 1233 const gfx::Transform& local_space_to_screen_space_transform,
1234 const gfx::RectF& local_space_rect, 1234 const gfx::Rect& local_space_rect,
1235 float* distance_to_camera) { 1235 float* distance_to_camera) {
1236 // If the transform is not invertible, then assume that this point doesn't hit 1236 // If the transform is not invertible, then assume that this point doesn't hit
1237 // this rect. 1237 // this rect.
1238 gfx::Transform inverse_local_space_to_screen_space( 1238 gfx::Transform inverse_local_space_to_screen_space(
1239 gfx::Transform::kSkipInitialization); 1239 gfx::Transform::kSkipInitialization);
1240 if (!local_space_to_screen_space_transform.GetInverse( 1240 if (!local_space_to_screen_space_transform.GetInverse(
1241 &inverse_local_space_to_screen_space)) 1241 &inverse_local_space_to_screen_space))
1242 return false; 1242 return false;
1243 1243
1244 // Transform the hit test point from screen space to the local space of the 1244 // Transform the hit test point from screen space to the local space of the
1245 // given rect. 1245 // given rect.
1246 bool clipped = false; 1246 bool clipped = false;
1247 gfx::Point3F planar_point = MathUtil::ProjectPoint3D( 1247 gfx::Point3F planar_point = MathUtil::ProjectPoint3D(
1248 inverse_local_space_to_screen_space, screen_space_point, &clipped); 1248 inverse_local_space_to_screen_space, screen_space_point, &clipped);
1249 gfx::PointF hit_test_point_in_local_space = 1249 gfx::PointF hit_test_point_in_local_space =
1250 gfx::PointF(planar_point.x(), planar_point.y()); 1250 gfx::PointF(planar_point.x(), planar_point.y());
1251 1251
1252 // If ProjectPoint could not project to a valid value, then we assume that 1252 // If ProjectPoint could not project to a valid value, then we assume that
1253 // this point doesn't hit this rect. 1253 // this point doesn't hit this rect.
1254 if (clipped) 1254 if (clipped)
1255 return false; 1255 return false;
1256 1256
1257 if (!local_space_rect.Contains(hit_test_point_in_local_space)) 1257 if (!gfx::RectF(local_space_rect).Contains(hit_test_point_in_local_space))
1258 return false; 1258 return false;
1259 1259
1260 if (distance_to_camera) { 1260 if (distance_to_camera) {
1261 // To compute the distance to the camera, we have to take the planar point 1261 // To compute the distance to the camera, we have to take the planar point
1262 // and pull it back to world space and compute the displacement along the 1262 // and pull it back to world space and compute the displacement along the
1263 // z-axis. 1263 // z-axis.
1264 gfx::Point3F planar_point_in_screen_space(planar_point); 1264 gfx::Point3F planar_point_in_screen_space(planar_point);
1265 local_space_to_screen_space_transform.TransformPoint( 1265 local_space_to_screen_space_transform.TransformPoint(
1266 &planar_point_in_screen_space); 1266 &planar_point_in_screen_space);
1267 *distance_to_camera = planar_point_in_screen_space.z(); 1267 *distance_to_camera = planar_point_in_screen_space.z();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1323 } 1323 }
1324 1324
1325 // If we have finished walking all ancestors without having already exited, 1325 // If we have finished walking all ancestors without having already exited,
1326 // then the point is not clipped by any ancestors. 1326 // then the point is not clipped by any ancestors.
1327 return false; 1327 return false;
1328 } 1328 }
1329 1329
1330 static bool PointHitsLayer(const LayerImpl* layer, 1330 static bool PointHitsLayer(const LayerImpl* layer,
1331 const gfx::PointF& screen_space_point, 1331 const gfx::PointF& screen_space_point,
1332 float* distance_to_intersection) { 1332 float* distance_to_intersection) {
1333 gfx::RectF content_rect(layer->bounds()); 1333 gfx::Rect content_rect(layer->bounds());
1334 if (!PointHitsRect(screen_space_point, 1334 if (!PointHitsRect(screen_space_point,
1335 layer->screen_space_transform(), 1335 layer->screen_space_transform(),
1336 content_rect, 1336 content_rect,
1337 distance_to_intersection)) 1337 distance_to_intersection))
1338 return false; 1338 return false;
1339 1339
1340 // At this point, we think the point does hit the layer, but we need to walk 1340 // At this point, we think the point does hit the layer, but we need to walk
1341 // up the parents to ensure that the layer was not clipped in such a way 1341 // up the parents to ensure that the layer was not clipped in such a way
1342 // that the hit point actually should not hit the layer. 1342 // that the hit point actually should not hit the layer.
1343 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer)) 1343 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer))
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1754 const gfx::BoxF& box, 1754 const gfx::BoxF& box,
1755 gfx::BoxF* bounds) const { 1755 gfx::BoxF* bounds) const {
1756 *bounds = gfx::BoxF(); 1756 *bounds = gfx::BoxF();
1757 return layer_tree_host_impl_->animation_host() 1757 return layer_tree_host_impl_->animation_host()
1758 ? layer_tree_host_impl_->animation_host() 1758 ? layer_tree_host_impl_->animation_host()
1759 ->TransformAnimationBoundsForBox(layer->id(), box, bounds) 1759 ->TransformAnimationBoundsForBox(layer->id(), box, bounds)
1760 : true; 1760 : true;
1761 } 1761 }
1762 1762
1763 } // namespace cc 1763 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698