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.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/common/content_client.h" | 17 #include "content/public/common/content_client.h" |
18 #include "ipc/ipc_forwarding_message_filter.h" | 18 #include "ipc/ipc_forwarding_message_filter.h" |
19 | 19 |
20 namespace content { | 20 namespace content { |
21 | 21 |
22 BrowserGpuChannelHostFactory* BrowserGpuChannelHostFactory::instance_ = NULL; | 22 BrowserGpuChannelHostFactory* BrowserGpuChannelHostFactory::instance_ = NULL; |
23 | 23 |
24 BrowserGpuChannelHostFactory::CreateRequest::CreateRequest() | 24 BrowserGpuChannelHostFactory::CreateRequest::CreateRequest() |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 unsigned internalformat) { | 374 unsigned internalformat) { |
375 if (!GpuMemoryBufferImpl::IsFormatValid(internalformat)) | 375 if (!GpuMemoryBufferImpl::IsFormatValid(internalformat)) |
376 return scoped_ptr<gfx::GpuMemoryBuffer>(); | 376 return scoped_ptr<gfx::GpuMemoryBuffer>(); |
377 | 377 |
378 size_t size = width * height * | 378 size_t size = width * height * |
379 GpuMemoryBufferImpl::BytesPerPixel(internalformat); | 379 GpuMemoryBufferImpl::BytesPerPixel(internalformat); |
380 scoped_ptr<base::SharedMemory> shm(new base::SharedMemory()); | 380 scoped_ptr<base::SharedMemory> shm(new base::SharedMemory()); |
381 if (!shm->CreateAnonymous(size)) | 381 if (!shm->CreateAnonymous(size)) |
382 return scoped_ptr<gfx::GpuMemoryBuffer>(); | 382 return scoped_ptr<gfx::GpuMemoryBuffer>(); |
383 | 383 |
384 return make_scoped_ptr<gfx::GpuMemoryBuffer>( | 384 scoped_ptr<GpuMemoryBufferImplShm> buffer( |
385 new GpuMemoryBufferImpl(shm.Pass(), | 385 new GpuMemoryBufferImplShm(gfx::Size(width, height), internalformat)); |
386 width, | 386 if (!buffer->InitializeFromSharedMemory(shm.Pass())) |
387 height, | 387 return scoped_ptr<gfx::GpuMemoryBuffer>(); |
388 internalformat)); | 388 |
| 389 return buffer.PassAs<gfx::GpuMemoryBuffer>(); |
389 } | 390 } |
390 | 391 |
391 // static | 392 // static |
392 void BrowserGpuChannelHostFactory::AddFilterOnIO( | 393 void BrowserGpuChannelHostFactory::AddFilterOnIO( |
393 int host_id, | 394 int host_id, |
394 scoped_refptr<IPC::ChannelProxy::MessageFilter> filter) { | 395 scoped_refptr<IPC::ChannelProxy::MessageFilter> filter) { |
395 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 396 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
396 | 397 |
397 GpuProcessHost* host = GpuProcessHost::FromID(host_id); | 398 GpuProcessHost* host = GpuProcessHost::FromID(host_id); |
398 if (host) | 399 if (host) |
(...skipping 17 matching lines...) Expand all Loading... |
416 filter->AddRoute(MSG_ROUTING_CONTROL, handler); | 417 filter->AddRoute(MSG_ROUTING_CONTROL, handler); |
417 | 418 |
418 GetIOLoopProxy()->PostTask( | 419 GetIOLoopProxy()->PostTask( |
419 FROM_HERE, | 420 FROM_HERE, |
420 base::Bind(&BrowserGpuChannelHostFactory::AddFilterOnIO, | 421 base::Bind(&BrowserGpuChannelHostFactory::AddFilterOnIO, |
421 gpu_host_id_, | 422 gpu_host_id_, |
422 filter)); | 423 filter)); |
423 } | 424 } |
424 | 425 |
425 } // namespace content | 426 } // namespace content |
OLD | NEW |