[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 1 | // Copyright 2011 The Chromium Authors. All rights reserved. |
[email protected] | 0fb2500 | 2012-10-12 07:20:02 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 4 | |
[email protected] | 556fd29 | 2013-03-18 08:03:04 | [diff] [blame] | 5 | #ifndef CC_TREES_DAMAGE_TRACKER_H_ |
| 6 | #define CC_TREES_DAMAGE_TRACKER_H_ |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 7 | |
[email protected] | 681ccff | 2013-03-18 06:13:52 | [diff] [blame] | 8 | #include <vector> |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 9 | #include "base/memory/scoped_ptr.h" |
[email protected] | 681ccff | 2013-03-18 06:13:52 | [diff] [blame] | 10 | #include "cc/base/cc_export.h" |
[email protected] | 50761e9 | 2013-03-29 20:51:28 | [diff] [blame] | 11 | #include "cc/layers/layer_lists.h" |
heejin.r.chung | d28506ba | 2014-10-23 16:36:20 | [diff] [blame^] | 12 | #include "ui/gfx/geometry/rect.h" |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 13 | |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 14 | class SkImageFilter; |
| 15 | |
| 16 | namespace gfx { |
| 17 | class Rect; |
| 18 | } |
| 19 | |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 20 | namespace cc { |
| 21 | |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 22 | class FilterOperations; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 23 | class LayerImpl; |
| 24 | class RenderSurfaceImpl; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 25 | |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame] | 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. |
[email protected] | 52347c84 | 2012-11-02 21:06:20 | [diff] [blame] | 29 | class CC_EXPORT DamageTracker { |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame] | 30 | public: |
| 31 | static scoped_ptr<DamageTracker> Create(); |
| 32 | ~DamageTracker(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 33 | |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 34 | void DidDrawDamagedArea() { current_damage_rect_ = gfx::Rect(); } |
| 35 | void AddDamageNextUpdate(const gfx::Rect& dmg) { |
[email protected] | 0023fc7 | 2014-01-10 20:05:06 | [diff] [blame] | 36 | current_damage_rect_.Union(dmg); |
| 37 | } |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame] | 38 | void UpdateDamageTrackingState( |
[email protected] | 50761e9 | 2013-03-29 20:51:28 | [diff] [blame] | 39 | const LayerImplList& layer_list, |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame] | 40 | int target_surface_layer_id, |
| 41 | bool target_surface_property_changed_only_from_descendant, |
[email protected] | 0023fc7 | 2014-01-10 20:05:06 | [diff] [blame] | 42 | const gfx::Rect& target_surface_content_rect, |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame] | 43 | LayerImpl* target_surface_mask_layer, |
[email protected] | 1dc7943e | 2013-09-26 04:41:48 | [diff] [blame] | 44 | const FilterOperations& filters); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 45 | |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 46 | gfx::Rect current_damage_rect() { return current_damage_rect_; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 47 | |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame] | 48 | private: |
| 49 | DamageTracker(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 50 | |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 51 | gfx::Rect TrackDamageFromActiveLayers(const LayerImplList& layer_list, |
| 52 | int target_surface_layer_id); |
| 53 | gfx::Rect TrackDamageFromSurfaceMask(LayerImpl* target_surface_mask_layer); |
| 54 | gfx::Rect TrackDamageFromLeftoverRects(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 55 | |
[email protected] | deacb8e | 2013-11-25 23:18:58 | [diff] [blame] | 56 | void PrepareRectHistoryForUpdate(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 57 | |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame] | 58 | // These helper functions are used only in TrackDamageFromActiveLayers(). |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 59 | void ExtendDamageForLayer(LayerImpl* layer, gfx::Rect* target_damage_rect); |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame] | 60 | void ExtendDamageForRenderSurface(LayerImpl* layer, |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 61 | gfx::Rect* target_damage_rect); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 62 | |
[email protected] | deacb8e | 2013-11-25 23:18:58 | [diff] [blame] | 63 | struct RectMapData { |
| 64 | RectMapData() : layer_id_(0), mailboxId_(0) {} |
| 65 | explicit RectMapData(int layer_id) : layer_id_(layer_id), mailboxId_(0) {} |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 66 | void Update(const gfx::Rect& rect, unsigned int mailboxId) { |
[email protected] | deacb8e | 2013-11-25 23:18:58 | [diff] [blame] | 67 | mailboxId_ = mailboxId; |
| 68 | rect_ = rect; |
| 69 | } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 70 | |
[email protected] | deacb8e | 2013-11-25 23:18:58 | [diff] [blame] | 71 | bool operator < (const RectMapData& other) const { |
| 72 | return layer_id_ < other.layer_id_; |
| 73 | } |
| 74 | |
| 75 | int layer_id_; |
| 76 | unsigned int mailboxId_; |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 77 | gfx::Rect rect_; |
[email protected] | deacb8e | 2013-11-25 23:18:58 | [diff] [blame] | 78 | }; |
| 79 | typedef std::vector<RectMapData> SortedRectMap; |
| 80 | |
| 81 | RectMapData& RectDataForLayer(int layer_id, bool* layer_is_new); |
| 82 | |
| 83 | SortedRectMap rect_history_; |
| 84 | |
| 85 | unsigned int mailboxId_; |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 86 | gfx::Rect current_damage_rect_; |
[email protected] | 52347c84 | 2012-11-02 21:06:20 | [diff] [blame] | 87 | |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame] | 88 | DISALLOW_COPY_AND_ASSIGN(DamageTracker); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 89 | }; |
| 90 | |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame] | 91 | } // namespace cc |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 92 | |
[email protected] | 556fd29 | 2013-03-18 08:03:04 | [diff] [blame] | 93 | #endif // CC_TREES_DAMAGE_TRACKER_H_ |