| 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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> | 438 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> |
| 439 GpuProcessTransportFactory::CreateContextCommon(int surface_id) { | 439 GpuProcessTransportFactory::CreateContextCommon(int surface_id) { |
| 440 if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) | 440 if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) |
| 441 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); | 441 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); |
| 442 blink::WebGraphicsContext3D::Attributes attrs; | 442 blink::WebGraphicsContext3D::Attributes attrs; |
| 443 attrs.shareResources = true; | 443 attrs.shareResources = true; |
| 444 attrs.depth = false; | 444 attrs.depth = false; |
| 445 attrs.stencil = false; | 445 attrs.stencil = false; |
| 446 attrs.antialias = false; | 446 attrs.antialias = false; |
| 447 attrs.noAutomaticFlushes = true; | 447 attrs.noAutomaticFlushes = true; |
| 448 bool bind_generates_resources = false; | |
| 449 bool lose_context_when_out_of_memory = true; | 448 bool lose_context_when_out_of_memory = true; |
| 450 CauseForGpuLaunch cause = | 449 CauseForGpuLaunch cause = |
| 451 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; | 450 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; |
| 452 scoped_refptr<GpuChannelHost> gpu_channel_host( | 451 scoped_refptr<GpuChannelHost> gpu_channel_host( |
| 453 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync(cause)); | 452 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync(cause)); |
| 454 if (!gpu_channel_host) { | 453 if (!gpu_channel_host) { |
| 455 LOG(ERROR) << "Failed to establish GPU channel."; | 454 LOG(ERROR) << "Failed to establish GPU channel."; |
| 456 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); | 455 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); |
| 457 } | 456 } |
| 458 GURL url("chrome://gpu/GpuProcessTransportFactory::CreateContextCommon"); | 457 GURL url("chrome://gpu/GpuProcessTransportFactory::CreateContextCommon"); |
| 459 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( | 458 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( |
| 460 new WebGraphicsContext3DCommandBufferImpl( | 459 new WebGraphicsContext3DCommandBufferImpl( |
| 461 surface_id, | 460 surface_id, |
| 462 url, | 461 url, |
| 463 gpu_channel_host.get(), | 462 gpu_channel_host.get(), |
| 464 attrs, | 463 attrs, |
| 465 bind_generates_resources, | |
| 466 lose_context_when_out_of_memory, | 464 lose_context_when_out_of_memory, |
| 467 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), | 465 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), |
| 468 NULL)); | 466 NULL)); |
| 469 return context.Pass(); | 467 return context.Pass(); |
| 470 } | 468 } |
| 471 | 469 |
| 472 void GpuProcessTransportFactory::OnLostMainThreadSharedContextInsideCallback() { | 470 void GpuProcessTransportFactory::OnLostMainThreadSharedContextInsideCallback() { |
| 473 base::MessageLoop::current()->PostTask( | 471 base::MessageLoop::current()->PostTask( |
| 474 FROM_HERE, | 472 FROM_HERE, |
| 475 base::Bind(&GpuProcessTransportFactory::OnLostMainThreadSharedContext, | 473 base::Bind(&GpuProcessTransportFactory::OnLostMainThreadSharedContext, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 496 observer_list_, | 494 observer_list_, |
| 497 OnLostResources()); | 495 OnLostResources()); |
| 498 | 496 |
| 499 // Kill things that use the shared context before killing the shared context. | 497 // Kill things that use the shared context before killing the shared context. |
| 500 lost_gl_helper.reset(); | 498 lost_gl_helper.reset(); |
| 501 lost_offscreen_compositor_contexts = NULL; | 499 lost_offscreen_compositor_contexts = NULL; |
| 502 lost_shared_main_thread_contexts = NULL; | 500 lost_shared_main_thread_contexts = NULL; |
| 503 } | 501 } |
| 504 | 502 |
| 505 } // namespace content | 503 } // namespace content |
| OLD | NEW |