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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 overlay_processor_->Initialize(); | 80 overlay_processor_->Initialize(); |
| 81 | 81 |
| 82 auto* context_provider = output_surface_->context_provider(); | 82 auto* context_provider = output_surface_->context_provider(); |
| 83 | 83 |
| 84 use_partial_swap_ = settings_->partial_swap_enabled && CanPartialSwap(); | 84 use_partial_swap_ = settings_->partial_swap_enabled && CanPartialSwap(); |
| 85 allow_empty_swap_ = use_partial_swap_; | 85 allow_empty_swap_ = use_partial_swap_; |
| 86 if (context_provider && | 86 if (context_provider && |
| 87 context_provider->ContextCapabilities().commit_overlay_planes) | 87 context_provider->ContextCapabilities().commit_overlay_planes) |
| 88 allow_empty_swap_ = true; | 88 allow_empty_swap_ = true; |
| 89 | 89 |
| 90 if (context_provider && | |
| 91 context_provider->ContextCapabilities().set_draw_rectangle) { | |
| 92 use_set_draw_rectangle_ = true; | |
| 93 } | |
| 94 | |
| 90 initialized_ = true; | 95 initialized_ = true; |
| 91 } | 96 } |
| 92 | 97 |
| 93 // static | 98 // static |
| 94 gfx::RectF DirectRenderer::QuadVertexRect() { | 99 gfx::RectF DirectRenderer::QuadVertexRect() { |
| 95 return gfx::RectF(-0.5f, -0.5f, 1.f, 1.f); | 100 return gfx::RectF(-0.5f, -0.5f, 1.f, 1.f); |
| 96 } | 101 } |
| 97 | 102 |
| 98 // static | 103 // static |
| 99 void DirectRenderer::QuadRectTransform(gfx::Transform* quad_rect_transform, | 104 void DirectRenderer::QuadRectTransform(gfx::Transform* quad_rect_transform, |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 491 if (frame->current_render_pass == frame->root_render_pass) { | 496 if (frame->current_render_pass == frame->root_render_pass) { |
| 492 render_pass_scissor_in_draw_space.Intersect( | 497 render_pass_scissor_in_draw_space.Intersect( |
| 493 DeviceViewportRectInDrawSpace(frame)); | 498 DeviceViewportRectInDrawSpace(frame)); |
| 494 } | 499 } |
| 495 | 500 |
| 496 if (use_partial_swap_) { | 501 if (use_partial_swap_) { |
| 497 render_pass_scissor_in_draw_space.Intersect( | 502 render_pass_scissor_in_draw_space.Intersect( |
| 498 ComputeScissorRectForRenderPass(frame)); | 503 ComputeScissorRectForRenderPass(frame)); |
| 499 } | 504 } |
| 500 | 505 |
| 501 bool render_pass_is_clipped = | |
| 502 !render_pass_scissor_in_draw_space.Contains(surface_rect_in_draw_space); | |
| 503 bool is_root_render_pass = | 506 bool is_root_render_pass = |
| 504 frame->current_render_pass == frame->root_render_pass; | 507 frame->current_render_pass == frame->root_render_pass; |
| 508 bool render_pass_is_clipped = | |
| 509 (use_set_draw_rectangle_ && is_root_render_pass) || | |
| 510 !render_pass_scissor_in_draw_space.Contains(surface_rect_in_draw_space); | |
| 505 bool has_external_stencil_test = | 511 bool has_external_stencil_test = |
| 506 is_root_render_pass && output_surface_->HasExternalStencilTest(); | 512 is_root_render_pass && output_surface_->HasExternalStencilTest(); |
| 507 bool should_clear_surface = | 513 bool should_clear_surface = |
| 508 !has_external_stencil_test && | 514 !has_external_stencil_test && |
| 509 (!is_root_render_pass || settings_->should_clear_root_render_pass); | 515 (!is_root_render_pass || settings_->should_clear_root_render_pass); |
| 510 | 516 |
| 511 // If |has_external_stencil_test| we can't discard or clear. Make sure we | 517 // If |has_external_stencil_test| we can't discard or clear. Make sure we |
| 512 // don't need to. | 518 // don't need to. |
| 513 DCHECK(!has_external_stencil_test || | 519 DCHECK(!has_external_stencil_test || |
| 514 !frame->current_render_pass->has_transparent_background); | 520 !frame->current_render_pass->has_transparent_background); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 565 DoDrawQuad(frame, &quad, nullptr); | 571 DoDrawQuad(frame, &quad, nullptr); |
| 566 } | 572 } |
| 567 FlushPolygons(&poly_list, frame, render_pass_scissor_in_draw_space, | 573 FlushPolygons(&poly_list, frame, render_pass_scissor_in_draw_space, |
| 568 render_pass_is_clipped); | 574 render_pass_is_clipped); |
| 569 FinishDrawingQuadList(); | 575 FinishDrawingQuadList(); |
| 570 } | 576 } |
| 571 | 577 |
| 572 bool DirectRenderer::UseRenderPass(DrawingFrame* frame, | 578 bool DirectRenderer::UseRenderPass(DrawingFrame* frame, |
| 573 const RenderPass* render_pass) { | 579 const RenderPass* render_pass) { |
| 574 frame->current_render_pass = render_pass; | 580 frame->current_render_pass = render_pass; |
| 575 frame->current_texture = NULL; | 581 frame->current_texture = NULL; |
|
sunnyps
2017/01/28 01:33:58
nit: nullptr
| |
| 576 if (render_pass == frame->root_render_pass) { | 582 if (render_pass == frame->root_render_pass) { |
| 577 BindFramebufferToOutputSurface(frame); | 583 BindFramebufferToOutputSurface(frame); |
| 584 | |
| 585 if (use_set_draw_rectangle_) | |
| 586 output_surface_->SetDrawRectangle(frame->root_damage_rect); | |
| 587 | |
| 578 InitializeViewport(frame, render_pass->output_rect, | 588 InitializeViewport(frame, render_pass->output_rect, |
| 579 gfx::Rect(frame->device_viewport_size), | 589 gfx::Rect(frame->device_viewport_size), |
| 580 frame->device_viewport_size); | 590 frame->device_viewport_size); |
| 581 return true; | 591 return true; |
| 582 } | 592 } |
| 583 | 593 |
| 584 ScopedResource* texture = render_pass_textures_[render_pass->id].get(); | 594 ScopedResource* texture = render_pass_textures_[render_pass->id].get(); |
| 585 DCHECK(texture); | 595 DCHECK(texture); |
| 586 | 596 |
| 587 gfx::Size size = RenderPassTextureSize(render_pass); | 597 gfx::Size size = RenderPassTextureSize(render_pass); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 608 auto iter = render_pass_textures_.find(render_pass_id); | 618 auto iter = render_pass_textures_.find(render_pass_id); |
| 609 return iter != render_pass_textures_.end() && iter->second->id(); | 619 return iter != render_pass_textures_.end() && iter->second->id(); |
| 610 } | 620 } |
| 611 | 621 |
| 612 // static | 622 // static |
| 613 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { | 623 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { |
| 614 return render_pass->output_rect.size(); | 624 return render_pass->output_rect.size(); |
| 615 } | 625 } |
| 616 | 626 |
| 617 } // namespace cc | 627 } // namespace cc |
| OLD | NEW |