OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/compositor/gpu_process_transport_factory.h" | 5 #include "content/browser/compositor/gpu_process_transport_factory.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 if (!create_software_renderer) { | 154 if (!create_software_renderer) { |
155 context_provider = ContextProviderCommandBuffer::Create( | 155 context_provider = ContextProviderCommandBuffer::Create( |
156 GpuProcessTransportFactory::CreateContextCommon(data->surface_id), | 156 GpuProcessTransportFactory::CreateContextCommon(data->surface_id), |
157 "Compositor"); | 157 "Compositor"); |
158 } | 158 } |
159 | 159 |
160 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", !!context_provider); | 160 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", !!context_provider); |
161 | 161 |
162 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 162 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
163 switches::kUseSurfaces)) { | 163 switches::kUseSurfaces)) { |
164 if (!context_provider.get()) | |
165 LOG(FATAL) << "Surfaces do not support software compositing yet"; | |
166 // This gets a bit confusing. Here we have a ContextProvider configured to | 164 // This gets a bit confusing. Here we have a ContextProvider configured to |
167 // render directly to this widget. We need to make an OnscreenDisplayClient | 165 // render directly to this widget. We need to make an OnscreenDisplayClient |
168 // associated with this context, then return a SurfaceDisplayOutputSurface | 166 // associated with this context, then return a SurfaceDisplayOutputSurface |
169 // set up to draw to the display's surface. | 167 // set up to draw to the display's surface. |
170 cc::SurfaceManager* manager = surface_manager_.get(); | 168 cc::SurfaceManager* manager = surface_manager_.get(); |
171 scoped_ptr<OnscreenDisplayClient> display_client( | 169 scoped_ptr<cc::OutputSurface> software_surface; |
172 new OnscreenDisplayClient(context_provider, manager)); | 170 if (!context_provider) { |
| 171 software_surface = |
| 172 make_scoped_ptr(new SoftwareBrowserCompositorOutputSurface( |
| 173 output_surface_proxy_, |
| 174 CreateSoftwareOutputDevice(compositor), |
| 175 per_compositor_data_[compositor]->surface_id, |
| 176 &output_surface_map_, |
| 177 compositor->vsync_manager())); |
| 178 } |
| 179 scoped_ptr<OnscreenDisplayClient> display_client(new OnscreenDisplayClient( |
| 180 context_provider, software_surface.Pass(), manager)); |
173 // TODO(jamesr): Need to set up filtering for the | 181 // TODO(jamesr): Need to set up filtering for the |
174 // GpuHostMsg_UpdateVSyncParameters message. | 182 // GpuHostMsg_UpdateVSyncParameters message. |
175 | 183 |
176 scoped_refptr<cc::ContextProvider> offscreen_context_provider = | 184 scoped_refptr<cc::ContextProvider> offscreen_context_provider; |
177 ContextProviderCommandBuffer::Create( | 185 if (context_provider) { |
178 GpuProcessTransportFactory::CreateOffscreenCommandBufferContext(), | 186 offscreen_context_provider = ContextProviderCommandBuffer::Create( |
179 "Offscreen-MainThread"); | 187 GpuProcessTransportFactory::CreateOffscreenCommandBufferContext(), |
180 scoped_ptr<cc::SoftwareOutputDevice> software_device; | 188 "Offscreen-Compositor"); |
| 189 } |
181 scoped_ptr<SurfaceDisplayOutputSurface> output_surface( | 190 scoped_ptr<SurfaceDisplayOutputSurface> output_surface( |
182 new SurfaceDisplayOutputSurface(display_client->display(), | 191 new SurfaceDisplayOutputSurface( |
183 manager, | 192 display_client->display(), manager, offscreen_context_provider)); |
184 offscreen_context_provider, | |
185 software_device.Pass())); | |
186 data->display_client = display_client.Pass(); | 193 data->display_client = display_client.Pass(); |
187 return output_surface.PassAs<cc::OutputSurface>(); | 194 return output_surface.PassAs<cc::OutputSurface>(); |
188 } | 195 } |
189 | 196 |
190 if (!context_provider.get()) { | 197 if (!context_provider.get()) { |
191 if (compositor_thread_.get()) { | 198 if (compositor_thread_.get()) { |
192 LOG(FATAL) << "Failed to create UI context, but can't use software" | 199 LOG(FATAL) << "Failed to create UI context, but can't use software" |
193 " compositing with browser threaded compositing. Aborting."; | 200 " compositing with browser threaded compositing. Aborting."; |
194 } | 201 } |
195 | 202 |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, | 423 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, |
417 observer_list_, | 424 observer_list_, |
418 OnLostResources()); | 425 OnLostResources()); |
419 | 426 |
420 // Kill things that use the shared context before killing the shared context. | 427 // Kill things that use the shared context before killing the shared context. |
421 lost_gl_helper.reset(); | 428 lost_gl_helper.reset(); |
422 lost_shared_main_thread_contexts = NULL; | 429 lost_shared_main_thread_contexts = NULL; |
423 } | 430 } |
424 | 431 |
425 } // namespace content | 432 } // namespace content |
OLD | NEW |