| 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 <vector> | 8 #include <vector> |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "cc/base/cc_export.h" | 10 #include "cc/base/cc_export.h" |
| (...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 scoped_ptr<DamageTracker> Create(); | 31 static scoped_ptr<DamageTracker> Create(); |
| 32 ~DamageTracker(); | 32 ~DamageTracker(); |
| 33 | 33 |
| 34 void DidDrawDamagedArea() { current_damage_rect_ = gfx::Rect(); } | 34 void DidDrawDamagedArea() { |
| 35 current_damage_rect_ = gfx::Rect(); |
| 36 current_overlay_rect_ = gfx::Rect(); |
| 37 } |
| 35 void AddDamageNextUpdate(const gfx::Rect& dmg) { | 38 void AddDamageNextUpdate(const gfx::Rect& dmg) { |
| 36 current_damage_rect_.Union(dmg); | 39 current_damage_rect_.Union(dmg); |
| 37 } | 40 } |
| 38 void UpdateDamageTrackingState( | 41 void UpdateDamageTrackingState( |
| 39 const LayerImplList& layer_list, | 42 const LayerImplList& layer_list, |
| 40 int target_surface_layer_id, | 43 int target_surface_layer_id, |
| 41 bool target_surface_property_changed_only_from_descendant, | 44 bool target_surface_property_changed_only_from_descendant, |
| 42 const gfx::Rect& target_surface_content_rect, | 45 const gfx::Rect& target_surface_content_rect, |
| 43 LayerImpl* target_surface_mask_layer, | 46 LayerImpl* target_surface_mask_layer, |
| 44 const FilterOperations& filters); | 47 const FilterOperations& filters); |
| 45 | 48 |
| 46 gfx::Rect current_damage_rect() { return current_damage_rect_; } | 49 gfx::Rect current_damage_rect() { return current_damage_rect_; } |
| 50 gfx::Rect current_overlay_rect() { return current_overlay_rect_; } |
| 47 | 51 |
| 48 private: | 52 private: |
| 49 DamageTracker(); | 53 DamageTracker(); |
| 50 | 54 |
| 51 gfx::Rect TrackDamageFromActiveLayers(const LayerImplList& layer_list, | 55 void TrackDamageFromActiveLayers(const LayerImplList& layer_list, |
| 52 int target_surface_layer_id); | 56 int target_surface_layer_id, |
| 57 gfx::Rect* damage, |
| 58 gfx::Rect* overlay); |
| 53 gfx::Rect TrackDamageFromSurfaceMask(LayerImpl* target_surface_mask_layer); | 59 gfx::Rect TrackDamageFromSurfaceMask(LayerImpl* target_surface_mask_layer); |
| 54 gfx::Rect TrackDamageFromLeftoverRects(); | 60 gfx::Rect TrackDamageFromLeftoverRects(); |
| 55 | 61 |
| 56 void PrepareRectHistoryForUpdate(); | 62 void PrepareRectHistoryForUpdate(); |
| 57 | 63 |
| 58 // These helper functions are used only in TrackDamageFromActiveLayers(). | 64 // These helper functions are used only in TrackDamageFromActiveLayers(). |
| 59 void ExtendDamageForLayer(LayerImpl* layer, gfx::Rect* target_damage_rect); | 65 void ExtendDamageForLayer(LayerImpl* layer, |
| 66 gfx::Rect* target_damage_rect, |
| 67 gfx::Rect* target_overlay_rect); |
| 60 void ExtendDamageForRenderSurface(LayerImpl* layer, | 68 void ExtendDamageForRenderSurface(LayerImpl* layer, |
| 61 gfx::Rect* target_damage_rect); | 69 gfx::Rect* target_damage_rect); |
| 62 | 70 |
| 63 struct RectMapData { | 71 struct RectMapData { |
| 64 RectMapData() : layer_id_(0), mailboxId_(0) {} | 72 RectMapData() : layer_id_(0), mailboxId_(0) {} |
| 65 explicit RectMapData(int layer_id) : layer_id_(layer_id), mailboxId_(0) {} | 73 explicit RectMapData(int layer_id) : layer_id_(layer_id), mailboxId_(0) {} |
| 66 void Update(const gfx::Rect& rect, unsigned int mailboxId) { | 74 void Update(const gfx::Rect& rect, unsigned int mailboxId) { |
| 67 mailboxId_ = mailboxId; | 75 mailboxId_ = mailboxId; |
| 68 rect_ = rect; | 76 rect_ = rect; |
| 69 } | 77 } |
| 70 | 78 |
| 71 bool operator < (const RectMapData& other) const { | 79 bool operator < (const RectMapData& other) const { |
| 72 return layer_id_ < other.layer_id_; | 80 return layer_id_ < other.layer_id_; |
| 73 } | 81 } |
| 74 | 82 |
| 75 int layer_id_; | 83 int layer_id_; |
| 76 unsigned int mailboxId_; | 84 unsigned int mailboxId_; |
| 77 gfx::Rect rect_; | 85 gfx::Rect rect_; |
| 78 }; | 86 }; |
| 79 typedef std::vector<RectMapData> SortedRectMap; | 87 typedef std::vector<RectMapData> SortedRectMap; |
| 80 | 88 |
| 81 RectMapData& RectDataForLayer(int layer_id, bool* layer_is_new); | 89 RectMapData& RectDataForLayer(int layer_id, bool* layer_is_new); |
| 82 | 90 |
| 83 SortedRectMap rect_history_; | 91 SortedRectMap rect_history_; |
| 84 | 92 |
| 85 unsigned int mailboxId_; | 93 unsigned int mailboxId_; |
| 86 gfx::Rect current_damage_rect_; | 94 gfx::Rect current_damage_rect_; |
| 95 gfx::Rect current_overlay_rect_; |
| 87 | 96 |
| 88 DISALLOW_COPY_AND_ASSIGN(DamageTracker); | 97 DISALLOW_COPY_AND_ASSIGN(DamageTracker); |
| 89 }; | 98 }; |
| 90 | 99 |
| 91 } // namespace cc | 100 } // namespace cc |
| 92 | 101 |
| 93 #endif // CC_TREES_DAMAGE_TRACKER_H_ | 102 #endif // CC_TREES_DAMAGE_TRACKER_H_ |
| OLD | NEW |