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/gpu/browser_gpu_channel_host_factory.h" | 5 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/threading/thread_restrictions.h" | 9 #include "base/threading/thread_restrictions.h" |
10 #include "content/browser/gpu/gpu_data_manager_impl.h" | 10 #include "content/browser/gpu/gpu_data_manager_impl.h" |
11 #include "content/browser/gpu/gpu_process_host.h" | 11 #include "content/browser/gpu/gpu_process_host.h" |
12 #include "content/browser/gpu/gpu_surface_tracker.h" | 12 #include "content/browser/gpu/gpu_surface_tracker.h" |
13 #include "content/common/child_process_host_impl.h" | 13 #include "content/common/child_process_host_impl.h" |
14 #include "content/common/gpu/client/gpu_memory_buffer_impl_shm.h" | 14 #include "content/common/gpu/client/gpu_memory_buffer_impl_shm.h" |
15 #include "content/common/gpu/gpu_messages.h" | 15 #include "content/common/gpu/gpu_messages.h" |
16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
17 #include "content/public/browser/gpu_data_manager.h" | 17 #include "content/public/browser/gpu_data_manager.h" |
18 #include "content/public/common/content_client.h" | 18 #include "content/public/common/content_client.h" |
19 #include "ipc/ipc_forwarding_message_filter.h" | 19 #include "ipc/ipc_forwarding_message_filter.h" |
20 | 20 |
| 21 #if defined(OS_LINUX) |
| 22 #include "content/common/gpu/client/gpu_memory_buffer_impl_intel_drm.h" |
| 23 #include "ui/gl/gl_implementation.h" |
| 24 #endif |
| 25 |
21 namespace content { | 26 namespace content { |
22 | 27 |
23 BrowserGpuChannelHostFactory* BrowserGpuChannelHostFactory::instance_ = NULL; | 28 BrowserGpuChannelHostFactory* BrowserGpuChannelHostFactory::instance_ = NULL; |
24 | 29 |
25 BrowserGpuChannelHostFactory::CreateRequest::CreateRequest() | 30 BrowserGpuChannelHostFactory::CreateRequest::CreateRequest() |
26 : event(true, false), | 31 : event(true, false), |
27 gpu_host_id(0), | 32 gpu_host_id(0), |
28 route_id(MSG_ROUTING_NONE) { | 33 route_id(MSG_ROUTING_NONE) { |
29 } | 34 } |
30 | 35 |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 } | 380 } |
376 | 381 |
377 scoped_ptr<gfx::GpuMemoryBuffer> | 382 scoped_ptr<gfx::GpuMemoryBuffer> |
378 BrowserGpuChannelHostFactory::AllocateGpuMemoryBuffer( | 383 BrowserGpuChannelHostFactory::AllocateGpuMemoryBuffer( |
379 size_t width, | 384 size_t width, |
380 size_t height, | 385 size_t height, |
381 unsigned internalformat) { | 386 unsigned internalformat) { |
382 if (!GpuMemoryBufferImpl::IsFormatValid(internalformat)) | 387 if (!GpuMemoryBufferImpl::IsFormatValid(internalformat)) |
383 return scoped_ptr<gfx::GpuMemoryBuffer>(); | 388 return scoped_ptr<gfx::GpuMemoryBuffer>(); |
384 | 389 |
| 390 #if defined(OS_LINUX) |
| 391 // Intel DRM implementation of gpu memory buffer is limited to EGLGLES2 as we |
| 392 // currently depend on EGL_EXT_image_dma_buf_import to use this type of buffer |
| 393 // on the GPU side. |
| 394 bool is_gl_implementation_supported_by_intel_drm = |
| 395 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2; |
| 396 |
| 397 if (is_gl_implementation_supported_by_intel_drm && |
| 398 GpuMemoryBufferImplIntelDRM::IsFormatSupported(internalformat)) { |
| 399 drm_intel_bo* buffer_object = |
| 400 GpuMemoryBufferImplIntelDRM::CreateBufferObject( |
| 401 gfx::Size(width, height), internalformat); |
| 402 if (buffer_object) { |
| 403 scoped_ptr<GpuMemoryBufferImplIntelDRM> buffer( |
| 404 new GpuMemoryBufferImplIntelDRM(gfx::Size(width, height), |
| 405 internalformat)); |
| 406 if (buffer->InitializeFromBufferObject(buffer_object)) |
| 407 return buffer.PassAs<gfx::GpuMemoryBuffer>(); |
| 408 } |
| 409 } |
| 410 #endif |
| 411 |
385 size_t size = width * height * | 412 size_t size = width * height * |
386 GpuMemoryBufferImpl::BytesPerPixel(internalformat); | 413 GpuMemoryBufferImpl::BytesPerPixel(internalformat); |
387 scoped_ptr<base::SharedMemory> shm(new base::SharedMemory()); | 414 scoped_ptr<base::SharedMemory> shm(new base::SharedMemory()); |
388 if (!shm->CreateAnonymous(size)) | 415 if (!shm->CreateAnonymous(size)) |
389 return scoped_ptr<gfx::GpuMemoryBuffer>(); | 416 return scoped_ptr<gfx::GpuMemoryBuffer>(); |
390 | 417 |
391 scoped_ptr<GpuMemoryBufferImplShm> buffer( | 418 scoped_ptr<GpuMemoryBufferImplShm> buffer( |
392 new GpuMemoryBufferImplShm(gfx::Size(width, height), internalformat)); | 419 new GpuMemoryBufferImplShm(gfx::Size(width, height), internalformat)); |
393 if (!buffer->InitializeFromSharedMemory(shm.Pass())) | 420 if (!buffer->InitializeFromSharedMemory(shm.Pass())) |
394 return scoped_ptr<gfx::GpuMemoryBuffer>(); | 421 return scoped_ptr<gfx::GpuMemoryBuffer>(); |
(...skipping 29 matching lines...) Expand all Loading... |
424 filter->AddRoute(MSG_ROUTING_CONTROL, handler); | 451 filter->AddRoute(MSG_ROUTING_CONTROL, handler); |
425 | 452 |
426 GetIOLoopProxy()->PostTask( | 453 GetIOLoopProxy()->PostTask( |
427 FROM_HERE, | 454 FROM_HERE, |
428 base::Bind(&BrowserGpuChannelHostFactory::AddFilterOnIO, | 455 base::Bind(&BrowserGpuChannelHostFactory::AddFilterOnIO, |
429 gpu_host_id_, | 456 gpu_host_id_, |
430 filter)); | 457 filter)); |
431 } | 458 } |
432 | 459 |
433 } // namespace content | 460 } // namespace content |
OLD | NEW |