Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: cc/output/overlay_processor.cc

Issue 2844483004: Reset the state of the previous frame if overlay processing is skipped. (Closed)
Patch Set: Reset the state of the previous frame if hardware overlay processing is skipped. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/output/overlay_processor.h ('k') | cc/output/overlay_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // Reset |previous_frame_underlay_rect_| in case UpdateDamageRect() not being
132 // invoked.
133 const gfx::Rect previous_frame_underlay_rect = previous_frame_underlay_rect_;
134 previous_frame_underlay_rect_ = gfx::Rect();
135
131 // If we have any copy requests, we can't remove any quads for overlays or 136 // 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' 137 // CALayers because the framebuffer would be missing the removed quads'
133 // contents. 138 // contents.
134 if (!render_pass->copy_requests.empty()) { 139 if (!render_pass->copy_requests.empty()) {
135 dc_processor_.ClearOverlayState(); 140 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; 141 return;
140 } 142 }
141 143
142 // First attempt to process for CALayers. 144 // First attempt to process for CALayers.
143 if (ProcessForCALayers(resource_provider, render_pass, render_pass_filters, 145 if (ProcessForCALayers(resource_provider, render_pass, render_pass_filters,
144 render_pass_background_filters, candidates, 146 render_pass_background_filters, candidates,
145 ca_layer_overlays, damage_rect)) { 147 ca_layer_overlays, damage_rect)) {
146 return; 148 return;
147 } 149 }
148 150
149 if (ProcessForDCLayers(resource_provider, render_pass, render_pass_filters, 151 if (ProcessForDCLayers(resource_provider, render_pass, render_pass_filters,
150 render_pass_background_filters, candidates, 152 render_pass_background_filters, candidates,
151 dc_layer_overlays, damage_rect)) { 153 dc_layer_overlays, damage_rect)) {
152 return; 154 return;
153 } 155 }
154 156
155 // Only if that fails, attempt hardware overlay strategies. 157 // Only if that fails, attempt hardware overlay strategies.
156 for (const auto& strategy : strategies_) { 158 for (const auto& strategy : strategies_) {
157 if (!strategy->Attempt(resource_provider, render_pass, candidates, 159 if (!strategy->Attempt(resource_provider, render_pass, candidates,
158 content_bounds)) 160 content_bounds))
159 continue; 161 continue;
160 162
161 UpdateDamageRect(candidates, damage_rect); 163 UpdateDamageRect(candidates, previous_frame_underlay_rect, damage_rect);
162 return; 164 return;
163 } 165 }
164 } 166 }
165 167
166 // Subtract on-top overlays from the damage rect, unless the overlays use 168 // 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 169 // the backbuffer as their content (in which case, add their combined rect
168 // back to the damage at the end). 170 // back to the damage at the end).
169 // Also subtract unoccluded underlays from the damage rect if we know that the 171 // 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 172 // 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 173 // 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 174 // previous frame. This only handles the common case of a single underlay quad
173 // for fullscreen video. 175 // for fullscreen video.
174 void OverlayProcessor::UpdateDamageRect(OverlayCandidateList* candidates, 176 void OverlayProcessor::UpdateDamageRect(
175 gfx::Rect* damage_rect) { 177 OverlayCandidateList* candidates,
178 const gfx::Rect& previous_frame_underlay_rect,
179 gfx::Rect* damage_rect) {
176 gfx::Rect output_surface_overlay_damage_rect; 180 gfx::Rect output_surface_overlay_damage_rect;
177 gfx::Rect this_frame_underlay_rect; 181 gfx::Rect this_frame_underlay_rect;
178 for (const OverlayCandidate& overlay : *candidates) { 182 for (const OverlayCandidate& overlay : *candidates) {
179 if (overlay.plane_z_order > 0) { 183 if (overlay.plane_z_order > 0) {
180 const gfx::Rect overlay_display_rect = 184 const gfx::Rect overlay_display_rect =
181 ToEnclosedRect(overlay.display_rect); 185 ToEnclosedRect(overlay.display_rect);
182 overlay_damage_rect_.Union(overlay_display_rect); 186 overlay_damage_rect_.Union(overlay_display_rect);
183 damage_rect->Subtract(overlay_display_rect); 187 damage_rect->Subtract(overlay_display_rect);
184 if (overlay.use_output_surface_for_resource) 188 if (overlay.use_output_surface_for_resource)
185 output_surface_overlay_damage_rect.Union(overlay_display_rect); 189 output_surface_overlay_damage_rect.Union(overlay_display_rect);
186 } else if (overlay.plane_z_order < 0 && overlay.is_unoccluded && 190 } else if (overlay.plane_z_order < 0 && overlay.is_unoccluded &&
187 this_frame_underlay_rect.IsEmpty()) { 191 this_frame_underlay_rect.IsEmpty()) {
188 this_frame_underlay_rect = ToEnclosedRect(overlay.display_rect); 192 this_frame_underlay_rect = ToEnclosedRect(overlay.display_rect);
189 } 193 }
190 } 194 }
191 195
192 if (this_frame_underlay_rect == previous_frame_underlay_rect_) 196 if (this_frame_underlay_rect == previous_frame_underlay_rect)
193 damage_rect->Subtract(this_frame_underlay_rect); 197 damage_rect->Subtract(this_frame_underlay_rect);
194 previous_frame_underlay_rect_ = this_frame_underlay_rect; 198 previous_frame_underlay_rect_ = this_frame_underlay_rect;
195 199
196 damage_rect->Union(output_surface_overlay_damage_rect); 200 damage_rect->Union(output_surface_overlay_damage_rect);
197 } 201 }
198 202
199 } // namespace cc 203 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/overlay_processor.h ('k') | cc/output/overlay_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698