Chromium Code Reviews| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 | 77 |
| 78 DirectRenderer::~DirectRenderer() = default; | 78 DirectRenderer::~DirectRenderer() = default; |
| 79 | 79 |
| 80 void DirectRenderer::Initialize() { | 80 void DirectRenderer::Initialize() { |
| 81 overlay_processor_->Initialize(); | 81 overlay_processor_->Initialize(); |
| 82 | 82 |
| 83 auto* context_provider = output_surface_->context_provider(); | 83 auto* context_provider = output_surface_->context_provider(); |
| 84 | 84 |
| 85 use_partial_swap_ = settings_->partial_swap_enabled && CanPartialSwap(); | 85 use_partial_swap_ = settings_->partial_swap_enabled && CanPartialSwap(); |
| 86 allow_empty_swap_ = use_partial_swap_; | 86 allow_empty_swap_ = use_partial_swap_; |
| 87 if (context_provider && | 87 if (context_provider) { |
| 88 context_provider->ContextCapabilities().commit_overlay_planes) | 88 if (context_provider->ContextCapabilities().commit_overlay_planes) |
| 89 allow_empty_swap_ = true; | 89 allow_empty_swap_ = true; |
| 90 if (context_provider->ContextCapabilities().set_draw_rectangle) | |
| 91 use_set_draw_rectangle_ = true; | |
| 92 } | |
| 90 | 93 |
| 91 initialized_ = true; | 94 initialized_ = true; |
| 92 } | 95 } |
| 93 | 96 |
| 94 // static | 97 // static |
| 95 gfx::RectF DirectRenderer::QuadVertexRect() { | 98 gfx::RectF DirectRenderer::QuadVertexRect() { |
| 96 return gfx::RectF(-0.5f, -0.5f, 1.f, 1.f); | 99 return gfx::RectF(-0.5f, -0.5f, 1.f, 1.f); |
| 97 } | 100 } |
| 98 | 101 |
| 99 // static | 102 // static |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 503 current_frame()->root_render_pass) { | 506 current_frame()->root_render_pass) { |
| 504 render_pass_scissor_in_draw_space.Intersect( | 507 render_pass_scissor_in_draw_space.Intersect( |
| 505 DeviceViewportRectInDrawSpace()); | 508 DeviceViewportRectInDrawSpace()); |
| 506 } | 509 } |
| 507 | 510 |
| 508 if (use_partial_swap_) { | 511 if (use_partial_swap_) { |
| 509 render_pass_scissor_in_draw_space.Intersect( | 512 render_pass_scissor_in_draw_space.Intersect( |
| 510 current_frame()->ComputeScissorRectForRenderPass()); | 513 current_frame()->ComputeScissorRectForRenderPass()); |
| 511 } | 514 } |
| 512 | 515 |
| 513 bool render_pass_is_clipped = | |
| 514 !render_pass_scissor_in_draw_space.Contains(surface_rect_in_draw_space); | |
| 515 bool is_root_render_pass = | 516 bool is_root_render_pass = |
| 516 current_frame()->current_render_pass == current_frame()->root_render_pass; | 517 current_frame()->current_render_pass == current_frame()->root_render_pass; |
| 518 | |
| 519 // The SetDrawRectangleCHROMIUM spec requires that the scissor bit is always | |
| 520 // set on the root framebuffer or else the rendering may modify something | |
| 521 // outside the damage rectangle, even if the damage rectangle is the size of | |
| 522 // the full backbuffer. | |
| 523 bool render_pass_is_clipped = | |
| 524 (use_set_draw_rectangle_ && is_root_render_pass) || | |
| 525 !render_pass_scissor_in_draw_space.Contains(surface_rect_in_draw_space); | |
| 517 bool has_external_stencil_test = | 526 bool has_external_stencil_test = |
| 518 is_root_render_pass && output_surface_->HasExternalStencilTest(); | 527 is_root_render_pass && output_surface_->HasExternalStencilTest(); |
| 519 bool should_clear_surface = | 528 bool should_clear_surface = |
| 520 !has_external_stencil_test && | 529 !has_external_stencil_test && |
| 521 (!is_root_render_pass || settings_->should_clear_root_render_pass); | 530 (!is_root_render_pass || settings_->should_clear_root_render_pass); |
| 522 | 531 |
| 523 // If |has_external_stencil_test| we can't discard or clear. Make sure we | 532 // If |has_external_stencil_test| we can't discard or clear. Make sure we |
| 524 // don't need to. | 533 // don't need to. |
| 525 DCHECK(!has_external_stencil_test || | 534 DCHECK(!has_external_stencil_test || |
| 526 !current_frame()->current_render_pass->has_transparent_background); | 535 !current_frame()->current_render_pass->has_transparent_background); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 575 | 584 |
| 576 DoDrawQuad(&quad, nullptr); | 585 DoDrawQuad(&quad, nullptr); |
| 577 } | 586 } |
| 578 FlushPolygons(&poly_list, render_pass_scissor_in_draw_space, | 587 FlushPolygons(&poly_list, render_pass_scissor_in_draw_space, |
| 579 render_pass_is_clipped); | 588 render_pass_is_clipped); |
| 580 FinishDrawingQuadList(); | 589 FinishDrawingQuadList(); |
| 581 } | 590 } |
| 582 | 591 |
| 583 bool DirectRenderer::UseRenderPass(const RenderPass* render_pass) { | 592 bool DirectRenderer::UseRenderPass(const RenderPass* render_pass) { |
| 584 current_frame()->current_render_pass = render_pass; | 593 current_frame()->current_render_pass = render_pass; |
| 585 current_frame()->current_texture = NULL; | 594 current_frame()->current_texture = nullptr; |
| 586 if (render_pass == current_frame()->root_render_pass) { | 595 if (render_pass == current_frame()->root_render_pass) { |
| 587 BindFramebufferToOutputSurface(); | 596 BindFramebufferToOutputSurface(); |
| 597 | |
| 598 if (use_set_draw_rectangle_) | |
| 599 output_surface_->SetDrawRectangle(current_frame()->root_damage_rect); | |
|
danakj
2017/02/22 15:04:08
Is this guaranteed to be the full surface if the s
| |
| 588 InitializeViewport(current_frame(), render_pass->output_rect, | 600 InitializeViewport(current_frame(), render_pass->output_rect, |
| 589 gfx::Rect(current_frame()->device_viewport_size), | 601 gfx::Rect(current_frame()->device_viewport_size), |
| 590 current_frame()->device_viewport_size); | 602 current_frame()->device_viewport_size); |
| 591 return true; | 603 return true; |
| 592 } | 604 } |
| 593 | 605 |
| 594 ScopedResource* texture = render_pass_textures_[render_pass->id].get(); | 606 ScopedResource* texture = render_pass_textures_[render_pass->id].get(); |
| 595 DCHECK(texture); | 607 DCHECK(texture); |
| 596 | 608 |
| 597 gfx::Size size = RenderPassTextureSize(render_pass); | 609 gfx::Size size = RenderPassTextureSize(render_pass); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 623 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { | 635 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { |
| 624 return render_pass->output_rect.size(); | 636 return render_pass->output_rect.size(); |
| 625 } | 637 } |
| 626 | 638 |
| 627 void DirectRenderer::SetCurrentFrameForTesting(const DrawingFrame& frame) { | 639 void DirectRenderer::SetCurrentFrameForTesting(const DrawingFrame& frame) { |
| 628 current_frame_valid_ = true; | 640 current_frame_valid_ = true; |
| 629 current_frame_ = frame; | 641 current_frame_ = frame; |
| 630 } | 642 } |
| 631 | 643 |
| 632 } // namespace cc | 644 } // namespace cc |
| OLD | NEW |