blob: 37a1900f78811bcec5c7817e6afb9ba48017b03f [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]cd57cc5a2012-10-12 22:43:419#include "base/memory/scoped_ptr.h"
[email protected]681ccff2013-03-18 06:13:5210#include "cc/base/cc_export.h"
[email protected]50761e92013-03-29 20:51:2811#include "cc/layers/layer_lists.h"
[email protected]aad0a0072012-11-01 18:15:5812#include "ui/gfx/rect_f.h"
[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 cc {
21
[email protected]ae6b1a72013-06-25 18:49:2922class FilterOperations;
[email protected]96baf3e2012-10-22 23:09:5523class LayerImpl;
24class RenderSurfaceImpl;
[email protected]cd57cc5a2012-10-12 22:43:4125
[email protected]be3925ee2013-03-08 02:41:4726// 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.
[email protected]52347c842012-11-02 21:06:2029class CC_EXPORT DamageTracker {
[email protected]be3925ee2013-03-08 02:41:4730 public:
31 static scoped_ptr<DamageTracker> Create();
32 ~DamageTracker();
[email protected]cd57cc5a2012-10-12 22:43:4133
[email protected]be3925ee2013-03-08 02:41:4734 void DidDrawDamagedArea() { current_damage_rect_ = gfx::RectF(); }
[email protected]e0341352013-04-06 05:01:2035 void AddDamageNextUpdate(gfx::RectF dmg) { current_damage_rect_.Union(dmg); }
[email protected]be3925ee2013-03-08 02:41:4736 void UpdateDamageTrackingState(
[email protected]50761e92013-03-29 20:51:2837 const LayerImplList& layer_list,
[email protected]be3925ee2013-03-08 02:41:4738 int target_surface_layer_id,
39 bool target_surface_property_changed_only_from_descendant,
40 gfx::Rect target_surface_content_rect,
41 LayerImpl* target_surface_mask_layer,
[email protected]1dc7943e2013-09-26 04:41:4842 const FilterOperations& filters);
[email protected]cd57cc5a2012-10-12 22:43:4143
[email protected]be3925ee2013-03-08 02:41:4744 gfx::RectF current_damage_rect() { return current_damage_rect_; }
[email protected]cd57cc5a2012-10-12 22:43:4145
[email protected]be3925ee2013-03-08 02:41:4746 private:
47 DamageTracker();
[email protected]cd57cc5a2012-10-12 22:43:4148
[email protected]be3925ee2013-03-08 02:41:4749 gfx::RectF TrackDamageFromActiveLayers(
[email protected]50761e92013-03-29 20:51:2850 const LayerImplList& layer_list,
[email protected]be3925ee2013-03-08 02:41:4751 int target_surface_layer_id);
52 gfx::RectF TrackDamageFromSurfaceMask(LayerImpl* target_surface_mask_layer);
53 gfx::RectF TrackDamageFromLeftoverRects();
[email protected]cd57cc5a2012-10-12 22:43:4154
[email protected]deacb8e2013-11-25 23:18:5855 void PrepareRectHistoryForUpdate();
[email protected]cd57cc5a2012-10-12 22:43:4156
[email protected]be3925ee2013-03-08 02:41:4757 // These helper functions are used only in TrackDamageFromActiveLayers().
58 void ExtendDamageForLayer(LayerImpl* layer, gfx::RectF* target_damage_rect);
59 void ExtendDamageForRenderSurface(LayerImpl* layer,
60 gfx::RectF* target_damage_rect);
[email protected]cd57cc5a2012-10-12 22:43:4161
[email protected]deacb8e2013-11-25 23:18:5862 struct RectMapData {
63 RectMapData() : layer_id_(0), mailboxId_(0) {}
64 explicit RectMapData(int layer_id) : layer_id_(layer_id), mailboxId_(0) {}
65 void Update(const gfx::RectF& rect, unsigned int mailboxId) {
66 mailboxId_ = mailboxId;
67 rect_ = rect;
68 }
[email protected]cd57cc5a2012-10-12 22:43:4169
[email protected]deacb8e2013-11-25 23:18:5870 bool operator < (const RectMapData& other) const {
71 return layer_id_ < other.layer_id_;
72 }
73
74 int layer_id_;
75 unsigned int mailboxId_;
76 gfx::RectF rect_;
77 };
78 typedef std::vector<RectMapData> SortedRectMap;
79
80 RectMapData& RectDataForLayer(int layer_id, bool* layer_is_new);
81
82 SortedRectMap rect_history_;
83
84 unsigned int mailboxId_;
[email protected]be3925ee2013-03-08 02:41:4785 gfx::RectF current_damage_rect_;
[email protected]52347c842012-11-02 21:06:2086
[email protected]be3925ee2013-03-08 02:41:4787 DISALLOW_COPY_AND_ASSIGN(DamageTracker);
[email protected]cd57cc5a2012-10-12 22:43:4188};
89
[email protected]be3925ee2013-03-08 02:41:4790} // namespace cc
[email protected]cd57cc5a2012-10-12 22:43:4191
[email protected]556fd292013-03-18 08:03:0492#endif // CC_TREES_DAMAGE_TRACKER_H_