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/delegating_renderer.h" | 5 #include "cc/output/delegating_renderer.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/trace_event/trace_event.h" | 12 #include "base/trace_event/trace_event.h" |
13 #include "cc/output/context_provider.h" | 13 #include "cc/output/context_provider.h" |
14 #include "cc/quads/draw_quad.h" | 14 #include "cc/quads/draw_quad.h" |
15 #include "cc/quads/render_pass.h" | 15 #include "cc/quads/render_pass.h" |
16 #include "cc/resources/resource_provider.h" | 16 #include "cc/resources/resource_provider.h" |
17 #include "gpu/command_buffer/client/context_support.h" | 17 #include "gpu/command_buffer/client/context_support.h" |
18 #include "gpu/command_buffer/client/gles2_interface.h" | 18 #include "gpu/command_buffer/client/gles2_interface.h" |
19 | 19 |
20 | 20 |
21 namespace cc { | 21 namespace cc { |
22 | 22 |
23 DelegatingRenderer::DelegatingRenderer(const RendererSettings* settings, | 23 DelegatingRenderer::DelegatingRenderer(OutputSurface* output_surface, |
24 OutputSurface* output_surface, | |
25 ResourceProvider* resource_provider) | 24 ResourceProvider* resource_provider) |
26 : Renderer(settings), | 25 : output_surface_(output_surface), resource_provider_(resource_provider) { |
27 output_surface_(output_surface), | |
28 resource_provider_(resource_provider) { | |
29 DCHECK(resource_provider_); | 26 DCHECK(resource_provider_); |
30 | 27 |
31 capabilities_.using_partial_swap = false; | 28 capabilities_.using_partial_swap = false; |
32 capabilities_.max_texture_size = resource_provider_->max_texture_size(); | 29 capabilities_.max_texture_size = resource_provider_->max_texture_size(); |
33 capabilities_.best_texture_format = resource_provider_->best_texture_format(); | 30 capabilities_.best_texture_format = resource_provider_->best_texture_format(); |
34 capabilities_.allow_partial_texture_updates = | 31 capabilities_.allow_partial_texture_updates = |
35 output_surface->capabilities().can_force_reclaim_resources; | 32 output_surface->capabilities().can_force_reclaim_resources; |
36 | 33 |
37 if (!output_surface_->context_provider()) { | 34 if (!output_surface_->context_provider()) { |
38 capabilities_.using_shared_memory_resources = true; | 35 capabilities_.using_shared_memory_resources = true; |
(...skipping 10 matching lines...) Expand all Loading... |
49 | 46 |
50 // If MSAA is slow, we want this renderer to behave as though MSAA is not | 47 // If MSAA is slow, we want this renderer to behave as though MSAA is not |
51 // available. Set samples to 0 to achieve this. | 48 // available. Set samples to 0 to achieve this. |
52 if (caps.msaa_is_slow) | 49 if (caps.msaa_is_slow) |
53 capabilities_.max_msaa_samples = 0; | 50 capabilities_.max_msaa_samples = 0; |
54 else | 51 else |
55 capabilities_.max_msaa_samples = caps.max_samples; | 52 capabilities_.max_msaa_samples = caps.max_samples; |
56 } | 53 } |
57 } | 54 } |
58 | 55 |
59 DelegatingRenderer::~DelegatingRenderer() {} | 56 DelegatingRenderer::~DelegatingRenderer() = default; |
60 | 57 |
61 const RendererCapabilitiesImpl& DelegatingRenderer::Capabilities() const { | 58 void DelegatingRenderer::DrawFrame( |
62 return capabilities_; | 59 RenderPassList* render_passes_in_draw_order) { |
63 } | |
64 | |
65 void DelegatingRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order, | |
66 float device_scale_factor, | |
67 const gfx::ColorSpace& device_color_space, | |
68 const gfx::Rect& device_viewport_rect, | |
69 const gfx::Rect& device_clip_rect) { | |
70 TRACE_EVENT0("cc", "DelegatingRenderer::DrawFrame"); | 60 TRACE_EVENT0("cc", "DelegatingRenderer::DrawFrame"); |
71 | 61 |
72 DCHECK(!delegated_frame_data_); | |
73 | |
74 delegated_frame_data_ = base::WrapUnique(new DelegatedFrameData); | 62 delegated_frame_data_ = base::WrapUnique(new DelegatedFrameData); |
75 DelegatedFrameData& out_data = *delegated_frame_data_; | 63 DelegatedFrameData& out_data = *delegated_frame_data_; |
76 // Move the render passes and resources into the |out_frame|. | 64 // Move the render passes and resources into the |out_frame|. |
77 out_data.render_pass_list.swap(*render_passes_in_draw_order); | 65 out_data.render_pass_list.swap(*render_passes_in_draw_order); |
78 | 66 |
79 // Collect all resource ids in the render passes into a ResourceIdArray. | 67 // Collect all resource ids in the render passes into a ResourceIdArray. |
80 ResourceProvider::ResourceIdArray resources; | 68 ResourceProvider::ResourceIdArray resources; |
81 for (const auto& render_pass : out_data.render_pass_list) { | 69 for (const auto& render_pass : out_data.render_pass_list) { |
82 for (auto* quad : render_pass->quad_list) { | 70 for (auto* quad : render_pass->quad_list) { |
83 for (ResourceId resource_id : quad->resources) | 71 for (ResourceId resource_id : quad->resources) |
84 resources.push_back(resource_id); | 72 resources.push_back(resource_id); |
85 } | 73 } |
86 } | 74 } |
87 resource_provider_->PrepareSendToParent(resources, &out_data.resource_list); | 75 resource_provider_->PrepareSendToParent(resources, &out_data.resource_list); |
88 } | 76 } |
89 | 77 |
90 void DelegatingRenderer::SwapBuffers(CompositorFrameMetadata metadata) { | 78 void DelegatingRenderer::SwapBuffers(CompositorFrameMetadata metadata) { |
91 TRACE_EVENT0("cc,benchmark", "DelegatingRenderer::SwapBuffers"); | 79 TRACE_EVENT0("cc,benchmark", "DelegatingRenderer::SwapBuffers"); |
92 CompositorFrame compositor_frame; | 80 CompositorFrame compositor_frame; |
93 compositor_frame.metadata = std::move(metadata); | 81 compositor_frame.metadata = std::move(metadata); |
94 compositor_frame.delegated_frame_data = std::move(delegated_frame_data_); | 82 compositor_frame.delegated_frame_data = std::move(delegated_frame_data_); |
95 output_surface_->SwapBuffers(std::move(compositor_frame)); | 83 output_surface_->SwapBuffers(std::move(compositor_frame)); |
96 } | 84 } |
97 | 85 |
98 void DelegatingRenderer::ReclaimResources( | |
99 const ReturnedResourceArray& resources) { | |
100 resource_provider_->ReceiveReturnsFromParent(resources); | |
101 } | |
102 | |
103 } // namespace cc | 86 } // namespace cc |
OLD | NEW |