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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( | 349 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( |
350 new WebGraphicsContext3DCommandBufferImpl( | 350 new WebGraphicsContext3DCommandBufferImpl( |
351 offscreen ? 0 : data->surface_id, | 351 offscreen ? 0 : data->surface_id, |
352 GURL(), | 352 GURL("GpuProcessTransportFactory::CreateContextCommon"), |
353 factory, | 353 factory, |
354 data->swap_client->AsWeakPtr())); | 354 data->swap_client->AsWeakPtr())); |
355 if (!context->Initialize( | 355 if (!context->Initialize( |
356 attrs, | 356 attrs, |
357 false, | 357 false, |
358 content::CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INIT
IALIZE)) | 358 content::CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INIT
IALIZE)) |
359 return NULL; | 359 return NULL; |
360 return context.release(); | 360 return context.release(); |
361 } | 361 } |
362 | 362 |
363 void CreateSharedContext(ui::Compositor* compositor) { | 363 void CreateSharedContext(ui::Compositor* compositor) { |
364 PerCompositorData* data = per_compositor_data_[compositor]; | 364 PerCompositorData* data = per_compositor_data_[compositor]; |
365 DCHECK(data); | 365 DCHECK(data); |
366 | 366 |
367 data->swap_client.reset(new CompositorSwapClient(compositor, this)); | 367 data->swap_client.reset(new CompositorSwapClient(compositor, this)); |
368 | 368 |
369 GpuChannelHostFactory* factory = BrowserGpuChannelHostFactory::instance(); | 369 GpuChannelHostFactory* factory = BrowserGpuChannelHostFactory::instance(); |
370 WebKit::WebGraphicsContext3D::Attributes attrs; | 370 WebKit::WebGraphicsContext3D::Attributes attrs; |
371 attrs.shareResources = true; | 371 attrs.shareResources = true; |
372 data->shared_context.reset(new WebGraphicsContext3DCommandBufferImpl( | 372 data->shared_context.reset(new WebGraphicsContext3DCommandBufferImpl( |
373 0, | 373 0, |
374 GURL(), | 374 GURL("GpuProcessTransportFactory::CreateSharedContext"), |
375 factory, | 375 factory, |
376 data->swap_client->AsWeakPtr())); | 376 data->swap_client->AsWeakPtr())); |
377 if (!data->shared_context->Initialize( | 377 if (!data->shared_context->Initialize( |
378 attrs, | 378 attrs, |
379 false, | 379 false, |
380 content::CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INIT
IALIZE)) { | 380 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 | 381 // If we can't recreate contexts, we won't be able to show the UI. Better |
382 // crash at this point. | 382 // crash at this point. |
383 LOG(FATAL) << "Failed to initialize compositor shared context."; | 383 LOG(FATAL) << "Failed to initialize compositor shared context."; |
384 } | 384 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 void ImageTransportFactory::Terminate() { | 425 void ImageTransportFactory::Terminate() { |
426 ui::ContextFactory::SetInstance(NULL); | 426 ui::ContextFactory::SetInstance(NULL); |
427 delete g_factory; | 427 delete g_factory; |
428 g_factory = NULL; | 428 g_factory = NULL; |
429 } | 429 } |
430 | 430 |
431 // static | 431 // static |
432 ImageTransportFactory* ImageTransportFactory::GetInstance() { | 432 ImageTransportFactory* ImageTransportFactory::GetInstance() { |
433 return g_factory; | 433 return g_factory; |
434 } | 434 } |
OLD | NEW |