Next: , Previous: Win32 Fonts, Up: Top


11 cairo_surface_t

Base class for surfaces

11.1 Overview

11.2 Usage

— Function: cairo-surface-create-similar (other <cairo-surface-t>) (content <cairo-content-t>) (width <int>) (height <int>) =>  (ret <cairo-surface-t>)

Create a new surface that is as compatible as possible with an existing surface. For example the new surface will have the same fallback resolution and font options as other. Generally, the new surface will also use the same backend as other, unless that is not possible for some reason. The type of the returned surface may be examined with cairo-surface-get-type.

Initially the surface contents are all 0 (transparent if contents have transparency, black otherwise.)

other
an existing surface used to select the backend of the new surface
content
the content for the new surface
width
width of the new surface, (in device-space units)
height
height of the new surface (in device-space units)
ret
a pointer to the newly allocated surface. The caller owns the surface and should call cairo_surface_destroy when done with it. This function always returns a valid pointer, but it will return a pointer to a "nil" surface if other is already in an error state or any other error occurs.
— Function: cairo-surface-finish (surface <cairo-surface-t>)

This function finishes the surface and drops all references to external resources. For example, for the Xlib backend it means that cairo will no longer access the drawable, which can be freed. After calling cairo-surface-finish the only valid operations on a surface are getting and setting user data and referencing and destroying it. Further drawing to the surface will not affect the surface but will instead trigger a CAIRO_STATUS_SURFACE_FINISHED error.

When the last call to cairo-surface-destroy decreases the reference count to zero, cairo will call cairo-surface-finish if it hasn't been called already, before freeing the resources associated with the surface.

surface
the <cairo-surface-t> to finish
— Function: cairo-surface-flush (surface <cairo-surface-t>)

Do any pending drawing for the surface and also restore any temporary modification's cairo has made to the surface's state. This function must be called before switching from drawing on the surface with cairo to drawing on it directly with native APIs. If the surface doesn't support direct access, then this function does nothing.

surface
a <cairo-surface-t>
— Function: cairo-surface-get-font-options (surface <cairo-surface-t>) (options <cairo-font-options-t>)

Retrieves the default font rendering options for the surface. This allows display surfaces to report the correct subpixel order for rendering on them, print surfaces to disable hinting of metrics and so forth. The result can then be used with cairo-scaled-font-create.

surface
a <cairo-surface-t>
options
a <cairo-font-options-t> object into which to store the retrieved options. All existing values are overwritten
— Function: cairo-surface-get-content (surface <cairo-surface-t>) =>  (ret <cairo-content-t>)

This function returns the content type of surface which indicates whether the surface contains color and/or alpha information. See <cairo-content-t>.

surface
a <cairo-surface-t>
ret
The content type of surface.

Since 1.2

— Function: cairo-surface-mark-dirty (surface <cairo-surface-t>)

Tells cairo that drawing has been done to surface using means other than cairo, and that cairo should reread any cached areas. Note that you must call cairo-surface-flush before doing such drawing.

surface
a <cairo-surface-t>
— Function: cairo-surface-mark-dirty-rectangle (surface <cairo-surface-t>) (<int>) (<int>) (width <int>) (height <int>)

Like cairo-surface-mark-dirty, but drawing has been done only to the specified rectangle, so that cairo can retain cached contents for other parts of the surface.

Any cached clip set on the surface will be reset by this function, to make sure that future cairo calls have the clip set that they expect.

surface
a <cairo-surface-t>
x
X coordinate of dirty rectangle
y
Y coordinate of dirty rectangle
width
width of dirty rectangle
height
height of dirty rectangle
— Function: cairo-surface-set-device-offset (surface <cairo-surface-t>) (x-offset <double>) (y-offset <double>)

Sets an offset that is added to the device coordinates determined by the CTM when drawing to surface. One use case for this function is when we want to create a <cairo-surface-t> that redirects drawing for a portion of an onscreen surface to an offscreen surface in a way that is completely invisible to the user of the cairo API. Setting a transformation via cairo-translate isn't sufficient to do this, since functions like cairo-device-to-user will expose the hidden offset.

Note that the offset affects drawing to the surface as well as using the surface in a source pattern.

surface
a <cairo-surface-t>
x-offset
the offset in the X direction, in device units
y-offset
the offset in the Y direction, in device units
— Function: cairo-surface-get-device-offset (surface <cairo-surface-t>) =>  (x-offset <double>) (y-offset <double>)

This function returns the previous device offset set by cairo-surface-set-device-offset.

surface
a <cairo-surface-t>
x-offset
the offset in the X direction, in device units
y-offset
the offset in the Y direction, in device units

Since 1.2

— Function: cairo-surface-get-type (surface <cairo-surface-t>) =>  (ret <cairo-surface-type-t>)

This function returns the type of the backend used to create a surface. See <cairo-surface-type-t> for available types.

surface
a <cairo-surface-t>
ret
The type of surface.

Since 1.2