OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_OUTPUT_OVERLAY_PROCESSOR_H_ | 5 #ifndef CC_OUTPUT_OVERLAY_PROCESSOR_H_ |
6 #define CC_OUTPUT_OVERLAY_PROCESSOR_H_ | 6 #define CC_OUTPUT_OVERLAY_PROCESSOR_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 class CC_EXPORT Strategy { | 22 class CC_EXPORT Strategy { |
23 public: | 23 public: |
24 virtual ~Strategy() {} | 24 virtual ~Strategy() {} |
25 // Returns false if the strategy cannot be made to work with the | 25 // Returns false if the strategy cannot be made to work with the |
26 // current set of render passes. Returns true if the strategy was successful | 26 // current set of render passes. Returns true if the strategy was successful |
27 // and adds any additional passes necessary to represent overlays to | 27 // and adds any additional passes necessary to represent overlays to |
28 // |render_passes|. | 28 // |render_passes|. |
29 virtual bool Attempt(ResourceProvider* resource_provider, | 29 virtual bool Attempt(ResourceProvider* resource_provider, |
30 RenderPass* render_pass, | 30 RenderPass* render_pass, |
31 OverlayCandidateList* candidates) = 0; | 31 OverlayCandidateList* candidates) = 0; |
| 32 |
| 33 virtual bool GetSwapWithDamageRect(gfx::Rect* rect); |
32 }; | 34 }; |
33 using StrategyList = std::vector<std::unique_ptr<Strategy>>; | 35 using StrategyList = std::vector<std::unique_ptr<Strategy>>; |
34 | 36 |
35 explicit OverlayProcessor(OutputSurface* surface); | 37 explicit OverlayProcessor(OutputSurface* surface); |
36 virtual ~OverlayProcessor(); | 38 virtual ~OverlayProcessor(); |
37 // Virtual to allow testing different strategies. | 39 // Virtual to allow testing different strategies. |
38 virtual void Initialize(); | 40 virtual void Initialize(); |
39 | 41 |
40 gfx::Rect GetAndResetOverlayDamage(); | 42 gfx::Rect GetAndResetOverlayDamage(); |
41 | 43 |
42 // Attempt to replace quads from the specified root render pass with overlays | 44 // Attempt to replace quads from the specified root render pass with overlays |
43 // or CALayers. This must be called every frame. | 45 // or CALayers. This must be called every frame. |
44 void ProcessForOverlays(ResourceProvider* resource_provider, | 46 void ProcessForOverlays(ResourceProvider* resource_provider, |
45 RenderPass* root_render_pass, | 47 RenderPass* root_render_pass, |
46 OverlayCandidateList* overlay_candidates, | 48 OverlayCandidateList* overlay_candidates, |
47 CALayerOverlayList* ca_layer_overlays, | 49 CALayerOverlayList* ca_layer_overlays, |
48 gfx::Rect* damage_rect); | 50 gfx::Rect* damage_rect); |
49 | 51 |
| 52 bool GetSwapWithDamageRect(gfx::Rect* damage_rect); |
| 53 |
50 protected: | 54 protected: |
51 StrategyList strategies_; | 55 StrategyList strategies_; |
52 OutputSurface* surface_; | 56 OutputSurface* surface_; |
53 gfx::Rect overlay_damage_rect_; | 57 gfx::Rect overlay_damage_rect_; |
54 gfx::Rect previous_frame_underlay_rect_; | 58 gfx::Rect previous_frame_underlay_rect_; |
55 | 59 |
| 60 bool have_swap_with_damage_rect_; |
| 61 gfx::Rect swap_with_damage_rect_; |
| 62 |
56 private: | 63 private: |
57 bool ProcessForCALayers(ResourceProvider* resource_provider, | 64 bool ProcessForCALayers(ResourceProvider* resource_provider, |
58 RenderPass* render_pass, | 65 RenderPass* render_pass, |
59 OverlayCandidateList* overlay_candidates, | 66 OverlayCandidateList* overlay_candidates, |
60 CALayerOverlayList* ca_layer_overlays, | 67 CALayerOverlayList* ca_layer_overlays, |
61 gfx::Rect* damage_rect); | 68 gfx::Rect* damage_rect); |
62 // Update |damage_rect| by removing damage casued by |candidates|. | 69 // Update |damage_rect| by removing damage casued by |candidates|. |
63 void UpdateDamageRect(OverlayCandidateList* candidates, | 70 void UpdateDamageRect(OverlayCandidateList* candidates, |
64 gfx::Rect* damage_rect); | 71 gfx::Rect* damage_rect); |
65 | 72 |
66 DISALLOW_COPY_AND_ASSIGN(OverlayProcessor); | 73 DISALLOW_COPY_AND_ASSIGN(OverlayProcessor); |
67 }; | 74 }; |
68 | 75 |
69 } // namespace cc | 76 } // namespace cc |
70 | 77 |
71 #endif // CC_OUTPUT_OVERLAY_PROCESSOR_H_ | 78 #endif // CC_OUTPUT_OVERLAY_PROCESSOR_H_ |
OLD | NEW |