blob: b113337ae59a502a3cc28bf0973217055ab78b23 [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]8fcbaa372012-11-05 04:12:415#ifndef CC_DAMAGE_TRACKER_H_
6#define CC_DAMAGE_TRACKER_H_
[email protected]cd57cc5a2012-10-12 22:43:417
[email protected]9dcbad242012-10-16 01:34:248#include "base/hash_tables.h"
[email protected]cd57cc5a2012-10-12 22:43:419#include "base/memory/scoped_ptr.h"
[email protected]52347c842012-11-02 21:06:2010#include "cc/cc_export.h"
[email protected]aad0a0072012-11-01 18:15:5811#include "ui/gfx/rect_f.h"
[email protected]cd57cc5a2012-10-12 22:43:4112#include <vector>
[email protected]cd57cc5a2012-10-12 22:43:4113
[email protected]aad0a0072012-11-01 18:15:5814class SkImageFilter;
15
16namespace gfx {
17class Rect;
18}
19
[email protected]cd57cc5a2012-10-12 22:43:4120namespace WebKit {
21class WebFilterOperations;
22}
23
24namespace cc {
25
[email protected]96baf3e2012-10-22 23:09:5526class LayerImpl;
27class RenderSurfaceImpl;
[email protected]cd57cc5a2012-10-12 22:43:4128
[email protected]be3925ee2013-03-08 02:41:4729// Computes the region where pixels have actually changed on a
30// RenderSurfaceImpl. This region is used to scissor what is actually drawn to
31// the screen to save GPU computation and bandwidth.
[email protected]52347c842012-11-02 21:06:2032class CC_EXPORT DamageTracker {
[email protected]be3925ee2013-03-08 02:41:4733 public:
34 static scoped_ptr<DamageTracker> Create();
35 ~DamageTracker();
[email protected]cd57cc5a2012-10-12 22:43:4136
[email protected]be3925ee2013-03-08 02:41:4737 void DidDrawDamagedArea() { current_damage_rect_ = gfx::RectF(); }
38 void ForceFullDamageNextUpdate() { force_full_damage_next_update_ = true; }
39 void UpdateDamageTrackingState(
40 const std::vector<LayerImpl*>& layer_list,
41 int target_surface_layer_id,
42 bool target_surface_property_changed_only_from_descendant,
43 gfx::Rect target_surface_content_rect,
44 LayerImpl* target_surface_mask_layer,
45 const WebKit::WebFilterOperations& filters,
46 SkImageFilter* filter);
[email protected]cd57cc5a2012-10-12 22:43:4147
[email protected]be3925ee2013-03-08 02:41:4748 gfx::RectF current_damage_rect() { return current_damage_rect_; }
[email protected]cd57cc5a2012-10-12 22:43:4149
[email protected]be3925ee2013-03-08 02:41:4750 private:
51 DamageTracker();
[email protected]cd57cc5a2012-10-12 22:43:4152
[email protected]be3925ee2013-03-08 02:41:4753 gfx::RectF TrackDamageFromActiveLayers(
54 const std::vector<LayerImpl*>& layer_list,
55 int target_surface_layer_id);
56 gfx::RectF TrackDamageFromSurfaceMask(LayerImpl* target_surface_mask_layer);
57 gfx::RectF TrackDamageFromLeftoverRects();
[email protected]cd57cc5a2012-10-12 22:43:4158
[email protected]be3925ee2013-03-08 02:41:4759 gfx::RectF RemoveRectFromCurrentFrame(int layer_id, bool* layer_is_new);
60 void SaveRectForNextFrame(int layer_id, const gfx::RectF& target_space_rect);
[email protected]cd57cc5a2012-10-12 22:43:4161
[email protected]be3925ee2013-03-08 02:41:4762 // These helper functions are used only in TrackDamageFromActiveLayers().
63 void ExtendDamageForLayer(LayerImpl* layer, gfx::RectF* target_damage_rect);
64 void ExtendDamageForRenderSurface(LayerImpl* layer,
65 gfx::RectF* target_damage_rect);
[email protected]cd57cc5a2012-10-12 22:43:4166
[email protected]be3925ee2013-03-08 02:41:4767 // To correctly track exposed regions, two hashtables of rects are maintained.
68 // The "current" map is used to compute exposed regions of the current frame,
69 // while the "next" map is used to collect layer rects that are used in the
70 // next frame.
71 typedef base::hash_map<int, gfx::RectF> RectMap;
72 scoped_ptr<RectMap> current_rect_history_;
73 scoped_ptr<RectMap> next_rect_history_;
[email protected]cd57cc5a2012-10-12 22:43:4174
[email protected]be3925ee2013-03-08 02:41:4775 gfx::RectF current_damage_rect_;
76 bool force_full_damage_next_update_;
[email protected]52347c842012-11-02 21:06:2077
[email protected]be3925ee2013-03-08 02:41:4778 DISALLOW_COPY_AND_ASSIGN(DamageTracker);
[email protected]cd57cc5a2012-10-12 22:43:4179};
80
[email protected]be3925ee2013-03-08 02:41:4781} // namespace cc
[email protected]cd57cc5a2012-10-12 22:43:4182
[email protected]8fcbaa372012-11-05 04:12:4183#endif // CC_DAMAGE_TRACKER_H_