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..d6c8fb4ff570aa0a94987ec9e2f5d3f93d3d9483 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 { |
@@ -245,24 +248,72 @@ 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_.GetNext(); |
+ |
+ mojo::SizePtr size = mojo::Size::New(); |
+ size->width = width; |
yzshen1
2015/06/15 20:04:42
FYI, I tried to compile the patch on Windows and i
jam
2015/06/15 22:06:02
that's strange, i'm compiling on Windows and I don
yzshen1
2015/06/16 16:34:25
That is strange. I didn't explicitly set any gn ar
|
+ 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(); |
+ //gpu_memory_buffer_manager->SetDestructionSyncPoint(gpu_memory_buffer, |
danakj
2015/06/15 18:20:36
is a TODO needed?
jam
2015/06/15 22:06:01
Done.
|
+ // InsertSyncPoint()); |
piman
2015/06/15 18:14:33
nit: remove/add TODO?
jam
2015/06/15 22:06:01
Done.
|
+ } |
+ |
+ 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() { |