Index: content/common/gpu/gpu_memory_buffer_factory_io_surface.cc |
diff --git a/content/common/gpu/gpu_memory_buffer_factory_io_surface.cc b/content/common/gpu/gpu_memory_buffer_factory_io_surface.cc |
index 574b4f68697126c0d2bec7f38718deace1308fdd..18c2d9be457e452a7433303e4d16a063c9d7308b 100644 |
--- a/content/common/gpu/gpu_memory_buffer_factory_io_surface.cc |
+++ b/content/common/gpu/gpu_memory_buffer_factory_io_surface.cc |
@@ -7,18 +7,12 @@ |
#include <CoreFoundation/CoreFoundation.h> |
#include "base/logging.h" |
+#include "content/common/mac/io_surface_manager.h" |
#include "ui/gl/gl_image_io_surface.h" |
namespace content { |
namespace { |
-void AddBooleanValue(CFMutableDictionaryRef dictionary, |
- const CFStringRef key, |
- bool value) { |
- CFDictionaryAddValue( |
- dictionary, key, value ? kCFBooleanTrue : kCFBooleanFalse); |
-} |
- |
void AddIntegerValue(CFMutableDictionaryRef dictionary, |
const CFStringRef key, |
int32 value) { |
@@ -117,14 +111,16 @@ GpuMemoryBufferFactoryIOSurface::CreateGpuMemoryBuffer( |
AddIntegerValue(properties, kIOSurfaceHeight, size.height()); |
AddIntegerValue(properties, kIOSurfaceBytesPerElement, BytesPerPixel(format)); |
AddIntegerValue(properties, kIOSurfacePixelFormat, PixelFormat(format)); |
- // TODO(reveman): Remove this when using a mach_port_t to transfer |
- // IOSurface to browser and renderer process. crbug.com/323304 |
- AddBooleanValue(properties, kIOSurfaceIsGlobal, true); |
base::ScopedCFTypeRef<IOSurfaceRef> io_surface(IOSurfaceCreate(properties)); |
if (!io_surface) |
return gfx::GpuMemoryBufferHandle(); |
+ if (!IOSurfaceManager::GetInstance()->RegisterIOSurface(id, client_id, |
+ io_surface)) { |
+ return gfx::GpuMemoryBufferHandle(); |
+ } |
+ |
{ |
base::AutoLock lock(io_surfaces_lock_); |
@@ -136,19 +132,22 @@ GpuMemoryBufferFactoryIOSurface::CreateGpuMemoryBuffer( |
gfx::GpuMemoryBufferHandle handle; |
handle.type = gfx::IO_SURFACE_BUFFER; |
handle.id = id; |
- handle.io_surface_id = IOSurfaceGetID(io_surface); |
return handle; |
} |
void GpuMemoryBufferFactoryIOSurface::DestroyGpuMemoryBuffer( |
gfx::GpuMemoryBufferId id, |
int client_id) { |
- base::AutoLock lock(io_surfaces_lock_); |
+ { |
+ base::AutoLock lock(io_surfaces_lock_); |
- IOSurfaceMapKey key(id, client_id); |
- IOSurfaceMap::iterator it = io_surfaces_.find(key); |
- if (it != io_surfaces_.end()) |
- io_surfaces_.erase(it); |
+ IOSurfaceMapKey key(id, client_id); |
+ IOSurfaceMap::iterator it = io_surfaces_.find(key); |
Daniele Castagna
2015/05/08 18:58:30
io_surfaces_.erase(IOSurfaceMapKey(id, client_id))
reveman
2015/05/09 15:54:54
https://codereview.chromium.org/1131463004
|
+ if (it != io_surfaces_.end()) |
+ io_surfaces_.erase(it); |
+ } |
+ |
+ IOSurfaceManager::GetInstance()->UnregisterIOSurface(id, client_id); |
} |
gpu::ImageFactory* GpuMemoryBufferFactoryIOSurface::AsImageFactory() { |