| 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 CCDamageTracker_h | 5 #ifndef CCDamageTracker_h |
| 6 #define CCDamageTracker_h | 6 #define CCDamageTracker_h |
| 7 | 7 |
| 8 #include "base/hash_tables.h" | 8 #include "base/hash_tables.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "FloatRect.h" | 10 #include "FloatRect.h" |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 namespace WebKit { | 13 namespace WebKit { |
| 14 class WebFilterOperations; | 14 class WebFilterOperations; |
| 15 } | 15 } |
| 16 | 16 |
| 17 namespace cc { | 17 namespace cc { |
| 18 | 18 |
| 19 class CCLayerImpl; | 19 class LayerImpl; |
| 20 class CCRenderSurface; | 20 class RenderSurfaceImpl; |
| 21 | 21 |
| 22 // Computes the region where pixels have actually changed on a RenderSurface. Th
is region is used | 22 // Computes the region where pixels have actually changed on a RenderSurfaceImpl
. This region is used |
| 23 // to scissor what is actually drawn to the screen to save GPU computation and b
andwidth. | 23 // to scissor what is actually drawn to the screen to save GPU computation and b
andwidth. |
| 24 class CCDamageTracker { | 24 class DamageTracker { |
| 25 public: | 25 public: |
| 26 static scoped_ptr<CCDamageTracker> create(); | 26 static scoped_ptr<DamageTracker> create(); |
| 27 ~CCDamageTracker(); | 27 ~DamageTracker(); |
| 28 | 28 |
| 29 void didDrawDamagedArea() { m_currentDamageRect = FloatRect(); } | 29 void didDrawDamagedArea() { m_currentDamageRect = FloatRect(); } |
| 30 void forceFullDamageNextUpdate() { m_forceFullDamageNextUpdate = true; } | 30 void forceFullDamageNextUpdate() { m_forceFullDamageNextUpdate = true; } |
| 31 void updateDamageTrackingState(const std::vector<CCLayerImpl*>& layerList, i
nt targetSurfaceLayerID, bool targetSurfacePropertyChangedOnlyFromDescendant, co
nst IntRect& targetSurfaceContentRect, CCLayerImpl* targetSurfaceMaskLayer, cons
t WebKit::WebFilterOperations&); | 31 void updateDamageTrackingState(const std::vector<LayerImpl*>& layerList, int
targetSurfaceLayerID, bool targetSurfacePropertyChangedOnlyFromDescendant, cons
t IntRect& targetSurfaceContentRect, LayerImpl* targetSurfaceMaskLayer, const We
bKit::WebFilterOperations&); |
| 32 | 32 |
| 33 const FloatRect& currentDamageRect() { return m_currentDamageRect; } | 33 const FloatRect& currentDamageRect() { return m_currentDamageRect; } |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 CCDamageTracker(); | 36 DamageTracker(); |
| 37 | 37 |
| 38 FloatRect trackDamageFromActiveLayers(const std::vector<CCLayerImpl*>& layer
List, int targetSurfaceLayerID); | 38 FloatRect trackDamageFromActiveLayers(const std::vector<LayerImpl*>& layerLi
st, int targetSurfaceLayerID); |
| 39 FloatRect trackDamageFromSurfaceMask(CCLayerImpl* targetSurfaceMaskLayer); | 39 FloatRect trackDamageFromSurfaceMask(LayerImpl* targetSurfaceMaskLayer); |
| 40 FloatRect trackDamageFromLeftoverRects(); | 40 FloatRect trackDamageFromLeftoverRects(); |
| 41 | 41 |
| 42 FloatRect removeRectFromCurrentFrame(int layerID, bool& layerIsNew); | 42 FloatRect removeRectFromCurrentFrame(int layerID, bool& layerIsNew); |
| 43 void saveRectForNextFrame(int layerID, const FloatRect& targetSpaceRect); | 43 void saveRectForNextFrame(int layerID, const FloatRect& targetSpaceRect); |
| 44 | 44 |
| 45 // These helper functions are used only in trackDamageFromActiveLayers(). | 45 // These helper functions are used only in trackDamageFromActiveLayers(). |
| 46 void extendDamageForLayer(CCLayerImpl*, FloatRect& targetDamageRect); | 46 void extendDamageForLayer(LayerImpl*, FloatRect& targetDamageRect); |
| 47 void extendDamageForRenderSurface(CCLayerImpl*, FloatRect& targetDamageRect)
; | 47 void extendDamageForRenderSurface(LayerImpl*, FloatRect& targetDamageRect); |
| 48 | 48 |
| 49 // To correctly track exposed regions, two hashtables of rects are maintaine
d. | 49 // To correctly track exposed regions, two hashtables of rects are maintaine
d. |
| 50 // The "current" map is used to compute exposed regions of the current frame
, while | 50 // The "current" map is used to compute exposed regions of the current frame
, while |
| 51 // the "next" map is used to collect layer rects that are used in the next f
rame. | 51 // the "next" map is used to collect layer rects that are used in the next f
rame. |
| 52 typedef base::hash_map<int, FloatRect> RectMap; | 52 typedef base::hash_map<int, FloatRect> RectMap; |
| 53 scoped_ptr<RectMap> m_currentRectHistory; | 53 scoped_ptr<RectMap> m_currentRectHistory; |
| 54 scoped_ptr<RectMap> m_nextRectHistory; | 54 scoped_ptr<RectMap> m_nextRectHistory; |
| 55 | 55 |
| 56 FloatRect m_currentDamageRect; | 56 FloatRect m_currentDamageRect; |
| 57 bool m_forceFullDamageNextUpdate; | 57 bool m_forceFullDamageNextUpdate; |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 } // namespace cc | 60 } // namespace cc |
| 61 | 61 |
| 62 #endif // CCDamageTracker_h | 62 #endif // CCDamageTracker_h |
| OLD | NEW |