| 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 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 std::unique_ptr<DamageTracker> DamageTracker::Create() { | 23 std::unique_ptr<DamageTracker> DamageTracker::Create() { |
| 24 return base::WrapUnique(new DamageTracker()); | 24 return base::WrapUnique(new DamageTracker()); |
| 25 } | 25 } |
| 26 | 26 |
| 27 DamageTracker::DamageTracker() | 27 DamageTracker::DamageTracker() |
| 28 : mailboxId_(0) {} | 28 : mailboxId_(0) {} |
| 29 | 29 |
| 30 DamageTracker::~DamageTracker() {} | 30 DamageTracker::~DamageTracker() {} |
| 31 | 31 |
| 32 static inline void ExpandRectWithFilters(gfx::Rect* rect, | |
| 33 const FilterOperations& filters) { | |
| 34 int top, right, bottom, left; | |
| 35 filters.GetOutsets(&top, &right, &bottom, &left); | |
| 36 rect->Inset(-left, -top, -right, -bottom); | |
| 37 } | |
| 38 | |
| 39 static inline void ExpandDamageRectInsideRectWithFilters( | 32 static inline void ExpandDamageRectInsideRectWithFilters( |
| 40 gfx::Rect* damage_rect, | 33 gfx::Rect* damage_rect, |
| 41 const gfx::Rect& pre_filter_rect, | 34 const gfx::Rect& pre_filter_rect, |
| 42 const FilterOperations& filters) { | 35 const FilterOperations& filters) { |
| 43 gfx::Rect expanded_damage_rect = *damage_rect; | 36 // Compute the pixels in the background of the surface that could be affected |
| 44 ExpandRectWithFilters(&expanded_damage_rect, filters); | 37 // by the damage in the content below. |
| 45 gfx::Rect filter_rect = pre_filter_rect; | 38 gfx::Rect expanded_damage_rect = filters.MapRect(*damage_rect, SkMatrix::I()); |
| 46 ExpandRectWithFilters(&filter_rect, filters); | |
| 47 | 39 |
| 48 expanded_damage_rect.Intersect(filter_rect); | 40 // Restrict it to the rectangle in which the background filter is shown. |
| 41 expanded_damage_rect.Intersect(pre_filter_rect); |
| 42 |
| 49 damage_rect->Union(expanded_damage_rect); | 43 damage_rect->Union(expanded_damage_rect); |
| 50 } | 44 } |
| 51 | 45 |
| 52 void DamageTracker::UpdateDamageTrackingState( | 46 void DamageTracker::UpdateDamageTrackingState( |
| 53 const LayerImplList& layer_list, | 47 const LayerImplList& layer_list, |
| 54 const RenderSurfaceImpl* target_surface, | 48 const RenderSurfaceImpl* target_surface, |
| 55 bool target_surface_property_changed_only_from_descendant, | 49 bool target_surface_property_changed_only_from_descendant, |
| 56 const gfx::Rect& target_surface_content_rect, | 50 const gfx::Rect& target_surface_content_rect, |
| 57 LayerImpl* target_surface_mask_layer, | 51 LayerImpl* target_surface_mask_layer, |
| 58 const FilterOperations& filters) { | 52 const FilterOperations& filters) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 gfx::Rect damage_rect_for_this_update; | 131 gfx::Rect damage_rect_for_this_update; |
| 138 | 132 |
| 139 if (target_surface_property_changed_only_from_descendant) { | 133 if (target_surface_property_changed_only_from_descendant) { |
| 140 damage_rect_for_this_update = target_surface_content_rect; | 134 damage_rect_for_this_update = target_surface_content_rect; |
| 141 } else { | 135 } else { |
| 142 // TODO(shawnsingh): can we clamp this damage to the surface's content rect? | 136 // TODO(shawnsingh): can we clamp this damage to the surface's content rect? |
| 143 // (affects performance, but not correctness) | 137 // (affects performance, but not correctness) |
| 144 damage_rect_for_this_update = damage_from_active_layers; | 138 damage_rect_for_this_update = damage_from_active_layers; |
| 145 damage_rect_for_this_update.Union(damage_from_surface_mask); | 139 damage_rect_for_this_update.Union(damage_from_surface_mask); |
| 146 damage_rect_for_this_update.Union(damage_from_leftover_rects); | 140 damage_rect_for_this_update.Union(damage_from_leftover_rects); |
| 147 | 141 damage_rect_for_this_update = |
| 148 ExpandRectWithFilters(&damage_rect_for_this_update, filters); | 142 filters.MapRect(damage_rect_for_this_update, SkMatrix::I()); |
| 149 } | 143 } |
| 150 | 144 |
| 151 // Damage accumulates until we are notified that we actually did draw on that | 145 // Damage accumulates until we are notified that we actually did draw on that |
| 152 // frame. | 146 // frame. |
| 153 current_damage_rect_.Union(damage_rect_for_this_update); | 147 current_damage_rect_.Union(damage_rect_for_this_update); |
| 154 } | 148 } |
| 155 | 149 |
| 156 DamageTracker::LayerRectMapData& DamageTracker::RectDataForLayer( | 150 DamageTracker::LayerRectMapData& DamageTracker::RectDataForLayer( |
| 157 int layer_id, | 151 int layer_id, |
| 158 bool* layer_is_new) { | 152 bool* layer_is_new) { |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 // one in them. This means we need to redraw any pixels in the surface being | 429 // one in them. This means we need to redraw any pixels in the surface being |
| 436 // used for the blur in this layer this frame. | 430 // used for the blur in this layer this frame. |
| 437 if (layer->background_filters().HasFilterThatMovesPixels()) { | 431 if (layer->background_filters().HasFilterThatMovesPixels()) { |
| 438 ExpandDamageRectInsideRectWithFilters(target_damage_rect, | 432 ExpandDamageRectInsideRectWithFilters(target_damage_rect, |
| 439 surface_rect_in_target_space, | 433 surface_rect_in_target_space, |
| 440 layer->background_filters()); | 434 layer->background_filters()); |
| 441 } | 435 } |
| 442 } | 436 } |
| 443 | 437 |
| 444 } // namespace cc | 438 } // namespace cc |
| OLD | NEW |