Use SCHEME_HTTP for HTTPS proxies on Android.
[chromium-blink-merge.git] / cc / damage_tracker.h
blob190c92adbc8e70839dbf0882cfff7b4bf7a2e747
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
3 // found in the LICENSE file.
5 #ifndef CC_DAMAGE_TRACKER_H_
6 #define CC_DAMAGE_TRACKER_H_
8 #include "base/hash_tables.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "cc/cc_export.h"
11 #include "ui/gfx/rect_f.h"
12 #include <vector>
14 class SkImageFilter;
16 namespace gfx {
17 class Rect;
20 namespace WebKit {
21 class WebFilterOperations;
24 namespace cc {
26 class LayerImpl;
27 class RenderSurfaceImpl;
29 // Computes the region where pixels have actually changed on a RenderSurfaceImpl. This region is used
30 // to scissor what is actually drawn to the screen to save GPU computation and bandwidth.
31 class CC_EXPORT DamageTracker {
32 public:
33 static scoped_ptr<DamageTracker> create();
34 ~DamageTracker();
36 void didDrawDamagedArea() { m_currentDamageRect = gfx::RectF(); }
37 void forceFullDamageNextUpdate() { m_forceFullDamageNextUpdate = true; }
38 void updateDamageTrackingState(const std::vector<LayerImpl*>& layerList, int targetSurfaceLayerID, bool targetSurfacePropertyChangedOnlyFromDescendant, const gfx::Rect& targetSurfaceContentRect, LayerImpl* targetSurfaceMaskLayer, const WebKit::WebFilterOperations&, SkImageFilter* filter);
40 const gfx::RectF& currentDamageRect() { return m_currentDamageRect; }
42 private:
43 DamageTracker();
45 gfx::RectF trackDamageFromActiveLayers(const std::vector<LayerImpl*>& layerList, int targetSurfaceLayerID);
46 gfx::RectF trackDamageFromSurfaceMask(LayerImpl* targetSurfaceMaskLayer);
47 gfx::RectF trackDamageFromLeftoverRects();
49 gfx::RectF removeRectFromCurrentFrame(int layerID, bool& layerIsNew);
50 void saveRectForNextFrame(int layerID, const gfx::RectF& targetSpaceRect);
52 // These helper functions are used only in trackDamageFromActiveLayers().
53 void extendDamageForLayer(LayerImpl*, gfx::RectF& targetDamageRect);
54 void extendDamageForRenderSurface(LayerImpl*, gfx::RectF& targetDamageRect);
56 // To correctly track exposed regions, two hashtables of rects are maintained.
57 // The "current" map is used to compute exposed regions of the current frame, while
58 // the "next" map is used to collect layer rects that are used in the next frame.
59 typedef base::hash_map<int, gfx::RectF> RectMap;
60 scoped_ptr<RectMap> m_currentRectHistory;
61 scoped_ptr<RectMap> m_nextRectHistory;
63 gfx::RectF m_currentDamageRect;
64 bool m_forceFullDamageNextUpdate;
66 DISALLOW_COPY_AND_ASSIGN(DamageTracker);
69 } // namespace cc
71 #endif // CC_DAMAGE_TRACKER_H_