[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] | 14c1c23 | 2013-06-11 17:52:44 | [diff] [blame] | 9 | #include "base/containers/hash_tables.h" |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 10 | #include "base/memory/scoped_ptr.h" |
[email protected] | 681ccff | 2013-03-18 06:13:52 | [diff] [blame] | 11 | #include "cc/base/cc_export.h" |
[email protected] | 50761e9 | 2013-03-29 20:51:28 | [diff] [blame] | 12 | #include "cc/layers/layer_lists.h" |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 13 | #include "ui/gfx/rect_f.h" |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 14 | |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 15 | class SkImageFilter; |
| 16 | |
| 17 | namespace gfx { |
| 18 | class Rect; |
| 19 | } |
| 20 | |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 21 | namespace cc { |
| 22 | |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame^] | 23 | class FilterOperations; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 24 | class LayerImpl; |
| 25 | class RenderSurfaceImpl; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 26 | |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame] | 27 | // 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] | 52347c84 | 2012-11-02 21:06:20 | [diff] [blame] | 30 | class CC_EXPORT DamageTracker { |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame] | 31 | public: |
| 32 | static scoped_ptr<DamageTracker> Create(); |
| 33 | ~DamageTracker(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 34 | |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame] | 35 | void DidDrawDamagedArea() { current_damage_rect_ = gfx::RectF(); } |
[email protected] | e034135 | 2013-04-06 05:01:20 | [diff] [blame] | 36 | void AddDamageNextUpdate(gfx::RectF dmg) { current_damage_rect_.Union(dmg); } |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame] | 37 | void UpdateDamageTrackingState( |
[email protected] | 50761e9 | 2013-03-29 20:51:28 | [diff] [blame] | 38 | const LayerImplList& layer_list, |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame] | 39 | 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] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame^] | 43 | const FilterOperations& filters, |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame] | 44 | SkImageFilter* filter); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 45 | |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame] | 46 | gfx::RectF 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] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame] | 51 | gfx::RectF TrackDamageFromActiveLayers( |
[email protected] | 50761e9 | 2013-03-29 20:51:28 | [diff] [blame] | 52 | const LayerImplList& layer_list, |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame] | 53 | int target_surface_layer_id); |
| 54 | gfx::RectF TrackDamageFromSurfaceMask(LayerImpl* target_surface_mask_layer); |
| 55 | gfx::RectF TrackDamageFromLeftoverRects(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 56 | |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame] | 57 | gfx::RectF RemoveRectFromCurrentFrame(int layer_id, bool* layer_is_new); |
| 58 | void SaveRectForNextFrame(int layer_id, const gfx::RectF& target_space_rect); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 59 | |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame] | 60 | // These helper functions are used only in TrackDamageFromActiveLayers(). |
| 61 | void ExtendDamageForLayer(LayerImpl* layer, gfx::RectF* target_damage_rect); |
| 62 | void ExtendDamageForRenderSurface(LayerImpl* layer, |
| 63 | gfx::RectF* target_damage_rect); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 64 | |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame] | 65 | // To correctly track exposed regions, two hashtables of rects are maintained. |
| 66 | // The "current" map is used to compute exposed regions of the current frame, |
| 67 | // while the "next" map is used to collect layer rects that are used in the |
| 68 | // next frame. |
| 69 | typedef base::hash_map<int, gfx::RectF> RectMap; |
| 70 | scoped_ptr<RectMap> current_rect_history_; |
| 71 | scoped_ptr<RectMap> next_rect_history_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 72 | |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame] | 73 | gfx::RectF current_damage_rect_; |
[email protected] | 52347c84 | 2012-11-02 21:06:20 | [diff] [blame] | 74 | |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame] | 75 | DISALLOW_COPY_AND_ASSIGN(DamageTracker); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 76 | }; |
| 77 | |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame] | 78 | } // namespace cc |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 79 | |
[email protected] | 556fd29 | 2013-03-18 08:03:04 | [diff] [blame] | 80 | #endif // CC_TREES_DAMAGE_TRACKER_H_ |