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

Unified Diff: gpu/ipc/service/gpu_memory_buffer_factory_io_surface.cc

Issue 2061743004: Implement native GMB backbuffers in the GLES2 Command Decoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compile error on Windows. Created 4 years, 6 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: gpu/ipc/service/gpu_memory_buffer_factory_io_surface.cc
diff --git a/gpu/ipc/service/gpu_memory_buffer_factory_io_surface.cc b/gpu/ipc/service/gpu_memory_buffer_factory_io_surface.cc
index 3838414f7f75afe6d081c9e9b10caf829ed39ffe..dc8ce52147f341fcc4483a85ca6531d6208159aa 100644
--- a/gpu/ipc/service/gpu_memory_buffer_factory_io_surface.cc
+++ b/gpu/ipc/service/gpu_memory_buffer_factory_io_surface.cc
@@ -32,7 +32,8 @@ GpuMemoryBufferFactoryIOSurface::CreateGpuMemoryBuffer(
if (!io_surface)
return gfx::GpuMemoryBufferHandle();
- {
+ // A GpuMemoryBuffer with client_id = 0 behaves like anonymous shared memory.
+ if (client_id != 0) {
base::AutoLock lock(io_surfaces_lock_);
IOSurfaceMapKey key(id, client_id);
@@ -86,4 +87,26 @@ GpuMemoryBufferFactoryIOSurface::CreateImageForGpuMemoryBuffer(
return image;
}
+scoped_refptr<gl::GLImage>
+GpuMemoryBufferFactoryIOSurface::CreateAnonymousImage(const gfx::Size& size,
+ gfx::BufferFormat format,
+ unsigned internalformat) {
+ // Note that the GpuMemoryBufferId and child id don't matter since the texture
+ // will never be directly exposed to other processes, only via a mailbox.
+ int gmb_id = 0;
+ int client_id = 0;
+ gfx::GpuMemoryBufferHandle handle = CreateGpuMemoryBuffer(
+ gfx::GpuMemoryBufferId(gmb_id), size, format, gfx::BufferUsage::SCANOUT,
+ client_id, gpu::kNullSurfaceHandle);
+
+ base::ScopedCFTypeRef<IOSurfaceRef> io_surface;
+ io_surface.reset(IOSurfaceLookupFromMachPort(handle.mach_port.get()));
+ DCHECK_NE(nullptr, io_surface.get());
+ scoped_refptr<gl::GLImageIOSurface> image(
+ new gl::GLImageIOSurface(size, internalformat));
+ if (!image->Initialize(io_surface.get(), handle.id, format))
+ return scoped_refptr<gl::GLImage>();
+ return image;
+}
+
} // namespace gpu

Powered by Google App Engine
This is Rietveld 408576698