Chromium Code Reviews| 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 #ifndef CC_TREES_DAMAGE_TRACKER_H_ | 5 #ifndef CC_TREES_DAMAGE_TRACKER_H_ |
| 6 #define CC_TREES_DAMAGE_TRACKER_H_ | 6 #define CC_TREES_DAMAGE_TRACKER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 class RenderSurfaceImpl; | 24 class RenderSurfaceImpl; |
| 25 | 25 |
| 26 // Computes the region where pixels have actually changed on a | 26 // Computes the region where pixels have actually changed on a |
| 27 // RenderSurfaceImpl. This region is used to scissor what is actually drawn to | 27 // RenderSurfaceImpl. This region is used to scissor what is actually drawn to |
| 28 // the screen to save GPU computation and bandwidth. | 28 // the screen to save GPU computation and bandwidth. |
| 29 class CC_EXPORT DamageTracker { | 29 class CC_EXPORT DamageTracker { |
| 30 public: | 30 public: |
| 31 static std::unique_ptr<DamageTracker> Create(); | 31 static std::unique_ptr<DamageTracker> Create(); |
| 32 ~DamageTracker(); | 32 ~DamageTracker(); |
| 33 | 33 |
| 34 void DidDrawDamagedArea() { current_damage_rect_ = gfx::Rect(); } | 34 void DidDrawDamagedArea() { current_damage_ = DamageAccumulator(); } |
| 35 void AddDamageNextUpdate(const gfx::Rect& dmg) { | 35 void AddDamageNextUpdate(const gfx::Rect& dmg) { current_damage_.Union(dmg); } |
| 36 current_damage_rect_.Union(dmg); | |
| 37 } | |
| 38 void UpdateDamageTrackingState( | 36 void UpdateDamageTrackingState( |
| 39 const LayerImplList& layer_list, | 37 const LayerImplList& layer_list, |
| 40 const RenderSurfaceImpl* target_surface, | 38 const RenderSurfaceImpl* target_surface, |
| 41 bool target_surface_property_changed_only_from_descendant, | 39 bool target_surface_property_changed_only_from_descendant, |
| 42 const gfx::Rect& target_surface_content_rect, | 40 const gfx::Rect& target_surface_content_rect, |
| 43 LayerImpl* target_surface_mask_layer, | 41 LayerImpl* target_surface_mask_layer, |
| 44 const FilterOperations& filters); | 42 const FilterOperations& filters); |
| 45 | 43 |
| 46 gfx::Rect current_damage_rect() { return current_damage_rect_; } | 44 bool ShouldDamageEverything(); |
| 45 gfx::Rect CurrentDamageRect(); | |
| 47 | 46 |
| 48 private: | 47 private: |
| 49 DamageTracker(); | 48 DamageTracker(); |
| 50 | 49 |
| 51 gfx::Rect TrackDamageFromActiveLayers( | 50 class DamageAccumulator { |
| 51 public: | |
| 52 template <typename Type> | |
| 53 void Union(const Type& rect) { | |
| 54 if (!is_valid_rect_) | |
| 55 return; | |
| 56 | |
| 57 if (IsEmpty()) { | |
| 58 x_ = rect.x(); | |
| 59 y_ = rect.y(); | |
| 60 right_ = rect.right(); | |
| 61 bottom_ = rect.bottom(); | |
| 62 return; | |
| 63 } | |
| 64 if (rect.IsEmpty()) | |
|
danakj
2017/01/13 23:17:58
why is this below setting everything if we are alr
vmpstr
2017/01/19 23:08:27
Moved it up.
| |
| 65 return; | |
| 66 | |
| 67 x_ = std::min(x_, rect.x()); | |
| 68 y_ = std::min(y_, rect.y()); | |
| 69 right_ = std::max(right_, rect.right()); | |
| 70 bottom_ = std::max(bottom_, rect.bottom()); | |
| 71 } | |
| 72 | |
| 73 void SetInvalid() { is_valid_rect_ = false; } | |
| 74 | |
| 75 int x() const { return x_; } | |
| 76 int y() const { return y_; } | |
| 77 int right() const { return right_; } | |
| 78 int bottom() const { return bottom_; } | |
| 79 bool IsEmpty() const { return x_ == right_ || y_ == bottom_; } | |
| 80 | |
| 81 bool GetAsRect(gfx::Rect* rect); | |
| 82 | |
| 83 private: | |
| 84 bool is_valid_rect_ = true; | |
| 85 int x_ = 0; | |
| 86 int y_ = 0; | |
| 87 int right_ = 0; | |
| 88 int bottom_ = 0; | |
| 89 }; | |
| 90 | |
| 91 DamageAccumulator TrackDamageFromActiveLayers( | |
| 52 const LayerImplList& layer_list, | 92 const LayerImplList& layer_list, |
| 53 const RenderSurfaceImpl* target_surface); | 93 const RenderSurfaceImpl* target_surface); |
| 54 gfx::Rect TrackDamageFromSurfaceMask(LayerImpl* target_surface_mask_layer); | 94 DamageAccumulator TrackDamageFromSurfaceMask( |
| 55 gfx::Rect TrackDamageFromLeftoverRects(); | 95 LayerImpl* target_surface_mask_layer); |
| 96 DamageAccumulator TrackDamageFromLeftoverRects(); | |
| 97 void ExpandDamageInsideRectWithFilters(DamageAccumulator* damage, | |
| 98 const gfx::Rect& pre_filter_rect, | |
| 99 const FilterOperations& filters); | |
| 56 | 100 |
| 57 void PrepareRectHistoryForUpdate(); | 101 void PrepareRectHistoryForUpdate(); |
| 58 | 102 |
| 59 // These helper functions are used only in TrackDamageFromActiveLayers(). | 103 // These helper functions are used only in TrackDamageFromActiveLayers(). |
|
danakj
2017/01/13 23:17:59
ExpandDamageInsideRectWithFilters can be grouped w
vmpstr
2017/01/19 23:08:27
Done.
| |
| 60 void ExtendDamageForLayer(LayerImpl* layer, gfx::Rect* target_damage_rect); | 104 void ExtendDamageForLayer(LayerImpl* layer, DamageAccumulator* target_damage); |
| 61 void ExtendDamageForRenderSurface(RenderSurfaceImpl* render_surface, | 105 void ExtendDamageForRenderSurface(RenderSurfaceImpl* render_surface, |
| 62 gfx::Rect* target_damage_rect); | 106 DamageAccumulator* target_damage); |
| 63 | 107 |
| 64 struct LayerRectMapData { | 108 struct LayerRectMapData { |
| 65 LayerRectMapData() : layer_id_(0), mailboxId_(0) {} | 109 LayerRectMapData() : layer_id_(0), mailboxId_(0) {} |
| 66 explicit LayerRectMapData(int layer_id) | 110 explicit LayerRectMapData(int layer_id) |
| 67 : layer_id_(layer_id), mailboxId_(0) {} | 111 : layer_id_(layer_id), mailboxId_(0) {} |
| 68 void Update(const gfx::Rect& rect, unsigned int mailboxId) { | 112 void Update(const gfx::Rect& rect, unsigned int mailboxId) { |
| 69 mailboxId_ = mailboxId; | 113 mailboxId_ = mailboxId; |
| 70 rect_ = rect; | 114 rect_ = rect; |
| 71 } | 115 } |
| 72 | 116 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 99 typedef std::vector<LayerRectMapData> SortedRectMapForLayers; | 143 typedef std::vector<LayerRectMapData> SortedRectMapForLayers; |
| 100 typedef std::vector<SurfaceRectMapData> SortedRectMapForSurfaces; | 144 typedef std::vector<SurfaceRectMapData> SortedRectMapForSurfaces; |
| 101 | 145 |
| 102 LayerRectMapData& RectDataForLayer(int layer_id, bool* layer_is_new); | 146 LayerRectMapData& RectDataForLayer(int layer_id, bool* layer_is_new); |
| 103 SurfaceRectMapData& RectDataForSurface(int layer_id, bool* layer_is_new); | 147 SurfaceRectMapData& RectDataForSurface(int layer_id, bool* layer_is_new); |
| 104 | 148 |
| 105 SortedRectMapForLayers rect_history_for_layers_; | 149 SortedRectMapForLayers rect_history_for_layers_; |
| 106 SortedRectMapForSurfaces rect_history_for_surfaces_; | 150 SortedRectMapForSurfaces rect_history_for_surfaces_; |
| 107 | 151 |
| 108 unsigned int mailboxId_; | 152 unsigned int mailboxId_; |
| 109 gfx::Rect current_damage_rect_; | 153 DamageAccumulator current_damage_; |
| 110 | 154 |
| 111 DISALLOW_COPY_AND_ASSIGN(DamageTracker); | 155 DISALLOW_COPY_AND_ASSIGN(DamageTracker); |
| 112 }; | 156 }; |
| 113 | 157 |
| 114 } // namespace cc | 158 } // namespace cc |
| 115 | 159 |
| 116 #endif // CC_TREES_DAMAGE_TRACKER_H_ | 160 #endif // CC_TREES_DAMAGE_TRACKER_H_ |
| OLD | NEW |