| 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 #endif |
| 24 |
| 21 namespace content { | 25 namespace content { |
| 22 | 26 |
| 23 BrowserGpuChannelHostFactory* BrowserGpuChannelHostFactory::instance_ = NULL; | 27 BrowserGpuChannelHostFactory* BrowserGpuChannelHostFactory::instance_ = NULL; |
| 24 | 28 |
| 25 BrowserGpuChannelHostFactory::CreateRequest::CreateRequest() | 29 BrowserGpuChannelHostFactory::CreateRequest::CreateRequest() |
| 26 : event(true, false), | 30 : event(true, false), |
| 27 gpu_host_id(0), | 31 gpu_host_id(0), |
| 28 route_id(MSG_ROUTING_NONE) { | 32 route_id(MSG_ROUTING_NONE) { |
| 29 } | 33 } |
| 30 | 34 |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 } | 376 } |
| 373 | 377 |
| 374 scoped_ptr<gfx::GpuMemoryBuffer> | 378 scoped_ptr<gfx::GpuMemoryBuffer> |
| 375 BrowserGpuChannelHostFactory::AllocateGpuMemoryBuffer( | 379 BrowserGpuChannelHostFactory::AllocateGpuMemoryBuffer( |
| 376 size_t width, | 380 size_t width, |
| 377 size_t height, | 381 size_t height, |
| 378 unsigned internalformat) { | 382 unsigned internalformat) { |
| 379 if (!GpuMemoryBufferImpl::IsFormatValid(internalformat)) | 383 if (!GpuMemoryBufferImpl::IsFormatValid(internalformat)) |
| 380 return scoped_ptr<gfx::GpuMemoryBuffer>(); | 384 return scoped_ptr<gfx::GpuMemoryBuffer>(); |
| 381 | 385 |
| 386 #if defined(OS_LINUX) |
| 387 if (!GpuMemoryBufferImplIntelDRM::IsFormatSupported(internalformat)) { |
| 388 drm_intel_bo* buffer_object = |
| 389 GpuMemoryBufferImplIntelDRM::CreateBufferObject( |
| 390 gfx::Size(width, height), internalformat); |
| 391 if (buffer_object) { |
| 392 scoped_ptr<GpuMemoryBufferImplIntelDRM> buffer( |
| 393 new GpuMemoryBufferImplIntelDRM(gfx::Size(width, height), |
| 394 internalformat)); |
| 395 if (!buffer->InitializeFromBufferObject(buffer_object)) |
| 396 return buffer.PassAs<gfx::GpuMemoryBuffer>(); |
| 397 } |
| 398 } |
| 399 #endif |
| 400 |
| 382 size_t size = width * height * | 401 size_t size = width * height * |
| 383 GpuMemoryBufferImpl::BytesPerPixel(internalformat); | 402 GpuMemoryBufferImpl::BytesPerPixel(internalformat); |
| 384 scoped_ptr<base::SharedMemory> shm(new base::SharedMemory()); | 403 scoped_ptr<base::SharedMemory> shm(new base::SharedMemory()); |
| 385 if (!shm->CreateAnonymous(size)) | 404 if (!shm->CreateAnonymous(size)) |
| 386 return scoped_ptr<gfx::GpuMemoryBuffer>(); | 405 return scoped_ptr<gfx::GpuMemoryBuffer>(); |
| 387 | 406 |
| 388 scoped_ptr<GpuMemoryBufferImplShm> buffer( | 407 scoped_ptr<GpuMemoryBufferImplShm> buffer( |
| 389 new GpuMemoryBufferImplShm(gfx::Size(width, height), internalformat)); | 408 new GpuMemoryBufferImplShm(gfx::Size(width, height), internalformat)); |
| 390 if (!buffer->InitializeFromSharedMemory(shm.Pass())) | 409 if (!buffer->InitializeFromSharedMemory(shm.Pass())) |
| 391 return scoped_ptr<gfx::GpuMemoryBuffer>(); | 410 return scoped_ptr<gfx::GpuMemoryBuffer>(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 421 filter->AddRoute(MSG_ROUTING_CONTROL, handler); | 440 filter->AddRoute(MSG_ROUTING_CONTROL, handler); |
| 422 | 441 |
| 423 GetIOLoopProxy()->PostTask( | 442 GetIOLoopProxy()->PostTask( |
| 424 FROM_HERE, | 443 FROM_HERE, |
| 425 base::Bind(&BrowserGpuChannelHostFactory::AddFilterOnIO, | 444 base::Bind(&BrowserGpuChannelHostFactory::AddFilterOnIO, |
| 426 gpu_host_id_, | 445 gpu_host_id_, |
| 427 filter)); | 446 filter)); |
| 428 } | 447 } |
| 429 | 448 |
| 430 } // namespace content | 449 } // namespace content |
| OLD | NEW |