Merge branch 'hgr/quartz_for_ios' into 'master'

quartz: introducing support for ios

See merge request cairo/cairo!593
This commit is contained in:
Håvard Graff 2026-03-02 06:22:25 +00:00
commit 8caa7767c9
7 changed files with 80 additions and 31 deletions

View file

@ -453,11 +453,24 @@ if feature_conf.get('CAIRO_HAS_XCB_SURFACE', 0) == 1
endif
endif
if host_machine.system() == 'darwin' and not get_option('quartz').disabled()
quartz_deps = dependency('appleframeworks', modules : ['CoreFoundation', 'ApplicationServices'], required: get_option('quartz'))
if host_machine.system() in ['darwin', 'ios'] and not get_option('quartz').disabled()
core_graphics_dep = dependency('appleframeworks', modules : ['CoreFoundation', 'CoreGraphics'], required: get_option('quartz'))
core_text_dep = dependency('appleframeworks', modules : ['CoreFoundation', 'CoreGraphics', 'CoreText'], required: get_option('quartz'))
imageio_dep = dependency('appleframeworks', modules : ['ImageIO'], required: get_option('quartz'))
application_services_dep = dependency('appleframeworks', modules : ['ApplicationServices'], required: get_option('quartz'))
if quartz_deps.found()
deps += [quartz_deps]
if application_services_dep.found()
deps += [application_services_dep]
feature_conf.set('CAIRO_HAS_APPLICATION_SERVICES', 1)
endif
if imageio_dep.found()
deps += [imageio_dep]
feature_conf.set('CAIRO_HAS_IMAGEIO', 1)
endif
if core_graphics_dep.found()
deps += [core_graphics_dep]
feature_conf.set('CAIRO_HAS_QUARTZ_SURFACE', 1)
feature_conf.set('CAIRO_HAS_QUARTZ_IMAGE_SURFACE', 1)
@ -466,25 +479,30 @@ if host_machine.system() == 'darwin' and not get_option('quartz').disabled()
{
'name': 'cairo-quartz',
'description': 'Quartz surface backend',
'deps': quartz_deps,
'deps': core_graphics_dep,
},
{
'name': 'cairo-quartz-image',
'description': 'Quartz Image surface backend',
'deps': quartz_deps,
}]
'deps': core_graphics_dep,
}]
endif
if core_text_dep.found()
compiler = meson.get_compiler('c')
if compiler.has_function('CTFontDrawGlyphs', prefix: '#include <ApplicationServices/ApplicationServices.h>',
dependencies: quartz_deps)
if compiler.has_function('CTFontDrawGlyphs', prefix: '#include <CoreText/CoreText.h>',
dependencies: core_text_dep)
deps += [core_text_dep]
built_features += [
{
'name': 'cairo-quartz-font',
'description': 'Quartz font backend',
'deps': quartz_deps,
'deps': core_text_dep,
}]
feature_conf.set('CAIRO_HAS_QUARTZ_FONT', 1)
endif
endif
endif
if host_machine.system() == 'windows'

View file

@ -65,7 +65,10 @@
/* These are private functions */
static bool (*CGContextGetAllowsFontSmoothingPtr) (CGContextRef) = NULL;
#if defined(CAIRO_HAS_APPLICATION_SERVICES)
static ATSFontRef (*FMGetATSFontRefFromFontPtr) (FMFont iFont) = NULL;
#endif
static cairo_bool_t _cairo_quartz_font_symbol_lookup_done = FALSE;
/* Cairo's transformations assume a unit-scaled font. */
@ -92,7 +95,9 @@ quartz_font_ensure_symbols(void)
CGContextGetAllowsFontSmoothingPtr =
dlsym (RTLD_DEFAULT, "CGContextGetAllowsFontSmoothing");
#if defined(CAIRO_HAS_APPLICATION_SERVICES)
FMGetATSFontRefFromFontPtr = dlsym(RTLD_DEFAULT, "FMGetATSFontRefFromFont");
#endif
_cairo_quartz_font_symbol_lookup_done = TRUE;
}
@ -803,6 +808,10 @@ _cairo_quartz_scaled_font_get_ct_font (cairo_scaled_font_t *abstract_font)
}
}
#if defined(CAIRO_HAS_APPLICATION_SERVICES)
/*
* compat with old ATSUI backend
*/
@ -849,3 +858,5 @@ cairo_atsui_font_face_create_for_atsu_font_id (ATSUFontID font_id)
{
return cairo_quartz_font_face_create_for_atsu_font_id (font_id);
}
#endif /* CAIRO_HAS_APPLICATION_SERVICES */

View file

@ -36,6 +36,12 @@
#include "cairoint.h"
#if defined(CAIRO_HAS_APPLICATION_SERVICES)
#include <Carbon/Carbon.h>
#endif
#include <CoreGraphics/CoreGraphics.h>
#include "cairo-image-surface-inline.h"
#include "cairo-quartz-image.h"
#include "cairo-quartz-private.h"
@ -307,7 +313,13 @@ cairo_quartz_image_surface_create (cairo_surface_t *surface)
colorspace = _cairo_quartz_create_color_space (context);
}
else {
#if defined(CAIRO_HAS_APPLICATION_SERVICES)
colorspace = CGDisplayCopyColorSpace (CGMainDisplayID ());
#else
// FIXME: provide a colorspace!
colorspace = NULL;
#endif
}
bitinfo |= format == CAIRO_FORMAT_ARGB32 ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaNoneSkipFirst;

View file

@ -38,9 +38,10 @@
#include "cairo.h"
#if CAIRO_HAS_QUARTZ_IMAGE_SURFACE
#if !defined(CAIRO_HAS_QUARTZ_IMAGE_SURFACE)
# error Cairo was not compiled with support for the quartz-image backend
#endif
#include <Carbon/Carbon.h>
CAIRO_BEGIN_DECLS
@ -52,8 +53,5 @@ cairo_quartz_image_surface_get_image (cairo_surface_t *surface);
CAIRO_END_DECLS
#else /* CAIRO_HAS_QUARTZ_IMAGE_SURFACE */
# error Cairo was not compiled with support for the quartz-image backend
#endif /* CAIRO_HAS_QUARTZ_IMAGE_SURFACE */
#endif /* CAIRO_QUARTZ_IMAGE_H */

View file

@ -40,7 +40,10 @@
#include "cairoint.h"
#if CAIRO_HAS_QUARTZ_SURFACE
#if !defined(CAIRO_HAS_QUARTZ_SURFACE)
# error Cairo was not compiled with support for the quartz backend
#endif
#include "cairo-quartz.h"
#include "cairo-surface-clipper-private.h"
@ -113,10 +116,4 @@ _cairo_quartz_set_antialiasing (CGContextRef context, cairo_antialias_t antialia
cairo_status_t _cairo_quartz_surface_to_png (cairo_surface_t *abstract_surface, const char *dest);
cairo_private void _cairo_quartz_image_to_png (CGImageRef, const char *dest);
#else
# error Cairo was not compiled with support for the quartz backend
#endif /* CAIRO_HAS_QUARTZ_SURFACE */
#endif /* CAIRO_QUARTZ_PRIVATE_H */

View file

@ -36,6 +36,8 @@
#include "cairoint.h"
#include <ImageIO/ImageIO.h>
#include "cairo-quartz-private.h"
#include "cairo-quartz-image.h"
@ -200,8 +202,11 @@ _cairo_quartz_create_color_space (CGContextRef context)
if (color_space)
return color_space;
}
#if defined(CAIRO_HAS_APPLICATION_SERVICES)
if (!color_space)
color_space = CGDisplayCopyColorSpace (CGMainDisplayID ());
#endif
if (!color_space)
color_space = CGColorSpaceCreateDeviceRGB ();

View file

@ -38,12 +38,20 @@
#include "cairo.h"
#if CAIRO_HAS_QUARTZ_SURFACE
#if !defined (CAIRO_HAS_QUARTZ_SURFACE) && !defined(CAIRO_HAS_QUARTZ_FONT)
#error Cairo was not compiled with support for the quartz backend
#endif
#if defined(CAIRO_HAS_APPLICATION_SERVICES)
#include <ApplicationServices/ApplicationServices.h>
#endif
#include <CoreText/CoreText.h>
CAIRO_BEGIN_DECLS
#if defined(CAIRO_HAS_QUARTZ_SURFACE)
cairo_public cairo_surface_t *
cairo_quartz_surface_create (cairo_format_t format,
unsigned int width,
@ -57,26 +65,26 @@ cairo_quartz_surface_create_for_cg_context (CGContextRef cgContext,
cairo_public CGContextRef
cairo_quartz_surface_get_cg_context (cairo_surface_t *surface);
#if CAIRO_HAS_QUARTZ_FONT
#endif /* CAIRO_HAS_QUARTZ_SURFACE */
/*
* Quartz font support
*/
#if defined(CAIRO_HAS_QUARTZ_FONT)
cairo_public cairo_font_face_t *
cairo_quartz_font_face_create_for_cgfont (CGFontRef font);
#endif /* CAIRO_HAS_QUARTZ_FONT */
#if defined(CAIRO_HAS_APPLICATION_SERVICES)
cairo_public cairo_font_face_t *
cairo_quartz_font_face_create_for_atsu_font_id (ATSUFontID font_id);
#endif /* CAIRO_HAS_QUARTZ_FONT */
#endif /* CAIRO_HAS_APPLICATION_SERVICES */
CAIRO_END_DECLS
#else
# error Cairo was not compiled with support for the quartz backend
#endif /* CAIRO_HAS_QUARTZ_SURFACE */
#endif /* CAIRO_QUARTZ_H */