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