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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
375 } | 379 } |
376 | 380 |
377 scoped_ptr<gfx::GpuMemoryBuffer> | 381 scoped_ptr<gfx::GpuMemoryBuffer> |
378 BrowserGpuChannelHostFactory::AllocateGpuMemoryBuffer( | 382 BrowserGpuChannelHostFactory::AllocateGpuMemoryBuffer( |
379 size_t width, | 383 size_t width, |
380 size_t height, | 384 size_t height, |
381 unsigned internalformat) { | 385 unsigned internalformat) { |
382 if (!GpuMemoryBufferImpl::IsFormatValid(internalformat)) | 386 if (!GpuMemoryBufferImpl::IsFormatValid(internalformat)) |
383 return scoped_ptr<gfx::GpuMemoryBuffer>(); | 387 return scoped_ptr<gfx::GpuMemoryBuffer>(); |
384 | 388 |
389 #if defined(OS_LINUX) | |
390 if (!GpuMemoryBufferImplIntelDRM::IsFormatSupported(internalformat)) { | |
fjhenigman
2014/04/10 16:26:01
remove the !
reveman
2014/04/10 17:48:28
Done.
| |
391 drm_intel_bo* buffer_object = | |
392 GpuMemoryBufferImplIntelDRM::CreateBufferObject( | |
393 gfx::Size(width, height), internalformat); | |
394 if (buffer_object) { | |
395 scoped_ptr<GpuMemoryBufferImplIntelDRM> buffer( | |
396 new GpuMemoryBufferImplIntelDRM(gfx::Size(width, height), | |
397 internalformat)); | |
398 if (!buffer->InitializeFromBufferObject(buffer_object)) | |
fjhenigman
2014/04/10 16:26:01
remove this ! too
reveman
2014/04/10 17:48:28
Done.
| |
399 return buffer.PassAs<gfx::GpuMemoryBuffer>(); | |
400 } | |
401 } | |
402 #endif | |
403 | |
385 size_t size = width * height * | 404 size_t size = width * height * |
386 GpuMemoryBufferImpl::BytesPerPixel(internalformat); | 405 GpuMemoryBufferImpl::BytesPerPixel(internalformat); |
387 scoped_ptr<base::SharedMemory> shm(new base::SharedMemory()); | 406 scoped_ptr<base::SharedMemory> shm(new base::SharedMemory()); |
388 if (!shm->CreateAnonymous(size)) | 407 if (!shm->CreateAnonymous(size)) |
389 return scoped_ptr<gfx::GpuMemoryBuffer>(); | 408 return scoped_ptr<gfx::GpuMemoryBuffer>(); |
390 | 409 |
391 scoped_ptr<GpuMemoryBufferImplShm> buffer( | 410 scoped_ptr<GpuMemoryBufferImplShm> buffer( |
392 new GpuMemoryBufferImplShm(gfx::Size(width, height), internalformat)); | 411 new GpuMemoryBufferImplShm(gfx::Size(width, height), internalformat)); |
393 if (!buffer->InitializeFromSharedMemory(shm.Pass())) | 412 if (!buffer->InitializeFromSharedMemory(shm.Pass())) |
394 return scoped_ptr<gfx::GpuMemoryBuffer>(); | 413 return scoped_ptr<gfx::GpuMemoryBuffer>(); |
(...skipping 29 matching lines...) Expand all Loading... | |
424 filter->AddRoute(MSG_ROUTING_CONTROL, handler); | 443 filter->AddRoute(MSG_ROUTING_CONTROL, handler); |
425 | 444 |
426 GetIOLoopProxy()->PostTask( | 445 GetIOLoopProxy()->PostTask( |
427 FROM_HERE, | 446 FROM_HERE, |
428 base::Bind(&BrowserGpuChannelHostFactory::AddFilterOnIO, | 447 base::Bind(&BrowserGpuChannelHostFactory::AddFilterOnIO, |
429 gpu_host_id_, | 448 gpu_host_id_, |
430 filter)); | 449 filter)); |
431 } | 450 } |
432 | 451 |
433 } // namespace content | 452 } // namespace content |
OLD | NEW |