Chromium Code Reviews| Index: content/common/gpu/client/gpu_memory_buffer_impl.cc |
| diff --git a/content/common/gpu/client/gpu_memory_buffer_impl.cc b/content/common/gpu/client/gpu_memory_buffer_impl.cc |
| index 972ffa65e3a5ae1d7a89d147ac2ff575c32320a4..48f35a8e9728b562d0b75abd6c533b91d7b1743d 100644 |
| --- a/content/common/gpu/client/gpu_memory_buffer_impl.cc |
| +++ b/content/common/gpu/client/gpu_memory_buffer_impl.cc |
| @@ -11,6 +11,16 @@ |
| namespace content { |
| namespace { |
| +const struct TypeNamePair { |
| + gfx::GpuMemoryBufferType type; |
| + const char* name; |
| +} kTypeNamePairs[] = { |
| + { gfx::SHARED_MEMORY_BUFFER, "shmem" }, |
| + { gfx::IO_SURFACE_BUFFER, "iosurface" }, |
| + { gfx::SURFACE_TEXTURE_BUFFER, "surfacetexture" }, |
| + { gfx::OZONE_NATIVE_BUFFER, "ozone" } |
| +}; |
| + |
| gfx::GpuMemoryBufferType g_preferred_type = gfx::EMPTY_BUFFER; |
| struct DefaultPreferredType { |
| @@ -44,6 +54,27 @@ GpuMemoryBufferImpl::~GpuMemoryBufferImpl() { |
| } |
| // static |
| +gfx::GpuMemoryBufferType GpuMemoryBufferImpl::GetNamedType( |
| + const std::string& name) { |
| + for (size_t i = 0; i < arraysize(kTypeNamePairs); ++i) { |
|
piman
2014/11/19 02:39:40
nit: range for?
|
| + if (name == kTypeNamePairs[i].name) |
| + return kTypeNamePairs[i].type; |
| + } |
| + |
| + return gfx::EMPTY_BUFFER; |
| +} |
| + |
| +// static |
| +const char* GpuMemoryBufferImpl::GetTypeName(gfx::GpuMemoryBufferType type) { |
| + for (size_t i = 0; i < arraysize(kTypeNamePairs); ++i) { |
|
piman
2014/11/19 02:39:40
nit: range for?
|
| + if (type == kTypeNamePairs[i].type) |
| + return kTypeNamePairs[i].name; |
| + } |
| + |
| + return "unknown"; |
| +} |
| + |
| +// static |
| void GpuMemoryBufferImpl::SetPreferredType(gfx::GpuMemoryBufferType type) { |
| // EMPTY_BUFFER is a reserved value and not a valid preferred type. |
| DCHECK_NE(gfx::EMPTY_BUFFER, type); |