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

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

Issue 816543004: Update from https://crrev.com/308996 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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_common.h ('k') | cc/trees/layer_tree_host_common_perftest.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_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/layer_sorter.h" 18 #include "cc/trees/layer_sorter.h"
19 #include "cc/trees/layer_tree_host.h"
18 #include "cc/trees/layer_tree_impl.h" 20 #include "cc/trees/layer_tree_impl.h"
19 #include "ui/gfx/geometry/rect_conversions.h" 21 #include "ui/gfx/geometry/rect_conversions.h"
20 #include "ui/gfx/geometry/vector2d_conversions.h" 22 #include "ui/gfx/geometry/vector2d_conversions.h"
21 #include "ui/gfx/transform.h" 23 #include "ui/gfx/transform.h"
22 24
23 namespace cc { 25 namespace cc {
24 26
25 ScrollAndScaleSet::ScrollAndScaleSet() 27 ScrollAndScaleSet::ScrollAndScaleSet()
26 : page_scale_delta(1.f), top_controls_delta(0.f) { 28 : page_scale_delta(1.f), top_controls_delta(0.f) {
27 } 29 }
(...skipping 1804 matching lines...) Expand 10 before | Expand all | Expand 10 after
1832 ? combined_transform_scales 1834 ? combined_transform_scales
1833 : gfx::Vector2dF(layer_scale_factors, layer_scale_factors); 1835 : gfx::Vector2dF(layer_scale_factors, layer_scale_factors);
1834 1836
1835 bool render_to_separate_surface; 1837 bool render_to_separate_surface;
1836 if (globals.can_render_to_separate_surface) { 1838 if (globals.can_render_to_separate_surface) {
1837 render_to_separate_surface = SubtreeShouldRenderToSeparateSurface( 1839 render_to_separate_surface = SubtreeShouldRenderToSeparateSurface(
1838 layer, combined_transform.Preserves2dAxisAlignment()); 1840 layer, combined_transform.Preserves2dAxisAlignment());
1839 } else { 1841 } else {
1840 render_to_separate_surface = IsRootLayer(layer); 1842 render_to_separate_surface = IsRootLayer(layer);
1841 } 1843 }
1844
1845 layer->SetHasRenderSurface(render_to_separate_surface);
1846
1842 if (render_to_separate_surface) { 1847 if (render_to_separate_surface) {
1843 // Check back-face visibility before continuing with this surface and its 1848 // Check back-face visibility before continuing with this surface and its
1844 // subtree 1849 // subtree
1845 if (!layer->double_sided() && TransformToParentIsKnown(layer) && 1850 if (!layer->double_sided() && TransformToParentIsKnown(layer) &&
1846 IsSurfaceBackFaceVisible(layer, combined_transform)) { 1851 IsSurfaceBackFaceVisible(layer, combined_transform)) {
1847 layer->ClearRenderSurfaceLayerList(); 1852 layer->ClearRenderSurfaceLayerList();
1848 return; 1853 return;
1849 } 1854 }
1850 1855
1851 typename LayerType::RenderSurfaceType* render_surface = 1856 typename LayerType::RenderSurfaceType* render_surface =
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
2423 device_viewport_rect; 2428 device_viewport_rect;
2424 data_for_recursion->maximum_animation_contents_scale = 0.f; 2429 data_for_recursion->maximum_animation_contents_scale = 0.f;
2425 data_for_recursion->ancestor_is_animating_scale = false; 2430 data_for_recursion->ancestor_is_animating_scale = false;
2426 data_for_recursion->ancestor_clips_subtree = true; 2431 data_for_recursion->ancestor_clips_subtree = true;
2427 data_for_recursion->nearest_occlusion_immune_ancestor_surface = NULL; 2432 data_for_recursion->nearest_occlusion_immune_ancestor_surface = NULL;
2428 data_for_recursion->in_subtree_of_page_scale_application_layer = false; 2433 data_for_recursion->in_subtree_of_page_scale_application_layer = false;
2429 data_for_recursion->subtree_can_use_lcd_text = inputs.can_use_lcd_text; 2434 data_for_recursion->subtree_can_use_lcd_text = inputs.can_use_lcd_text;
2430 data_for_recursion->subtree_is_visible_from_ancestor = true; 2435 data_for_recursion->subtree_is_visible_from_ancestor = true;
2431 } 2436 }
2432 2437
2438 static bool ApproximatelyEqual(const gfx::Rect& r1, const gfx::Rect& r2) {
2439 static const int tolerance = 1;
2440 return std::abs(r1.x() - r2.x()) <= tolerance &&
2441 std::abs(r1.y() - r2.y()) <= tolerance &&
2442 std::abs(r1.width() - r2.width()) <= tolerance &&
2443 std::abs(r1.height() - r2.height()) <= tolerance;
2444 }
2445
2433 void LayerTreeHostCommon::CalculateDrawProperties( 2446 void LayerTreeHostCommon::CalculateDrawProperties(
2434 CalcDrawPropsMainInputs* inputs) { 2447 CalcDrawPropsMainInputs* inputs) {
2435 LayerList dummy_layer_list; 2448 LayerList dummy_layer_list;
2436 SubtreeGlobals<Layer> globals; 2449 SubtreeGlobals<Layer> globals;
2437 DataForRecursion<Layer> data_for_recursion; 2450 DataForRecursion<Layer> data_for_recursion;
2438 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); 2451 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion);
2439 2452
2440 PreCalculateMetaInformationRecursiveData recursive_data; 2453 PreCalculateMetaInformationRecursiveData recursive_data;
2441 PreCalculateMetaInformation(inputs->root_layer, &recursive_data); 2454 PreCalculateMetaInformation(inputs->root_layer, &recursive_data);
2442 std::vector<AccumulatedSurfaceState<Layer>> accumulated_surface_state; 2455 std::vector<AccumulatedSurfaceState<Layer>> accumulated_surface_state;
2443 CalculateDrawPropertiesInternal<Layer>( 2456 CalculateDrawPropertiesInternal<Layer>(
2444 inputs->root_layer, 2457 inputs->root_layer,
2445 globals, 2458 globals,
2446 data_for_recursion, 2459 data_for_recursion,
2447 inputs->render_surface_layer_list, 2460 inputs->render_surface_layer_list,
2448 &dummy_layer_list, 2461 &dummy_layer_list,
2449 &accumulated_surface_state, 2462 &accumulated_surface_state,
2450 inputs->current_render_surface_layer_list_id); 2463 inputs->current_render_surface_layer_list_id);
2451 2464
2452 // The dummy layer list should not have been used. 2465 // The dummy layer list should not have been used.
2453 DCHECK_EQ(0u, dummy_layer_list.size()); 2466 DCHECK_EQ(0u, dummy_layer_list.size());
2454 // A root layer render_surface should always exist after 2467 // A root layer render_surface should always exist after
2455 // CalculateDrawProperties. 2468 // CalculateDrawProperties.
2456 DCHECK(inputs->root_layer->render_surface()); 2469 DCHECK(inputs->root_layer->render_surface());
2470
2471 if (inputs->verify_property_trees) {
2472 // TODO(ajuma): Can we efficiently cache some of this rather than
2473 // starting from scratch every frame?
2474 TransformTree transform_tree;
2475 ClipTree clip_tree;
2476 ComputeVisibleRectsUsingPropertyTrees(
2477 inputs->root_layer, inputs->page_scale_application_layer,
2478 inputs->page_scale_factor, inputs->device_scale_factor,
2479 gfx::Rect(inputs->device_viewport_size), inputs->device_transform,
2480 &transform_tree, &clip_tree);
2481
2482 bool failed = false;
2483 LayerIterator<Layer> it, end;
2484 for (it = LayerIterator<Layer>::Begin(inputs->render_surface_layer_list),
2485 end = LayerIterator<Layer>::End(inputs->render_surface_layer_list);
2486 it != end; ++it) {
2487 Layer* current_layer = *it;
2488 if (it.represents_itself()) {
2489 if (!failed && current_layer->DrawsContent() &&
2490 !ApproximatelyEqual(
2491 current_layer->visible_content_rect(),
2492 current_layer->visible_rect_from_property_trees())) {
2493 failed = true;
2494 }
2495 }
2496 }
2497
2498 CHECK(!failed);
2499 }
2457 } 2500 }
2458 2501
2459 void LayerTreeHostCommon::CalculateDrawProperties( 2502 void LayerTreeHostCommon::CalculateDrawProperties(
2460 CalcDrawPropsImplInputs* inputs) { 2503 CalcDrawPropsImplInputs* inputs) {
2461 LayerImplList dummy_layer_list; 2504 LayerImplList dummy_layer_list;
2462 SubtreeGlobals<LayerImpl> globals; 2505 SubtreeGlobals<LayerImpl> globals;
2463 DataForRecursion<LayerImpl> data_for_recursion; 2506 DataForRecursion<LayerImpl> data_for_recursion;
2464 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); 2507 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion);
2465 2508
2466 LayerSorter layer_sorter; 2509 LayerSorter layer_sorter;
(...skipping 12 matching lines...) Expand all
2479 inputs->current_render_surface_layer_list_id); 2522 inputs->current_render_surface_layer_list_id);
2480 2523
2481 // The dummy layer list should not have been used. 2524 // The dummy layer list should not have been used.
2482 DCHECK_EQ(0u, dummy_layer_list.size()); 2525 DCHECK_EQ(0u, dummy_layer_list.size());
2483 // A root layer render_surface should always exist after 2526 // A root layer render_surface should always exist after
2484 // CalculateDrawProperties. 2527 // CalculateDrawProperties.
2485 DCHECK(inputs->root_layer->render_surface()); 2528 DCHECK(inputs->root_layer->render_surface());
2486 } 2529 }
2487 2530
2488 } // namespace cc 2531 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common.h ('k') | cc/trees/layer_tree_host_common_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698