Chromium Code Reviews| 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" |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 g_enabled_gpu_memory_buffer_usages.Get().insert(usage); | 247 g_enabled_gpu_memory_buffer_usages.Get().insert(usage); |
| 248 } | 248 } |
| 249 | 249 |
| 250 // static | 250 // static |
| 251 bool BrowserGpuChannelHostFactory::IsGpuMemoryBufferFactoryUsageEnabled( | 251 bool BrowserGpuChannelHostFactory::IsGpuMemoryBufferFactoryUsageEnabled( |
| 252 gfx::GpuMemoryBuffer::Usage usage) { | 252 gfx::GpuMemoryBuffer::Usage usage) { |
| 253 return g_enabled_gpu_memory_buffer_usages.Get().count(usage) != 0; | 253 return g_enabled_gpu_memory_buffer_usages.Get().count(usage) != 0; |
| 254 } | 254 } |
| 255 | 255 |
| 256 // static | 256 // static |
| 257 uint32 BrowserGpuChannelHostFactory::GetImageTextureTarget() { | 257 uint32 BrowserGpuChannelHostFactory::GetImageTextureTarget( |
| 258 if (!IsGpuMemoryBufferFactoryUsageEnabled(gfx::GpuMemoryBuffer::MAP)) | 258 gfx::GpuMemoryBuffer::Usage usage) { |
| 259 if (!IsGpuMemoryBufferFactoryUsageEnabled(usage)) | |
| 259 return GL_TEXTURE_2D; | 260 return GL_TEXTURE_2D; |
| 260 | 261 |
| 261 std::vector<gfx::GpuMemoryBufferType> supported_types; | 262 std::vector<gfx::GpuMemoryBufferType> supported_types; |
| 262 GpuMemoryBufferFactory::GetSupportedTypes(&supported_types); | 263 GpuMemoryBufferFactory::GetSupportedTypes(usage, &supported_types); |
|
reveman
2015/05/19 16:12:12
Instead of changing GetSupportedTypes (which might
danakj
2015/05/19 20:11:52
I don't understand this request :(
IsGpuMemoryBuf
danakj
2015/05/19 22:19:43
OK thanks for the discussion about this! I've pass
| |
| 263 DCHECK(!supported_types.empty()); | 264 DCHECK(!supported_types.empty()); |
| 264 | 265 |
| 265 // The GPU service will always use the preferred type. | 266 // The GPU service will always use the preferred type. |
| 266 gfx::GpuMemoryBufferType type = supported_types[0]; | 267 gfx::GpuMemoryBufferType type = supported_types[0]; |
| 267 | 268 |
| 268 switch (type) { | 269 switch (type) { |
| 269 case gfx::SURFACE_TEXTURE_BUFFER: | 270 case gfx::SURFACE_TEXTURE_BUFFER: |
| 270 case gfx::OZONE_NATIVE_BUFFER: | 271 case gfx::OZONE_NATIVE_BUFFER: |
| 271 // GPU memory buffers that are shared with the GL using EGLImages require | 272 // GPU memory buffers that are shared with the GL using EGLImages require |
| 272 // TEXTURE_EXTERNAL_OES. | 273 // TEXTURE_EXTERNAL_OES. |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 466 | 467 |
| 467 bool BrowserGpuChannelHostFactory::IsGpuMemoryBufferConfigurationSupported( | 468 bool BrowserGpuChannelHostFactory::IsGpuMemoryBufferConfigurationSupported( |
| 468 gfx::GpuMemoryBuffer::Format format, | 469 gfx::GpuMemoryBuffer::Format format, |
| 469 gfx::GpuMemoryBuffer::Usage usage) { | 470 gfx::GpuMemoryBuffer::Usage usage) { |
| 470 // Return early if usage is not enabled. | 471 // Return early if usage is not enabled. |
| 471 if (!IsGpuMemoryBufferFactoryUsageEnabled(usage)) | 472 if (!IsGpuMemoryBufferFactoryUsageEnabled(usage)) |
| 472 return false; | 473 return false; |
| 473 | 474 |
| 474 // Preferred type is always used by factory. | 475 // Preferred type is always used by factory. |
| 475 std::vector<gfx::GpuMemoryBufferType> supported_types; | 476 std::vector<gfx::GpuMemoryBufferType> supported_types; |
| 476 GpuMemoryBufferFactory::GetSupportedTypes(&supported_types); | 477 GpuMemoryBufferFactory::GetSupportedTypes(usage, &supported_types); |
| 477 DCHECK(!supported_types.empty()); | 478 DCHECK(!supported_types.empty()); |
| 478 switch (supported_types[0]) { | 479 switch (supported_types[0]) { |
| 479 case gfx::SHARED_MEMORY_BUFFER: | 480 case gfx::SHARED_MEMORY_BUFFER: |
| 480 // Shared memory buffers must be created in-process. | 481 // Shared memory buffers must be created in-process. |
| 481 return false; | 482 return false; |
| 482 #if defined(OS_MACOSX) | 483 #if defined(OS_MACOSX) |
| 483 case gfx::IO_SURFACE_BUFFER: | 484 case gfx::IO_SURFACE_BUFFER: |
| 484 return GpuMemoryBufferFactoryIOSurface:: | 485 return GpuMemoryBufferFactoryIOSurface:: |
| 485 IsGpuMemoryBufferConfigurationSupported(format, usage); | 486 IsGpuMemoryBufferConfigurationSupported(format, usage); |
| 486 #endif | 487 #endif |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 558 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 559 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 559 | 560 |
| 560 CreateGpuMemoryBufferCallbackMap::iterator iter = | 561 CreateGpuMemoryBufferCallbackMap::iterator iter = |
| 561 create_gpu_memory_buffer_requests_.find(request_id); | 562 create_gpu_memory_buffer_requests_.find(request_id); |
| 562 DCHECK(iter != create_gpu_memory_buffer_requests_.end()); | 563 DCHECK(iter != create_gpu_memory_buffer_requests_.end()); |
| 563 iter->second.Run(handle); | 564 iter->second.Run(handle); |
| 564 create_gpu_memory_buffer_requests_.erase(iter); | 565 create_gpu_memory_buffer_requests_.erase(iter); |
| 565 } | 566 } |
| 566 | 567 |
| 567 } // namespace content | 568 } // namespace content |
| OLD | NEW |