| 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 <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 return base::WrapUnique(new DamageTracker()); | 25 return base::WrapUnique(new DamageTracker()); |
| 26 } | 26 } |
| 27 | 27 |
| 28 DamageTracker::DamageTracker() | 28 DamageTracker::DamageTracker() |
| 29 : mailboxId_(0) {} | 29 : mailboxId_(0) {} |
| 30 | 30 |
| 31 DamageTracker::~DamageTracker() {} | 31 DamageTracker::~DamageTracker() {} |
| 32 | 32 |
| 33 void DamageTracker::UpdateDamageTracking( | 33 void DamageTracker::UpdateDamageTracking( |
| 34 LayerTreeImpl* layer_tree_impl, | 34 LayerTreeImpl* layer_tree_impl, |
| 35 const LayerImplList& render_surface_list) { | 35 const RenderSurfaceList& render_surface_list) { |
| 36 // | 36 // |
| 37 // This function computes the "damage rect" of each target surface, and | 37 // This function computes the "damage rect" of each target surface, and |
| 38 // updates the state that is used to correctly track damage across frames. The | 38 // updates the state that is used to correctly track damage across frames. The |
| 39 // damage rect is the region of the surface that may have changed and needs to | 39 // damage rect is the region of the surface that may have changed and needs to |
| 40 // be redrawn. This can be used to scissor what is actually drawn, to save GPU | 40 // be redrawn. This can be used to scissor what is actually drawn, to save GPU |
| 41 // computation and bandwidth. | 41 // computation and bandwidth. |
| 42 // | 42 // |
| 43 // The surface's damage rect is computed as the union of all possible changes | 43 // The surface's damage rect is computed as the union of all possible changes |
| 44 // that have happened to the surface since the last frame was drawn. This | 44 // that have happened to the surface since the last frame was drawn. This |
| 45 // includes: | 45 // includes: |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // layer changes or does not exist anymore, those regions are then | 99 // layer changes or does not exist anymore, those regions are then |
| 100 // exposed and damage the target surface. As the algorithm progresses, | 100 // exposed and damage the target surface. As the algorithm progresses, |
| 101 // entries are updated in the map until only leftover layers | 101 // entries are updated in the map until only leftover layers |
| 102 // that no longer exist stay marked not updated. | 102 // that no longer exist stay marked not updated. |
| 103 // | 103 // |
| 104 // 3. After the damage rect is computed, the leftover not marked regions | 104 // 3. After the damage rect is computed, the leftover not marked regions |
| 105 // in a map are used to compute are damaged by deleted layers and | 105 // in a map are used to compute are damaged by deleted layers and |
| 106 // erased from map. | 106 // erased from map. |
| 107 // | 107 // |
| 108 | 108 |
| 109 for (LayerImpl* layer : render_surface_list) { | 109 for (RenderSurfaceImpl* render_surface : render_surface_list) { |
| 110 layer->GetRenderSurface()->damage_tracker()->PrepareForUpdate(); | 110 render_surface->damage_tracker()->PrepareForUpdate(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 EffectTree& effect_tree = layer_tree_impl->property_trees()->effect_tree; | 113 EffectTree& effect_tree = layer_tree_impl->property_trees()->effect_tree; |
| 114 int current_target_effect_id = EffectTree::kContentsRootNodeId; | 114 int current_target_effect_id = EffectTree::kContentsRootNodeId; |
| 115 DCHECK(effect_tree.GetRenderSurface(current_target_effect_id)); | 115 DCHECK(effect_tree.GetRenderSurface(current_target_effect_id)); |
| 116 for (LayerImpl* layer : *layer_tree_impl) { | 116 for (LayerImpl* layer : *layer_tree_impl) { |
| 117 if (!layer->is_drawn_render_surface_layer_list_member()) | 117 if (!layer->is_drawn_render_surface_layer_list_member()) |
| 118 continue; | 118 continue; |
| 119 | 119 |
| 120 int next_target_effect_id = layer->render_target_effect_tree_index(); | 120 int next_target_effect_id = layer->render_target_effect_tree_index(); |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 } | 472 } |
| 473 | 473 |
| 474 rect->set_x(x_); | 474 rect->set_x(x_); |
| 475 rect->set_y(y_); | 475 rect->set_y(y_); |
| 476 rect->set_width(width.ValueOrDie()); | 476 rect->set_width(width.ValueOrDie()); |
| 477 rect->set_height(height.ValueOrDie()); | 477 rect->set_height(height.ValueOrDie()); |
| 478 return true; | 478 return true; |
| 479 } | 479 } |
| 480 | 480 |
| 481 } // namespace cc | 481 } // namespace cc |
| OLD | NEW |