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

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 6 years, 3 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/layer_sorter.h"
18 #include "cc/trees/layer_tree_impl.h" 17 #include "cc/trees/layer_tree_impl.h"
19 #include "ui/gfx/rect_conversions.h" 18 #include "ui/gfx/rect_conversions.h"
20 #include "ui/gfx/transform.h" 19 #include "ui/gfx/transform.h"
21 20
22 namespace cc { 21 namespace cc {
23 22
24 ScrollAndScaleSet::ScrollAndScaleSet() {} 23 ScrollAndScaleSet::ScrollAndScaleSet() {}
25 24
26 ScrollAndScaleSet::~ScrollAndScaleSet() {} 25 ScrollAndScaleSet::~ScrollAndScaleSet() {}
27 26
28 static void SortLayers(LayerList::iterator forst,
29 LayerList::iterator end,
30 void* layer_sorter) {
31 NOTREACHED();
32 }
33
34 static void SortLayers(LayerImplList::iterator first,
35 LayerImplList::iterator end,
36 LayerSorter* layer_sorter) {
37 DCHECK(layer_sorter);
38 TRACE_EVENT0("cc", "LayerTreeHostCommon::SortLayers");
39 layer_sorter->Sort(first, end);
40 }
41
42 template <typename LayerType> 27 template <typename LayerType>
43 static gfx::Vector2dF GetEffectiveScrollDelta(LayerType* layer) { 28 static gfx::Vector2dF GetEffectiveScrollDelta(LayerType* layer) {
44 gfx::Vector2dF scroll_delta = layer->ScrollDelta(); 29 gfx::Vector2dF scroll_delta = layer->ScrollDelta();
45 // The scroll parent's scroll delta is the amount we've scrolled on the 30 // The scroll parent's scroll delta is the amount we've scrolled on the
46 // compositor thread since the commit for this layer tree's source frame. 31 // compositor thread since the commit for this layer tree's source frame.
47 // we last reported to the main thread. I.e., it's the discrepancy between 32 // we last reported to the main thread. I.e., it's the discrepancy between
48 // a scroll parent's scroll delta and offset, so we must add it here. 33 // a scroll parent's scroll delta and offset, so we must add it here.
49 if (layer->scroll_parent()) 34 if (layer->scroll_parent())
50 scroll_delta += layer->scroll_parent()->ScrollDelta(); 35 scroll_delta += layer->scroll_parent()->ScrollDelta();
51 return scroll_delta; 36 return scroll_delta;
(...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 recursive_data->layer_or_descendant_has_input_handler; 1238 recursive_data->layer_or_descendant_has_input_handler;
1254 } 1239 }
1255 1240
1256 static void RoundTranslationComponents(gfx::Transform* transform) { 1241 static void RoundTranslationComponents(gfx::Transform* transform) {
1257 transform->matrix().set(0, 3, MathUtil::Round(transform->matrix().get(0, 3))); 1242 transform->matrix().set(0, 3, MathUtil::Round(transform->matrix().get(0, 3)));
1258 transform->matrix().set(1, 3, MathUtil::Round(transform->matrix().get(1, 3))); 1243 transform->matrix().set(1, 3, MathUtil::Round(transform->matrix().get(1, 3)));
1259 } 1244 }
1260 1245
1261 template <typename LayerType> 1246 template <typename LayerType>
1262 struct SubtreeGlobals { 1247 struct SubtreeGlobals {
1263 LayerSorter* layer_sorter;
1264 int max_texture_size; 1248 int max_texture_size;
1265 float device_scale_factor; 1249 float device_scale_factor;
1266 float page_scale_factor; 1250 float page_scale_factor;
1267 const LayerType* page_scale_application_layer; 1251 const LayerType* page_scale_application_layer;
1268 bool can_adjust_raster_scales; 1252 bool can_adjust_raster_scales;
1269 bool can_render_to_separate_surface; 1253 bool can_render_to_separate_surface;
1270 }; 1254 };
1271 1255
1272 template<typename LayerType> 1256 template<typename LayerType>
1273 struct DataForRecursion { 1257 struct DataForRecursion {
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after
2305 } 2289 }
2306 2290
2307 SavePaintPropertiesLayer(layer); 2291 SavePaintPropertiesLayer(layer);
2308 2292
2309 // If neither this layer nor any of its children were added, early out. 2293 // If neither this layer nor any of its children were added, early out.
2310 if (sorting_start_index == descendants.size()) { 2294 if (sorting_start_index == descendants.size()) {
2311 DCHECK(!layer->render_surface() || IsRootLayer(layer)); 2295 DCHECK(!layer->render_surface() || IsRootLayer(layer));
2312 return; 2296 return;
2313 } 2297 }
2314 2298
2315 // If preserves-3d then sort all the descendants in 3D so that they can be
2316 // drawn from back to front. If the preserves-3d property is also set on the
2317 // parent then skip the sorting as the parent will sort all the descendants
2318 // anyway.
2319 if (globals.layer_sorter && descendants.size() && layer->Is3dSorted() &&
2320 !LayerIsInExisting3DRenderingContext(layer)) {
2321 SortLayers(descendants.begin() + sorting_start_index,
2322 descendants.end(),
2323 globals.layer_sorter);
2324 }
2325
2326 UpdateAccumulatedSurfaceState<LayerType>( 2299 UpdateAccumulatedSurfaceState<LayerType>(
2327 layer, local_drawable_content_rect_of_subtree, accumulated_surface_state); 2300 layer, local_drawable_content_rect_of_subtree, accumulated_surface_state);
2328 2301
2329 if (layer->HasContributingDelegatedRenderPasses()) { 2302 if (layer->HasContributingDelegatedRenderPasses()) {
2330 layer->render_target()->render_surface()-> 2303 layer->render_target()->render_surface()->
2331 AddContributingDelegatedRenderPassLayer(layer); 2304 AddContributingDelegatedRenderPassLayer(layer);
2332 } 2305 }
2333 } // NOLINT(readability/fn_size) 2306 } // NOLINT(readability/fn_size)
2334 2307
2335 template <typename LayerType, typename RenderSurfaceLayerListType> 2308 template <typename LayerType, typename RenderSurfaceLayerListType>
(...skipping 17 matching lines...) Expand all
2353 MathUtil::ComputeTransform2dScaleComponents(inputs.device_transform, 1.f); 2326 MathUtil::ComputeTransform2dScaleComponents(inputs.device_transform, 1.f);
2354 // Not handling the rare case of different x and y device scale. 2327 // Not handling the rare case of different x and y device scale.
2355 float device_transform_scale = 2328 float device_transform_scale =
2356 std::max(device_transform_scale_components.x(), 2329 std::max(device_transform_scale_components.x(),
2357 device_transform_scale_components.y()); 2330 device_transform_scale_components.y());
2358 2331
2359 gfx::Transform scaled_device_transform = inputs.device_transform; 2332 gfx::Transform scaled_device_transform = inputs.device_transform;
2360 scaled_device_transform.Scale(inputs.device_scale_factor, 2333 scaled_device_transform.Scale(inputs.device_scale_factor,
2361 inputs.device_scale_factor); 2334 inputs.device_scale_factor);
2362 2335
2363 globals->layer_sorter = NULL;
2364 globals->max_texture_size = inputs.max_texture_size; 2336 globals->max_texture_size = inputs.max_texture_size;
2365 globals->device_scale_factor = 2337 globals->device_scale_factor =
2366 inputs.device_scale_factor * device_transform_scale; 2338 inputs.device_scale_factor * device_transform_scale;
2367 globals->page_scale_factor = inputs.page_scale_factor; 2339 globals->page_scale_factor = inputs.page_scale_factor;
2368 globals->page_scale_application_layer = inputs.page_scale_application_layer; 2340 globals->page_scale_application_layer = inputs.page_scale_application_layer;
2369 globals->can_render_to_separate_surface = 2341 globals->can_render_to_separate_surface =
2370 inputs.can_render_to_separate_surface; 2342 inputs.can_render_to_separate_surface;
2371 globals->can_adjust_raster_scales = inputs.can_adjust_raster_scales; 2343 globals->can_adjust_raster_scales = inputs.can_adjust_raster_scales;
2372 2344
2373 data_for_recursion->parent_matrix = scaled_device_transform; 2345 data_for_recursion->parent_matrix = scaled_device_transform;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2412 DCHECK(inputs->root_layer->render_surface()); 2384 DCHECK(inputs->root_layer->render_surface());
2413 } 2385 }
2414 2386
2415 void LayerTreeHostCommon::CalculateDrawProperties( 2387 void LayerTreeHostCommon::CalculateDrawProperties(
2416 CalcDrawPropsImplInputs* inputs) { 2388 CalcDrawPropsImplInputs* inputs) {
2417 LayerImplList dummy_layer_list; 2389 LayerImplList dummy_layer_list;
2418 SubtreeGlobals<LayerImpl> globals; 2390 SubtreeGlobals<LayerImpl> globals;
2419 DataForRecursion<LayerImpl> data_for_recursion; 2391 DataForRecursion<LayerImpl> data_for_recursion;
2420 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); 2392 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion);
2421 2393
2422 LayerSorter layer_sorter;
2423 globals.layer_sorter = &layer_sorter;
2424
2425 PreCalculateMetaInformationRecursiveData recursive_data; 2394 PreCalculateMetaInformationRecursiveData recursive_data;
2426 PreCalculateMetaInformation(inputs->root_layer, &recursive_data); 2395 PreCalculateMetaInformation(inputs->root_layer, &recursive_data);
2427 std::vector<AccumulatedSurfaceState<LayerImpl> > 2396 std::vector<AccumulatedSurfaceState<LayerImpl> >
2428 accumulated_surface_state; 2397 accumulated_surface_state;
2429 CalculateDrawPropertiesInternal<LayerImpl>( 2398 CalculateDrawPropertiesInternal<LayerImpl>(
2430 inputs->root_layer, 2399 inputs->root_layer,
2431 globals, 2400 globals,
2432 data_for_recursion, 2401 data_for_recursion,
2433 inputs->render_surface_layer_list, 2402 inputs->render_surface_layer_list,
2434 &dummy_layer_list, 2403 &dummy_layer_list,
2435 &accumulated_surface_state, 2404 &accumulated_surface_state,
2436 inputs->current_render_surface_layer_list_id); 2405 inputs->current_render_surface_layer_list_id);
2437 2406
2438 // The dummy layer list should not have been used. 2407 // The dummy layer list should not have been used.
2439 DCHECK_EQ(0u, dummy_layer_list.size()); 2408 DCHECK_EQ(0u, dummy_layer_list.size());
2440 // A root layer render_surface should always exist after 2409 // A root layer render_surface should always exist after
2441 // CalculateDrawProperties. 2410 // CalculateDrawProperties.
2442 DCHECK(inputs->root_layer->render_surface()); 2411 DCHECK(inputs->root_layer->render_surface());
2443 } 2412 }
2444 2413
2445 } // namespace cc 2414 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698