| 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 = Capabilities().using_partial_swap |
| 209 ? root_render_pass->damage_rect | 209 ? root_render_pass->damage_rect |
| 210 : root_render_pass->output_rect; | 210 : root_render_pass->output_rect; |
| 211 frame.root_damage_rect.Union(next_root_damage_rect_); | 211 frame.root_damage_rect.Union(overlay_processor_->GetAndResetOverlayDamage()); |
| 212 next_root_damage_rect_ = gfx::Rect(); | |
| 213 frame.root_damage_rect.Intersect(gfx::Rect(device_viewport_rect.size())); | 212 frame.root_damage_rect.Intersect(gfx::Rect(device_viewport_rect.size())); |
| 214 frame.device_viewport_rect = device_viewport_rect; | 213 frame.device_viewport_rect = device_viewport_rect; |
| 215 frame.device_clip_rect = device_clip_rect; | 214 frame.device_clip_rect = device_clip_rect; |
| 216 frame.disable_picture_quad_image_filtering = | 215 frame.disable_picture_quad_image_filtering = |
| 217 disable_picture_quad_image_filtering; | 216 disable_picture_quad_image_filtering; |
| 218 | 217 |
| 219 EnsureBackbuffer(); | 218 EnsureBackbuffer(); |
| 220 | 219 |
| 221 // Only reshape when we know we are going to draw. Otherwise, the reshape | 220 // Only reshape when we know we are going to draw. Otherwise, the reshape |
| 222 // can leave the window at the wrong size if we never draw and the proper | 221 // can leave the window at the wrong size if we never draw and the proper |
| 223 // viewport size is never set. | 222 // viewport size is never set. |
| 224 output_surface_->Reshape(device_viewport_rect.size(), device_scale_factor); | 223 output_surface_->Reshape(device_viewport_rect.size(), device_scale_factor); |
| 225 | 224 |
| 226 BeginDrawingFrame(&frame); | 225 BeginDrawingFrame(&frame); |
| 227 | 226 |
| 228 if (output_surface_->IsDisplayedAsOverlayPlane()) { | 227 if (output_surface_->IsDisplayedAsOverlayPlane()) { |
| 229 // Create the overlay candidate for the output surface, and mark it as | 228 // Create the overlay candidate for the output surface, and mark it as |
| 230 // always | 229 // always |
| 231 // handled. | 230 // handled. |
| 232 OverlayCandidate output_surface_plane; | 231 OverlayCandidate output_surface_plane; |
| 233 output_surface_plane.display_rect = | 232 output_surface_plane.display_rect = |
| 234 gfx::RectF(root_render_pass->output_rect); | 233 gfx::RectF(root_render_pass->output_rect); |
| 235 output_surface_plane.quad_rect_in_target_space = | 234 output_surface_plane.quad_rect_in_target_space = |
| 236 root_render_pass->output_rect; | 235 root_render_pass->output_rect; |
| 237 output_surface_plane.use_output_surface_for_resource = true; | 236 output_surface_plane.use_output_surface_for_resource = true; |
| 238 output_surface_plane.overlay_handled = true; | 237 output_surface_plane.overlay_handled = true; |
| 239 frame.overlay_list.push_back(output_surface_plane); | 238 frame.overlay_list.push_back(output_surface_plane); |
| 240 } | 239 } |
| 241 | 240 |
| 242 // If we have any copy requests, we can't remove any quads for overlays, | 241 // If we have any copy requests, we can't remove any quads for overlays or |
| 243 // otherwise the framebuffer will be missing the overlay contents. | 242 // CALayers because the framebuffer would be missing the removed quads' |
| 244 if (root_render_pass->copy_requests.empty()) { | 243 // contents. |
| 245 if (overlay_processor_->ProcessForCALayers( | 244 bool has_copy_requests = false; |
| 246 resource_provider_, render_passes_in_draw_order, | 245 for (const auto& pass : *render_passes_in_draw_order) { |
| 247 &frame.ca_layer_overlay_list, &frame.overlay_list)) { | 246 if (!pass->copy_requests.empty()) { |
| 248 // Ensure that the next frame to use the backbuffer will do a full redraw. | 247 has_copy_requests = true; |
| 249 next_root_damage_rect_.Union(root_render_pass->output_rect); | 248 break; |
| 250 } else { | 249 } |
| 251 overlay_processor_->ProcessForOverlays( | 250 } |
| 252 resource_provider_, render_passes_in_draw_order, &frame.overlay_list, | 251 if (!has_copy_requests) { |
| 253 &frame.root_damage_rect); | 252 overlay_processor_->ProcessForOverlays( |
| 253 resource_provider_, render_passes_in_draw_order, &frame.overlay_list, |
| 254 &frame.ca_layer_overlay_list, &frame.root_damage_rect); |
| 255 } |
| 254 | 256 |
| 255 // No need to render in case the damage rect is completely composited | 257 // If all damage is being drawn with overlays or CALayers then skip drawing |
| 256 // using | 258 // the render passes. |
| 257 // overlays and dont have any copy requests. | 259 if (frame.root_damage_rect.IsEmpty() && !has_copy_requests) { |
| 258 if (frame.root_damage_rect.IsEmpty()) { | 260 BindFramebufferToOutputSurface(&frame); |
| 259 bool handle_copy_requests = false; | 261 } else { |
| 260 for (const auto& pass : *render_passes_in_draw_order) { | 262 for (const auto& pass : *render_passes_in_draw_order) { |
| 261 if (!pass->copy_requests.empty()) { | 263 DrawRenderPass(&frame, pass.get()); |
| 262 handle_copy_requests = true; | |
| 263 break; | |
| 264 } | |
| 265 } | |
| 266 | 264 |
| 267 if (!handle_copy_requests) { | 265 bool first_request = true; |
| 268 BindFramebufferToOutputSurface(&frame); | 266 for (auto& copy_request : pass->copy_requests) { |
| 269 FinishDrawingFrame(&frame); | 267 // Doing a readback is destructive of our state on Mac, so make sure |
| 270 render_passes_in_draw_order->clear(); | 268 // we restore the state between readbacks. http://crbug.com/99393. |
| 271 return; | 269 if (!first_request) |
| 272 } | 270 UseRenderPass(&frame, pass.get()); |
| 273 overlay_processor_->ProcessForOverlays( | 271 CopyCurrentRenderPassToBitmap(&frame, std::move(copy_request)); |
| 274 resource_provider_, render_passes_in_draw_order, | 272 first_request = false; |
| 275 &frame.overlay_list, &frame.root_damage_rect); | |
| 276 } | 273 } |
| 277 } | 274 } |
| 278 } | 275 } |
| 279 | |
| 280 for (const auto& pass : *render_passes_in_draw_order) { | |
| 281 DrawRenderPass(&frame, pass.get()); | |
| 282 | |
| 283 bool first_request = true; | |
| 284 for (auto& copy_request : pass->copy_requests) { | |
| 285 // Doing a readback is destructive of our state on Mac, so make sure | |
| 286 // we restore the state between readbacks. http://crbug.com/99393. | |
| 287 if (!first_request) | |
| 288 UseRenderPass(&frame, pass.get()); | |
| 289 CopyCurrentRenderPassToBitmap(&frame, std::move(copy_request)); | |
| 290 first_request = false; | |
| 291 } | |
| 292 } | |
| 293 FinishDrawingFrame(&frame); | 276 FinishDrawingFrame(&frame); |
| 294 | |
| 295 render_passes_in_draw_order->clear(); | 277 render_passes_in_draw_order->clear(); |
| 296 } | 278 } |
| 297 | 279 |
| 298 gfx::Rect DirectRenderer::ComputeScissorRectForRenderPass( | 280 gfx::Rect DirectRenderer::ComputeScissorRectForRenderPass( |
| 299 const DrawingFrame* frame) { | 281 const DrawingFrame* frame) { |
| 300 gfx::Rect render_pass_scissor = frame->current_render_pass->output_rect; | 282 gfx::Rect render_pass_scissor = frame->current_render_pass->output_rect; |
| 301 | 283 |
| 302 if (frame->root_damage_rect == frame->root_render_pass->output_rect || | 284 if (frame->root_damage_rect == frame->root_render_pass->output_rect || |
| 303 !frame->current_render_pass->copy_requests.empty()) | 285 !frame->current_render_pass->copy_requests.empty()) |
| 304 return render_pass_scissor; | 286 return render_pass_scissor; |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 ScopedResource* texture = render_pass_textures_.get(id); | 550 ScopedResource* texture = render_pass_textures_.get(id); |
| 569 return texture && texture->id(); | 551 return texture && texture->id(); |
| 570 } | 552 } |
| 571 | 553 |
| 572 // static | 554 // static |
| 573 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { | 555 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { |
| 574 return render_pass->output_rect.size(); | 556 return render_pass->output_rect.size(); |
| 575 } | 557 } |
| 576 | 558 |
| 577 } // namespace cc | 559 } // namespace cc |
| OLD | NEW |