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 #include "cc/output/overlay_processor.h" | 5 #include "cc/output/overlay_processor.h" |
6 | 6 |
7 #include "cc/output/output_surface.h" | 7 #include "cc/output/output_surface.h" |
8 #include "cc/output/overlay_strategy_single_on_top.h" | 8 #include "cc/output/overlay_strategy_single_on_top.h" |
9 #include "cc/output/overlay_strategy_underlay.h" | 9 #include "cc/output/overlay_strategy_underlay.h" |
10 #include "cc/quads/draw_quad.h" | 10 #include "cc/quads/draw_quad.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 gfx::Rect OverlayProcessor::GetAndResetOverlayDamage() { | 55 gfx::Rect OverlayProcessor::GetAndResetOverlayDamage() { |
56 gfx::Rect result = overlay_damage_rect_; | 56 gfx::Rect result = overlay_damage_rect_; |
57 overlay_damage_rect_ = gfx::Rect(); | 57 overlay_damage_rect_ = gfx::Rect(); |
58 return result; | 58 return result; |
59 } | 59 } |
60 | 60 |
61 bool OverlayProcessor::ProcessForCALayers( | 61 bool OverlayProcessor::ProcessForCALayers( |
62 ResourceProvider* resource_provider, | 62 ResourceProvider* resource_provider, |
63 RenderPass* render_pass, | 63 RenderPass* render_pass, |
| 64 const RenderPassFilterList& render_pass_filters, |
| 65 const RenderPassFilterList& render_pass_background_filters, |
64 OverlayCandidateList* overlay_candidates, | 66 OverlayCandidateList* overlay_candidates, |
65 CALayerOverlayList* ca_layer_overlays, | 67 CALayerOverlayList* ca_layer_overlays, |
66 gfx::Rect* damage_rect) { | 68 gfx::Rect* damage_rect) { |
67 OverlayCandidateValidator* overlay_validator = | 69 OverlayCandidateValidator* overlay_validator = |
68 surface_->GetOverlayCandidateValidator(); | 70 surface_->GetOverlayCandidateValidator(); |
69 if (!overlay_validator || !overlay_validator->AllowCALayerOverlays()) | 71 if (!overlay_validator || !overlay_validator->AllowCALayerOverlays()) |
70 return false; | 72 return false; |
71 | 73 |
72 if (!ProcessForCALayerOverlays(resource_provider, | 74 if (!ProcessForCALayerOverlays( |
73 gfx::RectF(render_pass->output_rect), | 75 resource_provider, gfx::RectF(render_pass->output_rect), |
74 render_pass->quad_list, ca_layer_overlays)) | 76 render_pass->quad_list, render_pass_filters, |
| 77 render_pass_background_filters, ca_layer_overlays)) |
75 return false; | 78 return false; |
76 | 79 |
77 // CALayer overlays are all-or-nothing. If all quads were replaced with | 80 // CALayer overlays are all-or-nothing. If all quads were replaced with |
78 // layers then clear the list and remove the backbuffer from the overcandidate | 81 // layers then clear the list and remove the backbuffer from the overcandidate |
79 // list. | 82 // list. |
80 overlay_candidates->clear(); | 83 overlay_candidates->clear(); |
81 overlay_damage_rect_ = render_pass->output_rect; | 84 overlay_damage_rect_ = render_pass->output_rect; |
82 *damage_rect = gfx::Rect(); | 85 *damage_rect = gfx::Rect(); |
83 return true; | 86 return true; |
84 } | 87 } |
85 | 88 |
86 void OverlayProcessor::ProcessForOverlays(ResourceProvider* resource_provider, | 89 void OverlayProcessor::ProcessForOverlays( |
87 RenderPass* render_pass, | 90 ResourceProvider* resource_provider, |
88 OverlayCandidateList* candidates, | 91 RenderPass* render_pass, |
89 CALayerOverlayList* ca_layer_overlays, | 92 const RenderPassFilterList& render_pass_filters, |
90 gfx::Rect* damage_rect) { | 93 const RenderPassFilterList& render_pass_background_filters, |
| 94 OverlayCandidateList* candidates, |
| 95 CALayerOverlayList* ca_layer_overlays, |
| 96 gfx::Rect* damage_rect) { |
91 #if defined(OS_ANDROID) | 97 #if defined(OS_ANDROID) |
92 // Be sure to send out notifications, regardless of whether we get to | 98 // Be sure to send out notifications, regardless of whether we get to |
93 // processing for overlays or not. If we don't, then we should notify that | 99 // processing for overlays or not. If we don't, then we should notify that |
94 // they are not promotable. | 100 // they are not promotable. |
95 SendPromotionHintsBeforeReturning notifier(resource_provider, candidates); | 101 SendPromotionHintsBeforeReturning notifier(resource_provider, candidates); |
96 #endif | 102 #endif |
97 | 103 |
98 // If we have any copy requests, we can't remove any quads for overlays or | 104 // If we have any copy requests, we can't remove any quads for overlays or |
99 // CALayers because the framebuffer would be missing the removed quads' | 105 // CALayers because the framebuffer would be missing the removed quads' |
100 // contents. | 106 // contents. |
101 if (!render_pass->copy_requests.empty()) { | 107 if (!render_pass->copy_requests.empty()) { |
102 // If overlay processing was skipped for a frame there's no way to be sure | 108 // If overlay processing was skipped for a frame there's no way to be sure |
103 // of the state of the previous frame, so reset. | 109 // of the state of the previous frame, so reset. |
104 previous_frame_underlay_rect_ = gfx::Rect(); | 110 previous_frame_underlay_rect_ = gfx::Rect(); |
105 return; | 111 return; |
106 } | 112 } |
107 | 113 |
108 // First attempt to process for CALayers. | 114 // First attempt to process for CALayers. |
109 if (ProcessForCALayers(resource_provider, render_pass, candidates, | 115 if (ProcessForCALayers(resource_provider, render_pass, render_pass_filters, |
| 116 render_pass_background_filters, candidates, |
110 ca_layer_overlays, damage_rect)) { | 117 ca_layer_overlays, damage_rect)) { |
111 return; | 118 return; |
112 } | 119 } |
113 | 120 |
114 // Only if that fails, attempt hardware overlay strategies. | 121 // Only if that fails, attempt hardware overlay strategies. |
115 for (const auto& strategy : strategies_) { | 122 for (const auto& strategy : strategies_) { |
116 if (!strategy->Attempt(resource_provider, render_pass, candidates)) | 123 if (!strategy->Attempt(resource_provider, render_pass, candidates)) |
117 continue; | 124 continue; |
118 | 125 |
119 UpdateDamageRect(candidates, damage_rect); | 126 UpdateDamageRect(candidates, damage_rect); |
(...skipping 28 matching lines...) Expand all Loading... |
148 } | 155 } |
149 | 156 |
150 if (this_frame_underlay_rect == previous_frame_underlay_rect_) | 157 if (this_frame_underlay_rect == previous_frame_underlay_rect_) |
151 damage_rect->Subtract(this_frame_underlay_rect); | 158 damage_rect->Subtract(this_frame_underlay_rect); |
152 previous_frame_underlay_rect_ = this_frame_underlay_rect; | 159 previous_frame_underlay_rect_ = this_frame_underlay_rect; |
153 | 160 |
154 damage_rect->Union(output_surface_overlay_damage_rect); | 161 damage_rect->Union(output_surface_overlay_damage_rect); |
155 } | 162 } |
156 | 163 |
157 } // namespace cc | 164 } // namespace cc |
OLD | NEW |