| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_memory_buffer_manager.h" | 5 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
| 6 | 6 |
| 7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 GpuMemoryBufferFactory::GetSupportedTypes(&supported_types); | 80 GpuMemoryBufferFactory::GetSupportedTypes(&supported_types); |
| 81 DCHECK(!supported_types.empty()); | 81 DCHECK(!supported_types.empty()); |
| 82 | 82 |
| 83 // The GPU service will always use the preferred type. | 83 // The GPU service will always use the preferred type. |
| 84 return supported_types[0]; | 84 return supported_types[0]; |
| 85 } | 85 } |
| 86 | 86 |
| 87 std::vector<GpuMemoryBufferFactory::Configuration> | 87 std::vector<GpuMemoryBufferFactory::Configuration> |
| 88 GetSupportedGpuMemoryBufferConfigurations(gfx::GpuMemoryBufferType type) { | 88 GetSupportedGpuMemoryBufferConfigurations(gfx::GpuMemoryBufferType type) { |
| 89 std::vector<GpuMemoryBufferFactory::Configuration> configurations; | 89 std::vector<GpuMemoryBufferFactory::Configuration> configurations; |
| 90 #if defined(OS_MACOSX) | 90 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 91 bool enable_native_gpu_memory_buffers = | 91 switches::kEnableNativeGpuMemoryBuffers)) { |
| 92 !base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 93 switches::kDisableNativeGpuMemoryBuffers); | |
| 94 #else | |
| 95 bool enable_native_gpu_memory_buffers = | |
| 96 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 97 switches::kEnableNativeGpuMemoryBuffers); | |
| 98 #endif | |
| 99 if (enable_native_gpu_memory_buffers) { | |
| 100 const GpuMemoryBufferFactory::Configuration kNativeConfigurations[] = { | 92 const GpuMemoryBufferFactory::Configuration kNativeConfigurations[] = { |
| 101 {gfx::GpuMemoryBuffer::R_8, gfx::GpuMemoryBuffer::MAP}, | 93 {gfx::GpuMemoryBuffer::R_8, gfx::GpuMemoryBuffer::MAP}, |
| 102 {gfx::GpuMemoryBuffer::R_8, gfx::GpuMemoryBuffer::PERSISTENT_MAP}, | 94 {gfx::GpuMemoryBuffer::R_8, gfx::GpuMemoryBuffer::PERSISTENT_MAP}, |
| 103 {gfx::GpuMemoryBuffer::RGBA_4444, gfx::GpuMemoryBuffer::MAP}, | 95 {gfx::GpuMemoryBuffer::RGBA_4444, gfx::GpuMemoryBuffer::MAP}, |
| 104 {gfx::GpuMemoryBuffer::RGBA_4444, gfx::GpuMemoryBuffer::PERSISTENT_MAP}, | 96 {gfx::GpuMemoryBuffer::RGBA_4444, gfx::GpuMemoryBuffer::PERSISTENT_MAP}, |
| 105 {gfx::GpuMemoryBuffer::RGBA_8888, gfx::GpuMemoryBuffer::MAP}, | 97 {gfx::GpuMemoryBuffer::RGBA_8888, gfx::GpuMemoryBuffer::MAP}, |
| 106 {gfx::GpuMemoryBuffer::RGBA_8888, gfx::GpuMemoryBuffer::PERSISTENT_MAP}, | 98 {gfx::GpuMemoryBuffer::RGBA_8888, gfx::GpuMemoryBuffer::PERSISTENT_MAP}, |
| 107 {gfx::GpuMemoryBuffer::BGRA_8888, gfx::GpuMemoryBuffer::MAP}, | 99 {gfx::GpuMemoryBuffer::BGRA_8888, gfx::GpuMemoryBuffer::MAP}, |
| 108 {gfx::GpuMemoryBuffer::BGRA_8888, | 100 {gfx::GpuMemoryBuffer::BGRA_8888, |
| 109 gfx::GpuMemoryBuffer::PERSISTENT_MAP}}; | 101 gfx::GpuMemoryBuffer::PERSISTENT_MAP}}; |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 } | 560 } |
| 569 | 561 |
| 570 GpuProcessHost* host = GpuProcessHost::FromID(buffer_it->second.gpu_host_id); | 562 GpuProcessHost* host = GpuProcessHost::FromID(buffer_it->second.gpu_host_id); |
| 571 if (host) | 563 if (host) |
| 572 host->DestroyGpuMemoryBuffer(id, client_id, sync_point); | 564 host->DestroyGpuMemoryBuffer(id, client_id, sync_point); |
| 573 | 565 |
| 574 buffers.erase(buffer_it); | 566 buffers.erase(buffer_it); |
| 575 } | 567 } |
| 576 | 568 |
| 577 } // namespace content | 569 } // namespace content |
| OLD | NEW |