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

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

Issue 988693005: Chromium roll (https://codereview.chromium.org/976353002) (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: fixed bad android build patch 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
« no previous file with comments | « cc/trees/layer_tree_host_common.h ('k') | cc/trees/layer_tree_host_common_unittest.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/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"
(...skipping 2477 matching lines...) Expand 10 before | Expand all | Expand 10 after
2488 } 2488 }
2489 2489
2490 static bool ApproximatelyEqual(const gfx::Rect& r1, const gfx::Rect& r2) { 2490 static bool ApproximatelyEqual(const gfx::Rect& r1, const gfx::Rect& r2) {
2491 static const int tolerance = 1; 2491 static const int tolerance = 1;
2492 return std::abs(r1.x() - r2.x()) <= tolerance && 2492 return std::abs(r1.x() - r2.x()) <= tolerance &&
2493 std::abs(r1.y() - r2.y()) <= tolerance && 2493 std::abs(r1.y() - r2.y()) <= tolerance &&
2494 std::abs(r1.width() - r2.width()) <= tolerance && 2494 std::abs(r1.width() - r2.width()) <= tolerance &&
2495 std::abs(r1.height() - r2.height()) <= tolerance; 2495 std::abs(r1.height() - r2.height()) <= tolerance;
2496 } 2496 }
2497 2497
2498 static bool ApproximatelyEqual(const gfx::Transform& a,
2499 const gfx::Transform& b) {
2500 static const float tolerance = 0.01f;
2501 return gfx::MatrixDistance(a, b) < tolerance;
2502 }
2503
2504 void LayerTreeHostCommon::CalculateDrawProperties( 2498 void LayerTreeHostCommon::CalculateDrawProperties(
2505 CalcDrawPropsMainInputs* inputs) { 2499 CalcDrawPropsMainInputs* inputs) {
2506 UpdateRenderSurfaces(inputs->root_layer, 2500 UpdateRenderSurfaces(inputs->root_layer,
2507 inputs->can_render_to_separate_surface, gfx::Transform(), 2501 inputs->can_render_to_separate_surface, gfx::Transform(),
2508 false); 2502 false);
2509 LayerList dummy_layer_list; 2503 LayerList dummy_layer_list;
2510 SubtreeGlobals<Layer> globals; 2504 SubtreeGlobals<Layer> globals;
2511 DataForRecursion<Layer> data_for_recursion; 2505 DataForRecursion<Layer> data_for_recursion;
2512 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); 2506 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion);
2513 2507
2514 PreCalculateMetaInformationRecursiveData recursive_data; 2508 PreCalculateMetaInformationRecursiveData recursive_data;
2515 PreCalculateMetaInformation(inputs->root_layer, &recursive_data);
2516 std::vector<AccumulatedSurfaceState<Layer>> accumulated_surface_state;
2517 CalculateDrawPropertiesInternal<Layer>(
2518 inputs->root_layer, globals, data_for_recursion,
2519 inputs->render_surface_layer_list, &dummy_layer_list,
2520 &accumulated_surface_state, inputs->current_render_surface_layer_list_id);
2521 2509
2522 // The dummy layer list should not have been used. 2510 if (!inputs->verify_property_trees) {
2523 DCHECK_EQ(0u, dummy_layer_list.size()); 2511 PreCalculateMetaInformation(inputs->root_layer, &recursive_data);
2524 // A root layer render_surface should always exist after 2512 std::vector<AccumulatedSurfaceState<Layer>> accumulated_surface_state;
2525 // CalculateDrawProperties. 2513 CalculateDrawPropertiesInternal<Layer>(
2526 DCHECK(inputs->root_layer->render_surface()); 2514 inputs->root_layer, globals, data_for_recursion,
2515 inputs->render_surface_layer_list, &dummy_layer_list,
2516 &accumulated_surface_state,
2517 inputs->current_render_surface_layer_list_id);
2518 } else {
2519 {
2520 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"),
2521 "LayerTreeHostCommon::CalculateDrawProperties");
2522 PreCalculateMetaInformation(inputs->root_layer, &recursive_data);
2523 std::vector<AccumulatedSurfaceState<Layer>> accumulated_surface_state;
2524 CalculateDrawPropertiesInternal<Layer>(
2525 inputs->root_layer, globals, data_for_recursion,
2526 inputs->render_surface_layer_list, &dummy_layer_list,
2527 &accumulated_surface_state,
2528 inputs->current_render_surface_layer_list_id);
2529 }
2527 2530
2528 if (inputs->verify_property_trees) {
2529 // The translation from layer to property trees is an intermediate state. We 2531 // The translation from layer to property trees is an intermediate state. We
2530 // will eventually get these data passed directly to the compositor. 2532 // will eventually get these data passed directly to the compositor.
2531 TransformTree transform_tree; 2533 TransformTree transform_tree;
2532 ClipTree clip_tree; 2534 ClipTree clip_tree;
2533 OpacityTree opacity_tree; 2535 OpacityTree opacity_tree;
2534 ComputeVisibleRectsUsingPropertyTrees( 2536 {
2535 inputs->root_layer, inputs->page_scale_application_layer, 2537 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"),
2536 inputs->page_scale_factor, inputs->device_scale_factor, 2538 "LayerTreeHostCommon::ComputeVisibleRectsWithPropertyTrees");
2537 gfx::Rect(inputs->device_viewport_size), inputs->device_transform, 2539 ComputeVisibleRectsUsingPropertyTrees(
2538 &transform_tree, &clip_tree, &opacity_tree); 2540 inputs->root_layer, inputs->page_scale_application_layer,
2541 inputs->page_scale_factor, inputs->device_scale_factor,
2542 gfx::Rect(inputs->device_viewport_size), inputs->device_transform,
2543 &transform_tree, &clip_tree, &opacity_tree);
2544 }
2539 2545
2540 LayerIterator<Layer> it, end; 2546 LayerIterator<Layer> it, end;
2541 for (it = LayerIterator<Layer>::Begin(inputs->render_surface_layer_list), 2547 for (it = LayerIterator<Layer>::Begin(inputs->render_surface_layer_list),
2542 end = LayerIterator<Layer>::End(inputs->render_surface_layer_list); 2548 end = LayerIterator<Layer>::End(inputs->render_surface_layer_list);
2543 it != end; ++it) { 2549 it != end; ++it) {
2544 Layer* current_layer = *it; 2550 Layer* current_layer = *it;
2545 if (!it.represents_itself() || !current_layer->DrawsContent()) 2551 if (!it.represents_itself() || !current_layer->DrawsContent())
2546 continue; 2552 continue;
2547 2553
2548 const bool visible_rects_match = 2554 const bool visible_rects_match =
2549 ApproximatelyEqual(current_layer->visible_content_rect(), 2555 ApproximatelyEqual(current_layer->visible_content_rect(),
2550 current_layer->visible_rect_from_property_trees()); 2556 current_layer->visible_rect_from_property_trees());
2551 CHECK(visible_rects_match); 2557 CHECK(visible_rects_match);
2552 2558
2553 const bool draw_transforms_match = ApproximatelyEqual(
2554 current_layer->draw_transform(),
2555 current_layer->draw_transform_from_property_trees(transform_tree));
2556 CHECK(draw_transforms_match);
2557
2558 const bool draw_opacities_match = 2559 const bool draw_opacities_match =
2559 current_layer->draw_opacity() == 2560 current_layer->draw_opacity() ==
2560 current_layer->DrawOpacityFromPropertyTrees(opacity_tree); 2561 current_layer->DrawOpacityFromPropertyTrees(opacity_tree);
2561 CHECK(draw_opacities_match); 2562 CHECK(draw_opacities_match);
2562 } 2563 }
2563 } 2564 }
2565
2566 // The dummy layer list should not have been used.
2567 DCHECK_EQ(0u, dummy_layer_list.size());
2568 // A root layer render_surface should always exist after
2569 // CalculateDrawProperties.
2570 DCHECK(inputs->root_layer->render_surface());
2564 } 2571 }
2565 2572
2566 void LayerTreeHostCommon::CalculateDrawProperties( 2573 void LayerTreeHostCommon::CalculateDrawProperties(
2567 CalcDrawPropsImplInputs* inputs) { 2574 CalcDrawPropsImplInputs* inputs) {
2568 LayerImplList dummy_layer_list; 2575 LayerImplList dummy_layer_list;
2569 SubtreeGlobals<LayerImpl> globals; 2576 SubtreeGlobals<LayerImpl> globals;
2570 DataForRecursion<LayerImpl> data_for_recursion; 2577 DataForRecursion<LayerImpl> data_for_recursion;
2571 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); 2578 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion);
2572 2579
2573 LayerSorter layer_sorter; 2580 LayerSorter layer_sorter;
(...skipping 12 matching lines...) Expand all
2586 inputs->current_render_surface_layer_list_id); 2593 inputs->current_render_surface_layer_list_id);
2587 2594
2588 // The dummy layer list should not have been used. 2595 // The dummy layer list should not have been used.
2589 DCHECK_EQ(0u, dummy_layer_list.size()); 2596 DCHECK_EQ(0u, dummy_layer_list.size());
2590 // A root layer render_surface should always exist after 2597 // A root layer render_surface should always exist after
2591 // CalculateDrawProperties. 2598 // CalculateDrawProperties.
2592 DCHECK(inputs->root_layer->render_surface()); 2599 DCHECK(inputs->root_layer->render_surface());
2593 } 2600 }
2594 2601
2595 } // namespace cc 2602 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common.h ('k') | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698