| 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 65edde33f1259e49fb1c0fde177646b3f2d3ddff..972ffa65e3a5ae1d7a89d147ac2ff575c32320a4 100644
|
| --- a/content/common/gpu/client/gpu_memory_buffer_impl.cc
|
| +++ b/content/common/gpu/client/gpu_memory_buffer_impl.cc
|
| @@ -4,9 +4,28 @@
|
|
|
| #include "content/common/gpu/client/gpu_memory_buffer_impl.h"
|
|
|
| +#include "base/lazy_instance.h"
|
| +#include "base/logging.h"
|
| #include "ui/gl/gl_bindings.h"
|
|
|
| namespace content {
|
| +namespace {
|
| +
|
| +gfx::GpuMemoryBufferType g_preferred_type = gfx::EMPTY_BUFFER;
|
| +
|
| +struct DefaultPreferredType {
|
| + DefaultPreferredType() : value(gfx::EMPTY_BUFFER) {
|
| + std::vector<gfx::GpuMemoryBufferType> supported_types;
|
| + GpuMemoryBufferImpl::GetSupportedTypes(&supported_types);
|
| + DCHECK(!supported_types.empty());
|
| + value = supported_types[0];
|
| + }
|
| + gfx::GpuMemoryBufferType value;
|
| +};
|
| +base::LazyInstance<DefaultPreferredType> g_default_preferred_type =
|
| + LAZY_INSTANCE_INITIALIZER;
|
| +
|
| +} // namespace
|
|
|
| GpuMemoryBufferImpl::GpuMemoryBufferImpl(gfx::GpuMemoryBufferId id,
|
| const gfx::Size& size,
|
| @@ -25,6 +44,26 @@ GpuMemoryBufferImpl::~GpuMemoryBufferImpl() {
|
| }
|
|
|
| // 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);
|
| +
|
| + // Make sure this function is only called once before the first call
|
| + // to GetPreferredType().
|
| + DCHECK_EQ(gfx::EMPTY_BUFFER, g_preferred_type);
|
| +
|
| + g_preferred_type = type;
|
| +}
|
| +
|
| +// static
|
| +gfx::GpuMemoryBufferType GpuMemoryBufferImpl::GetPreferredType() {
|
| + if (g_preferred_type == gfx::EMPTY_BUFFER)
|
| + g_preferred_type = g_default_preferred_type.Get().value;
|
| +
|
| + return g_preferred_type;
|
| +}
|
| +
|
| +// static
|
| GpuMemoryBufferImpl* GpuMemoryBufferImpl::FromClientBuffer(
|
| ClientBuffer buffer) {
|
| return reinterpret_cast<GpuMemoryBufferImpl*>(buffer);
|
|
|