Getting rid of GetDefaultProfile(), clean up of ProfileManager (which was in a seriou...
[chromium-blink-merge.git] / cc / trees / damage_tracker.h
blob3809447389ab664284b31248c4cabc572b55115e
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_TREES_DAMAGE_TRACKER_H_
6 #define CC_TREES_DAMAGE_TRACKER_H_
8 #include <vector>
9 #include "base/memory/scoped_ptr.h"
10 #include "cc/base/cc_export.h"
11 #include "cc/layers/layer_lists.h"
12 #include "ui/gfx/rect_f.h"
14 class SkImageFilter;
16 namespace gfx {
17 class Rect;
20 namespace cc {
22 class FilterOperations;
23 class LayerImpl;
24 class RenderSurfaceImpl;
26 // Computes the region where pixels have actually changed on a
27 // RenderSurfaceImpl. This region is used to scissor what is actually drawn to
28 // the screen to save GPU computation and bandwidth.
29 class CC_EXPORT DamageTracker {
30 public:
31 static scoped_ptr<DamageTracker> Create();
32 ~DamageTracker();
34 void DidDrawDamagedArea() { current_damage_rect_ = gfx::RectF(); }
35 void AddDamageNextUpdate(const gfx::RectF& dmg) {
36 current_damage_rect_.Union(dmg);
38 void UpdateDamageTrackingState(
39 const LayerImplList& layer_list,
40 int target_surface_layer_id,
41 bool target_surface_property_changed_only_from_descendant,
42 const gfx::Rect& target_surface_content_rect,
43 LayerImpl* target_surface_mask_layer,
44 const FilterOperations& filters);
46 gfx::RectF current_damage_rect() { return current_damage_rect_; }
48 private:
49 DamageTracker();
51 gfx::RectF TrackDamageFromActiveLayers(
52 const LayerImplList& layer_list,
53 int target_surface_layer_id);
54 gfx::RectF TrackDamageFromSurfaceMask(LayerImpl* target_surface_mask_layer);
55 gfx::RectF TrackDamageFromLeftoverRects();
57 void PrepareRectHistoryForUpdate();
59 // These helper functions are used only in TrackDamageFromActiveLayers().
60 void ExtendDamageForLayer(LayerImpl* layer, gfx::RectF* target_damage_rect);
61 void ExtendDamageForRenderSurface(LayerImpl* layer,
62 gfx::RectF* target_damage_rect);
64 struct RectMapData {
65 RectMapData() : layer_id_(0), mailboxId_(0) {}
66 explicit RectMapData(int layer_id) : layer_id_(layer_id), mailboxId_(0) {}
67 void Update(const gfx::RectF& rect, unsigned int mailboxId) {
68 mailboxId_ = mailboxId;
69 rect_ = rect;
72 bool operator < (const RectMapData& other) const {
73 return layer_id_ < other.layer_id_;
76 int layer_id_;
77 unsigned int mailboxId_;
78 gfx::RectF rect_;
80 typedef std::vector<RectMapData> SortedRectMap;
82 RectMapData& RectDataForLayer(int layer_id, bool* layer_is_new);
84 SortedRectMap rect_history_;
86 unsigned int mailboxId_;
87 gfx::RectF current_damage_rect_;
89 DISALLOW_COPY_AND_ASSIGN(DamageTracker);
92 } // namespace cc
94 #endif // CC_TREES_DAMAGE_TRACKER_H_