diff options
author | Chris Loer <chris.loer@gmail.com> | 2017-11-27 12:50:28 -0800 |
---|---|---|
committer | Fabian Guerra <fabian.guerra@mapbox.com> | 2018-01-02 12:06:31 -0600 |
commit | 24c6cf6a07edb95b519709de10255d8cf11e7a69 (patch) | |
tree | c40f551fd37e7a23ed0ff5ce824d26e5242f462b /platform/darwin/src/CFHandle.hpp | |
parent | 33faa3811e1833ef99e7e9b5be835793c81892f7 (diff) | |
download | qtlocation-mapboxgl-24c6cf6a07edb95b519709de10255d8cf11e7a69.tar.gz |
[ios,macos] Darwin implementation of a CoreText-based LocalGlyphRasterizer.
- Changing font weight does not currently appear to be working.
- Glyph metric extraction code not working; currently unused.
Diffstat (limited to 'platform/darwin/src/CFHandle.hpp')
-rw-r--r-- | platform/darwin/src/CFHandle.hpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/platform/darwin/src/CFHandle.hpp b/platform/darwin/src/CFHandle.hpp new file mode 100644 index 0000000000..edcc9aafdf --- /dev/null +++ b/platform/darwin/src/CFHandle.hpp @@ -0,0 +1,31 @@ +#pragma once + +/* + CFHandle is a minimal wrapper designed to hold and release CoreFoundation-style handles + It is non-transferrable: wrap it in something like a unique_ptr if you need to pass it around, + or just use unique_ptr with a custom deleter. + CFHandle has no special treatment for null handles -- be careful not to let it hold a null + handle if the behavior of the Releaser isn't defined for null. + + ex: + using CFDataHandle = CFHandle<CFDataRef, CFTypeRef, CFRelease>; + + CFDataHandle data(CFDataCreateWithBytesNoCopy( + kCFAllocatorDefault, reinterpret_cast<const unsigned char*>(source.data()), source.size(), + kCFAllocatorNull)); +*/ + +namespace { + +template <typename HandleType, typename ReleaserArgumentType, void (*Releaser)(ReleaserArgumentType)> +struct CFHandle { + CFHandle(HandleType handle_): handle(handle_) {} + ~CFHandle() { Releaser(handle); } + HandleType operator*() { return handle; } + operator bool() { return handle; } +private: + HandleType handle; +}; + +} // namespace + |