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/hash_tables.h" | 9 #include "base/hash_tables.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "cc/base/cc_export.h" | 11 #include "cc/base/cc_export.h" |
| 12 #include "cc/layers/layer_lists.h" |
12 #include "ui/gfx/rect_f.h" | 13 #include "ui/gfx/rect_f.h" |
13 | 14 |
14 class SkImageFilter; | 15 class SkImageFilter; |
15 | 16 |
16 namespace gfx { | 17 namespace gfx { |
17 class Rect; | 18 class Rect; |
18 } | 19 } |
19 | 20 |
20 namespace WebKit { | 21 namespace WebKit { |
21 class WebFilterOperations; | 22 class WebFilterOperations; |
22 } | 23 } |
23 | 24 |
24 namespace cc { | 25 namespace cc { |
25 | 26 |
26 class LayerImpl; | 27 class LayerImpl; |
27 class RenderSurfaceImpl; | 28 class RenderSurfaceImpl; |
28 | 29 |
29 // Computes the region where pixels have actually changed on a | 30 // Computes the region where pixels have actually changed on a |
30 // RenderSurfaceImpl. This region is used to scissor what is actually drawn to | 31 // RenderSurfaceImpl. This region is used to scissor what is actually drawn to |
31 // the screen to save GPU computation and bandwidth. | 32 // the screen to save GPU computation and bandwidth. |
32 class CC_EXPORT DamageTracker { | 33 class CC_EXPORT DamageTracker { |
33 public: | 34 public: |
34 static scoped_ptr<DamageTracker> Create(); | 35 static scoped_ptr<DamageTracker> Create(); |
35 ~DamageTracker(); | 36 ~DamageTracker(); |
36 | 37 |
37 void DidDrawDamagedArea() { current_damage_rect_ = gfx::RectF(); } | 38 void DidDrawDamagedArea() { current_damage_rect_ = gfx::RectF(); } |
38 void ForceFullDamageNextUpdate() { force_full_damage_next_update_ = true; } | 39 void ForceFullDamageNextUpdate() { force_full_damage_next_update_ = true; } |
39 void UpdateDamageTrackingState( | 40 void UpdateDamageTrackingState( |
40 const std::vector<LayerImpl*>& layer_list, | 41 const LayerImplList& layer_list, |
41 int target_surface_layer_id, | 42 int target_surface_layer_id, |
42 bool target_surface_property_changed_only_from_descendant, | 43 bool target_surface_property_changed_only_from_descendant, |
43 gfx::Rect target_surface_content_rect, | 44 gfx::Rect target_surface_content_rect, |
44 LayerImpl* target_surface_mask_layer, | 45 LayerImpl* target_surface_mask_layer, |
45 const WebKit::WebFilterOperations& filters, | 46 const WebKit::WebFilterOperations& filters, |
46 SkImageFilter* filter); | 47 SkImageFilter* filter); |
47 | 48 |
48 gfx::RectF current_damage_rect() { return current_damage_rect_; } | 49 gfx::RectF current_damage_rect() { return current_damage_rect_; } |
49 | 50 |
50 private: | 51 private: |
51 DamageTracker(); | 52 DamageTracker(); |
52 | 53 |
53 gfx::RectF TrackDamageFromActiveLayers( | 54 gfx::RectF TrackDamageFromActiveLayers( |
54 const std::vector<LayerImpl*>& layer_list, | 55 const LayerImplList& layer_list, |
55 int target_surface_layer_id); | 56 int target_surface_layer_id); |
56 gfx::RectF TrackDamageFromSurfaceMask(LayerImpl* target_surface_mask_layer); | 57 gfx::RectF TrackDamageFromSurfaceMask(LayerImpl* target_surface_mask_layer); |
57 gfx::RectF TrackDamageFromLeftoverRects(); | 58 gfx::RectF TrackDamageFromLeftoverRects(); |
58 | 59 |
59 gfx::RectF RemoveRectFromCurrentFrame(int layer_id, bool* layer_is_new); | 60 gfx::RectF RemoveRectFromCurrentFrame(int layer_id, bool* layer_is_new); |
60 void SaveRectForNextFrame(int layer_id, const gfx::RectF& target_space_rect); | 61 void SaveRectForNextFrame(int layer_id, const gfx::RectF& target_space_rect); |
61 | 62 |
62 // These helper functions are used only in TrackDamageFromActiveLayers(). | 63 // These helper functions are used only in TrackDamageFromActiveLayers(). |
63 void ExtendDamageForLayer(LayerImpl* layer, gfx::RectF* target_damage_rect); | 64 void ExtendDamageForLayer(LayerImpl* layer, gfx::RectF* target_damage_rect); |
64 void ExtendDamageForRenderSurface(LayerImpl* layer, | 65 void ExtendDamageForRenderSurface(LayerImpl* layer, |
65 gfx::RectF* target_damage_rect); | 66 gfx::RectF* target_damage_rect); |
66 | 67 |
67 // To correctly track exposed regions, two hashtables of rects are maintained. | 68 // To correctly track exposed regions, two hashtables of rects are maintained. |
68 // The "current" map is used to compute exposed regions of the current frame, | 69 // The "current" map is used to compute exposed regions of the current frame, |
69 // while the "next" map is used to collect layer rects that are used in the | 70 // while the "next" map is used to collect layer rects that are used in the |
70 // next frame. | 71 // next frame. |
71 typedef base::hash_map<int, gfx::RectF> RectMap; | 72 typedef base::hash_map<int, gfx::RectF> RectMap; |
72 scoped_ptr<RectMap> current_rect_history_; | 73 scoped_ptr<RectMap> current_rect_history_; |
73 scoped_ptr<RectMap> next_rect_history_; | 74 scoped_ptr<RectMap> next_rect_history_; |
74 | 75 |
75 gfx::RectF current_damage_rect_; | 76 gfx::RectF current_damage_rect_; |
76 bool force_full_damage_next_update_; | 77 bool force_full_damage_next_update_; |
77 | 78 |
78 DISALLOW_COPY_AND_ASSIGN(DamageTracker); | 79 DISALLOW_COPY_AND_ASSIGN(DamageTracker); |
79 }; | 80 }; |
80 | 81 |
81 } // namespace cc | 82 } // namespace cc |
82 | 83 |
83 #endif // CC_TREES_DAMAGE_TRACKER_H_ | 84 #endif // CC_TREES_DAMAGE_TRACKER_H_ |
OLD | NEW |