Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Side by Side Diff: cc/trees/damage_tracker.h

Issue 2632463005: cc: Ensure that large damage doesn't register as "frame has no damage" (Closed)
Patch Set: update Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/render_surface_impl.cc ('k') | cc/trees/damage_tracker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 GetDamageRectIfValid(gfx::Rect* rect);
47 45
48 private: 46 private:
49 DamageTracker(); 47 DamageTracker();
50 48
51 gfx::Rect TrackDamageFromActiveLayers( 49 class DamageAccumulator {
50 public:
51 template <typename Type>
52 void Union(const Type& rect) {
53 if (!is_valid_rect_)
54 return;
55 if (rect.IsEmpty())
56 return;
57 if (IsEmpty()) {
58 x_ = rect.x();
59 y_ = rect.y();
60 right_ = rect.right();
61 bottom_ = rect.bottom();
62 return;
63 }
64
65 x_ = std::min(x_, rect.x());
66 y_ = std::min(y_, rect.y());
67 right_ = std::max(right_, rect.right());
68 bottom_ = std::max(bottom_, rect.bottom());
69 }
70
71 int x() const { return x_; }
72 int y() const { return y_; }
73 int right() const { return right_; }
74 int bottom() const { return bottom_; }
75 bool IsEmpty() const { return x_ == right_ || y_ == bottom_; }
76
77 bool GetAsRect(gfx::Rect* rect);
78
79 private:
80 bool is_valid_rect_ = true;
81 int x_ = 0;
82 int y_ = 0;
83 int right_ = 0;
84 int bottom_ = 0;
85 };
86
87 DamageAccumulator TrackDamageFromActiveLayers(
52 const LayerImplList& layer_list, 88 const LayerImplList& layer_list,
53 const RenderSurfaceImpl* target_surface); 89 const RenderSurfaceImpl* target_surface);
54 gfx::Rect TrackDamageFromSurfaceMask(LayerImpl* target_surface_mask_layer); 90 DamageAccumulator TrackDamageFromSurfaceMask(
55 gfx::Rect TrackDamageFromLeftoverRects(); 91 LayerImpl* target_surface_mask_layer);
56 92 DamageAccumulator TrackDamageFromLeftoverRects();
57 void PrepareRectHistoryForUpdate(); 93 void PrepareRectHistoryForUpdate();
58 94
59 // These helper functions are used only in TrackDamageFromActiveLayers(). 95 // These helper functions are used only in TrackDamageFromActiveLayers().
60 void ExtendDamageForLayer(LayerImpl* layer, gfx::Rect* target_damage_rect); 96 void ExtendDamageForLayer(LayerImpl* layer, DamageAccumulator* target_damage);
61 void ExtendDamageForRenderSurface(RenderSurfaceImpl* render_surface, 97 void ExtendDamageForRenderSurface(RenderSurfaceImpl* render_surface,
62 gfx::Rect* target_damage_rect); 98 DamageAccumulator* target_damage);
99 void ExpandDamageInsideRectWithFilters(const gfx::Rect& pre_filter_rect,
100 const FilterOperations& filters,
101 DamageAccumulator* damage);
63 102
64 struct LayerRectMapData { 103 struct LayerRectMapData {
65 LayerRectMapData() : layer_id_(0), mailboxId_(0) {} 104 LayerRectMapData() : layer_id_(0), mailboxId_(0) {}
66 explicit LayerRectMapData(int layer_id) 105 explicit LayerRectMapData(int layer_id)
67 : layer_id_(layer_id), mailboxId_(0) {} 106 : layer_id_(layer_id), mailboxId_(0) {}
68 void Update(const gfx::Rect& rect, unsigned int mailboxId) { 107 void Update(const gfx::Rect& rect, unsigned int mailboxId) {
69 mailboxId_ = mailboxId; 108 mailboxId_ = mailboxId;
70 rect_ = rect; 109 rect_ = rect;
71 } 110 }
72 111
(...skipping 26 matching lines...) Expand all
99 typedef std::vector<LayerRectMapData> SortedRectMapForLayers; 138 typedef std::vector<LayerRectMapData> SortedRectMapForLayers;
100 typedef std::vector<SurfaceRectMapData> SortedRectMapForSurfaces; 139 typedef std::vector<SurfaceRectMapData> SortedRectMapForSurfaces;
101 140
102 LayerRectMapData& RectDataForLayer(int layer_id, bool* layer_is_new); 141 LayerRectMapData& RectDataForLayer(int layer_id, bool* layer_is_new);
103 SurfaceRectMapData& RectDataForSurface(int layer_id, bool* layer_is_new); 142 SurfaceRectMapData& RectDataForSurface(int layer_id, bool* layer_is_new);
104 143
105 SortedRectMapForLayers rect_history_for_layers_; 144 SortedRectMapForLayers rect_history_for_layers_;
106 SortedRectMapForSurfaces rect_history_for_surfaces_; 145 SortedRectMapForSurfaces rect_history_for_surfaces_;
107 146
108 unsigned int mailboxId_; 147 unsigned int mailboxId_;
109 gfx::Rect current_damage_rect_; 148 DamageAccumulator current_damage_;
110 149
111 DISALLOW_COPY_AND_ASSIGN(DamageTracker); 150 DISALLOW_COPY_AND_ASSIGN(DamageTracker);
112 }; 151 };
113 152
114 } // namespace cc 153 } // namespace cc
115 154
116 #endif // CC_TREES_DAMAGE_TRACKER_H_ 155 #endif // CC_TREES_DAMAGE_TRACKER_H_
OLDNEW
« no previous file with comments | « cc/layers/render_surface_impl.cc ('k') | cc/trees/damage_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698