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

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: Rebase 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
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('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 <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 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 return data_for_recursion.closest_match; 1327 return data_for_recursion.closest_match;
1328 } 1328 }
1329 1329
1330 void LayerTreeImpl::RegisterSelection(const LayerSelectionBound& start, 1330 void LayerTreeImpl::RegisterSelection(const LayerSelectionBound& start,
1331 const LayerSelectionBound& end) { 1331 const LayerSelectionBound& end) {
1332 selection_start_ = start; 1332 selection_start_ = start;
1333 selection_end_ = end; 1333 selection_end_ = end;
1334 } 1334 }
1335 1335
1336 static ViewportSelectionBound ComputeViewportSelection( 1336 static ViewportSelectionBound ComputeViewportSelection(
1337 const LayerSelectionBound& bound, 1337 const LayerSelectionBound& layer_bound,
1338 LayerImpl* layer, 1338 LayerImpl* layer,
1339 float device_scale_factor) { 1339 float device_scale_factor) {
1340 ViewportSelectionBound result; 1340 ViewportSelectionBound viewport_bound;
1341 result.type = bound.type; 1341 viewport_bound.type = layer_bound.type;
1342 1342
1343 if (!layer || bound.type == SELECTION_BOUND_EMPTY) 1343 if (!layer || layer_bound.type == SELECTION_BOUND_EMPTY)
1344 return result; 1344 return viewport_bound;
1345 1345
1346 gfx::RectF layer_scaled_rect = gfx::ScaleRect( 1346 gfx::PointF layer_scaled_top = gfx::ScalePoint(layer_bound.edge_top,
1347 bound.layer_rect, layer->contents_scale_x(), layer->contents_scale_y()); 1347 layer->contents_scale_x(),
1348 gfx::RectF screen_rect = MathUtil::ProjectClippedRect( 1348 layer->contents_scale_y());
1349 layer->screen_space_transform(), layer_scaled_rect); 1349 gfx::PointF layer_scaled_bottom = gfx::ScalePoint(layer_bound.edge_bottom,
1350 layer->contents_scale_x(),
1351 layer->contents_scale_y());
1350 1352
1351 // The bottom left of the bound is used for visibility because 1) the bound 1353 bool clipped = false;
1352 // edge rect is one-dimensional (no width), and 2) the bottom is the logical 1354 gfx::PointF screen_top = MathUtil::MapPoint(
1355 layer->screen_space_transform(), layer_scaled_top, &clipped);
1356 gfx::PointF screen_bottom = MathUtil::MapPoint(
1357 layer->screen_space_transform(), layer_scaled_bottom, &clipped);
1358
1359 const float inv_scale = 1.f / device_scale_factor;
1360 viewport_bound.edge_top = gfx::ScalePoint(screen_top, inv_scale);
1361 viewport_bound.edge_bottom = gfx::ScalePoint(screen_bottom, inv_scale);
1362
1363 // The bottom edge point is used for visibility testing as it is the logical
1353 // focal point for bound selection handles (this may change in the future). 1364 // focal point for bound selection handles (this may change in the future).
1354 const gfx::PointF& visibility_point = screen_rect.bottom_left(); 1365 // Shifting the visibility point fractionally inward ensures that neighboring
1366 // or logically coincident layers aligned to integral DPI coordinates will not
1367 // spuriously occlude the bound.
1368 gfx::Vector2dF visibility_offset = layer_scaled_top - layer_scaled_bottom;
1369 visibility_offset.Scale(device_scale_factor / visibility_offset.Length());
1370 gfx::PointF visibility_point = layer_scaled_bottom + visibility_offset;
1371 if (visibility_point.x() <= 0)
1372 visibility_point.set_x(visibility_point.x() + device_scale_factor);
1373 visibility_point = MathUtil::MapPoint(
1374 layer->screen_space_transform(), visibility_point, &clipped);
1375
1355 float intersect_distance = 0.f; 1376 float intersect_distance = 0.f;
1356 result.visible = PointHitsLayer(layer, visibility_point, &intersect_distance); 1377 viewport_bound.visible =
1378 PointHitsLayer(layer, visibility_point, &intersect_distance);
1357 1379
1358 screen_rect.Scale(1.f / device_scale_factor); 1380 return viewport_bound;
1359 result.viewport_rect = screen_rect;
1360
1361 return result;
1362 } 1381 }
1363 1382
1364 void LayerTreeImpl::GetViewportSelection(ViewportSelectionBound* start, 1383 void LayerTreeImpl::GetViewportSelection(ViewportSelectionBound* start,
1365 ViewportSelectionBound* end) { 1384 ViewportSelectionBound* end) {
1366 DCHECK(start); 1385 DCHECK(start);
1367 DCHECK(end); 1386 DCHECK(end);
1368 1387
1369 *start = ComputeViewportSelection( 1388 *start = ComputeViewportSelection(
1370 selection_start_, 1389 selection_start_,
1371 selection_start_.layer_id ? LayerById(selection_start_.layer_id) : NULL, 1390 selection_start_.layer_id ? LayerById(selection_start_.layer_id) : NULL,
(...skipping 15 matching lines...) Expand all
1387 1406
1388 void LayerTreeImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { 1407 void LayerTreeImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) {
1389 layer_tree_host_impl_->UnregisterPictureLayerImpl(layer); 1408 layer_tree_host_impl_->UnregisterPictureLayerImpl(layer);
1390 } 1409 }
1391 1410
1392 void LayerTreeImpl::InputScrollAnimationFinished() { 1411 void LayerTreeImpl::InputScrollAnimationFinished() {
1393 layer_tree_host_impl_->ScrollEnd(); 1412 layer_tree_host_impl_->ScrollEnd();
1394 } 1413 }
1395 1414
1396 } // namespace cc 1415 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/layer_tree_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698