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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 frames_since_using_dc_layers_ = 0; | 330 frames_since_using_dc_layers_ = 0; |
331 } else if (++frames_since_using_dc_layers_ >= | 331 } else if (++frames_since_using_dc_layers_ >= |
332 kNumberOfFramesBeforeDisablingDCLayers) { | 332 kNumberOfFramesBeforeDisablingDCLayers) { |
333 using_dc_layers_ = false; | 333 using_dc_layers_ = false; |
334 } | 334 } |
335 if (was_using_dc_layers != using_dc_layers_) { | 335 if (was_using_dc_layers != using_dc_layers_) { |
336 current_frame()->root_damage_rect = | 336 current_frame()->root_damage_rect = |
337 current_frame()->root_render_pass->output_rect; | 337 current_frame()->root_render_pass->output_rect; |
338 } | 338 } |
339 | 339 |
| 340 allow_partial_draw_ = |
| 341 use_partial_swap_ || |
| 342 output_surface_->CanPartialDraw(current_frame()->root_damage_rect); |
| 343 |
340 // We can skip all drawing if the damage rect is now empty. | 344 // We can skip all drawing if the damage rect is now empty. |
341 bool skip_drawing_root_render_pass = | 345 bool skip_drawing_root_render_pass = |
342 current_frame()->root_damage_rect.IsEmpty() && allow_empty_swap_; | 346 current_frame()->root_damage_rect.IsEmpty() && allow_empty_swap_; |
343 | 347 |
344 // If we have to draw but don't support partial swap, the whole output should | |
345 // be considered damaged. | |
346 if (!skip_drawing_root_render_pass && !use_partial_swap_) | |
347 current_frame()->root_damage_rect = root_render_pass->output_rect; | |
348 | |
349 if (skip_drawing_root_render_pass) { | 348 if (skip_drawing_root_render_pass) { |
350 // If any of the overlays is the output surface, then ensure that the | 349 // If any of the overlays is the output surface, then ensure that the |
351 // backbuffer be allocated (allocation of the backbuffer is a side-effect | 350 // backbuffer be allocated (allocation of the backbuffer is a side-effect |
352 // of BindFramebufferToOutputSurface). | 351 // of BindFramebufferToOutputSurface). |
353 for (auto& overlay : current_frame()->overlay_list) { | 352 for (auto& overlay : current_frame()->overlay_list) { |
354 if (overlay.use_output_surface_for_resource) { | 353 if (overlay.use_output_surface_for_resource) { |
355 BindFramebufferToOutputSurface(); | 354 BindFramebufferToOutputSurface(); |
356 break; | 355 break; |
357 } | 356 } |
358 } | 357 } |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 | 524 |
526 const gfx::Rect surface_rect_in_draw_space = OutputSurfaceRectInDrawSpace(); | 525 const gfx::Rect surface_rect_in_draw_space = OutputSurfaceRectInDrawSpace(); |
527 gfx::Rect render_pass_scissor_in_draw_space = surface_rect_in_draw_space; | 526 gfx::Rect render_pass_scissor_in_draw_space = surface_rect_in_draw_space; |
528 | 527 |
529 if (current_frame()->current_render_pass == | 528 if (current_frame()->current_render_pass == |
530 current_frame()->root_render_pass) { | 529 current_frame()->root_render_pass) { |
531 render_pass_scissor_in_draw_space.Intersect( | 530 render_pass_scissor_in_draw_space.Intersect( |
532 DeviceViewportRectInDrawSpace()); | 531 DeviceViewportRectInDrawSpace()); |
533 } | 532 } |
534 | 533 |
535 if (use_partial_swap_) { | 534 if (allow_partial_draw_) { |
536 render_pass_scissor_in_draw_space.Intersect( | 535 render_pass_scissor_in_draw_space.Intersect( |
537 current_frame()->ComputeScissorRectForRenderPass()); | 536 current_frame()->ComputeScissorRectForRenderPass()); |
538 } | 537 } |
539 | 538 |
540 bool is_root_render_pass = | 539 bool is_root_render_pass = |
541 current_frame()->current_render_pass == current_frame()->root_render_pass; | 540 current_frame()->current_render_pass == current_frame()->root_render_pass; |
542 | 541 |
543 bool render_pass_is_clipped = | 542 bool render_pass_is_clipped = |
544 !render_pass_scissor_in_draw_space.Contains(surface_rect_in_draw_space); | 543 !render_pass_scissor_in_draw_space.Contains(surface_rect_in_draw_space); |
545 | 544 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { | 662 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { |
664 return render_pass->output_rect.size(); | 663 return render_pass->output_rect.size(); |
665 } | 664 } |
666 | 665 |
667 void DirectRenderer::SetCurrentFrameForTesting(const DrawingFrame& frame) { | 666 void DirectRenderer::SetCurrentFrameForTesting(const DrawingFrame& frame) { |
668 current_frame_valid_ = true; | 667 current_frame_valid_ = true; |
669 current_frame_ = frame; | 668 current_frame_ = frame; |
670 } | 669 } |
671 | 670 |
672 } // namespace cc | 671 } // namespace cc |
OLD | NEW |