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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> | 421 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> |
422 GpuProcessTransportFactory::CreateContextCommon(int surface_id) { | 422 GpuProcessTransportFactory::CreateContextCommon(int surface_id) { |
423 if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) | 423 if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) |
424 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); | 424 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); |
425 blink::WebGraphicsContext3D::Attributes attrs; | 425 blink::WebGraphicsContext3D::Attributes attrs; |
426 attrs.shareResources = true; | 426 attrs.shareResources = true; |
427 attrs.depth = false; | 427 attrs.depth = false; |
428 attrs.stencil = false; | 428 attrs.stencil = false; |
429 attrs.antialias = false; | 429 attrs.antialias = false; |
430 attrs.noAutomaticFlushes = true; | 430 attrs.noAutomaticFlushes = true; |
431 bool bind_generates_resources = false; | |
432 bool lose_context_when_out_of_memory = true; | |
433 CauseForGpuLaunch cause = | 431 CauseForGpuLaunch cause = |
434 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; | 432 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; |
435 scoped_refptr<GpuChannelHost> gpu_channel_host( | 433 scoped_refptr<GpuChannelHost> gpu_channel_host( |
436 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync(cause)); | 434 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync(cause)); |
437 if (!gpu_channel_host) { | 435 if (!gpu_channel_host) { |
438 LOG(ERROR) << "Failed to establish GPU channel."; | 436 LOG(ERROR) << "Failed to establish GPU channel."; |
439 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); | 437 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); |
440 } | 438 } |
441 GURL url("chrome://gpu/GpuProcessTransportFactory::CreateContextCommon"); | 439 GURL url("chrome://gpu/GpuProcessTransportFactory::CreateContextCommon"); |
442 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( | 440 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( |
443 new WebGraphicsContext3DCommandBufferImpl( | 441 new WebGraphicsContext3DCommandBufferImpl( |
444 surface_id, | 442 surface_id, |
445 url, | 443 url, |
446 gpu_channel_host.get(), | 444 gpu_channel_host.get(), |
447 attrs, | 445 attrs, |
448 bind_generates_resources, | 446 false, |
449 lose_context_when_out_of_memory, | |
450 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), | 447 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), |
451 NULL)); | 448 NULL)); |
452 return context.Pass(); | 449 return context.Pass(); |
453 } | 450 } |
454 | 451 |
455 void GpuProcessTransportFactory::OnLostMainThreadSharedContextInsideCallback() { | 452 void GpuProcessTransportFactory::OnLostMainThreadSharedContextInsideCallback() { |
456 base::MessageLoop::current()->PostTask( | 453 base::MessageLoop::current()->PostTask( |
457 FROM_HERE, | 454 FROM_HERE, |
458 base::Bind(&GpuProcessTransportFactory::OnLostMainThreadSharedContext, | 455 base::Bind(&GpuProcessTransportFactory::OnLostMainThreadSharedContext, |
459 callback_factory_.GetWeakPtr())); | 456 callback_factory_.GetWeakPtr())); |
(...skipping 19 matching lines...) Expand all Loading... |
479 observer_list_, | 476 observer_list_, |
480 OnLostResources()); | 477 OnLostResources()); |
481 | 478 |
482 // Kill things that use the shared context before killing the shared context. | 479 // Kill things that use the shared context before killing the shared context. |
483 lost_gl_helper.reset(); | 480 lost_gl_helper.reset(); |
484 lost_offscreen_compositor_contexts = NULL; | 481 lost_offscreen_compositor_contexts = NULL; |
485 lost_shared_main_thread_contexts = NULL; | 482 lost_shared_main_thread_contexts = NULL; |
486 } | 483 } |
487 | 484 |
488 } // namespace content | 485 } // namespace content |
OLD | NEW |