| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 DirectRenderer::DrawingFrame::DrawingFrame() = default; | 66 DirectRenderer::DrawingFrame::DrawingFrame() = default; |
| 67 DirectRenderer::DrawingFrame::~DrawingFrame() = default; | 67 DirectRenderer::DrawingFrame::~DrawingFrame() = default; |
| 68 | 68 |
| 69 DirectRenderer::DirectRenderer(const RendererSettings* settings, | 69 DirectRenderer::DirectRenderer(const RendererSettings* settings, |
| 70 OutputSurface* output_surface, | 70 OutputSurface* output_surface, |
| 71 ResourceProvider* resource_provider) | 71 ResourceProvider* resource_provider) |
| 72 : settings_(settings), | 72 : settings_(settings), |
| 73 output_surface_(output_surface), | 73 output_surface_(output_surface), |
| 74 resource_provider_(resource_provider), | 74 resource_provider_(resource_provider), |
| 75 overlay_processor_(new OverlayProcessor(output_surface)) { | 75 overlay_processor_(new OverlayProcessor(output_surface)) {} |
| 76 // TODO(danakj): This should not be happening in the constructor. | |
| 77 overlay_processor_->Initialize(); | |
| 78 } | |
| 79 | 76 |
| 80 DirectRenderer::~DirectRenderer() = default; | 77 DirectRenderer::~DirectRenderer() = default; |
| 81 | 78 |
| 79 void DirectRenderer::Initialize() { |
| 80 overlay_processor_->Initialize(); |
| 81 |
| 82 auto* context_provider = output_surface_->context_provider(); |
| 83 |
| 84 use_partial_swap_ = settings_->partial_swap_enabled && CanPartialSwap(); |
| 85 allow_empty_swap_ = use_partial_swap_; |
| 86 if (context_provider && |
| 87 context_provider->ContextCapabilities().commit_overlay_planes) |
| 88 allow_empty_swap_ = true; |
| 89 |
| 90 initialized_ = true; |
| 91 } |
| 92 |
| 82 // static | 93 // static |
| 83 gfx::RectF DirectRenderer::QuadVertexRect() { | 94 gfx::RectF DirectRenderer::QuadVertexRect() { |
| 84 return gfx::RectF(-0.5f, -0.5f, 1.f, 1.f); | 95 return gfx::RectF(-0.5f, -0.5f, 1.f, 1.f); |
| 85 } | 96 } |
| 86 | 97 |
| 87 // static | 98 // static |
| 88 void DirectRenderer::QuadRectTransform(gfx::Transform* quad_rect_transform, | 99 void DirectRenderer::QuadRectTransform(gfx::Transform* quad_rect_transform, |
| 89 const gfx::Transform& quad_transform, | 100 const gfx::Transform& quad_transform, |
| 90 const gfx::RectF& quad_rect) { | 101 const gfx::RectF& quad_rect) { |
| 91 *quad_rect_transform = quad_transform; | 102 *quad_rect_transform = quad_transform; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 window_rect.set_y(current_surface_size_.height() - window_rect.bottom()); | 149 window_rect.set_y(current_surface_size_.height() - window_rect.bottom()); |
| 139 return window_rect; | 150 return window_rect; |
| 140 } | 151 } |
| 141 | 152 |
| 142 const TileDrawQuad* DirectRenderer::CanPassBeDrawnDirectly( | 153 const TileDrawQuad* DirectRenderer::CanPassBeDrawnDirectly( |
| 143 const RenderPass* pass) { | 154 const RenderPass* pass) { |
| 144 return nullptr; | 155 return nullptr; |
| 145 } | 156 } |
| 146 | 157 |
| 147 void DirectRenderer::SetVisible(bool visible) { | 158 void DirectRenderer::SetVisible(bool visible) { |
| 159 DCHECK(initialized_); |
| 148 if (visible_ == visible) | 160 if (visible_ == visible) |
| 149 return; | 161 return; |
| 150 visible_ = visible; | 162 visible_ = visible; |
| 151 DidChangeVisibility(); | 163 DidChangeVisibility(); |
| 152 } | 164 } |
| 153 | 165 |
| 154 void DirectRenderer::DecideRenderPassAllocationsForFrame( | 166 void DirectRenderer::DecideRenderPassAllocationsForFrame( |
| 155 const RenderPassList& render_passes_in_draw_order) { | 167 const RenderPassList& render_passes_in_draw_order) { |
| 156 render_pass_bypass_quads_.clear(); | 168 render_pass_bypass_quads_.clear(); |
| 157 | 169 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 } | 266 } |
| 255 | 267 |
| 256 // Attempt to replace some or all of the quads of the root render pass with | 268 // Attempt to replace some or all of the quads of the root render pass with |
| 257 // overlays. | 269 // overlays. |
| 258 overlay_processor_->ProcessForOverlays( | 270 overlay_processor_->ProcessForOverlays( |
| 259 resource_provider_, root_render_pass, &frame.overlay_list, | 271 resource_provider_, root_render_pass, &frame.overlay_list, |
| 260 &frame.ca_layer_overlay_list, &frame.root_damage_rect); | 272 &frame.ca_layer_overlay_list, &frame.root_damage_rect); |
| 261 | 273 |
| 262 // We can skip all drawing if the damage rect is now empty. | 274 // We can skip all drawing if the damage rect is now empty. |
| 263 bool skip_drawing_root_render_pass = | 275 bool skip_drawing_root_render_pass = |
| 264 frame.root_damage_rect.IsEmpty() && Capabilities().allow_empty_swap; | 276 frame.root_damage_rect.IsEmpty() && allow_empty_swap_; |
| 265 | 277 |
| 266 // If we have to draw but don't support partial swap, the whole output should | 278 // If we have to draw but don't support partial swap, the whole output should |
| 267 // be considered damaged. | 279 // be considered damaged. |
| 268 if (!skip_drawing_root_render_pass && !Capabilities().using_partial_swap) | 280 if (!skip_drawing_root_render_pass && !use_partial_swap_) |
| 269 frame.root_damage_rect = root_render_pass->output_rect; | 281 frame.root_damage_rect = root_render_pass->output_rect; |
| 270 | 282 |
| 271 if (skip_drawing_root_render_pass) { | 283 if (skip_drawing_root_render_pass) { |
| 272 // If any of the overlays is the output surface, then ensure that the | 284 // If any of the overlays is the output surface, then ensure that the |
| 273 // backbuffer be allocated (allocation of the backbuffer is a side-effect | 285 // backbuffer be allocated (allocation of the backbuffer is a side-effect |
| 274 // of BindFramebufferToOutputSurface). | 286 // of BindFramebufferToOutputSurface). |
| 275 for (auto& overlay : frame.overlay_list) { | 287 for (auto& overlay : frame.overlay_list) { |
| 276 if (overlay.use_output_surface_for_resource) { | 288 if (overlay.use_output_surface_for_resource) { |
| 277 BindFramebufferToOutputSurface(&frame); | 289 BindFramebufferToOutputSurface(&frame); |
| 278 break; | 290 break; |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 | 456 |
| 445 const gfx::Rect surface_rect_in_draw_space = | 457 const gfx::Rect surface_rect_in_draw_space = |
| 446 OutputSurfaceRectInDrawSpace(frame); | 458 OutputSurfaceRectInDrawSpace(frame); |
| 447 gfx::Rect render_pass_scissor_in_draw_space = surface_rect_in_draw_space; | 459 gfx::Rect render_pass_scissor_in_draw_space = surface_rect_in_draw_space; |
| 448 | 460 |
| 449 if (frame->current_render_pass == frame->root_render_pass) { | 461 if (frame->current_render_pass == frame->root_render_pass) { |
| 450 render_pass_scissor_in_draw_space.Intersect( | 462 render_pass_scissor_in_draw_space.Intersect( |
| 451 DeviceViewportRectInDrawSpace(frame)); | 463 DeviceViewportRectInDrawSpace(frame)); |
| 452 } | 464 } |
| 453 | 465 |
| 454 if (Capabilities().using_partial_swap) { | 466 if (use_partial_swap_) { |
| 455 render_pass_scissor_in_draw_space.Intersect( | 467 render_pass_scissor_in_draw_space.Intersect( |
| 456 ComputeScissorRectForRenderPass(frame)); | 468 ComputeScissorRectForRenderPass(frame)); |
| 457 } | 469 } |
| 458 | 470 |
| 459 if (NeedDeviceClip(frame)) { | 471 if (NeedDeviceClip(frame)) { |
| 460 render_pass_scissor_in_draw_space.Intersect( | 472 render_pass_scissor_in_draw_space.Intersect( |
| 461 DeviceClipRectInDrawSpace(frame)); | 473 DeviceClipRectInDrawSpace(frame)); |
| 462 } | 474 } |
| 463 | 475 |
| 464 bool render_pass_is_clipped = | 476 bool render_pass_is_clipped = |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 auto iter = render_pass_textures_.find(id); | 585 auto iter = render_pass_textures_.find(id); |
| 574 return iter != render_pass_textures_.end() && iter->second->id(); | 586 return iter != render_pass_textures_.end() && iter->second->id(); |
| 575 } | 587 } |
| 576 | 588 |
| 577 // static | 589 // static |
| 578 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { | 590 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { |
| 579 return render_pass->output_rect.size(); | 591 return render_pass->output_rect.size(); |
| 580 } | 592 } |
| 581 | 593 |
| 582 } // namespace cc | 594 } // namespace cc |
| OLD | NEW |