Chromium Code Reviews| Index: gpu/command_buffer/client/gl_in_process_context.cc |
| diff --git a/gpu/command_buffer/client/gl_in_process_context.cc b/gpu/command_buffer/client/gl_in_process_context.cc |
| index 52e8d22b27bc8e261e6e17da1531858c84f19420..63fad1cfd241bc8e4d63e314a713fa719fa8df8d 100644 |
| --- a/gpu/command_buffer/client/gl_in_process_context.cc |
| +++ b/gpu/command_buffer/client/gl_in_process_context.cc |
| @@ -25,6 +25,7 @@ |
| #include "base/synchronization/lock.h" |
| #include "gpu/command_buffer/client/gles2_implementation.h" |
| #include "gpu/command_buffer/client/gpu_memory_buffer.h" |
| +#include "gpu/command_buffer/client/gpu_memory_buffer_factory.h" |
| #include "gpu/command_buffer/client/image_factory.h" |
| #include "gpu/command_buffer/client/transfer_buffer.h" |
| #include "gpu/command_buffer/common/constants.h" |
| @@ -70,8 +71,7 @@ static base::LazyInstance< |
| static bool g_use_virtualized_gl_context = false; |
| -static GLInProcessContext::GpuMemoryBufferCreator* g_gpu_memory_buffer_creator = |
| - NULL; |
| +static GpuMemoryBufferFactory* g_gpu_memory_buffer_factory = NULL; |
| // Also calls DetachFromThreadHack on all GLES2Decoders before the lock is |
| // released to maintain the invariant that all decoders are unbound while the |
| @@ -180,14 +180,12 @@ scoped_ptr<GpuMemoryBuffer> GLInProcessContextImpl::CreateGpuMemoryBuffer( |
| // shared IdManager. |
| AutoLockAndDecoderDetachThread lock(g_decoder_lock.Get(), |
| g_all_shared_contexts.Get()); |
| - // For Android WebView we assume the |internalformat| will always be |
| - // GL_RGBA8_OES. |
| - DCHECK_EQ(static_cast<GLenum>(GL_RGBA8_OES), internalformat); |
| - scoped_ptr<GpuMemoryBuffer> buffer = |
| - g_gpu_memory_buffer_creator(width, height); |
| - |
| - if (buffer.get() == NULL) |
| - return buffer.Pass(); |
| + scoped_ptr<GpuMemoryBuffer> buffer( |
| + g_gpu_memory_buffer_factory->CreateGpuMemoryBuffer(width, |
| + height, |
| + internalformat)); |
| + if (!buffer) |
| + return scoped_ptr<GpuMemoryBuffer>(); |
| scoped_refptr<gfx::GLImage> gl_image = |
| gfx::GLImage::CreateGLImageForGpuMemoryBuffer(buffer->GetNativeBuffer(), |
| @@ -594,9 +592,16 @@ GLInProcessContext* GLInProcessContext::CreateContext( |
| } |
| // static |
| -void GLInProcessContext::SetGpuMemoryBufferCreator( |
| - GpuMemoryBufferCreator* creator) { |
| - g_gpu_memory_buffer_creator = creator; |
| +void GLInProcessContext::SetGpuMemoryBufferFactory( |
| + GpuMemoryBufferFactory* factory) { |
| +#if !defined(NDEBUG) |
|
kaanb
2013/07/26 05:59:13
isn't it possible to replace this with a function?
reveman
2013/07/26 15:40:57
I don't think there's a good reason to avoid this
|
| + { |
| + AutoLockAndDecoderDetachThread lock(g_decoder_lock.Get(), |
| + g_all_shared_contexts.Get()); |
| + DCHECK(g_all_shared_contexts.Get().empty()); |
| + } |
| +#endif // !defined(NDEBUG) |
| + g_gpu_memory_buffer_factory = factory; |
| } |
| // static |