blob: fbcaa69824df97de458e29d2c0c81fd1a315834b [file] [log] [blame]
[email protected]cd57cc5a2012-10-12 22:43:411// Copyright 2011 The Chromium Authors. All rights reserved.
[email protected]0fb25002012-10-12 07:20:022// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
[email protected]cd57cc5a2012-10-12 22:43:414
[email protected]556fd292013-03-18 08:03:045#ifndef CC_TREES_DAMAGE_TRACKER_H_
6#define CC_TREES_DAMAGE_TRACKER_H_
[email protected]cd57cc5a2012-10-12 22:43:417
[email protected]681ccff2013-03-18 06:13:528#include <vector>
[email protected]14c1c232013-06-11 17:52:449#include "base/containers/hash_tables.h"
[email protected]cd57cc5a2012-10-12 22:43:4110#include "base/memory/scoped_ptr.h"
[email protected]681ccff2013-03-18 06:13:5211#include "cc/base/cc_export.h"
[email protected]50761e92013-03-29 20:51:2812#include "cc/layers/layer_lists.h"
[email protected]aad0a0072012-11-01 18:15:5813#include "ui/gfx/rect_f.h"
[email protected]cd57cc5a2012-10-12 22:43:4114
[email protected]aad0a0072012-11-01 18:15:5815class SkImageFilter;
16
17namespace gfx {
18class Rect;
19}
20
[email protected]cd57cc5a2012-10-12 22:43:4121namespace cc {
22
[email protected]ae6b1a72013-06-25 18:49:2923class FilterOperations;
[email protected]96baf3e2012-10-22 23:09:5524class LayerImpl;
25class RenderSurfaceImpl;
[email protected]cd57cc5a2012-10-12 22:43:4126
[email protected]be3925ee2013-03-08 02:41:4727// Computes the region where pixels have actually changed on a
28// RenderSurfaceImpl. This region is used to scissor what is actually drawn to
29// the screen to save GPU computation and bandwidth.
[email protected]52347c842012-11-02 21:06:2030class CC_EXPORT DamageTracker {
[email protected]be3925ee2013-03-08 02:41:4731 public:
32 static scoped_ptr<DamageTracker> Create();
33 ~DamageTracker();
[email protected]cd57cc5a2012-10-12 22:43:4134
[email protected]be3925ee2013-03-08 02:41:4735 void DidDrawDamagedArea() { current_damage_rect_ = gfx::RectF(); }
[email protected]e0341352013-04-06 05:01:2036 void AddDamageNextUpdate(gfx::RectF dmg) { current_damage_rect_.Union(dmg); }
[email protected]be3925ee2013-03-08 02:41:4737 void UpdateDamageTrackingState(
[email protected]50761e92013-03-29 20:51:2838 const LayerImplList& layer_list,
[email protected]be3925ee2013-03-08 02:41:4739 int target_surface_layer_id,
40 bool target_surface_property_changed_only_from_descendant,
41 gfx::Rect target_surface_content_rect,
42 LayerImpl* target_surface_mask_layer,
[email protected]1dc7943e2013-09-26 04:41:4843 const FilterOperations& filters);
[email protected]cd57cc5a2012-10-12 22:43:4144
[email protected]be3925ee2013-03-08 02:41:4745 gfx::RectF current_damage_rect() { return current_damage_rect_; }
[email protected]cd57cc5a2012-10-12 22:43:4146
[email protected]be3925ee2013-03-08 02:41:4747 private:
48 DamageTracker();
[email protected]cd57cc5a2012-10-12 22:43:4149
[email protected]be3925ee2013-03-08 02:41:4750 gfx::RectF TrackDamageFromActiveLayers(
[email protected]50761e92013-03-29 20:51:2851 const LayerImplList& layer_list,
[email protected]be3925ee2013-03-08 02:41:4752 int target_surface_layer_id);
53 gfx::RectF TrackDamageFromSurfaceMask(LayerImpl* target_surface_mask_layer);
54 gfx::RectF TrackDamageFromLeftoverRects();
[email protected]cd57cc5a2012-10-12 22:43:4155
[email protected]be3925ee2013-03-08 02:41:4756 gfx::RectF RemoveRectFromCurrentFrame(int layer_id, bool* layer_is_new);
57 void SaveRectForNextFrame(int layer_id, const gfx::RectF& target_space_rect);
[email protected]cd57cc5a2012-10-12 22:43:4158
[email protected]be3925ee2013-03-08 02:41:4759 // 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);
[email protected]cd57cc5a2012-10-12 22:43:4163
[email protected]be3925ee2013-03-08 02:41:4764 // To correctly track exposed regions, two hashtables of rects are maintained.
65 // The "current" map is used to compute exposed regions of the current frame,
66 // while the "next" map is used to collect layer rects that are used in the
67 // next frame.
68 typedef base::hash_map<int, gfx::RectF> RectMap;
69 scoped_ptr<RectMap> current_rect_history_;
70 scoped_ptr<RectMap> next_rect_history_;
[email protected]cd57cc5a2012-10-12 22:43:4171
[email protected]be3925ee2013-03-08 02:41:4772 gfx::RectF current_damage_rect_;
[email protected]52347c842012-11-02 21:06:2073
[email protected]be3925ee2013-03-08 02:41:4774 DISALLOW_COPY_AND_ASSIGN(DamageTracker);
[email protected]cd57cc5a2012-10-12 22:43:4175};
76
[email protected]be3925ee2013-03-08 02:41:4777} // namespace cc
[email protected]cd57cc5a2012-10-12 22:43:4178
[email protected]556fd292013-03-18 08:03:0479#endif // CC_TREES_DAMAGE_TRACKER_H_