| 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
|
|
|