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/dc_layer_overlay.h" | 7 #include "cc/output/dc_layer_overlay.h" |
8 #include "cc/output/output_surface.h" | 8 #include "cc/output/output_surface.h" |
9 #include "cc/output/overlay_strategy_single_on_top.h" | 9 #include "cc/output/overlay_strategy_single_on_top.h" |
10 #include "cc/output/overlay_strategy_underlay.h" | 10 #include "cc/output/overlay_strategy_underlay.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 DCLayerOverlayList* dc_layer_overlays, | 121 DCLayerOverlayList* dc_layer_overlays, |
122 gfx::Rect* damage_rect, | 122 gfx::Rect* damage_rect, |
123 std::vector<gfx::Rect>* content_bounds) { | 123 std::vector<gfx::Rect>* content_bounds) { |
124 #if defined(OS_ANDROID) | 124 #if defined(OS_ANDROID) |
125 // Be sure to send out notifications, regardless of whether we get to | 125 // Be sure to send out notifications, regardless of whether we get to |
126 // processing for overlays or not. If we don't, then we should notify that | 126 // processing for overlays or not. If we don't, then we should notify that |
127 // they are not promotable. | 127 // they are not promotable. |
128 SendPromotionHintsBeforeReturning notifier(resource_provider, candidates); | 128 SendPromotionHintsBeforeReturning notifier(resource_provider, candidates); |
129 #endif | 129 #endif |
130 | 130 |
131 // If overlay processing is skipped, reset |previous_frame_underlay_rect_|. | |
132 // Otherwise, |previous_frame_underlay_rect_| will be set to current frame | |
133 // underlay rect. | |
134 const gfx::Rect previous_frame_underlay_rect = previous_frame_underlay_rect_; | |
135 previous_frame_underlay_rect_ = gfx::Rect(); | |
danakj
2017/04/27 15:32:00
Doesn't this just mean every frame previous_frame_
AndyWu
2017/04/27 15:53:01
The thing we care about is UpdateDamageRect() bein
danakj
2017/04/27 16:26:19
I see, UpdateDamageRect() is setting this to somet
| |
136 | |
131 // If we have any copy requests, we can't remove any quads for overlays or | 137 // If we have any copy requests, we can't remove any quads for overlays or |
132 // CALayers because the framebuffer would be missing the removed quads' | 138 // CALayers because the framebuffer would be missing the removed quads' |
133 // contents. | 139 // contents. |
134 if (!render_pass->copy_requests.empty()) { | 140 if (!render_pass->copy_requests.empty()) { |
135 dc_processor_.ClearOverlayState(); | 141 dc_processor_.ClearOverlayState(); |
136 // If overlay processing was skipped for a frame there's no way to be sure | |
137 // of the state of the previous frame, so reset. | |
138 previous_frame_underlay_rect_ = gfx::Rect(); | |
139 return; | 142 return; |
140 } | 143 } |
141 | 144 |
142 // First attempt to process for CALayers. | 145 // First attempt to process for CALayers. |
143 if (ProcessForCALayers(resource_provider, render_pass, render_pass_filters, | 146 if (ProcessForCALayers(resource_provider, render_pass, render_pass_filters, |
144 render_pass_background_filters, candidates, | 147 render_pass_background_filters, candidates, |
145 ca_layer_overlays, damage_rect)) { | 148 ca_layer_overlays, damage_rect)) { |
146 return; | 149 return; |
147 } | 150 } |
148 | 151 |
149 if (ProcessForDCLayers(resource_provider, render_pass, render_pass_filters, | 152 if (ProcessForDCLayers(resource_provider, render_pass, render_pass_filters, |
150 render_pass_background_filters, candidates, | 153 render_pass_background_filters, candidates, |
151 dc_layer_overlays, damage_rect)) { | 154 dc_layer_overlays, damage_rect)) { |
152 return; | 155 return; |
153 } | 156 } |
154 | 157 |
155 // Only if that fails, attempt hardware overlay strategies. | 158 // Only if that fails, attempt hardware overlay strategies. |
156 for (const auto& strategy : strategies_) { | 159 for (const auto& strategy : strategies_) { |
157 if (!strategy->Attempt(resource_provider, render_pass, candidates, | 160 if (!strategy->Attempt(resource_provider, render_pass, candidates, |
158 content_bounds)) | 161 content_bounds)) |
159 continue; | 162 continue; |
160 | 163 |
161 UpdateDamageRect(candidates, damage_rect); | 164 UpdateDamageRect(candidates, previous_frame_underlay_rect, damage_rect); |
162 return; | 165 return; |
163 } | 166 } |
164 } | 167 } |
165 | 168 |
166 // Subtract on-top overlays from the damage rect, unless the overlays use | 169 // Subtract on-top overlays from the damage rect, unless the overlays use |
167 // the backbuffer as their content (in which case, add their combined rect | 170 // the backbuffer as their content (in which case, add their combined rect |
168 // back to the damage at the end). | 171 // back to the damage at the end). |
169 // Also subtract unoccluded underlays from the damage rect if we know that the | 172 // Also subtract unoccluded underlays from the damage rect if we know that the |
170 // same underlay was scheduled on the previous frame. If the renderer decides | 173 // same underlay was scheduled on the previous frame. If the renderer decides |
171 // not to swap the framebuffer there will still be a transparent hole in the | 174 // not to swap the framebuffer there will still be a transparent hole in the |
172 // previous frame. This only handles the common case of a single underlay quad | 175 // previous frame. This only handles the common case of a single underlay quad |
173 // for fullscreen video. | 176 // for fullscreen video. |
174 void OverlayProcessor::UpdateDamageRect(OverlayCandidateList* candidates, | 177 void OverlayProcessor::UpdateDamageRect( |
175 gfx::Rect* damage_rect) { | 178 OverlayCandidateList* candidates, |
179 const gfx::Rect& previous_frame_underlay_rect, | |
180 gfx::Rect* damage_rect) { | |
176 gfx::Rect output_surface_overlay_damage_rect; | 181 gfx::Rect output_surface_overlay_damage_rect; |
177 gfx::Rect this_frame_underlay_rect; | 182 gfx::Rect this_frame_underlay_rect; |
178 for (const OverlayCandidate& overlay : *candidates) { | 183 for (const OverlayCandidate& overlay : *candidates) { |
179 if (overlay.plane_z_order > 0) { | 184 if (overlay.plane_z_order > 0) { |
180 const gfx::Rect overlay_display_rect = | 185 const gfx::Rect overlay_display_rect = |
181 ToEnclosedRect(overlay.display_rect); | 186 ToEnclosedRect(overlay.display_rect); |
182 overlay_damage_rect_.Union(overlay_display_rect); | 187 overlay_damage_rect_.Union(overlay_display_rect); |
183 damage_rect->Subtract(overlay_display_rect); | 188 damage_rect->Subtract(overlay_display_rect); |
184 if (overlay.use_output_surface_for_resource) | 189 if (overlay.use_output_surface_for_resource) |
185 output_surface_overlay_damage_rect.Union(overlay_display_rect); | 190 output_surface_overlay_damage_rect.Union(overlay_display_rect); |
186 } else if (overlay.plane_z_order < 0 && overlay.is_unoccluded && | 191 } else if (overlay.plane_z_order < 0 && overlay.is_unoccluded && |
187 this_frame_underlay_rect.IsEmpty()) { | 192 this_frame_underlay_rect.IsEmpty()) { |
188 this_frame_underlay_rect = ToEnclosedRect(overlay.display_rect); | 193 this_frame_underlay_rect = ToEnclosedRect(overlay.display_rect); |
189 } | 194 } |
190 } | 195 } |
191 | 196 |
192 if (this_frame_underlay_rect == previous_frame_underlay_rect_) | 197 if (this_frame_underlay_rect == previous_frame_underlay_rect) |
193 damage_rect->Subtract(this_frame_underlay_rect); | 198 damage_rect->Subtract(this_frame_underlay_rect); |
194 previous_frame_underlay_rect_ = this_frame_underlay_rect; | 199 previous_frame_underlay_rect_ = this_frame_underlay_rect; |
195 | 200 |
196 damage_rect->Union(output_surface_overlay_damage_rect); | 201 damage_rect->Union(output_surface_overlay_damage_rect); |
197 } | 202 } |
198 | 203 |
199 } // namespace cc | 204 } // namespace cc |
OLD | NEW |