OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/direct_renderer.h" | 5 #include "cc/output/direct_renderer.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 "Renderer4.renderPassCount", | 198 "Renderer4.renderPassCount", |
199 base::saturated_cast<int>(render_passes_in_draw_order->size())); | 199 base::saturated_cast<int>(render_passes_in_draw_order->size())); |
200 | 200 |
201 const RenderPass* root_render_pass = | 201 const RenderPass* root_render_pass = |
202 render_passes_in_draw_order->back().get(); | 202 render_passes_in_draw_order->back().get(); |
203 DCHECK(root_render_pass); | 203 DCHECK(root_render_pass); |
204 | 204 |
205 DrawingFrame frame; | 205 DrawingFrame frame; |
206 frame.render_passes_in_draw_order = render_passes_in_draw_order; | 206 frame.render_passes_in_draw_order = render_passes_in_draw_order; |
207 frame.root_render_pass = root_render_pass; | 207 frame.root_render_pass = root_render_pass; |
208 frame.root_damage_rect = Capabilities().using_partial_swap | 208 frame.root_damage_rect = root_render_pass->damage_rect; |
209 ? root_render_pass->damage_rect | |
210 : root_render_pass->output_rect; | |
211 frame.root_damage_rect.Union(overlay_processor_->GetAndResetOverlayDamage()); | 209 frame.root_damage_rect.Union(overlay_processor_->GetAndResetOverlayDamage()); |
212 frame.root_damage_rect.Intersect(gfx::Rect(device_viewport_rect.size())); | 210 frame.root_damage_rect.Intersect(gfx::Rect(device_viewport_rect.size())); |
213 frame.device_viewport_rect = device_viewport_rect; | 211 frame.device_viewport_rect = device_viewport_rect; |
214 frame.device_clip_rect = device_clip_rect; | 212 frame.device_clip_rect = device_clip_rect; |
215 frame.disable_picture_quad_image_filtering = | 213 frame.disable_picture_quad_image_filtering = |
216 disable_picture_quad_image_filtering; | 214 disable_picture_quad_image_filtering; |
217 | 215 |
218 EnsureBackbuffer(); | 216 EnsureBackbuffer(); |
219 | 217 |
220 // Only reshape when we know we are going to draw. Otherwise, the reshape | 218 // Only reshape when we know we are going to draw. Otherwise, the reshape |
221 // can leave the window at the wrong size if we never draw and the proper | 219 // can leave the window at the wrong size if we never draw and the proper |
222 // viewport size is never set. | 220 // viewport size is never set. |
223 output_surface_->Reshape(device_viewport_rect.size(), device_scale_factor); | 221 output_surface_->Reshape(device_viewport_rect.size(), device_scale_factor); |
224 | 222 |
225 BeginDrawingFrame(&frame); | 223 BeginDrawingFrame(&frame); |
226 | 224 |
227 if (output_surface_->IsDisplayedAsOverlayPlane()) { | 225 if (output_surface_->IsDisplayedAsOverlayPlane()) { |
228 // Create the overlay candidate for the output surface, and mark it as | 226 // Create the overlay candidate for the output surface, and mark it as |
229 // always | 227 // always handled. |
230 // handled. | |
231 OverlayCandidate output_surface_plane; | 228 OverlayCandidate output_surface_plane; |
232 output_surface_plane.display_rect = | 229 output_surface_plane.display_rect = |
233 gfx::RectF(root_render_pass->output_rect); | 230 gfx::RectF(root_render_pass->output_rect); |
234 output_surface_plane.quad_rect_in_target_space = | 231 output_surface_plane.quad_rect_in_target_space = |
235 root_render_pass->output_rect; | 232 root_render_pass->output_rect; |
236 output_surface_plane.use_output_surface_for_resource = true; | 233 output_surface_plane.use_output_surface_for_resource = true; |
237 output_surface_plane.overlay_handled = true; | 234 output_surface_plane.overlay_handled = true; |
238 frame.overlay_list.push_back(output_surface_plane); | 235 frame.overlay_list.push_back(output_surface_plane); |
239 } | 236 } |
240 | 237 |
241 // If we have any copy requests, we can't remove any quads for overlays or | 238 // If we have any copy requests, we can't remove any quads for overlays or |
242 // CALayers because the framebuffer would be missing the removed quads' | 239 // CALayers because the framebuffer would be missing the removed quads' |
243 // contents. | 240 // contents. |
244 bool has_copy_requests = false; | 241 bool has_copy_requests = false; |
245 for (const auto& pass : *render_passes_in_draw_order) { | 242 for (const auto& pass : *render_passes_in_draw_order) { |
246 if (!pass->copy_requests.empty()) { | 243 if (!pass->copy_requests.empty()) { |
247 has_copy_requests = true; | 244 has_copy_requests = true; |
248 break; | 245 break; |
249 } | 246 } |
250 } | 247 } |
251 if (!has_copy_requests) { | 248 if (!has_copy_requests) { |
252 overlay_processor_->ProcessForOverlays( | 249 overlay_processor_->ProcessForOverlays( |
253 resource_provider_, render_passes_in_draw_order, &frame.overlay_list, | 250 resource_provider_, render_passes_in_draw_order, &frame.overlay_list, |
254 &frame.ca_layer_overlay_list, &frame.root_damage_rect); | 251 &frame.ca_layer_overlay_list, &frame.root_damage_rect); |
255 } | 252 } |
256 | 253 |
| 254 // The damage rect might be empty now, but if empty swap isn't allowed we |
| 255 // still have to draw. |
| 256 bool should_draw = has_copy_requests || !frame.root_damage_rect.IsEmpty() || |
| 257 !Capabilities().allow_empty_swap; |
| 258 // If we have to draw but don't support partial swap the whole output should |
| 259 // be considered damaged. |
| 260 if (should_draw && !Capabilities().using_partial_swap) |
| 261 frame.root_damage_rect = root_render_pass->output_rect; |
| 262 |
257 // If all damage is being drawn with overlays or CALayers then skip drawing | 263 // If all damage is being drawn with overlays or CALayers then skip drawing |
258 // the render passes. | 264 // the render passes. |
259 if (frame.root_damage_rect.IsEmpty() && !has_copy_requests) { | 265 if (!should_draw) { |
260 BindFramebufferToOutputSurface(&frame); | 266 BindFramebufferToOutputSurface(&frame); |
261 } else { | 267 } else { |
262 for (const auto& pass : *render_passes_in_draw_order) { | 268 for (const auto& pass : *render_passes_in_draw_order) { |
263 DrawRenderPass(&frame, pass.get()); | 269 DrawRenderPass(&frame, pass.get()); |
264 | 270 |
265 bool first_request = true; | 271 bool first_request = true; |
266 for (auto& copy_request : pass->copy_requests) { | 272 for (auto& copy_request : pass->copy_requests) { |
267 // Doing a readback is destructive of our state on Mac, so make sure | 273 // Doing a readback is destructive of our state on Mac, so make sure |
268 // we restore the state between readbacks. http://crbug.com/99393. | 274 // we restore the state between readbacks. http://crbug.com/99393. |
269 if (!first_request) | 275 if (!first_request) |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 ScopedResource* texture = render_pass_textures_.get(id); | 556 ScopedResource* texture = render_pass_textures_.get(id); |
551 return texture && texture->id(); | 557 return texture && texture->id(); |
552 } | 558 } |
553 | 559 |
554 // static | 560 // static |
555 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { | 561 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { |
556 return render_pass->output_rect.size(); | 562 return render_pass->output_rect.size(); |
557 } | 563 } |
558 | 564 |
559 } // namespace cc | 565 } // namespace cc |
OLD | NEW |