OLD | NEW |
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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 if (page_scale_layer_ && inner_viewport_scroll_layer_) { | 204 if (page_scale_layer_ && inner_viewport_scroll_layer_) { |
205 target_tree->SetViewportLayersFromIds( | 205 target_tree->SetViewportLayersFromIds( |
206 page_scale_layer_->id(), | 206 page_scale_layer_->id(), |
207 inner_viewport_scroll_layer_->id(), | 207 inner_viewport_scroll_layer_->id(), |
208 outer_viewport_scroll_layer_ ? outer_viewport_scroll_layer_->id() | 208 outer_viewport_scroll_layer_ ? outer_viewport_scroll_layer_->id() |
209 : Layer::INVALID_ID); | 209 : Layer::INVALID_ID); |
210 } else { | 210 } else { |
211 target_tree->ClearViewportLayers(); | 211 target_tree->ClearViewportLayers(); |
212 } | 212 } |
213 | 213 |
214 target_tree->RegisterSelection(selection_anchor_, selection_focus_); | 214 target_tree->RegisterSelection(selection_start_, selection_end_); |
215 | 215 |
216 // This should match the property synchronization in | 216 // This should match the property synchronization in |
217 // LayerTreeHost::finishCommitOnImplThread(). | 217 // LayerTreeHost::finishCommitOnImplThread(). |
218 target_tree->set_source_frame_number(source_frame_number()); | 218 target_tree->set_source_frame_number(source_frame_number()); |
219 target_tree->set_background_color(background_color()); | 219 target_tree->set_background_color(background_color()); |
220 target_tree->set_has_transparent_background(has_transparent_background()); | 220 target_tree->set_has_transparent_background(has_transparent_background()); |
221 | 221 |
222 if (ContentsTexturesPurged()) | 222 if (ContentsTexturesPurged()) |
223 target_tree->SetContentsTexturesPurged(); | 223 target_tree->SetContentsTexturesPurged(); |
224 else | 224 else |
(...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1304 return NULL; | 1304 return NULL; |
1305 if (!UpdateDrawProperties()) | 1305 if (!UpdateDrawProperties()) |
1306 return NULL; | 1306 return NULL; |
1307 FindTouchEventLayerFunctor func = {screen_space_point}; | 1307 FindTouchEventLayerFunctor func = {screen_space_point}; |
1308 FindClosestMatchingLayerDataForRecursion data_for_recursion; | 1308 FindClosestMatchingLayerDataForRecursion data_for_recursion; |
1309 FindClosestMatchingLayer( | 1309 FindClosestMatchingLayer( |
1310 screen_space_point, root_layer(), func, &data_for_recursion); | 1310 screen_space_point, root_layer(), func, &data_for_recursion); |
1311 return data_for_recursion.closest_match; | 1311 return data_for_recursion.closest_match; |
1312 } | 1312 } |
1313 | 1313 |
1314 void LayerTreeImpl::RegisterSelection(const LayerSelectionBound& anchor, | 1314 void LayerTreeImpl::RegisterSelection(const LayerSelectionBound& start, |
1315 const LayerSelectionBound& focus) { | 1315 const LayerSelectionBound& end) { |
1316 selection_anchor_ = anchor; | 1316 selection_start_ = start; |
1317 selection_focus_ = focus; | 1317 selection_end_ = end; |
1318 } | 1318 } |
1319 | 1319 |
1320 static ViewportSelectionBound ComputeViewportSelection( | 1320 static ViewportSelectionBound ComputeViewportSelection( |
1321 const LayerSelectionBound& bound, | 1321 const LayerSelectionBound& bound, |
1322 LayerImpl* layer, | 1322 LayerImpl* layer, |
1323 float device_scale_factor) { | 1323 float device_scale_factor) { |
1324 ViewportSelectionBound result; | 1324 ViewportSelectionBound result; |
1325 result.type = bound.type; | 1325 result.type = bound.type; |
1326 | 1326 |
1327 if (!layer || bound.type == SELECTION_BOUND_EMPTY) | 1327 if (!layer || bound.type == SELECTION_BOUND_EMPTY) |
(...skipping 10 matching lines...) Expand all Loading... |
1338 const gfx::PointF& visibility_point = screen_rect.bottom_left(); | 1338 const gfx::PointF& visibility_point = screen_rect.bottom_left(); |
1339 float intersect_distance = 0.f; | 1339 float intersect_distance = 0.f; |
1340 result.visible = PointHitsLayer(layer, visibility_point, &intersect_distance); | 1340 result.visible = PointHitsLayer(layer, visibility_point, &intersect_distance); |
1341 | 1341 |
1342 screen_rect.Scale(1.f / device_scale_factor); | 1342 screen_rect.Scale(1.f / device_scale_factor); |
1343 result.viewport_rect = screen_rect; | 1343 result.viewport_rect = screen_rect; |
1344 | 1344 |
1345 return result; | 1345 return result; |
1346 } | 1346 } |
1347 | 1347 |
1348 void LayerTreeImpl::GetViewportSelection(ViewportSelectionBound* anchor, | 1348 void LayerTreeImpl::GetViewportSelection(ViewportSelectionBound* start, |
1349 ViewportSelectionBound* focus) { | 1349 ViewportSelectionBound* end) { |
1350 DCHECK(anchor); | 1350 DCHECK(start); |
1351 DCHECK(focus); | 1351 DCHECK(end); |
1352 | 1352 |
1353 *anchor = ComputeViewportSelection( | 1353 *start = ComputeViewportSelection( |
1354 selection_anchor_, | 1354 selection_start_, |
1355 selection_anchor_.layer_id ? LayerById(selection_anchor_.layer_id) : NULL, | 1355 selection_start_.layer_id ? LayerById(selection_start_.layer_id) : NULL, |
1356 device_scale_factor()); | 1356 device_scale_factor()); |
1357 if (anchor->type == SELECTION_BOUND_CENTER || | 1357 if (start->type == SELECTION_BOUND_CENTER || |
1358 anchor->type == SELECTION_BOUND_EMPTY) { | 1358 start->type == SELECTION_BOUND_EMPTY) { |
1359 *focus = *anchor; | 1359 *end = *start; |
1360 } else { | 1360 } else { |
1361 *focus = ComputeViewportSelection( | 1361 *end = ComputeViewportSelection( |
1362 selection_focus_, | 1362 selection_end_, |
1363 selection_focus_.layer_id ? LayerById(selection_focus_.layer_id) : NULL, | 1363 selection_end_.layer_id ? LayerById(selection_end_.layer_id) : NULL, |
1364 device_scale_factor()); | 1364 device_scale_factor()); |
1365 } | 1365 } |
1366 } | 1366 } |
1367 | 1367 |
1368 void LayerTreeImpl::RegisterPictureLayerImpl(PictureLayerImpl* layer) { | 1368 void LayerTreeImpl::RegisterPictureLayerImpl(PictureLayerImpl* layer) { |
1369 layer_tree_host_impl_->RegisterPictureLayerImpl(layer); | 1369 layer_tree_host_impl_->RegisterPictureLayerImpl(layer); |
1370 } | 1370 } |
1371 | 1371 |
1372 void LayerTreeImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 1372 void LayerTreeImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
1373 layer_tree_host_impl_->UnregisterPictureLayerImpl(layer); | 1373 layer_tree_host_impl_->UnregisterPictureLayerImpl(layer); |
1374 } | 1374 } |
1375 | 1375 |
1376 } // namespace cc | 1376 } // namespace cc |
OLD | NEW |