Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(759)

Unified Diff: services/ui/public/cpp/mojo_gpu_memory_buffer.cc

Issue 2251693005: services/ui: Implement MojoGpuMemoryBufferManager::CreateGpuMemoryBufferFromHandle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: services/ui/public/cpp/mojo_gpu_memory_buffer.cc
diff --git a/services/ui/public/cpp/mojo_gpu_memory_buffer.cc b/services/ui/public/cpp/mojo_gpu_memory_buffer.cc
index fcc89b5d614eb862450b70a5c9628b473c8728dd..fad3ea0797257b7928def6a9f3a12ee8da74273e 100644
--- a/services/ui/public/cpp/mojo_gpu_memory_buffer.cc
+++ b/services/ui/public/cpp/mojo_gpu_memory_buffer.cc
@@ -27,6 +27,7 @@ MojoGpuMemoryBufferImpl::MojoGpuMemoryBufferImpl(
// TODO(rjkroege): Support running a destructor callback as necessary.
MojoGpuMemoryBufferImpl::~MojoGpuMemoryBufferImpl() {}
+// static
std::unique_ptr<gfx::GpuMemoryBuffer> MojoGpuMemoryBufferImpl::Create(
const gfx::Size& size,
gfx::BufferFormat format,
@@ -53,6 +54,21 @@ std::unique_ptr<gfx::GpuMemoryBuffer> MojoGpuMemoryBufferImpl::Create(
new MojoGpuMemoryBufferImpl(size, format, std::move(shared_memory)));
}
+// static
+std::unique_ptr<gfx::GpuMemoryBuffer> MojoGpuMemoryBufferImpl::CreateFromHandle(
+ const gfx::GpuMemoryBufferHandle& handle,
+ const gfx::Size& size,
+ gfx::BufferFormat format,
+ gfx::BufferUsage usage) {
+ DCHECK_EQ(handle.type, gfx::SHARED_MEMORY_BUFFER);
+ DCHECK(base::SharedMemory::IsHandleValid(handle.handle));
+ const bool readonly = false;
+ auto shared_memory =
+ base::MakeUnique<base::SharedMemory>(handle.handle, readonly);
+ return base::WrapUnique<gfx::GpuMemoryBuffer>(
dcheng 2016/08/17 22:59:00 Nit: Omit the template parameter here (WrapUnique
Peng 2016/08/17 23:28:17 Done.
+ new MojoGpuMemoryBufferImpl(size, format, std::move(shared_memory)));
+}
+
MojoGpuMemoryBufferImpl* MojoGpuMemoryBufferImpl::FromClientBuffer(
ClientBuffer buffer) {
return reinterpret_cast<MojoGpuMemoryBufferImpl*>(buffer);
« no previous file with comments | « services/ui/public/cpp/mojo_gpu_memory_buffer.h ('k') | services/ui/public/cpp/mojo_gpu_memory_buffer_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698