| 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/damage_tracker.h" | 5 #include "cc/trees/damage_tracker.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "cc/base/math_util.h" | 9 #include "cc/base/math_util.h" |
| 10 #include "cc/layers/layer_impl.h" | 10 #include "cc/layers/layer_impl.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root); | 36 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root); |
| 37 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 37 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
| 38 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 38 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 39 root, root->bounds(), render_surface_layer_list, | 39 root, root->bounds(), render_surface_layer_list, |
| 40 root->layer_tree_impl()->current_render_surface_list_id()); | 40 root->layer_tree_impl()->current_render_surface_list_id()); |
| 41 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 41 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 42 ASSERT_TRUE(root->render_surface()); | 42 ASSERT_TRUE(root->render_surface()); |
| 43 } | 43 } |
| 44 | 44 |
| 45 void ClearDamageForAllSurfaces(LayerImpl* layer) { | 45 void ClearDamageForAllSurfaces(LayerImpl* root) { |
| 46 if (layer->render_surface()) | 46 for (auto* layer : *root->layer_tree_impl()) { |
| 47 layer->render_surface()->damage_tracker()->DidDrawDamagedArea(); | 47 if (layer->render_surface()) |
| 48 | 48 layer->render_surface()->damage_tracker()->DidDrawDamagedArea(); |
| 49 // Recursively clear damage for any existing surface. | 49 } |
| 50 for (size_t i = 0; i < layer->children().size(); ++i) | |
| 51 ClearDamageForAllSurfaces(layer->children()[i]); | |
| 52 } | 50 } |
| 53 | 51 |
| 54 void EmulateDrawingOneFrame(LayerImpl* root) { | 52 void EmulateDrawingOneFrame(LayerImpl* root) { |
| 55 // This emulates only steps that are relevant to testing the damage tracker: | 53 // This emulates only steps that are relevant to testing the damage tracker: |
| 56 // 1. computing the render passes and layerlists | 54 // 1. computing the render passes and layerlists |
| 57 // 2. updating all damage trackers in the correct order | 55 // 2. updating all damage trackers in the correct order |
| 58 // 3. resetting all update_rects and property_changed flags for all layers | 56 // 3. resetting all update_rects and property_changed flags for all layers |
| 59 // and surfaces. | 57 // and surfaces. |
| 60 | 58 |
| 61 LayerImplList render_surface_layer_list; | 59 LayerImplList render_surface_layer_list; |
| (...skipping 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1554 gfx::Rect root_damage_rect = | 1552 gfx::Rect root_damage_rect = |
| 1555 root->render_surface()->damage_tracker()->current_damage_rect(); | 1553 root->render_surface()->damage_tracker()->current_damage_rect(); |
| 1556 gfx::Rect damage_we_care_about = gfx::Rect(i, i); | 1554 gfx::Rect damage_we_care_about = gfx::Rect(i, i); |
| 1557 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); | 1555 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); |
| 1558 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); | 1556 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); |
| 1559 } | 1557 } |
| 1560 } | 1558 } |
| 1561 | 1559 |
| 1562 } // namespace | 1560 } // namespace |
| 1563 } // namespace cc | 1561 } // namespace cc |
| OLD | NEW |