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

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: static_assert 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 f07ef78fcb5b5f8162d161b124503c718139b02c..1b6b8d0393bc8593f87ebd89304ca6eddaf5cc5a 100644
--- a/content/common/gpu/gpu_memory_buffer_factory_io_surface.cc
+++ b/content/common/gpu/gpu_memory_buffer_factory_io_surface.cc
@@ -6,19 +6,15 @@
#include <CoreFoundation/CoreFoundation.h>
+#include <vector>
+
#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) {
@@ -121,14 +117,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_);
@@ -140,18 +138,21 @@ 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);
+ DCHECK(io_surfaces_.find(key) != io_surfaces_.end());
+ io_surfaces_.erase(key);
+ }
- IOSurfaceMapKey key(id, client_id);
- DCHECK(io_surfaces_.find(key) != io_surfaces_.end());
- io_surfaces_.erase(key);
+ IOSurfaceManager::GetInstance()->UnregisterIOSurface(id, client_id);
}
gpu::ImageFactory* GpuMemoryBufferFactoryIOSurface::AsImageFactory() {
« no previous file with comments | « content/common/gpu/client/gpu_memory_buffer_impl_io_surface.cc ('k') | content/common/mac/io_surface_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698