| Index: mojo/gles2/command_buffer_client_impl.cc
|
| diff --git a/mojo/gles2/command_buffer_client_impl.cc b/mojo/gles2/command_buffer_client_impl.cc
|
| index 97ea89a4e3481282c121ad7159e2d7aa4328f3ed..72d1f5d6f96f7e67fb4e22ed333221b2d12a9f7b 100644
|
| --- a/mojo/gles2/command_buffer_client_impl.cc
|
| +++ b/mojo/gles2/command_buffer_client_impl.cc
|
| @@ -10,6 +10,9 @@
|
| #include "base/process/process_handle.h"
|
| #include "components/view_manager/gles2/command_buffer_type_conversions.h"
|
| #include "components/view_manager/gles2/mojo_buffer_backing.h"
|
| +#include "components/view_manager/gles2/mojo_gpu_memory_buffer.h"
|
| +#include "gpu/command_buffer/service/image_factory.h"
|
| +#include "mojo/platform_handle/platform_handle_functions.h"
|
|
|
| namespace gles2 {
|
|
|
| @@ -120,6 +123,7 @@ CommandBufferClientImpl::CommandBufferClientImpl(
|
| shared_state_(NULL),
|
| last_put_offset_(-1),
|
| next_transfer_buffer_id_(0),
|
| + next_image_id_(0),
|
| async_waiter_(async_waiter) {
|
| command_buffer_.Bind(mojo::InterfacePtrInfo<mojo::CommandBuffer>(
|
| command_buffer_handle.Pass(), 0u),
|
| @@ -245,24 +249,74 @@ int32_t CommandBufferClientImpl::CreateImage(ClientBuffer buffer,
|
| size_t width,
|
| size_t height,
|
| unsigned internalformat) {
|
| - // TODO(piman)
|
| - NOTIMPLEMENTED();
|
| - return -1;
|
| + int32 new_id = ++next_image_id_;
|
| +
|
| + mojo::SizePtr size = mojo::Size::New();
|
| + size->width = width;
|
| + size->height = height;
|
| +
|
| + MojoGpuMemoryBufferImpl* gpu_memory_buffer =
|
| + MojoGpuMemoryBufferImpl::FromClientBuffer(buffer);
|
| + gfx::GpuMemoryBufferHandle handle = gpu_memory_buffer->GetHandle();
|
| +
|
| + bool requires_sync_point = false;
|
| + base::SharedMemoryHandle dupd_handle =
|
| + base::SharedMemory::DuplicateHandle(handle.handle);
|
| +#if defined(OS_WIN)
|
| + HANDLE platform_handle = dupd_handle;
|
| +#else
|
| + int platform_handle = dupd_handle.fd;
|
| +#endif
|
| +
|
| + if (handle.type != gfx::SHARED_MEMORY_BUFFER) {
|
| + requires_sync_point = true;
|
| + NOTIMPLEMENTED();
|
| + return -1;
|
| + }
|
| +
|
| + MojoHandle mojo_handle = MOJO_HANDLE_INVALID;
|
| + MojoResult create_result = MojoCreatePlatformHandleWrapper(
|
| + platform_handle, &mojo_handle);
|
| + if (create_result != MOJO_RESULT_OK) {
|
| + NOTIMPLEMENTED();
|
| + return -1;
|
| + }
|
| + mojo::ScopedHandle scoped_handle;
|
| + scoped_handle.reset(mojo::Handle(mojo_handle));
|
| + command_buffer_->CreateImage(new_id,
|
| + scoped_handle.Pass(),
|
| + handle.type,
|
| + size.Pass(),
|
| + gpu_memory_buffer->GetFormat(),
|
| + internalformat);
|
| + if (requires_sync_point) {
|
| + NOTIMPLEMENTED();
|
| + // TODO(jam): need to support this if we support types other than
|
| + // SHARED_MEMORY_BUFFER.
|
| + //gpu_memory_buffer_manager->SetDestructionSyncPoint(gpu_memory_buffer,
|
| + // InsertSyncPoint());
|
| + }
|
| +
|
| + return new_id;
|
| }
|
|
|
| void CommandBufferClientImpl::DestroyImage(int32 id) {
|
| - // TODO(piman)
|
| - NOTIMPLEMENTED();
|
| + command_buffer_->DestroyImage(id);
|
| }
|
|
|
| int32_t CommandBufferClientImpl::CreateGpuMemoryBufferImage(
|
| size_t width,
|
| size_t height,
|
| unsigned internalformat,
|
| - unsigned usage) {
|
| - // TODO(piman)
|
| - NOTIMPLEMENTED();
|
| - return -1;
|
| + unsigned usage) {
|
| + scoped_ptr<gfx::GpuMemoryBuffer> buffer(MojoGpuMemoryBufferImpl::Create(
|
| + gfx::Size(width, height),
|
| + gpu::ImageFactory::ImageFormatToGpuMemoryBufferFormat(internalformat),
|
| + gpu::ImageFactory::ImageUsageToGpuMemoryBufferUsage(usage)));
|
| + if (!buffer)
|
| + return -1;
|
| +
|
| + return CreateImage(buffer->AsClientBuffer(), width, height, internalformat);
|
| }
|
|
|
| uint32_t CommandBufferClientImpl::InsertSyncPoint() {
|
|
|