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

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

Issue 687873004: Introduce Property Trees (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wip-awoloszyn2
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
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/transform.h" 22 #include "ui/gfx/transform.h"
21 23
22 namespace cc { 24 namespace cc {
23 25
24 ScrollAndScaleSet::ScrollAndScaleSet() 26 ScrollAndScaleSet::ScrollAndScaleSet()
25 : page_scale_delta(1.f), top_controls_delta(0.f) { 27 : page_scale_delta(1.f), top_controls_delta(0.f) {
26 } 28 }
27 29
(...skipping 2365 matching lines...) Expand 10 before | Expand all | Expand 10 after
2393 device_viewport_rect; 2395 device_viewport_rect;
2394 data_for_recursion->maximum_animation_contents_scale = 0.f; 2396 data_for_recursion->maximum_animation_contents_scale = 0.f;
2395 data_for_recursion->ancestor_is_animating_scale = false; 2397 data_for_recursion->ancestor_is_animating_scale = false;
2396 data_for_recursion->ancestor_clips_subtree = true; 2398 data_for_recursion->ancestor_clips_subtree = true;
2397 data_for_recursion->nearest_occlusion_immune_ancestor_surface = NULL; 2399 data_for_recursion->nearest_occlusion_immune_ancestor_surface = NULL;
2398 data_for_recursion->in_subtree_of_page_scale_application_layer = false; 2400 data_for_recursion->in_subtree_of_page_scale_application_layer = false;
2399 data_for_recursion->subtree_can_use_lcd_text = inputs.can_use_lcd_text; 2401 data_for_recursion->subtree_can_use_lcd_text = inputs.can_use_lcd_text;
2400 data_for_recursion->subtree_is_visible_from_ancestor = true; 2402 data_for_recursion->subtree_is_visible_from_ancestor = true;
2401 } 2403 }
2402 2404
2405 static bool ApproximatelyEqual(const gfx::Rect& r1, const gfx::Rect& r2) {
2406 static const int tolerance = 1;
2407 return std::abs(r1.x() - r2.x()) <= tolerance &&
2408 std::abs(r1.y() - r2.y()) <= tolerance &&
2409 std::abs(r1.width() - r2.width()) <= tolerance &&
2410 std::abs(r1.height() - r2.height()) <= tolerance;
2411 }
2412
2403 void LayerTreeHostCommon::CalculateDrawProperties( 2413 void LayerTreeHostCommon::CalculateDrawProperties(
2404 CalcDrawPropsMainInputs* inputs) { 2414 CalcDrawPropsMainInputs* inputs) {
2405 LayerList dummy_layer_list; 2415 LayerList dummy_layer_list;
2406 SubtreeGlobals<Layer> globals; 2416 SubtreeGlobals<Layer> globals;
2407 DataForRecursion<Layer> data_for_recursion; 2417 DataForRecursion<Layer> data_for_recursion;
2408 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); 2418 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion);
2409 2419
2410 PreCalculateMetaInformationRecursiveData recursive_data; 2420 PreCalculateMetaInformationRecursiveData recursive_data;
2411 PreCalculateMetaInformation(inputs->root_layer, &recursive_data); 2421 PreCalculateMetaInformation(inputs->root_layer, &recursive_data);
2412 std::vector<AccumulatedSurfaceState<Layer>> accumulated_surface_state; 2422 std::vector<AccumulatedSurfaceState<Layer>> accumulated_surface_state;
2413 CalculateDrawPropertiesInternal<Layer>( 2423 CalculateDrawPropertiesInternal<Layer>(
2414 inputs->root_layer, 2424 inputs->root_layer,
2415 globals, 2425 globals,
2416 data_for_recursion, 2426 data_for_recursion,
2417 inputs->render_surface_layer_list, 2427 inputs->render_surface_layer_list,
2418 &dummy_layer_list, 2428 &dummy_layer_list,
2419 &accumulated_surface_state, 2429 &accumulated_surface_state,
2420 inputs->current_render_surface_layer_list_id); 2430 inputs->current_render_surface_layer_list_id);
2421 2431
2422 // The dummy layer list should not have been used. 2432 // The dummy layer list should not have been used.
2423 DCHECK_EQ(0u, dummy_layer_list.size()); 2433 DCHECK_EQ(0u, dummy_layer_list.size());
2424 // A root layer render_surface should always exist after 2434 // A root layer render_surface should always exist after
2425 // CalculateDrawProperties. 2435 // CalculateDrawProperties.
2426 DCHECK(inputs->root_layer->render_surface()); 2436 DCHECK(inputs->root_layer->render_surface());
2437
2438 // Now compare with the new approach.
2439 //
2440 // TODO(ajuma): Can we efficiently cache some of this rather than
2441 // starting from scratch every frame?
2442 //
2443 // TODO(vollick): This needs to be cleaned up, moved, and enabled with a
2444 // runtime flag.
2445 TransformTree transform_tree;
2446 ClipTree clip_tree;
2447 ComputeVisibleRectsUsingPropertyTrees(inputs->root_layer,
2448 inputs->page_scale_application_layer,
2449 inputs->page_scale_factor,
2450 inputs->device_scale_factor,
2451 gfx::Rect(inputs->device_viewport_size),
2452 inputs->device_transform,
2453 &transform_tree,
2454 &clip_tree);
2455
2456 bool failed = false;
2457 LayerIterator<Layer> it, end;
2458 for (it = LayerIterator<Layer>::Begin(inputs->render_surface_layer_list),
2459 end = LayerIterator<Layer>::End(inputs->render_surface_layer_list);
2460 it != end; ++it) {
2461 Layer* current_layer = *it;
2462 if (it.represents_itself()) {
2463 if (!failed && current_layer->DrawsContent() &&
2464 !ApproximatelyEqual(current_layer->visible_content_rect(),
2465 current_layer->debug_visible_rect())) {
2466 failed = true;
2467 }
2468 }
2469 }
2470
2471 CHECK(!failed);
2427 } 2472 }
2428 2473
2429 void LayerTreeHostCommon::CalculateDrawProperties( 2474 void LayerTreeHostCommon::CalculateDrawProperties(
2430 CalcDrawPropsImplInputs* inputs) { 2475 CalcDrawPropsImplInputs* inputs) {
2431 LayerImplList dummy_layer_list; 2476 LayerImplList dummy_layer_list;
2432 SubtreeGlobals<LayerImpl> globals; 2477 SubtreeGlobals<LayerImpl> globals;
2433 DataForRecursion<LayerImpl> data_for_recursion; 2478 DataForRecursion<LayerImpl> data_for_recursion;
2434 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); 2479 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion);
2435 2480
2436 LayerSorter layer_sorter; 2481 LayerSorter layer_sorter;
(...skipping 12 matching lines...) Expand all
2449 inputs->current_render_surface_layer_list_id); 2494 inputs->current_render_surface_layer_list_id);
2450 2495
2451 // The dummy layer list should not have been used. 2496 // The dummy layer list should not have been used.
2452 DCHECK_EQ(0u, dummy_layer_list.size()); 2497 DCHECK_EQ(0u, dummy_layer_list.size());
2453 // A root layer render_surface should always exist after 2498 // A root layer render_surface should always exist after
2454 // CalculateDrawProperties. 2499 // CalculateDrawProperties.
2455 DCHECK(inputs->root_layer->render_surface()); 2500 DCHECK(inputs->root_layer->render_surface());
2456 } 2501 }
2457 2502
2458 } // namespace cc 2503 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698