OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_GFX_MAC_IO_SURFACE_H_ |
| 6 #define UI_GFX_MAC_IO_SURFACE_H_ |
| 7 |
| 8 #include <IOSurface/IOSurface.h> |
| 9 #include <mach/mach.h> |
| 10 |
| 11 #include "base/mac/scoped_cftyperef.h" |
| 12 #include "ui/gfx/buffer_types.h" |
| 13 #include "ui/gfx/generic_shared_memory_id.h" |
| 14 #include "ui/gfx/geometry/size.h" |
| 15 #include "ui/gfx/gfx_export.h" |
| 16 |
| 17 namespace gfx { |
| 18 |
| 19 namespace internal { |
| 20 |
| 21 struct IOSurfaceMachPortTraits { |
| 22 GFX_EXPORT static mach_port_t InvalidValue() { return MACH_PORT_NULL; } |
| 23 GFX_EXPORT static mach_port_t Retain(mach_port_t); |
| 24 GFX_EXPORT static void Release(mach_port_t); |
| 25 }; |
| 26 |
| 27 } // namespace internal |
| 28 |
| 29 using IOSurfaceId = GenericSharedMemoryId; |
| 30 |
| 31 // Helper function to create an IOSurface with a specified size and format. |
| 32 GFX_EXPORT IOSurfaceRef CreateIOSurface(const Size& size, BufferFormat format); |
| 33 |
| 34 // A scoper for handling Mach port names that are send rights for IOSurfaces. |
| 35 // This scoper is both copyable and assignable, which will increase the kernel |
| 36 // reference count of the right. On destruction, the reference count is |
| 37 // decremented. |
| 38 using ScopedRefCountedIOSurfaceMachPort = |
| 39 base::ScopedTypeRef<mach_port_t, internal::IOSurfaceMachPortTraits>; |
| 40 |
| 41 } // namespace gfx |
| 42 |
| 43 #endif // UI_GFX_MAC_IO_SURFACE_H_ |
OLD | NEW |