| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <unordered_map> | 9 #include <unordered_map> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 reshape_device_scale_factor_ = device_scale_factor; | 246 reshape_device_scale_factor_ = device_scale_factor; |
| 247 reshape_device_color_space_ = device_color_space; | 247 reshape_device_color_space_ = device_color_space; |
| 248 reshape_has_alpha_ = frame.root_render_pass->has_transparent_background; | 248 reshape_has_alpha_ = frame.root_render_pass->has_transparent_background; |
| 249 output_surface_->Reshape(reshape_surface_size_, | 249 output_surface_->Reshape(reshape_surface_size_, |
| 250 reshape_device_scale_factor_, | 250 reshape_device_scale_factor_, |
| 251 reshape_device_color_space_, reshape_has_alpha_); | 251 reshape_device_color_space_, reshape_has_alpha_); |
| 252 } | 252 } |
| 253 | 253 |
| 254 BeginDrawingFrame(&frame); | 254 BeginDrawingFrame(&frame); |
| 255 | 255 |
| 256 for (const auto& pass : *render_passes_in_draw_order) { |
| 257 if (!pass->filters.IsEmpty()) |
| 258 render_pass_filters_.push_back(std::make_pair(pass->id, &pass->filters)); |
| 259 if (!pass->background_filters.IsEmpty()) { |
| 260 render_pass_background_filters_.push_back( |
| 261 std::make_pair(pass->id, &pass->background_filters)); |
| 262 } |
| 263 std::sort(render_pass_filters_.begin(), render_pass_filters_.end()); |
| 264 std::sort(render_pass_background_filters_.begin(), |
| 265 render_pass_background_filters_.end()); |
| 266 } |
| 267 |
| 256 // Draw all non-root render passes except for the root render pass. | 268 // Draw all non-root render passes except for the root render pass. |
| 257 for (const auto& pass : *render_passes_in_draw_order) { | 269 for (const auto& pass : *render_passes_in_draw_order) { |
| 258 if (pass.get() == root_render_pass) | 270 if (pass.get() == root_render_pass) |
| 259 break; | 271 break; |
| 260 DrawRenderPassAndExecuteCopyRequests(&frame, pass.get()); | 272 DrawRenderPassAndExecuteCopyRequests(&frame, pass.get()); |
| 261 } | 273 } |
| 262 | 274 |
| 263 // Create the overlay candidate for the output surface, and mark it as | 275 // Create the overlay candidate for the output surface, and mark it as |
| 264 // always handled. | 276 // always handled. |
| 265 if (output_surface_->IsDisplayedAsOverlayPlane()) { | 277 if (output_surface_->IsDisplayedAsOverlayPlane()) { |
| 266 OverlayCandidate output_surface_plane; | 278 OverlayCandidate output_surface_plane; |
| 267 output_surface_plane.display_rect = | 279 output_surface_plane.display_rect = |
| 268 gfx::RectF(root_render_pass->output_rect); | 280 gfx::RectF(root_render_pass->output_rect); |
| 269 output_surface_plane.quad_rect_in_target_space = | 281 output_surface_plane.quad_rect_in_target_space = |
| 270 root_render_pass->output_rect; | 282 root_render_pass->output_rect; |
| 271 output_surface_plane.use_output_surface_for_resource = true; | 283 output_surface_plane.use_output_surface_for_resource = true; |
| 272 output_surface_plane.overlay_handled = true; | 284 output_surface_plane.overlay_handled = true; |
| 273 frame.overlay_list.push_back(output_surface_plane); | 285 frame.overlay_list.push_back(output_surface_plane); |
| 274 } | 286 } |
| 275 | 287 |
| 276 // Attempt to replace some or all of the quads of the root render pass with | 288 // Attempt to replace some or all of the quads of the root render pass with |
| 277 // overlays. | 289 // overlays. |
| 278 overlay_processor_->ProcessForOverlays( | 290 overlay_processor_->ProcessForOverlays( |
| 279 resource_provider_, root_render_pass, &frame.overlay_list, | 291 resource_provider_, root_render_pass, render_pass_filters_, |
| 292 render_pass_background_filters_, &frame.overlay_list, |
| 280 &frame.ca_layer_overlay_list, &frame.root_damage_rect); | 293 &frame.ca_layer_overlay_list, &frame.root_damage_rect); |
| 281 | 294 |
| 282 // We can skip all drawing if the damage rect is now empty. | 295 // We can skip all drawing if the damage rect is now empty. |
| 283 bool skip_drawing_root_render_pass = | 296 bool skip_drawing_root_render_pass = |
| 284 frame.root_damage_rect.IsEmpty() && allow_empty_swap_; | 297 frame.root_damage_rect.IsEmpty() && allow_empty_swap_; |
| 285 | 298 |
| 286 // If we have to draw but don't support partial swap, the whole output should | 299 // If we have to draw but don't support partial swap, the whole output should |
| 287 // be considered damaged. | 300 // be considered damaged. |
| 288 if (!skip_drawing_root_render_pass && !use_partial_swap_) | 301 if (!skip_drawing_root_render_pass && !use_partial_swap_) |
| 289 frame.root_damage_rect = root_render_pass->output_rect; | 302 frame.root_damage_rect = root_render_pass->output_rect; |
| 290 | 303 |
| 291 if (skip_drawing_root_render_pass) { | 304 if (skip_drawing_root_render_pass) { |
| 292 // If any of the overlays is the output surface, then ensure that the | 305 // If any of the overlays is the output surface, then ensure that the |
| 293 // backbuffer be allocated (allocation of the backbuffer is a side-effect | 306 // backbuffer be allocated (allocation of the backbuffer is a side-effect |
| 294 // of BindFramebufferToOutputSurface). | 307 // of BindFramebufferToOutputSurface). |
| 295 for (auto& overlay : frame.overlay_list) { | 308 for (auto& overlay : frame.overlay_list) { |
| 296 if (overlay.use_output_surface_for_resource) { | 309 if (overlay.use_output_surface_for_resource) { |
| 297 BindFramebufferToOutputSurface(&frame); | 310 BindFramebufferToOutputSurface(&frame); |
| 298 break; | 311 break; |
| 299 } | 312 } |
| 300 } | 313 } |
| 301 } else { | 314 } else { |
| 302 DrawRenderPassAndExecuteCopyRequests(&frame, root_render_pass); | 315 DrawRenderPassAndExecuteCopyRequests(&frame, root_render_pass); |
| 303 } | 316 } |
| 304 | 317 |
| 305 FinishDrawingFrame(&frame); | 318 FinishDrawingFrame(&frame); |
| 306 render_passes_in_draw_order->clear(); | 319 render_passes_in_draw_order->clear(); |
| 320 render_pass_filters_.clear(); |
| 321 render_pass_background_filters_.clear(); |
| 307 } | 322 } |
| 308 | 323 |
| 309 gfx::Rect DirectRenderer::ComputeScissorRectForRenderPass( | 324 gfx::Rect DirectRenderer::ComputeScissorRectForRenderPass( |
| 310 const DrawingFrame* frame) { | 325 const DrawingFrame* frame) { |
| 311 if (frame->current_render_pass == frame->root_render_pass) | 326 if (frame->current_render_pass == frame->root_render_pass) |
| 312 return frame->root_damage_rect; | 327 return frame->root_damage_rect; |
| 313 | 328 |
| 314 // If the root damage rect has been expanded due to overlays, all the other | 329 // If the root damage rect has been expanded due to overlays, all the other |
| 315 // damage rect calculations are incorrect. | 330 // damage rect calculations are incorrect. |
| 316 if (!frame->root_render_pass->damage_rect.Contains(frame->root_damage_rect)) | 331 if (!frame->root_render_pass->damage_rect.Contains(frame->root_damage_rect)) |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 return; | 412 return; |
| 398 } | 413 } |
| 399 | 414 |
| 400 std::vector<gfx::QuadF> quads; | 415 std::vector<gfx::QuadF> quads; |
| 401 poly.ToQuads2D(&quads); | 416 poly.ToQuads2D(&quads); |
| 402 for (size_t i = 0; i < quads.size(); ++i) { | 417 for (size_t i = 0; i < quads.size(); ++i) { |
| 403 DoDrawQuad(frame, poly.original_ref(), &quads[i]); | 418 DoDrawQuad(frame, poly.original_ref(), &quads[i]); |
| 404 } | 419 } |
| 405 } | 420 } |
| 406 | 421 |
| 422 const FilterOperations* DirectRenderer::FiltersForPass( |
| 423 int render_pass_id) const { |
| 424 auto it = std::lower_bound( |
| 425 render_pass_filters_.begin(), render_pass_filters_.end(), |
| 426 std::pair<int, FilterOperations*>(render_pass_id, nullptr)); |
| 427 if (it != render_pass_filters_.end() && it->first == render_pass_id) |
| 428 return it->second; |
| 429 return nullptr; |
| 430 } |
| 431 |
| 432 const FilterOperations* DirectRenderer::BackgroundFiltersForPass( |
| 433 int render_pass_id) const { |
| 434 auto it = std::lower_bound( |
| 435 render_pass_background_filters_.begin(), |
| 436 render_pass_background_filters_.end(), |
| 437 std::pair<int, FilterOperations*>(render_pass_id, nullptr)); |
| 438 if (it != render_pass_background_filters_.end() && |
| 439 it->first == render_pass_id) |
| 440 return it->second; |
| 441 return nullptr; |
| 442 } |
| 443 |
| 407 void DirectRenderer::FlushPolygons( | 444 void DirectRenderer::FlushPolygons( |
| 408 std::deque<std::unique_ptr<DrawPolygon>>* poly_list, | 445 std::deque<std::unique_ptr<DrawPolygon>>* poly_list, |
| 409 DrawingFrame* frame, | 446 DrawingFrame* frame, |
| 410 const gfx::Rect& render_pass_scissor, | 447 const gfx::Rect& render_pass_scissor, |
| 411 bool use_render_pass_scissor) { | 448 bool use_render_pass_scissor) { |
| 412 if (poly_list->empty()) { | 449 if (poly_list->empty()) { |
| 413 return; | 450 return; |
| 414 } | 451 } |
| 415 | 452 |
| 416 BspTree bsp_tree(poly_list); | 453 BspTree bsp_tree(poly_list); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 auto iter = render_pass_textures_.find(render_pass_id); | 608 auto iter = render_pass_textures_.find(render_pass_id); |
| 572 return iter != render_pass_textures_.end() && iter->second->id(); | 609 return iter != render_pass_textures_.end() && iter->second->id(); |
| 573 } | 610 } |
| 574 | 611 |
| 575 // static | 612 // static |
| 576 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { | 613 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { |
| 577 return render_pass->output_rect.size(); | 614 return render_pass->output_rect.size(); |
| 578 } | 615 } |
| 579 | 616 |
| 580 } // namespace cc | 617 } // namespace cc |
| OLD | NEW |