| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 ExpandRectWithFilters(&expanded_damage_rect, filters); | 44 ExpandRectWithFilters(&expanded_damage_rect, filters); |
| 45 gfx::Rect filter_rect = pre_filter_rect; | 45 gfx::Rect filter_rect = pre_filter_rect; |
| 46 ExpandRectWithFilters(&filter_rect, filters); | 46 ExpandRectWithFilters(&filter_rect, filters); |
| 47 | 47 |
| 48 expanded_damage_rect.Intersect(filter_rect); | 48 expanded_damage_rect.Intersect(filter_rect); |
| 49 damage_rect->Union(expanded_damage_rect); | 49 damage_rect->Union(expanded_damage_rect); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void DamageTracker::UpdateDamageTrackingState( | 52 void DamageTracker::UpdateDamageTrackingState( |
| 53 const LayerImplList& layer_list, | 53 const LayerImplList& layer_list, |
| 54 int target_surface_layer_id, | 54 const RenderSurfaceImpl* target_surface, |
| 55 bool target_surface_property_changed_only_from_descendant, | 55 bool target_surface_property_changed_only_from_descendant, |
| 56 const gfx::Rect& target_surface_content_rect, | 56 const gfx::Rect& target_surface_content_rect, |
| 57 LayerImpl* target_surface_mask_layer, | 57 LayerImpl* target_surface_mask_layer, |
| 58 const FilterOperations& filters) { | 58 const FilterOperations& filters) { |
| 59 // | 59 // |
| 60 // This function computes the "damage rect" of a target surface, and updates | 60 // This function computes the "damage rect" of a target surface, and updates |
| 61 // the state that is used to correctly track damage across frames. The damage | 61 // the state that is used to correctly track damage across frames. The damage |
| 62 // rect is the region of the surface that may have changed and needs to be | 62 // rect is the region of the surface that may have changed and needs to be |
| 63 // redrawn. This can be used to scissor what is actually drawn, to save GPU | 63 // redrawn. This can be used to scissor what is actually drawn, to save GPU |
| 64 // computation and bandwidth. | 64 // computation and bandwidth. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 // 3. After the damage rect is computed, the leftover not marked regions | 122 // 3. After the damage rect is computed, the leftover not marked regions |
| 123 // in a map are used to compute are damaged by deleted layers and | 123 // in a map are used to compute are damaged by deleted layers and |
| 124 // erased from map. | 124 // erased from map. |
| 125 // | 125 // |
| 126 | 126 |
| 127 PrepareRectHistoryForUpdate(); | 127 PrepareRectHistoryForUpdate(); |
| 128 // These functions cannot be bypassed with early-exits, even if we know what | 128 // These functions cannot be bypassed with early-exits, even if we know what |
| 129 // the damage will be for this frame, because we need to update the damage | 129 // the damage will be for this frame, because we need to update the damage |
| 130 // tracker state to correctly track the next frame. | 130 // tracker state to correctly track the next frame. |
| 131 gfx::Rect damage_from_active_layers = | 131 gfx::Rect damage_from_active_layers = |
| 132 TrackDamageFromActiveLayers(layer_list, target_surface_layer_id); | 132 TrackDamageFromActiveLayers(layer_list, target_surface); |
| 133 gfx::Rect damage_from_surface_mask = | 133 gfx::Rect damage_from_surface_mask = |
| 134 TrackDamageFromSurfaceMask(target_surface_mask_layer); | 134 TrackDamageFromSurfaceMask(target_surface_mask_layer); |
| 135 gfx::Rect damage_from_leftover_rects = TrackDamageFromLeftoverRects(); | 135 gfx::Rect damage_from_leftover_rects = TrackDamageFromLeftoverRects(); |
| 136 | 136 |
| 137 gfx::Rect damage_rect_for_this_update; | 137 gfx::Rect damage_rect_for_this_update; |
| 138 | 138 |
| 139 if (target_surface_property_changed_only_from_descendant) { | 139 if (target_surface_property_changed_only_from_descendant) { |
| 140 damage_rect_for_this_update = target_surface_content_rect; | 140 damage_rect_for_this_update = target_surface_content_rect; |
| 141 } else { | 141 } else { |
| 142 // TODO(shawnsingh): can we clamp this damage to the surface's content rect? | 142 // TODO(shawnsingh): can we clamp this damage to the surface's content rect? |
| (...skipping 22 matching lines...) Expand all Loading... |
| 165 if (it == rect_history_.end() || it->layer_id_ != layer_id) { | 165 if (it == rect_history_.end() || it->layer_id_ != layer_id) { |
| 166 *layer_is_new = true; | 166 *layer_is_new = true; |
| 167 it = rect_history_.insert(it, data); | 167 it = rect_history_.insert(it, data); |
| 168 } | 168 } |
| 169 | 169 |
| 170 return *it; | 170 return *it; |
| 171 } | 171 } |
| 172 | 172 |
| 173 gfx::Rect DamageTracker::TrackDamageFromActiveLayers( | 173 gfx::Rect DamageTracker::TrackDamageFromActiveLayers( |
| 174 const LayerImplList& layer_list, | 174 const LayerImplList& layer_list, |
| 175 int target_surface_layer_id) { | 175 const RenderSurfaceImpl* target_surface) { |
| 176 gfx::Rect damage_rect; | 176 gfx::Rect damage_rect; |
| 177 | 177 |
| 178 for (size_t layer_index = 0; layer_index < layer_list.size(); ++layer_index) { | 178 for (size_t layer_index = 0; layer_index < layer_list.size(); ++layer_index) { |
| 179 // Visit layers in back-to-front order. | 179 // Visit layers in back-to-front order. |
| 180 LayerImpl* layer = layer_list[layer_index]; | 180 LayerImpl* layer = layer_list[layer_index]; |
| 181 | 181 |
| 182 // We skip damage from the HUD layer because (a) the HUD layer damages the | 182 // We skip damage from the HUD layer because (a) the HUD layer damages the |
| 183 // whole frame and (b) we don't want HUD layer damage to be shown by the | 183 // whole frame and (b) we don't want HUD layer damage to be shown by the |
| 184 // HUD damage rect visualization. | 184 // HUD damage rect visualization. |
| 185 if (layer == layer->layer_tree_impl()->hud_layer()) | 185 if (layer == layer->layer_tree_impl()->hud_layer()) |
| 186 continue; | 186 continue; |
| 187 if (LayerTreeHostCommon::RenderSurfaceContributesToTarget<LayerImpl>( | 187 |
| 188 layer, target_surface_layer_id)) | 188 if (layer->render_surface() && layer->render_surface() != target_surface) |
| 189 ExtendDamageForRenderSurface(layer, &damage_rect); | 189 ExtendDamageForRenderSurface(layer, &damage_rect); |
| 190 else | 190 else |
| 191 ExtendDamageForLayer(layer, &damage_rect); | 191 ExtendDamageForLayer(layer, &damage_rect); |
| 192 } | 192 } |
| 193 | 193 |
| 194 return damage_rect; | 194 return damage_rect; |
| 195 } | 195 } |
| 196 | 196 |
| 197 gfx::Rect DamageTracker::TrackDamageFromSurfaceMask( | 197 gfx::Rect DamageTracker::TrackDamageFromSurfaceMask( |
| 198 LayerImpl* target_surface_mask_layer) { | 198 LayerImpl* target_surface_mask_layer) { |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 // one in them. This means we need to redraw any pixels in the surface being | 394 // one in them. This means we need to redraw any pixels in the surface being |
| 395 // used for the blur in this layer this frame. | 395 // used for the blur in this layer this frame. |
| 396 if (layer->background_filters().HasFilterThatMovesPixels()) { | 396 if (layer->background_filters().HasFilterThatMovesPixels()) { |
| 397 ExpandDamageRectInsideRectWithFilters(target_damage_rect, | 397 ExpandDamageRectInsideRectWithFilters(target_damage_rect, |
| 398 surface_rect_in_target_space, | 398 surface_rect_in_target_space, |
| 399 layer->background_filters()); | 399 layer->background_filters()); |
| 400 } | 400 } |
| 401 } | 401 } |
| 402 | 402 |
| 403 } // namespace cc | 403 } // namespace cc |
| OLD | NEW |