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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 context_provider->ContextCapabilities().commit_overlay_planes) |
89 allow_empty_swap_ = true; | 89 allow_empty_swap_ = true; |
90 | 90 |
| 91 if (context_provider && |
| 92 context_provider->ContextCapabilities().set_draw_rectangle) { |
| 93 use_set_draw_rectangle_ = true; |
| 94 } |
| 95 |
91 initialized_ = true; | 96 initialized_ = true; |
92 } | 97 } |
93 | 98 |
94 // static | 99 // static |
95 gfx::RectF DirectRenderer::QuadVertexRect() { | 100 gfx::RectF DirectRenderer::QuadVertexRect() { |
96 return gfx::RectF(-0.5f, -0.5f, 1.f, 1.f); | 101 return gfx::RectF(-0.5f, -0.5f, 1.f, 1.f); |
97 } | 102 } |
98 | 103 |
99 // static | 104 // static |
100 void DirectRenderer::QuadRectTransform(gfx::Transform* quad_rect_transform, | 105 void DirectRenderer::QuadRectTransform(gfx::Transform* quad_rect_transform, |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 if (frame->current_render_pass == frame->root_render_pass) { | 517 if (frame->current_render_pass == frame->root_render_pass) { |
513 render_pass_scissor_in_draw_space.Intersect( | 518 render_pass_scissor_in_draw_space.Intersect( |
514 DeviceViewportRectInDrawSpace(frame)); | 519 DeviceViewportRectInDrawSpace(frame)); |
515 } | 520 } |
516 | 521 |
517 if (use_partial_swap_) { | 522 if (use_partial_swap_) { |
518 render_pass_scissor_in_draw_space.Intersect( | 523 render_pass_scissor_in_draw_space.Intersect( |
519 ComputeScissorRectForRenderPass(frame)); | 524 ComputeScissorRectForRenderPass(frame)); |
520 } | 525 } |
521 | 526 |
522 bool render_pass_is_clipped = | |
523 !render_pass_scissor_in_draw_space.Contains(surface_rect_in_draw_space); | |
524 bool is_root_render_pass = | 527 bool is_root_render_pass = |
525 frame->current_render_pass == frame->root_render_pass; | 528 frame->current_render_pass == frame->root_render_pass; |
| 529 bool render_pass_is_clipped = |
| 530 (use_set_draw_rectangle_ && is_root_render_pass) || |
| 531 !render_pass_scissor_in_draw_space.Contains(surface_rect_in_draw_space); |
526 bool has_external_stencil_test = | 532 bool has_external_stencil_test = |
527 is_root_render_pass && output_surface_->HasExternalStencilTest(); | 533 is_root_render_pass && output_surface_->HasExternalStencilTest(); |
528 bool should_clear_surface = | 534 bool should_clear_surface = |
529 !has_external_stencil_test && | 535 !has_external_stencil_test && |
530 (!is_root_render_pass || settings_->should_clear_root_render_pass); | 536 (!is_root_render_pass || settings_->should_clear_root_render_pass); |
531 | 537 |
532 // If |has_external_stencil_test| we can't discard or clear. Make sure we | 538 // If |has_external_stencil_test| we can't discard or clear. Make sure we |
533 // don't need to. | 539 // don't need to. |
534 DCHECK(!has_external_stencil_test || | 540 DCHECK(!has_external_stencil_test || |
535 !frame->current_render_pass->has_transparent_background); | 541 !frame->current_render_pass->has_transparent_background); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 DoDrawQuad(frame, &quad, nullptr); | 592 DoDrawQuad(frame, &quad, nullptr); |
587 } | 593 } |
588 FlushPolygons(&poly_list, frame, render_pass_scissor_in_draw_space, | 594 FlushPolygons(&poly_list, frame, render_pass_scissor_in_draw_space, |
589 render_pass_is_clipped); | 595 render_pass_is_clipped); |
590 FinishDrawingQuadList(); | 596 FinishDrawingQuadList(); |
591 } | 597 } |
592 | 598 |
593 bool DirectRenderer::UseRenderPass(DrawingFrame* frame, | 599 bool DirectRenderer::UseRenderPass(DrawingFrame* frame, |
594 const RenderPass* render_pass) { | 600 const RenderPass* render_pass) { |
595 frame->current_render_pass = render_pass; | 601 frame->current_render_pass = render_pass; |
596 frame->current_texture = NULL; | 602 frame->current_texture = nullptr; |
597 if (render_pass == frame->root_render_pass) { | 603 if (render_pass == frame->root_render_pass) { |
598 BindFramebufferToOutputSurface(frame); | 604 BindFramebufferToOutputSurface(frame); |
| 605 |
| 606 if (use_set_draw_rectangle_) |
| 607 output_surface_->SetDrawRectangle(frame->root_damage_rect); |
| 608 |
599 InitializeViewport(frame, render_pass->output_rect, | 609 InitializeViewport(frame, render_pass->output_rect, |
600 gfx::Rect(frame->device_viewport_size), | 610 gfx::Rect(frame->device_viewport_size), |
601 frame->device_viewport_size); | 611 frame->device_viewport_size); |
602 return true; | 612 return true; |
603 } | 613 } |
604 | 614 |
605 ScopedResource* texture = render_pass_textures_[render_pass->id].get(); | 615 ScopedResource* texture = render_pass_textures_[render_pass->id].get(); |
606 DCHECK(texture); | 616 DCHECK(texture); |
607 | 617 |
608 gfx::Size size = RenderPassTextureSize(render_pass); | 618 gfx::Size size = RenderPassTextureSize(render_pass); |
(...skipping 20 matching lines...) Expand all Loading... |
629 auto iter = render_pass_textures_.find(render_pass_id); | 639 auto iter = render_pass_textures_.find(render_pass_id); |
630 return iter != render_pass_textures_.end() && iter->second->id(); | 640 return iter != render_pass_textures_.end() && iter->second->id(); |
631 } | 641 } |
632 | 642 |
633 // static | 643 // static |
634 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { | 644 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { |
635 return render_pass->output_rect.size(); | 645 return render_pass->output_rect.size(); |
636 } | 646 } |
637 | 647 |
638 } // namespace cc | 648 } // namespace cc |
OLD | NEW |