[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] | 8fcbaa37 | 2012-11-05 04:12:41 | [diff] [blame] | 5 | #ifndef CC_DAMAGE_TRACKER_H_ |
| 6 | #define CC_DAMAGE_TRACKER_H_ |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 7 | |
[email protected] | 9dcbad24 | 2012-10-16 01:34:24 | [diff] [blame] | 8 | #include "base/hash_tables.h" |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 9 | #include "base/memory/scoped_ptr.h" |
[email protected] | 52347c84 | 2012-11-02 21:06:20 | [diff] [blame] | 10 | #include "cc/cc_export.h" |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 11 | #include "ui/gfx/rect_f.h" |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 12 | #include <vector> |
[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 WebKit { |
| 21 | class WebFilterOperations; |
| 22 | } |
| 23 | |
| 24 | namespace cc { |
| 25 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 26 | class LayerImpl; |
| 27 | class RenderSurfaceImpl; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 28 | |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame^] | 29 | // 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] | 52347c84 | 2012-11-02 21:06:20 | [diff] [blame] | 32 | class CC_EXPORT DamageTracker { |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame^] | 33 | public: |
| 34 | static scoped_ptr<DamageTracker> Create(); |
| 35 | ~DamageTracker(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 36 | |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame^] | 37 | 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] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 47 | |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame^] | 48 | gfx::RectF current_damage_rect() { return current_damage_rect_; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 49 | |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame^] | 50 | private: |
| 51 | DamageTracker(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 52 | |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame^] | 53 | 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] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 58 | |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame^] | 59 | gfx::RectF RemoveRectFromCurrentFrame(int layer_id, bool* layer_is_new); |
| 60 | void SaveRectForNextFrame(int layer_id, const gfx::RectF& target_space_rect); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 61 | |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame^] | 62 | // 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] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 66 | |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame^] | 67 | // 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] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 74 | |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame^] | 75 | gfx::RectF current_damage_rect_; |
| 76 | bool force_full_damage_next_update_; |
[email protected] | 52347c84 | 2012-11-02 21:06:20 | [diff] [blame] | 77 | |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame^] | 78 | DISALLOW_COPY_AND_ASSIGN(DamageTracker); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 79 | }; |
| 80 | |
[email protected] | be3925ee | 2013-03-08 02:41:47 | [diff] [blame^] | 81 | } // namespace cc |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 82 | |
[email protected] | 8fcbaa37 | 2012-11-05 04:12:41 | [diff] [blame] | 83 | #endif // CC_DAMAGE_TRACKER_H_ |