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

Unified Diff: ui/gfx/mac/io_surface.cc

Issue 1532813002: Replace IOSurfaceManager by directly passing IOSurface Mach ports over Chrome IPC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 12 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 | « ui/gfx/mac/io_surface.h ('k') | ui/gfx/mac/io_surface_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/mac/io_surface.cc
diff --git a/ui/gfx/mac/io_surface_manager.cc b/ui/gfx/mac/io_surface.cc
similarity index 84%
rename from ui/gfx/mac/io_surface_manager.cc
rename to ui/gfx/mac/io_surface.cc
index 9e3e9cfdb377418c7563a12024ce396f35f6cc29..8c748bca1846623b73902095adf8688df99598e8 100644
--- a/ui/gfx/mac/io_surface_manager.cc
+++ b/ui/gfx/mac/io_surface.cc
@@ -2,21 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/gfx/mac/io_surface_manager.h"
+#include "ui/gfx/mac/io_surface.h"
-#include <IOSurface/IOSurface.h>
#include <stddef.h>
#include <stdint.h>
#include "base/logging.h"
-#include "base/mac/scoped_cftyperef.h"
+#include "base/mac/mach_logging.h"
#include "base/macros.h"
#include "ui/gfx/buffer_format_util.h"
namespace gfx {
-namespace {
-IOSurfaceManager* g_instance = NULL;
+namespace {
void AddIntegerValue(CFMutableDictionaryRef dictionary,
const CFStringRef key,
@@ -89,21 +87,28 @@ int32_t PixelFormat(gfx::BufferFormat format) {
} // namespace
+namespace internal {
+
// static
-IOSurfaceManager* IOSurfaceManager::GetInstance() {
- DCHECK(g_instance);
- return g_instance;
+mach_port_t IOSurfaceMachPortTraits::Retain(mach_port_t port) {
+ kern_return_t kr =
+ mach_port_mod_refs(mach_task_self(), port, MACH_PORT_RIGHT_SEND, 1);
+ MACH_LOG_IF(ERROR, kr != KERN_SUCCESS, kr)
+ << "IOSurfaceMachPortTraits::Retain mach_port_mod_refs";
+ return port;
}
// static
-void IOSurfaceManager::SetInstance(IOSurfaceManager* instance) {
- DCHECK(!g_instance || !instance);
- g_instance = instance;
+void IOSurfaceMachPortTraits::Release(mach_port_t port) {
+ kern_return_t kr =
+ mach_port_mod_refs(mach_task_self(), port, MACH_PORT_RIGHT_SEND, -1);
+ MACH_LOG_IF(ERROR, kr != KERN_SUCCESS, kr)
+ << "IOSurfaceMachPortTraits::Release mach_port_mod_refs";
}
-// static
-IOSurfaceRef IOSurfaceManager::CreateIOSurface(const gfx::Size& size,
- gfx::BufferFormat format) {
+} // namespace internal
+
+IOSurfaceRef CreateIOSurface(const gfx::Size& size, gfx::BufferFormat format) {
size_t num_planes = gfx::NumberOfPlanesForBufferFormat(format);
base::ScopedCFTypeRef<CFMutableArrayRef> planes(CFArrayCreateMutable(
kCFAllocatorDefault, num_planes, &kCFTypeArrayCallBacks));
@@ -146,4 +151,4 @@ IOSurfaceRef IOSurfaceManager::CreateIOSurface(const gfx::Size& size,
return IOSurfaceCreate(properties);
}
-} // namespace content
+} // namespace gfx
« no previous file with comments | « ui/gfx/mac/io_surface.h ('k') | ui/gfx/mac/io_surface_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698