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 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 capabilities_.max_msaa_samples = caps.gpu.max_samples; | 59 capabilities_.max_msaa_samples = caps.gpu.max_samples; |
60 } | 60 } |
61 } | 61 } |
62 | 62 |
63 DelegatingRenderer::~DelegatingRenderer() {} | 63 DelegatingRenderer::~DelegatingRenderer() {} |
64 | 64 |
65 const RendererCapabilitiesImpl& DelegatingRenderer::Capabilities() const { | 65 const RendererCapabilitiesImpl& DelegatingRenderer::Capabilities() const { |
66 return capabilities_; | 66 return capabilities_; |
67 } | 67 } |
68 | 68 |
69 static ResourceId AppendToArray(ResourceProvider::ResourceIdArray* array, | |
70 ResourceId id) { | |
71 array->push_back(id); | |
72 return id; | |
73 } | |
74 | |
75 void DelegatingRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order, | 69 void DelegatingRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order, |
76 float device_scale_factor, | 70 float device_scale_factor, |
77 const gfx::Rect& device_viewport_rect, | 71 const gfx::Rect& device_viewport_rect, |
78 const gfx::Rect& device_clip_rect, | 72 const gfx::Rect& device_clip_rect, |
79 bool disable_picture_quad_image_filtering) { | 73 bool disable_picture_quad_image_filtering) { |
80 TRACE_EVENT0("cc", "DelegatingRenderer::DrawFrame"); | 74 TRACE_EVENT0("cc", "DelegatingRenderer::DrawFrame"); |
81 | 75 |
82 DCHECK(!delegated_frame_data_); | 76 DCHECK(!delegated_frame_data_); |
83 | 77 |
84 delegated_frame_data_ = make_scoped_ptr(new DelegatedFrameData); | 78 delegated_frame_data_ = make_scoped_ptr(new DelegatedFrameData); |
85 DelegatedFrameData& out_data = *delegated_frame_data_; | 79 DelegatedFrameData& out_data = *delegated_frame_data_; |
86 out_data.device_scale_factor = device_scale_factor; | 80 out_data.device_scale_factor = device_scale_factor; |
87 // Move the render passes and resources into the |out_frame|. | 81 // Move the render passes and resources into the |out_frame|. |
88 out_data.render_pass_list.swap(*render_passes_in_draw_order); | 82 out_data.render_pass_list.swap(*render_passes_in_draw_order); |
89 | 83 |
90 // Collect all resource ids in the render passes into a ResourceIdArray. | 84 // Collect all resource ids in the render passes into a ResourceIdArray. |
91 ResourceProvider::ResourceIdArray resources; | 85 ResourceProvider::ResourceIdArray resources; |
92 DrawQuad::ResourceIteratorCallback append_to_array = | |
93 base::Bind(&AppendToArray, &resources); | |
94 for (const auto& render_pass : out_data.render_pass_list) { | 86 for (const auto& render_pass : out_data.render_pass_list) { |
95 for (const auto& quad : render_pass->quad_list) | 87 for (const auto& quad : render_pass->quad_list) { |
96 quad->IterateResources(append_to_array); | 88 for (ResourceId resource_id : quad->resources) |
| 89 resources.push_back(resource_id); |
| 90 } |
97 } | 91 } |
98 resource_provider_->PrepareSendToParent(resources, &out_data.resource_list); | 92 resource_provider_->PrepareSendToParent(resources, &out_data.resource_list); |
99 } | 93 } |
100 | 94 |
101 void DelegatingRenderer::SwapBuffers(const CompositorFrameMetadata& metadata) { | 95 void DelegatingRenderer::SwapBuffers(const CompositorFrameMetadata& metadata) { |
102 TRACE_EVENT0("cc,benchmark", "DelegatingRenderer::SwapBuffers"); | 96 TRACE_EVENT0("cc,benchmark", "DelegatingRenderer::SwapBuffers"); |
103 CompositorFrame compositor_frame; | 97 CompositorFrame compositor_frame; |
104 compositor_frame.metadata = metadata; | 98 compositor_frame.metadata = metadata; |
105 compositor_frame.delegated_frame_data = delegated_frame_data_.Pass(); | 99 compositor_frame.delegated_frame_data = delegated_frame_data_.Pass(); |
106 output_surface_->SwapBuffers(&compositor_frame); | 100 output_surface_->SwapBuffers(&compositor_frame); |
(...skipping 15 matching lines...) Expand all Loading... |
122 } | 116 } |
123 } | 117 } |
124 // We loop visibility to the GPU process, since that's what manages memory. | 118 // We loop visibility to the GPU process, since that's what manages memory. |
125 // That will allow it to feed us with memory allocations that we can act | 119 // That will allow it to feed us with memory allocations that we can act |
126 // upon. | 120 // upon. |
127 if (context_provider) | 121 if (context_provider) |
128 context_provider->ContextSupport()->SetSurfaceVisible(visible()); | 122 context_provider->ContextSupport()->SetSurfaceVisible(visible()); |
129 } | 123 } |
130 | 124 |
131 } // namespace cc | 125 } // namespace cc |
OLD | NEW |