OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/aura/gpu_process_transport_factory.h" | 5 #include "content/browser/aura/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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 NOTREACHED(); | 212 NOTREACHED(); |
213 return scoped_ptr<cc::SoftwareOutputDevice>(); | 213 return scoped_ptr<cc::SoftwareOutputDevice>(); |
214 } | 214 } |
215 | 215 |
216 scoped_ptr<cc::OutputSurface> GpuProcessTransportFactory::CreateOutputSurface( | 216 scoped_ptr<cc::OutputSurface> GpuProcessTransportFactory::CreateOutputSurface( |
217 ui::Compositor* compositor) { | 217 ui::Compositor* compositor) { |
218 PerCompositorData* data = per_compositor_data_[compositor]; | 218 PerCompositorData* data = per_compositor_data_[compositor]; |
219 if (!data) | 219 if (!data) |
220 data = CreatePerCompositorData(compositor); | 220 data = CreatePerCompositorData(compositor); |
221 | 221 |
222 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context; | 222 scoped_refptr<ContextProviderCommandBuffer> context_provider; |
| 223 |
223 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 224 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
224 if (!command_line->HasSwitch(switches::kUIEnableSoftwareCompositing)) { | 225 if (!command_line->HasSwitch(switches::kUIEnableSoftwareCompositing)) { |
225 context = | 226 context_provider = ContextProviderCommandBuffer::Create( |
226 CreateContextCommon(data->swap_client->AsWeakPtr(), data->surface_id); | 227 base::Bind(&GpuProcessTransportFactory::CreateContextCommon, |
| 228 base::Unretained(this), |
| 229 data->swap_client->AsWeakPtr(), |
| 230 data->surface_id)); |
227 } | 231 } |
228 if (!context) { | 232 if (!context_provider.get()) { |
229 if (ui::Compositor::WasInitializedWithThread()) { | 233 if (ui::Compositor::WasInitializedWithThread()) { |
230 LOG(FATAL) << "Failed to create UI context, but can't use software " | 234 LOG(FATAL) << "Failed to create UI context, but can't use software " |
231 " compositing with browser threaded compositing. Aborting."; | 235 " compositing with browser threaded compositing. Aborting."; |
232 } | 236 } |
233 | 237 |
234 scoped_ptr<SoftwareBrowserCompositorOutputSurface> surface = | 238 scoped_ptr<SoftwareBrowserCompositorOutputSurface> surface = |
235 SoftwareBrowserCompositorOutputSurface::Create( | 239 SoftwareBrowserCompositorOutputSurface::Create( |
236 CreateSoftwareOutputDevice(compositor)); | 240 CreateSoftwareOutputDevice(compositor)); |
237 return surface.PassAs<cc::OutputSurface>(); | 241 return surface.PassAs<cc::OutputSurface>(); |
238 } | 242 } |
239 | 243 |
240 scoped_refptr<base::SingleThreadTaskRunner> compositor_thread_task_runner = | 244 scoped_refptr<base::SingleThreadTaskRunner> compositor_thread_task_runner = |
241 ui::Compositor::GetCompositorMessageLoop(); | 245 ui::Compositor::GetCompositorMessageLoop(); |
242 if (!compositor_thread_task_runner.get()) | 246 if (!compositor_thread_task_runner.get()) |
243 compositor_thread_task_runner = base::MessageLoopProxy::current(); | 247 compositor_thread_task_runner = base::MessageLoopProxy::current(); |
244 | 248 |
245 // Here we know the GpuProcessHost has been set up, because we created a | 249 // Here we know the GpuProcessHost has been set up, because we created a |
246 // context. | 250 // context. |
247 output_surface_proxy_->ConnectToGpuProcessHost( | 251 output_surface_proxy_->ConnectToGpuProcessHost( |
248 compositor_thread_task_runner.get()); | 252 compositor_thread_task_runner.get()); |
249 | 253 |
250 scoped_ptr<BrowserCompositorOutputSurface> surface( | 254 scoped_ptr<BrowserCompositorOutputSurface> surface( |
251 new BrowserCompositorOutputSurface( | 255 new BrowserCompositorOutputSurface( |
252 context.PassAs<WebKit::WebGraphicsContext3D>(), | 256 context_provider, |
253 per_compositor_data_[compositor]->surface_id, | 257 per_compositor_data_[compositor]->surface_id, |
254 &output_surface_map_, | 258 &output_surface_map_, |
255 base::MessageLoopProxy::current().get(), | 259 base::MessageLoopProxy::current().get(), |
256 compositor->AsWeakPtr())); | 260 compositor->AsWeakPtr())); |
257 if (data->reflector.get()) { | 261 if (data->reflector.get()) { |
258 data->reflector->CreateSharedTexture(); | 262 data->reflector->CreateSharedTexture(); |
259 data->reflector->AttachToOutputSurface(surface.get()); | 263 data->reflector->AttachToOutputSurface(surface.get()); |
260 } | 264 } |
261 | 265 |
262 return surface.PassAs<cc::OutputSurface>(); | 266 return surface.PassAs<cc::OutputSurface>(); |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 shared_contexts_main_thread_ = NULL; | 506 shared_contexts_main_thread_ = NULL; |
503 | 507 |
504 scoped_ptr<GLHelper> old_helper(gl_helper_.release()); | 508 scoped_ptr<GLHelper> old_helper(gl_helper_.release()); |
505 | 509 |
506 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, | 510 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, |
507 observer_list_, | 511 observer_list_, |
508 OnLostResources()); | 512 OnLostResources()); |
509 } | 513 } |
510 | 514 |
511 } // namespace content | 515 } // namespace content |
OLD | NEW |