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

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: Fixes from issues introduced by the rebase, added tests for video_quads. Created 5 years, 11 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/debug/trace_event.h" 9 #include "base/debug/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"
enne (OOO) 2015/02/04 21:24:00 Can layer sorter get deleted too?
awoloszyn 2015/02/12 16:48:52 Done.
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 23
25 namespace cc { 24 namespace cc {
26 25
27 ScrollAndScaleSet::ScrollAndScaleSet() 26 ScrollAndScaleSet::ScrollAndScaleSet()
28 : page_scale_delta(1.f), top_controls_delta(0.f) { 27 : page_scale_delta(1.f), top_controls_delta(0.f) {
29 } 28 }
30 29
31 ScrollAndScaleSet::~ScrollAndScaleSet() {} 30 ScrollAndScaleSet::~ScrollAndScaleSet() {}
32 31
33 static void SortLayers(LayerList::iterator forst,
34 LayerList::iterator end,
35 void* layer_sorter) {
36 NOTREACHED();
37 }
38
39 static void SortLayers(LayerImplList::iterator first,
40 LayerImplList::iterator end,
41 LayerSorter* layer_sorter) {
42 DCHECK(layer_sorter);
43 TRACE_EVENT0("cc", "LayerTreeHostCommon::SortLayers");
44 layer_sorter->Sort(first, end);
45 }
46
47 template <typename LayerType> 32 template <typename LayerType>
48 static gfx::Vector2dF GetEffectiveScrollDelta(LayerType* layer) { 33 static gfx::Vector2dF GetEffectiveScrollDelta(LayerType* layer) {
49 gfx::Vector2dF scroll_delta = layer->ScrollDelta(); 34 gfx::Vector2dF scroll_delta = layer->ScrollDelta();
50 // The scroll parent's scroll delta is the amount we've scrolled on the 35 // The scroll parent's scroll delta is the amount we've scrolled on the
51 // compositor thread since the commit for this layer tree's source frame. 36 // compositor thread since the commit for this layer tree's source frame.
52 // we last reported to the main thread. I.e., it's the discrepancy between 37 // we last reported to the main thread. I.e., it's the discrepancy between
53 // a scroll parent's scroll delta and offset, so we must add it here. 38 // a scroll parent's scroll delta and offset, so we must add it here.
54 if (layer->scroll_parent()) 39 if (layer->scroll_parent())
55 scroll_delta += layer->scroll_parent()->ScrollDelta(); 40 scroll_delta += layer->scroll_parent()->ScrollDelta();
56 return scroll_delta; 41 return scroll_delta;
(...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 recursive_data->layer_or_descendant_has_input_handler; 1247 recursive_data->layer_or_descendant_has_input_handler;
1263 } 1248 }
1264 1249
1265 static void RoundTranslationComponents(gfx::Transform* transform) { 1250 static void RoundTranslationComponents(gfx::Transform* transform) {
1266 transform->matrix().set(0, 3, MathUtil::Round(transform->matrix().get(0, 3))); 1251 transform->matrix().set(0, 3, MathUtil::Round(transform->matrix().get(0, 3)));
1267 transform->matrix().set(1, 3, MathUtil::Round(transform->matrix().get(1, 3))); 1252 transform->matrix().set(1, 3, MathUtil::Round(transform->matrix().get(1, 3)));
1268 } 1253 }
1269 1254
1270 template <typename LayerType> 1255 template <typename LayerType>
1271 struct SubtreeGlobals { 1256 struct SubtreeGlobals {
1272 LayerSorter* layer_sorter;
1273 int max_texture_size; 1257 int max_texture_size;
1274 float device_scale_factor; 1258 float device_scale_factor;
1275 float page_scale_factor; 1259 float page_scale_factor;
1276 const LayerType* page_scale_application_layer; 1260 const LayerType* page_scale_application_layer;
1277 gfx::Vector2dF elastic_overscroll; 1261 gfx::Vector2dF elastic_overscroll;
1278 const LayerType* elastic_overscroll_application_layer; 1262 const LayerType* elastic_overscroll_application_layer;
1279 bool can_adjust_raster_scales; 1263 bool can_adjust_raster_scales;
1280 bool can_render_to_separate_surface; 1264 bool can_render_to_separate_surface;
1281 bool layers_always_allowed_lcd_text; 1265 bool layers_always_allowed_lcd_text;
1282 }; 1266 };
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
2351 } 2335 }
2352 2336
2353 SavePaintPropertiesLayer(layer); 2337 SavePaintPropertiesLayer(layer);
2354 2338
2355 // If neither this layer nor any of its children were added, early out. 2339 // If neither this layer nor any of its children were added, early out.
2356 if (sorting_start_index == descendants.size()) { 2340 if (sorting_start_index == descendants.size()) {
2357 DCHECK(!render_to_separate_surface || IsRootLayer(layer)); 2341 DCHECK(!render_to_separate_surface || IsRootLayer(layer));
2358 return; 2342 return;
2359 } 2343 }
2360 2344
2361 // If preserves-3d then sort all the descendants in 3D so that they can be
2362 // drawn from back to front. If the preserves-3d property is also set on the
2363 // parent then skip the sorting as the parent will sort all the descendants
2364 // anyway.
2365 if (globals.layer_sorter && descendants.size() && layer->Is3dSorted() &&
2366 !LayerIsInExisting3DRenderingContext(layer)) {
2367 SortLayers(descendants.begin() + sorting_start_index,
2368 descendants.end(),
2369 globals.layer_sorter);
2370 }
2371
2372 UpdateAccumulatedSurfaceState<LayerType>( 2345 UpdateAccumulatedSurfaceState<LayerType>(
2373 layer, local_drawable_content_rect_of_subtree, accumulated_surface_state); 2346 layer, local_drawable_content_rect_of_subtree, accumulated_surface_state);
2374 2347
2375 if (layer->HasContributingDelegatedRenderPasses()) { 2348 if (layer->HasContributingDelegatedRenderPasses()) {
2376 layer->render_target()->render_surface()-> 2349 layer->render_target()->render_surface()->
2377 AddContributingDelegatedRenderPassLayer(layer); 2350 AddContributingDelegatedRenderPassLayer(layer);
2378 } 2351 }
2379 } // NOLINT(readability/fn_size) 2352 } // NOLINT(readability/fn_size)
2380 2353
2381 template <typename LayerType, typename RenderSurfaceLayerListType> 2354 template <typename LayerType, typename RenderSurfaceLayerListType>
(...skipping 17 matching lines...) Expand all
2399 MathUtil::ComputeTransform2dScaleComponents(inputs.device_transform, 1.f); 2372 MathUtil::ComputeTransform2dScaleComponents(inputs.device_transform, 1.f);
2400 // Not handling the rare case of different x and y device scale. 2373 // Not handling the rare case of different x and y device scale.
2401 float device_transform_scale = 2374 float device_transform_scale =
2402 std::max(device_transform_scale_components.x(), 2375 std::max(device_transform_scale_components.x(),
2403 device_transform_scale_components.y()); 2376 device_transform_scale_components.y());
2404 2377
2405 gfx::Transform scaled_device_transform = inputs.device_transform; 2378 gfx::Transform scaled_device_transform = inputs.device_transform;
2406 scaled_device_transform.Scale(inputs.device_scale_factor, 2379 scaled_device_transform.Scale(inputs.device_scale_factor,
2407 inputs.device_scale_factor); 2380 inputs.device_scale_factor);
2408 2381
2409 globals->layer_sorter = NULL;
2410 globals->max_texture_size = inputs.max_texture_size; 2382 globals->max_texture_size = inputs.max_texture_size;
2411 globals->device_scale_factor = 2383 globals->device_scale_factor =
2412 inputs.device_scale_factor * device_transform_scale; 2384 inputs.device_scale_factor * device_transform_scale;
2413 globals->page_scale_factor = inputs.page_scale_factor; 2385 globals->page_scale_factor = inputs.page_scale_factor;
2414 globals->page_scale_application_layer = inputs.page_scale_application_layer; 2386 globals->page_scale_application_layer = inputs.page_scale_application_layer;
2415 globals->elastic_overscroll = inputs.elastic_overscroll; 2387 globals->elastic_overscroll = inputs.elastic_overscroll;
2416 globals->elastic_overscroll_application_layer = 2388 globals->elastic_overscroll_application_layer =
2417 inputs.elastic_overscroll_application_layer; 2389 inputs.elastic_overscroll_application_layer;
2418 globals->can_render_to_separate_surface = 2390 globals->can_render_to_separate_surface =
2419 inputs.can_render_to_separate_surface; 2391 inputs.can_render_to_separate_surface;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
2547 } 2519 }
2548 } 2520 }
2549 2521
2550 void LayerTreeHostCommon::CalculateDrawProperties( 2522 void LayerTreeHostCommon::CalculateDrawProperties(
2551 CalcDrawPropsImplInputs* inputs) { 2523 CalcDrawPropsImplInputs* inputs) {
2552 LayerImplList dummy_layer_list; 2524 LayerImplList dummy_layer_list;
2553 SubtreeGlobals<LayerImpl> globals; 2525 SubtreeGlobals<LayerImpl> globals;
2554 DataForRecursion<LayerImpl> data_for_recursion; 2526 DataForRecursion<LayerImpl> data_for_recursion;
2555 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); 2527 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion);
2556 2528
2557 LayerSorter layer_sorter;
2558 globals.layer_sorter = &layer_sorter;
2559
2560 PreCalculateMetaInformationRecursiveData recursive_data; 2529 PreCalculateMetaInformationRecursiveData recursive_data;
2561 PreCalculateMetaInformation(inputs->root_layer, &recursive_data); 2530 PreCalculateMetaInformation(inputs->root_layer, &recursive_data);
2562 std::vector<AccumulatedSurfaceState<LayerImpl>> accumulated_surface_state; 2531 std::vector<AccumulatedSurfaceState<LayerImpl>> accumulated_surface_state;
2563 CalculateDrawPropertiesInternal<LayerImpl>( 2532 CalculateDrawPropertiesInternal<LayerImpl>(
2564 inputs->root_layer, 2533 inputs->root_layer,
2565 globals, 2534 globals,
2566 data_for_recursion, 2535 data_for_recursion,
2567 inputs->render_surface_layer_list, 2536 inputs->render_surface_layer_list,
2568 &dummy_layer_list, 2537 &dummy_layer_list,
2569 &accumulated_surface_state, 2538 &accumulated_surface_state,
2570 inputs->current_render_surface_layer_list_id); 2539 inputs->current_render_surface_layer_list_id);
2571 2540
2572 // The dummy layer list should not have been used. 2541 // The dummy layer list should not have been used.
2573 DCHECK_EQ(0u, dummy_layer_list.size()); 2542 DCHECK_EQ(0u, dummy_layer_list.size());
2574 // A root layer render_surface should always exist after 2543 // A root layer render_surface should always exist after
2575 // CalculateDrawProperties. 2544 // CalculateDrawProperties.
2576 DCHECK(inputs->root_layer->render_surface()); 2545 DCHECK(inputs->root_layer->render_surface());
2577 } 2546 }
2578 2547
2579 } // namespace cc 2548 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698