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

Unified Diff: content/common/gpu/gpu_memory_buffer_factory_io_surface.cc

Issue 1137453002: content: Pass IOSurface references using Mach IPC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add MachBrokerTest.IOSurfaces test Created 5 years, 7 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: 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() {

Powered by Google App Engine
This is Rietveld 408576698