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 <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/profiler/scoped_tracker.h" | 10 #include "base/profiler/scoped_tracker.h" |
11 #include "base/synchronization/waitable_event.h" | 11 #include "base/synchronization/waitable_event.h" |
12 #include "base/threading/thread_restrictions.h" | 12 #include "base/threading/thread_restrictions.h" |
13 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
14 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | 14 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
15 #include "content/browser/gpu/gpu_data_manager_impl.h" | 15 #include "content/browser/gpu/gpu_data_manager_impl.h" |
16 #include "content/browser/gpu/gpu_process_host.h" | 16 #include "content/browser/gpu/gpu_process_host.h" |
17 #include "content/browser/gpu/gpu_surface_tracker.h" | 17 #include "content/browser/gpu/gpu_surface_tracker.h" |
18 #include "content/common/child_process_host_impl.h" | 18 #include "content/common/child_process_host_impl.h" |
19 #include "content/common/gpu/gpu_memory_buffer_factory.h" | 19 #include "content/common/gpu/gpu_memory_buffer_factory.h" |
20 #include "content/common/gpu/gpu_messages.h" | 20 #include "content/common/gpu/gpu_messages.h" |
21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
22 #include "content/public/browser/gpu_data_manager.h" | 22 #include "content/public/browser/gpu_data_manager.h" |
23 #include "content/public/common/content_client.h" | 23 #include "content/public/common/content_client.h" |
| 24 #include "gpu/GLES2/gl2extchromium.h" |
24 #include "ipc/ipc_channel_handle.h" | 25 #include "ipc/ipc_channel_handle.h" |
25 #include "ipc/ipc_forwarding_message_filter.h" | 26 #include "ipc/ipc_forwarding_message_filter.h" |
26 #include "ipc/message_filter.h" | 27 #include "ipc/message_filter.h" |
27 | 28 |
28 #if defined(OS_MACOSX) | 29 #if defined(OS_MACOSX) |
29 #include "content/common/gpu/gpu_memory_buffer_factory_io_surface.h" | 30 #include "content/common/gpu/gpu_memory_buffer_factory_io_surface.h" |
30 #endif | 31 #endif |
31 | 32 |
32 #if defined(OS_ANDROID) | 33 #if defined(OS_ANDROID) |
33 #include "content/common/gpu/gpu_memory_buffer_factory_surface_texture.h" | 34 #include "content/common/gpu/gpu_memory_buffer_factory_surface_texture.h" |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 gfx::GpuMemoryBuffer::Usage usage) { | 241 gfx::GpuMemoryBuffer::Usage usage) { |
241 g_enabled_gpu_memory_buffer_usages.Get().insert(usage); | 242 g_enabled_gpu_memory_buffer_usages.Get().insert(usage); |
242 } | 243 } |
243 | 244 |
244 // static | 245 // static |
245 bool BrowserGpuChannelHostFactory::IsGpuMemoryBufferFactoryUsageEnabled( | 246 bool BrowserGpuChannelHostFactory::IsGpuMemoryBufferFactoryUsageEnabled( |
246 gfx::GpuMemoryBuffer::Usage usage) { | 247 gfx::GpuMemoryBuffer::Usage usage) { |
247 return g_enabled_gpu_memory_buffer_usages.Get().count(usage) != 0; | 248 return g_enabled_gpu_memory_buffer_usages.Get().count(usage) != 0; |
248 } | 249 } |
249 | 250 |
| 251 // static |
| 252 uint32 BrowserGpuChannelHostFactory::GetImageTextureTarget() { |
| 253 if (!IsGpuMemoryBufferFactoryUsageEnabled(gfx::GpuMemoryBuffer::MAP)) |
| 254 return GL_TEXTURE_2D; |
| 255 |
| 256 std::vector<gfx::GpuMemoryBufferType> supported_types; |
| 257 GpuMemoryBufferFactory::GetSupportedTypes(&supported_types); |
| 258 DCHECK(!supported_types.empty()); |
| 259 |
| 260 // The GPU service will always use the preferred type. |
| 261 gfx::GpuMemoryBufferType type = supported_types[0]; |
| 262 |
| 263 switch (type) { |
| 264 case gfx::SURFACE_TEXTURE_BUFFER: |
| 265 // Surface texture backed GPU memory buffers require |
| 266 // TEXTURE_EXTERNAL_OES. |
| 267 return GL_TEXTURE_EXTERNAL_OES; |
| 268 case gfx::IO_SURFACE_BUFFER: |
| 269 // IOSurface backed images require GL_TEXTURE_RECTANGLE_ARB. |
| 270 return GL_TEXTURE_RECTANGLE_ARB; |
| 271 default: |
| 272 return GL_TEXTURE_2D; |
| 273 } |
| 274 } |
| 275 |
250 BrowserGpuChannelHostFactory::BrowserGpuChannelHostFactory() | 276 BrowserGpuChannelHostFactory::BrowserGpuChannelHostFactory() |
251 : gpu_client_id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), | 277 : gpu_client_id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), |
252 shutdown_event_(new base::WaitableEvent(true, false)), | 278 shutdown_event_(new base::WaitableEvent(true, false)), |
253 gpu_memory_buffer_manager_( | 279 gpu_memory_buffer_manager_( |
254 new BrowserGpuMemoryBufferManager(this, gpu_client_id_)), | 280 new BrowserGpuMemoryBufferManager(this, gpu_client_id_)), |
255 gpu_host_id_(0), | 281 gpu_host_id_(0), |
256 next_create_gpu_memory_buffer_request_id_(0) { | 282 next_create_gpu_memory_buffer_request_id_(0) { |
257 } | 283 } |
258 | 284 |
259 BrowserGpuChannelHostFactory::~BrowserGpuChannelHostFactory() { | 285 BrowserGpuChannelHostFactory::~BrowserGpuChannelHostFactory() { |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 542 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
517 | 543 |
518 CreateGpuMemoryBufferCallbackMap::iterator iter = | 544 CreateGpuMemoryBufferCallbackMap::iterator iter = |
519 create_gpu_memory_buffer_requests_.find(request_id); | 545 create_gpu_memory_buffer_requests_.find(request_id); |
520 DCHECK(iter != create_gpu_memory_buffer_requests_.end()); | 546 DCHECK(iter != create_gpu_memory_buffer_requests_.end()); |
521 iter->second.Run(handle); | 547 iter->second.Run(handle); |
522 create_gpu_memory_buffer_requests_.erase(iter); | 548 create_gpu_memory_buffer_requests_.erase(iter); |
523 } | 549 } |
524 | 550 |
525 } // namespace content | 551 } // namespace content |
OLD | NEW |