OLD | NEW |
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 2580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2591 const float tolerance = | 2591 const float tolerance = |
2592 col == 3 && row < 3 ? translation_tolerance : component_tolerance; | 2592 col == 3 && row < 3 ? translation_tolerance : component_tolerance; |
2593 if (delta > tolerance) | 2593 if (delta > tolerance) |
2594 return false; | 2594 return false; |
2595 } | 2595 } |
2596 } | 2596 } |
2597 | 2597 |
2598 return true; | 2598 return true; |
2599 } | 2599 } |
2600 | 2600 |
| 2601 template <typename LayerType> |
| 2602 void VerifyPropertyTreeValuesForLayer(LayerType* current_layer, |
| 2603 PropertyTrees* property_trees) { |
| 2604 const bool visible_rects_match = |
| 2605 ApproximatelyEqual(current_layer->visible_content_rect(), |
| 2606 current_layer->visible_rect_from_property_trees()); |
| 2607 CHECK(visible_rects_match) |
| 2608 << "expected: " << current_layer->visible_content_rect().ToString() |
| 2609 << " actual: " |
| 2610 << current_layer->visible_rect_from_property_trees().ToString(); |
| 2611 |
| 2612 const bool draw_transforms_match = |
| 2613 ApproximatelyEqual(current_layer->draw_transform(), |
| 2614 DrawTransformFromPropertyTrees( |
| 2615 current_layer, property_trees->transform_tree)); |
| 2616 CHECK(draw_transforms_match) |
| 2617 << "expected: " << current_layer->draw_transform().ToString() |
| 2618 << " actual: " |
| 2619 << DrawTransformFromPropertyTrees( |
| 2620 current_layer, property_trees->transform_tree).ToString(); |
| 2621 |
| 2622 const bool draw_opacities_match = |
| 2623 current_layer->draw_opacity() == |
| 2624 DrawOpacityFromPropertyTrees(current_layer, property_trees->opacity_tree); |
| 2625 CHECK(draw_opacities_match) |
| 2626 << "expected: " << current_layer->draw_opacity() |
| 2627 << " actual: " << DrawOpacityFromPropertyTrees( |
| 2628 current_layer, property_trees->opacity_tree); |
| 2629 } |
| 2630 |
2601 void VerifyPropertyTreeValues( | 2631 void VerifyPropertyTreeValues( |
2602 LayerTreeHostCommon::CalcDrawPropsMainInputs* inputs) { | 2632 LayerTreeHostCommon::CalcDrawPropsMainInputs* inputs) { |
2603 LayerIterator<Layer> it, end; | 2633 LayerIterator<Layer> it, end; |
2604 for (it = LayerIterator<Layer>::Begin(inputs->render_surface_layer_list), | 2634 for (it = LayerIterator<Layer>::Begin(inputs->render_surface_layer_list), |
2605 end = LayerIterator<Layer>::End(inputs->render_surface_layer_list); | 2635 end = LayerIterator<Layer>::End(inputs->render_surface_layer_list); |
2606 it != end; ++it) { | 2636 it != end; ++it) { |
2607 Layer* current_layer = *it; | 2637 Layer* current_layer = *it; |
2608 if (!it.represents_itself() || !current_layer->DrawsContent()) | 2638 if (!it.represents_itself() || !current_layer->DrawsContent()) |
2609 continue; | 2639 continue; |
2610 | 2640 VerifyPropertyTreeValuesForLayer(current_layer, inputs->property_trees); |
2611 const bool visible_rects_match = | |
2612 ApproximatelyEqual(current_layer->visible_content_rect(), | |
2613 current_layer->visible_rect_from_property_trees()); | |
2614 CHECK(visible_rects_match) | |
2615 << "expected: " << current_layer->visible_content_rect().ToString() | |
2616 << " actual: " | |
2617 << current_layer->visible_rect_from_property_trees().ToString(); | |
2618 | |
2619 const bool draw_transforms_match = ApproximatelyEqual( | |
2620 current_layer->draw_transform(), | |
2621 DrawTransformFromPropertyTrees(current_layer, | |
2622 inputs->property_trees->transform_tree)); | |
2623 CHECK(draw_transforms_match) | |
2624 << "expected: " << current_layer->draw_transform().ToString() | |
2625 << " actual: " | |
2626 << DrawTransformFromPropertyTrees( | |
2627 current_layer, inputs->property_trees->transform_tree) | |
2628 .ToString(); | |
2629 | |
2630 const bool draw_opacities_match = | |
2631 current_layer->draw_opacity() == | |
2632 DrawOpacityFromPropertyTrees(current_layer, | |
2633 inputs->property_trees->opacity_tree); | |
2634 CHECK(draw_opacities_match) | |
2635 << "expected: " << current_layer->draw_opacity() << " actual: " | |
2636 << DrawOpacityFromPropertyTrees(current_layer, | |
2637 inputs->property_trees->opacity_tree); | |
2638 } | 2641 } |
2639 } | 2642 } |
2640 | 2643 |
2641 void VerifyPropertyTreeValues( | 2644 void VerifyPropertyTreeValues( |
2642 LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs) { | 2645 LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs) { |
2643 // TODO(enne): need to synchronize compositor thread changes | 2646 LayerIterator<LayerImpl> it, end; |
2644 // for animation and scrolling to the property trees before these | 2647 for (it = LayerIterator<LayerImpl>::Begin(inputs->render_surface_layer_list), |
2645 // can be correct. | 2648 end = LayerIterator<LayerImpl>::End(inputs->render_surface_layer_list); |
| 2649 it != end; ++it) { |
| 2650 LayerImpl* current_layer = *it; |
| 2651 if (!it.represents_itself() || !current_layer->DrawsContent()) |
| 2652 continue; |
| 2653 VerifyPropertyTreeValuesForLayer(current_layer, inputs->property_trees); |
| 2654 } |
2646 } | 2655 } |
2647 | 2656 |
2648 enum PropertyTreeOption { | 2657 enum PropertyTreeOption { |
2649 BUILD_PROPERTY_TREES_IF_NEEDED, | 2658 BUILD_PROPERTY_TREES_IF_NEEDED, |
2650 DONT_BUILD_PROPERTY_TREES | 2659 DONT_BUILD_PROPERTY_TREES |
2651 }; | 2660 }; |
2652 | 2661 |
2653 template <typename LayerType, typename RenderSurfaceLayerListType> | 2662 template <typename LayerType, typename RenderSurfaceLayerListType> |
2654 void CalculateDrawPropertiesAndVerify(LayerTreeHostCommon::CalcDrawPropsInputs< | 2663 void CalculateDrawPropertiesAndVerify(LayerTreeHostCommon::CalcDrawPropsInputs< |
2655 LayerType, | 2664 LayerType, |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2757 PropertyTrees* trees_from_inputs) { | 2766 PropertyTrees* trees_from_inputs) { |
2758 return layer->layer_tree_host()->property_trees(); | 2767 return layer->layer_tree_host()->property_trees(); |
2759 } | 2768 } |
2760 | 2769 |
2761 PropertyTrees* GetPropertyTrees(LayerImpl* layer, | 2770 PropertyTrees* GetPropertyTrees(LayerImpl* layer, |
2762 PropertyTrees* trees_from_inputs) { | 2771 PropertyTrees* trees_from_inputs) { |
2763 return trees_from_inputs; | 2772 return trees_from_inputs; |
2764 } | 2773 } |
2765 | 2774 |
2766 } // namespace cc | 2775 } // namespace cc |
OLD | NEW |