Index: content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.cc |
diff --git a/content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.cc b/content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.cc |
index 872fad108bd65f49f9ba28571e845333763e2ec4..52e0362913300b61ee5545f032cd84e3ff5ba9e5 100644 |
--- a/content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.cc |
+++ b/content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.cc |
@@ -4,21 +4,51 @@ |
#include "content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.h" |
+#include "base/atomic_sequence_num.h" |
+#include "base/bind.h" |
#include "base/debug/trace_event.h" |
#include "base/logging.h" |
-#include "content/common/android/surface_texture_lookup.h" |
+#include "content/common/android/surface_texture_manager.h" |
+#include "content/common/gpu/client/gpu_memory_buffer_factory_host.h" |
#include "ui/gl/gl_bindings.h" |
namespace content { |
+namespace { |
+ |
+base::StaticAtomicSequenceNumber g_next_buffer_id; |
+ |
+void Noop() { |
+} |
+ |
+void GpuMemoryBufferCreated( |
+ const gfx::Size& size, |
+ unsigned internalformat, |
+ const GpuMemoryBufferImpl::CreationCallback& callback, |
+ const gfx::GpuMemoryBufferHandle& handle) { |
+ DCHECK_EQ(gfx::SURFACE_TEXTURE_BUFFER, handle.type); |
+ |
+ callback.Run(GpuMemoryBufferImplSurfaceTexture::CreateFromHandle( |
+ handle, size, internalformat, base::Bind(&Noop))); |
+} |
+ |
+void GpuMemoryBufferCreatedForChildProcess( |
+ const GpuMemoryBufferImpl::AllocationCallback& callback, |
+ const gfx::GpuMemoryBufferHandle& handle) { |
+ DCHECK_EQ(gfx::SURFACE_TEXTURE_BUFFER, handle.type); |
+ |
+ callback.Run(handle); |
+} |
+ |
+} // namespace |
GpuMemoryBufferImplSurfaceTexture::GpuMemoryBufferImplSurfaceTexture( |
const gfx::Size& size, |
unsigned internalformat, |
const DestructionCallback& callback, |
- const gfx::SurfaceTextureId& surface_texture_id, |
+ const gfx::GpuMemoryBufferId& id, |
ANativeWindow* native_window) |
: GpuMemoryBufferImpl(size, internalformat, callback), |
- surface_texture_id_(surface_texture_id), |
+ id_(id), |
native_window_(native_window), |
stride_(0u) { |
} |
@@ -28,6 +58,44 @@ GpuMemoryBufferImplSurfaceTexture::~GpuMemoryBufferImplSurfaceTexture() { |
} |
// static |
+void GpuMemoryBufferImplSurfaceTexture::Create( |
+ const gfx::Size& size, |
+ unsigned internalformat, |
+ unsigned usage, |
+ int client_id, |
+ const CreationCallback& callback) { |
+ gfx::GpuMemoryBufferHandle handle; |
+ handle.global_id.primary_id = g_next_buffer_id.GetNext(); |
+ handle.global_id.secondary_id = client_id; |
+ handle.type = gfx::SURFACE_TEXTURE_BUFFER; |
+ GpuMemoryBufferFactoryHost::GetInstance()->CreateGpuMemoryBuffer( |
+ handle, |
+ size, |
+ internalformat, |
+ usage, |
+ base::Bind(&GpuMemoryBufferCreated, size, internalformat, callback)); |
+} |
+ |
+// static |
+void GpuMemoryBufferImplSurfaceTexture::AllocateForChildProcess( |
+ const gfx::Size& size, |
+ unsigned internalformat, |
+ unsigned usage, |
+ int child_client_id, |
+ const AllocationCallback& callback) { |
+ gfx::GpuMemoryBufferHandle handle; |
+ handle.global_id.primary_id = g_next_buffer_id.GetNext(); |
+ handle.global_id.secondary_id = child_client_id; |
+ handle.type = gfx::SURFACE_TEXTURE_BUFFER; |
+ GpuMemoryBufferFactoryHost::GetInstance()->CreateGpuMemoryBuffer( |
+ handle, |
+ size, |
+ internalformat, |
+ usage, |
+ base::Bind(&GpuMemoryBufferCreatedForChildProcess, callback)); |
+} |
+ |
+// static |
scoped_ptr<GpuMemoryBufferImpl> |
GpuMemoryBufferImplSurfaceTexture::CreateFromHandle( |
const gfx::GpuMemoryBufferHandle& handle, |
@@ -37,9 +105,8 @@ GpuMemoryBufferImplSurfaceTexture::CreateFromHandle( |
DCHECK(IsFormatSupported(internalformat)); |
ANativeWindow* native_window = |
- SurfaceTextureLookup::GetInstance()->AcquireNativeWidget( |
- handle.surface_texture_id.primary_id, |
- handle.surface_texture_id.secondary_id); |
+ SurfaceTextureManager::GetInstance()->AcquireNativeWidget( |
+ handle.global_id.primary_id, handle.global_id.secondary_id); |
if (!native_window) |
return scoped_ptr<GpuMemoryBufferImpl>(); |
@@ -47,11 +114,8 @@ GpuMemoryBufferImplSurfaceTexture::CreateFromHandle( |
native_window, size.width(), size.height(), WindowFormat(internalformat)); |
return make_scoped_ptr<GpuMemoryBufferImpl>( |
- new GpuMemoryBufferImplSurfaceTexture(size, |
- internalformat, |
- callback, |
- handle.surface_texture_id, |
- native_window)); |
+ new GpuMemoryBufferImplSurfaceTexture( |
+ size, internalformat, callback, handle.global_id, native_window)); |
} |
// static |
@@ -125,7 +189,7 @@ gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle() |
const { |
gfx::GpuMemoryBufferHandle handle; |
handle.type = gfx::SURFACE_TEXTURE_BUFFER; |
- handle.surface_texture_id = surface_texture_id_; |
+ handle.global_id = id_; |
return handle; |
} |