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

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: Comments from piman. 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
« no previous file with comments | « gpu/ipc/service/gpu_memory_buffer_factory_io_surface.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..31aec60db1751ee1c07ac3163ae088c55d062e01 100644
--- a/gpu/ipc/service/gpu_memory_buffer_factory_io_surface.cc
+++ b/gpu/ipc/service/gpu_memory_buffer_factory_io_surface.cc
@@ -7,6 +7,7 @@
#include <vector>
#include "base/logging.h"
+#include "gpu/GLES2/gl2extchromium.h"
#include "ui/gfx/buffer_format_util.h"
#include "ui/gfx/mac/io_surface.h"
#include "ui/gl/gl_image_io_surface.h"
@@ -32,7 +33,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 +88,34 @@ 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;
+}
+
+unsigned GpuMemoryBufferFactoryIOSurface::RequiredTextureType() {
+ return GL_TEXTURE_RECTANGLE_ARB;
+}
+
+bool GpuMemoryBufferFactoryIOSurface::SupportsFormatRGB() {
+ return false;
+}
+
} // namespace gpu
« no previous file with comments | « gpu/ipc/service/gpu_memory_buffer_factory_io_surface.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698