OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "content/browser/renderer_host/image_transport_factory.h" | 5 #include "content/browser/renderer_host/image_transport_factory.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 WebKit::WebGraphicsContext3D* CreateContextCommon( | 339 WebKit::WebGraphicsContext3D* CreateContextCommon( |
340 ui::Compositor* compositor, | 340 ui::Compositor* compositor, |
341 bool offscreen) { | 341 bool offscreen) { |
342 PerCompositorData* data = per_compositor_data_[compositor]; | 342 PerCompositorData* data = per_compositor_data_[compositor]; |
343 if (!data) | 343 if (!data) |
344 data = CreatePerCompositorData(compositor); | 344 data = CreatePerCompositorData(compositor); |
345 | 345 |
346 WebKit::WebGraphicsContext3D::Attributes attrs; | 346 WebKit::WebGraphicsContext3D::Attributes attrs; |
347 attrs.shareResources = true; | 347 attrs.shareResources = true; |
348 GpuChannelHostFactory* factory = BrowserGpuChannelHostFactory::instance(); | 348 GpuChannelHostFactory* factory = BrowserGpuChannelHostFactory::instance(); |
| 349 GURL url("chrome://gpu/GpuProcessTransportFactory::CreateContextCommon"); |
349 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( | 350 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( |
350 new WebGraphicsContext3DCommandBufferImpl( | 351 new WebGraphicsContext3DCommandBufferImpl( |
351 offscreen ? 0 : data->surface_id, | 352 offscreen ? 0 : data->surface_id, |
352 GURL(), | 353 url, |
353 factory, | 354 factory, |
354 data->swap_client->AsWeakPtr())); | 355 data->swap_client->AsWeakPtr())); |
355 if (!context->Initialize( | 356 if (!context->Initialize( |
356 attrs, | 357 attrs, |
357 false, | 358 false, |
358 content::CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INIT
IALIZE)) | 359 content::CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INIT
IALIZE)) |
359 return NULL; | 360 return NULL; |
360 return context.release(); | 361 return context.release(); |
361 } | 362 } |
362 | 363 |
363 void CreateSharedContext(ui::Compositor* compositor) { | 364 void CreateSharedContext(ui::Compositor* compositor) { |
364 PerCompositorData* data = per_compositor_data_[compositor]; | 365 PerCompositorData* data = per_compositor_data_[compositor]; |
365 DCHECK(data); | 366 DCHECK(data); |
366 | 367 |
367 data->swap_client.reset(new CompositorSwapClient(compositor, this)); | 368 data->swap_client.reset(new CompositorSwapClient(compositor, this)); |
368 | 369 |
369 GpuChannelHostFactory* factory = BrowserGpuChannelHostFactory::instance(); | 370 GpuChannelHostFactory* factory = BrowserGpuChannelHostFactory::instance(); |
370 WebKit::WebGraphicsContext3D::Attributes attrs; | 371 WebKit::WebGraphicsContext3D::Attributes attrs; |
371 attrs.shareResources = true; | 372 attrs.shareResources = true; |
| 373 GURL url("chrome://gpu/GpuProcessTransportFactory::CreateSharedContext"); |
372 data->shared_context.reset(new WebGraphicsContext3DCommandBufferImpl( | 374 data->shared_context.reset(new WebGraphicsContext3DCommandBufferImpl( |
373 0, | 375 0, |
374 GURL(), | 376 url, |
375 factory, | 377 factory, |
376 data->swap_client->AsWeakPtr())); | 378 data->swap_client->AsWeakPtr())); |
377 if (!data->shared_context->Initialize( | 379 if (!data->shared_context->Initialize( |
378 attrs, | 380 attrs, |
379 false, | 381 false, |
380 content::CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INIT
IALIZE)) { | 382 content::CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INIT
IALIZE)) { |
381 // If we can't recreate contexts, we won't be able to show the UI. Better | 383 // If we can't recreate contexts, we won't be able to show the UI. Better |
382 // crash at this point. | 384 // crash at this point. |
383 LOG(FATAL) << "Failed to initialize compositor shared context."; | 385 LOG(FATAL) << "Failed to initialize compositor shared context."; |
384 } | 386 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 void ImageTransportFactory::Terminate() { | 427 void ImageTransportFactory::Terminate() { |
426 ui::ContextFactory::SetInstance(NULL); | 428 ui::ContextFactory::SetInstance(NULL); |
427 delete g_factory; | 429 delete g_factory; |
428 g_factory = NULL; | 430 g_factory = NULL; |
429 } | 431 } |
430 | 432 |
431 // static | 433 // static |
432 ImageTransportFactory* ImageTransportFactory::GetInstance() { | 434 ImageTransportFactory* ImageTransportFactory::GetInstance() { |
433 return g_factory; | 435 return g_factory; |
434 } | 436 } |
OLD | NEW |