Quartz Surfaces

Quartz Surfaces — Rendering to Quartz surfaces

Synopsis




cairo_surface_t*    cairo_quartz_surface_create         (cairo_format_t format,
                                                         unsigned int width,
                                                         unsigned int height);
cairo_surface_t*    cairo_quartz_surface_create_for_cg_context
                                                        (CGContextRef cgContext,
                                                         unsigned int width,
                                                         unsigned int height);
CGContextRef        cairo_quartz_surface_get_cg_context (cairo_surface_t *surface);
cairo_surface_t*    cairo_quartz_image_surface_create   (cairo_surface_t *image_surface);
cairo_surface_t*    cairo_quartz_image_surface_get_image
                                                        (cairo_surface_t *surface);

Description

The Quartz surface is used to render cairo graphics targeting the Apple OS X Quartz rendering system.

Details

cairo_quartz_surface_create ()

cairo_surface_t*    cairo_quartz_surface_create         (cairo_format_t format,
                                                         unsigned int width,
                                                         unsigned int height);

Creates a Quartz surface backed by a CGBitmap. The surface is created using the Device RGB (or Device Gray, for A8) color space. All Cairo operations, including those that require software rendering, will succeed on this surface.

format :

format of pixels in the surface to create

width :

width of the surface, in pixels

height :

height of the surface, in pixels

Returns :

the newly created surface.

Since 1.4


cairo_quartz_surface_create_for_cg_context ()

cairo_surface_t*    cairo_quartz_surface_create_for_cg_context
                                                        (CGContextRef cgContext,
                                                         unsigned int width,
                                                         unsigned int height);

Creates a Quartz surface that wraps the given CGContext. The CGContext is assumed to be in the QuickDraw coordinate space (that is, with the origin at the upper left and the Y axis increasing downward.) If the CGContext is in the Quartz coordinate space (with the origin at the bottom left), then it should be flipped before this function is called:

CGContextTranslateCTM (cgContext, 0.0, height);
CGContextScaleCTM (cgContext, 1.0, -1.0);

A very small number of Cairo operations cannot be translated to Quartz operations; those operations will fail on this surface. If all Cairo operations are required to succeed, consider rendering to a surface created by cairo_quartz_surface_create() and then copying the result to the CGContext.

cgContext :

the existing CGContext for which to create the surface

width :

width of the surface, in pixels

height :

height of the surface, in pixels

Returns :

the newly created Cairo surface.

Since 1.4


cairo_quartz_surface_get_cg_context ()

CGContextRef        cairo_quartz_surface_get_cg_context (cairo_surface_t *surface);

Returns the CGContextRef that the given Quartz surface is backed by.

surface :

the Cairo Quartz surface

Returns :

the CGContextRef for the given surface.

Since 1.4


cairo_quartz_image_surface_create ()

cairo_surface_t*    cairo_quartz_image_surface_create   (cairo_surface_t *image_surface);

Creates a Quartz surface backed by a CGImageRef that references the given image surface. The resulting surface can be rendered quickly when used as a source when rendering to a cairo_quartz_surface. If the data in the image surface is ever updated, cairo_surface_flush() must be called on the cairo_quartz_image_surface to ensure that the CGImageRef refers to the updated data.

image_surface :

Returns :

the newly created surface.

Since 1.6


cairo_quartz_image_surface_get_image ()

cairo_surface_t*    cairo_quartz_image_surface_get_image
                                                        (cairo_surface_t *surface);

surface :

Returns :

See Also