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

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

Issue 494823002: Plumb selection edge points through the compositor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Order tweak Created 6 years, 4 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 <limits> 7 #include <limits>
8 #include <set> 8 #include <set>
9 9
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 return data_for_recursion.closest_match; 1336 return data_for_recursion.closest_match;
1337 } 1337 }
1338 1338
1339 void LayerTreeImpl::RegisterSelection(const LayerSelectionBound& start, 1339 void LayerTreeImpl::RegisterSelection(const LayerSelectionBound& start,
1340 const LayerSelectionBound& end) { 1340 const LayerSelectionBound& end) {
1341 selection_start_ = start; 1341 selection_start_ = start;
1342 selection_end_ = end; 1342 selection_end_ = end;
1343 } 1343 }
1344 1344
1345 static ViewportSelectionBound ComputeViewportSelection( 1345 static ViewportSelectionBound ComputeViewportSelection(
1346 const LayerSelectionBound& bound, 1346 const LayerSelectionBound& layer_bound,
1347 LayerImpl* layer, 1347 LayerImpl* layer,
1348 float device_scale_factor) { 1348 float device_scale_factor) {
1349 ViewportSelectionBound result; 1349 ViewportSelectionBound viewport_bound;
1350 result.type = bound.type; 1350 viewport_bound.type = layer_bound.type;
1351 1351
1352 if (!layer || bound.type == SELECTION_BOUND_EMPTY) 1352 if (!layer || layer_bound.type == SELECTION_BOUND_EMPTY)
1353 return result; 1353 return viewport_bound;
1354 1354
1355 gfx::RectF layer_scaled_rect = gfx::ScaleRect( 1355 gfx::PointF layer_scaled_top = gfx::ScalePoint(layer_bound.edge_top,
1356 bound.layer_rect, layer->contents_scale_x(), layer->contents_scale_y()); 1356 layer->contents_scale_x(),
1357 gfx::RectF screen_rect = MathUtil::ProjectClippedRect( 1357 layer->contents_scale_y());
1358 layer->screen_space_transform(), layer_scaled_rect); 1358 gfx::PointF layer_scaled_bottom = gfx::ScalePoint(layer_bound.edge_bottom,
1359 layer->contents_scale_x(),
1360 layer->contents_scale_y());
1359 1361
1360 // The bottom left of the bound is used for visibility because 1) the bound 1362 bool clipped = false;
1361 // edge rect is one-dimensional (no width), and 2) the bottom is the logical 1363 gfx::PointF screen_top = MathUtil::MapPoint(
1364 layer->screen_space_transform(), layer_scaled_top, &clipped);
1365 gfx::PointF screen_bottom = MathUtil::MapPoint(
1366 layer->screen_space_transform(), layer_scaled_bottom, &clipped);
1367
1368 const float inv_scale = 1.f / device_scale_factor;
1369 viewport_bound.edge_top = gfx::ScalePoint(screen_top, inv_scale);
1370 viewport_bound.edge_bottom = gfx::ScalePoint(screen_bottom, inv_scale);
1371
1372 // The bottom edge point is used for visibility testing as it is the logical
1362 // focal point for bound selection handles (this may change in the future). 1373 // focal point for bound selection handles (this may change in the future).
1363 const gfx::PointF& visibility_point = screen_rect.bottom_left(); 1374 // Shifting the visibility point fractionally inward ensures that neighboring
1375 // or logically coincident layers aligned to integral DPI coordinates will not
1376 // spuriously occlude the bound.
1377 gfx::Vector2dF visibility_offset = layer_scaled_top - layer_scaled_bottom;
1378 visibility_offset.Scale(device_scale_factor / visibility_offset.Length());
1379 gfx::PointF visibility_point = layer_scaled_bottom + visibility_offset;
1380 if (visibility_point.x() <= 0)
1381 visibility_point.set_x(visibility_point.x() + device_scale_factor);
1382 visibility_point = MathUtil::MapPoint(
1383 layer->screen_space_transform(), visibility_point, &clipped);
1384
1364 float intersect_distance = 0.f; 1385 float intersect_distance = 0.f;
1365 result.visible = PointHitsLayer(layer, visibility_point, &intersect_distance); 1386 viewport_bound.visible =
1387 PointHitsLayer(layer, visibility_point, &intersect_distance);
1366 1388
1367 screen_rect.Scale(1.f / device_scale_factor); 1389 return viewport_bound;
1368 result.viewport_rect = screen_rect;
1369
1370 return result;
1371 } 1390 }
1372 1391
1373 void LayerTreeImpl::GetViewportSelection(ViewportSelectionBound* start, 1392 void LayerTreeImpl::GetViewportSelection(ViewportSelectionBound* start,
1374 ViewportSelectionBound* end) { 1393 ViewportSelectionBound* end) {
1375 DCHECK(start); 1394 DCHECK(start);
1376 DCHECK(end); 1395 DCHECK(end);
1377 1396
1378 *start = ComputeViewportSelection( 1397 *start = ComputeViewportSelection(
1379 selection_start_, 1398 selection_start_,
1380 selection_start_.layer_id ? LayerById(selection_start_.layer_id) : NULL, 1399 selection_start_.layer_id ? LayerById(selection_start_.layer_id) : NULL,
(...skipping 15 matching lines...) Expand all
1396 1415
1397 void LayerTreeImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { 1416 void LayerTreeImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) {
1398 layer_tree_host_impl_->UnregisterPictureLayerImpl(layer); 1417 layer_tree_host_impl_->UnregisterPictureLayerImpl(layer);
1399 } 1418 }
1400 1419
1401 void LayerTreeImpl::InputScrollAnimationFinished() { 1420 void LayerTreeImpl::InputScrollAnimationFinished() {
1402 layer_tree_host_impl_->ScrollEnd(); 1421 layer_tree_host_impl_->ScrollEnd();
1403 } 1422 }
1404 1423
1405 } // namespace cc 1424 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698