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

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

Issue 595593002: Splitting of layers for correct intersections (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
11 #include "cc/layers/heads_up_display_layer_impl.h" 11 #include "cc/layers/heads_up_display_layer_impl.h"
12 #include "cc/layers/layer.h" 12 #include "cc/layers/layer.h"
13 #include "cc/layers/layer_impl.h" 13 #include "cc/layers/layer_impl.h"
14 #include "cc/layers/layer_iterator.h" 14 #include "cc/layers/layer_iterator.h"
15 #include "cc/layers/render_surface.h" 15 #include "cc/layers/render_surface.h"
16 #include "cc/layers/render_surface_impl.h" 16 #include "cc/layers/render_surface_impl.h"
17 #include "cc/trees/draw_property_utils.h" 17 #include "cc/trees/draw_property_utils.h"
18 #include "cc/trees/layer_sorter.h"
19 #include "cc/trees/layer_tree_host.h" 18 #include "cc/trees/layer_tree_host.h"
20 #include "cc/trees/layer_tree_impl.h" 19 #include "cc/trees/layer_tree_impl.h"
21 #include "ui/gfx/geometry/rect_conversions.h" 20 #include "ui/gfx/geometry/rect_conversions.h"
22 #include "ui/gfx/geometry/vector2d_conversions.h" 21 #include "ui/gfx/geometry/vector2d_conversions.h"
23 #include "ui/gfx/transform.h" 22 #include "ui/gfx/transform.h"
24 #include "ui/gfx/transform_util.h" 23 #include "ui/gfx/transform_util.h"
25 24
26 namespace cc { 25 namespace cc {
27 26
28 ScrollAndScaleSet::ScrollAndScaleSet() 27 ScrollAndScaleSet::ScrollAndScaleSet()
29 : page_scale_delta(1.f), top_controls_delta(0.f) { 28 : page_scale_delta(1.f), top_controls_delta(0.f) {
30 } 29 }
31 30
32 ScrollAndScaleSet::~ScrollAndScaleSet() {} 31 ScrollAndScaleSet::~ScrollAndScaleSet() {}
33 32
34 static void SortLayers(LayerList::iterator first,
35 LayerList::iterator end,
36 void* layer_sorter) {
37 NOTREACHED();
38 }
39
40 static void SortLayers(LayerImplList::iterator first,
41 LayerImplList::iterator end,
42 LayerSorter* layer_sorter) {
43 DCHECK(layer_sorter);
44 TRACE_EVENT0("cc", "LayerTreeHostCommon::SortLayers");
45 layer_sorter->Sort(first, end);
46 }
47
48 template <typename LayerType> 33 template <typename LayerType>
49 static gfx::Vector2dF GetEffectiveScrollDelta(LayerType* layer) { 34 static gfx::Vector2dF GetEffectiveScrollDelta(LayerType* layer) {
50 // Layer's scroll offset can have an integer part and fractional part. 35 // Layer's scroll offset can have an integer part and fractional part.
51 // Due to Blink's limitation, it only counter-scrolls the position-fixed 36 // Due to Blink's limitation, it only counter-scrolls the position-fixed
52 // layer using the integer part of Layer's scroll offset. 37 // layer using the integer part of Layer's scroll offset.
53 // CC scrolls the layer using the full scroll offset, so we have to 38 // CC scrolls the layer using the full scroll offset, so we have to
54 // add the ScrollCompensationAdjustment (fractional part of the scroll 39 // add the ScrollCompensationAdjustment (fractional part of the scroll
55 // offset) to the effective scroll delta which is used to counter-scroll 40 // offset) to the effective scroll delta which is used to counter-scroll
56 // the position-fixed layer. 41 // the position-fixed layer.
57 gfx::Vector2dF scroll_delta = 42 gfx::Vector2dF scroll_delta =
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 layer->draw_properties().num_unclipped_descendants = 1257 layer->draw_properties().num_unclipped_descendants =
1273 recursive_data->num_unclipped_descendants; 1258 recursive_data->num_unclipped_descendants;
1274 layer->draw_properties().layer_or_descendant_has_copy_request = 1259 layer->draw_properties().layer_or_descendant_has_copy_request =
1275 recursive_data->layer_or_descendant_has_copy_request; 1260 recursive_data->layer_or_descendant_has_copy_request;
1276 layer->draw_properties().layer_or_descendant_has_input_handler = 1261 layer->draw_properties().layer_or_descendant_has_input_handler =
1277 recursive_data->layer_or_descendant_has_input_handler; 1262 recursive_data->layer_or_descendant_has_input_handler;
1278 } 1263 }
1279 1264
1280 template <typename LayerType> 1265 template <typename LayerType>
1281 struct SubtreeGlobals { 1266 struct SubtreeGlobals {
1282 LayerSorter* layer_sorter;
1283 int max_texture_size; 1267 int max_texture_size;
1284 float device_scale_factor; 1268 float device_scale_factor;
1285 float page_scale_factor; 1269 float page_scale_factor;
1286 const LayerType* page_scale_application_layer; 1270 const LayerType* page_scale_application_layer;
1287 gfx::Vector2dF elastic_overscroll; 1271 gfx::Vector2dF elastic_overscroll;
1288 const LayerType* elastic_overscroll_application_layer; 1272 const LayerType* elastic_overscroll_application_layer;
1289 bool can_adjust_raster_scales; 1273 bool can_adjust_raster_scales;
1290 bool can_render_to_separate_surface; 1274 bool can_render_to_separate_surface;
1291 bool layers_always_allowed_lcd_text; 1275 bool layers_always_allowed_lcd_text;
1292 }; 1276 };
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after
2358 } 2342 }
2359 2343
2360 SavePaintPropertiesLayer(layer); 2344 SavePaintPropertiesLayer(layer);
2361 2345
2362 // If neither this layer nor any of its children were added, early out. 2346 // If neither this layer nor any of its children were added, early out.
2363 if (sorting_start_index == descendants.size()) { 2347 if (sorting_start_index == descendants.size()) {
2364 DCHECK(!render_to_separate_surface || IsRootLayer(layer)); 2348 DCHECK(!render_to_separate_surface || IsRootLayer(layer));
2365 return; 2349 return;
2366 } 2350 }
2367 2351
2368 // If preserves-3d then sort all the descendants in 3D so that they can be
2369 // drawn from back to front. If the preserves-3d property is also set on the
2370 // parent then skip the sorting as the parent will sort all the descendants
2371 // anyway.
2372 if (globals.layer_sorter && descendants.size() && layer->Is3dSorted() &&
2373 !LayerIsInExisting3DRenderingContext(layer)) {
2374 SortLayers(descendants.begin() + sorting_start_index,
2375 descendants.end(),
2376 globals.layer_sorter);
2377 }
2378
2379 UpdateAccumulatedSurfaceState<LayerType>( 2352 UpdateAccumulatedSurfaceState<LayerType>(
2380 layer, local_drawable_content_rect_of_subtree, accumulated_surface_state); 2353 layer, local_drawable_content_rect_of_subtree, accumulated_surface_state);
2381 2354
2382 if (layer->HasContributingDelegatedRenderPasses()) { 2355 if (layer->HasContributingDelegatedRenderPasses()) {
2383 layer->render_target()->render_surface()-> 2356 layer->render_target()->render_surface()->
2384 AddContributingDelegatedRenderPassLayer(layer); 2357 AddContributingDelegatedRenderPassLayer(layer);
2385 } 2358 }
2386 } // NOLINT(readability/fn_size) 2359 } // NOLINT(readability/fn_size)
2387 2360
2388 template <typename LayerType, typename RenderSurfaceLayerListType> 2361 template <typename LayerType, typename RenderSurfaceLayerListType>
(...skipping 17 matching lines...) Expand all
2406 MathUtil::ComputeTransform2dScaleComponents(inputs.device_transform, 1.f); 2379 MathUtil::ComputeTransform2dScaleComponents(inputs.device_transform, 1.f);
2407 // Not handling the rare case of different x and y device scale. 2380 // Not handling the rare case of different x and y device scale.
2408 float device_transform_scale = 2381 float device_transform_scale =
2409 std::max(device_transform_scale_components.x(), 2382 std::max(device_transform_scale_components.x(),
2410 device_transform_scale_components.y()); 2383 device_transform_scale_components.y());
2411 2384
2412 gfx::Transform scaled_device_transform = inputs.device_transform; 2385 gfx::Transform scaled_device_transform = inputs.device_transform;
2413 scaled_device_transform.Scale(inputs.device_scale_factor, 2386 scaled_device_transform.Scale(inputs.device_scale_factor,
2414 inputs.device_scale_factor); 2387 inputs.device_scale_factor);
2415 2388
2416 globals->layer_sorter = NULL;
2417 globals->max_texture_size = inputs.max_texture_size; 2389 globals->max_texture_size = inputs.max_texture_size;
2418 globals->device_scale_factor = 2390 globals->device_scale_factor =
2419 inputs.device_scale_factor * device_transform_scale; 2391 inputs.device_scale_factor * device_transform_scale;
2420 globals->page_scale_factor = inputs.page_scale_factor; 2392 globals->page_scale_factor = inputs.page_scale_factor;
2421 globals->page_scale_application_layer = inputs.page_scale_application_layer; 2393 globals->page_scale_application_layer = inputs.page_scale_application_layer;
2422 globals->elastic_overscroll = inputs.elastic_overscroll; 2394 globals->elastic_overscroll = inputs.elastic_overscroll;
2423 globals->elastic_overscroll_application_layer = 2395 globals->elastic_overscroll_application_layer =
2424 inputs.elastic_overscroll_application_layer; 2396 inputs.elastic_overscroll_application_layer;
2425 globals->can_render_to_separate_surface = 2397 globals->can_render_to_separate_surface =
2426 inputs.can_render_to_separate_surface; 2398 inputs.can_render_to_separate_surface;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
2563 } 2535 }
2564 } 2536 }
2565 2537
2566 void LayerTreeHostCommon::CalculateDrawProperties( 2538 void LayerTreeHostCommon::CalculateDrawProperties(
2567 CalcDrawPropsImplInputs* inputs) { 2539 CalcDrawPropsImplInputs* inputs) {
2568 LayerImplList dummy_layer_list; 2540 LayerImplList dummy_layer_list;
2569 SubtreeGlobals<LayerImpl> globals; 2541 SubtreeGlobals<LayerImpl> globals;
2570 DataForRecursion<LayerImpl> data_for_recursion; 2542 DataForRecursion<LayerImpl> data_for_recursion;
2571 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); 2543 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion);
2572 2544
2573 LayerSorter layer_sorter;
2574 globals.layer_sorter = &layer_sorter;
2575
2576 PreCalculateMetaInformationRecursiveData recursive_data; 2545 PreCalculateMetaInformationRecursiveData recursive_data;
2577 PreCalculateMetaInformation(inputs->root_layer, &recursive_data); 2546 PreCalculateMetaInformation(inputs->root_layer, &recursive_data);
2578 std::vector<AccumulatedSurfaceState<LayerImpl>> accumulated_surface_state; 2547 std::vector<AccumulatedSurfaceState<LayerImpl>> accumulated_surface_state;
2579 CalculateDrawPropertiesInternal<LayerImpl>( 2548 CalculateDrawPropertiesInternal<LayerImpl>(
2580 inputs->root_layer, 2549 inputs->root_layer,
2581 globals, 2550 globals,
2582 data_for_recursion, 2551 data_for_recursion,
2583 inputs->render_surface_layer_list, 2552 inputs->render_surface_layer_list,
2584 &dummy_layer_list, 2553 &dummy_layer_list,
2585 &accumulated_surface_state, 2554 &accumulated_surface_state,
2586 inputs->current_render_surface_layer_list_id); 2555 inputs->current_render_surface_layer_list_id);
2587 2556
2588 // The dummy layer list should not have been used. 2557 // The dummy layer list should not have been used.
2589 DCHECK_EQ(0u, dummy_layer_list.size()); 2558 DCHECK_EQ(0u, dummy_layer_list.size());
2590 // A root layer render_surface should always exist after 2559 // A root layer render_surface should always exist after
2591 // CalculateDrawProperties. 2560 // CalculateDrawProperties.
2592 DCHECK(inputs->root_layer->render_surface()); 2561 DCHECK(inputs->root_layer->render_surface());
2593 } 2562 }
2594 2563
2595 } // namespace cc 2564 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698