
@c %start of fragment

@deffn Function cairo-surface-create-similar  (@var{other}@tie{}@code{<cairo-surface-t>}) (@var{content}@tie{}@code{<cairo-content-t>}) (@var{width}@tie{}@code{<int>}) (@var{height}@tie{}@code{<int>}) @result{}@tie{} (@var{ret}@tie{}@code{<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 @var{other}. Generally, the new surface
will also use the same backend as @var{other}, unless that is not
possible for some reason. The type of the returned surface may be
examined with @code{cairo-surface-get-type}.

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

@table @var
@item other
an existing surface used to select the backend of the new surface

@item content
the content for the new surface

@item width
width of the new surface, (in device-space units)

@item height
height of the new surface (in device-space units)

@item ret
a pointer to the newly allocated surface. The caller owns the surface
and should call @code{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 @var{other} is already in an error state or any other
error occurs.

@end table

@end deffn

@deffn Function cairo-surface-create-for-rectangle  (@var{target}@tie{}@code{<cairo-surface-t>}) (@var{x}@tie{}@code{<double>}) (@var{y}@tie{}@code{<double>}) (@var{width}@tie{}@code{<double>}) (@var{height}@tie{}@code{<double>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-surface-t >})
Create a new surface that is a rectangle within the target surface. All
operations drawn to this surface are then clipped and translated onto
the target surface. Nothing drawn via this sub-surface outside of its
bounds is drawn onto the target surface, making this a useful method for
passing constrained child surfaces to library routines that draw
directly onto the parent surface, i.e. with no further backend
allocations, double buffering or copies.

The semantics of subsurfaces have not been finalized yet unless the
rectangle is in full device units, is contained within the extents of
the target surface, and the target or subsurface's device transforms are
not changed.

@table @var
@item target
an existing surface for which the sub-surface will point to

@item x
the x-origin of the sub-surface from the top-left of the target surface
(in device-space units)

@item y
the y-origin of the sub-surface from the top-left of the target surface
(in device-space units)

@item width
width of the sub-surface (in device-space units)

@item height
height of the sub-surface (in device-space units)

@item ret
a pointer to the newly allocated surface. The caller owns the surface
and should call @code{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 @var{other} is already in an error state or any other
error occurs.

@end table

Since 1.10

@end deffn

@deffn Function cairo-surface-finish  (@var{surface}@tie{}@code{<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
@code{cairo-surface-finish} the only valid operations on a surface are
getting and setting user, referencing and destroying, and flushing and
finishing it. Further drawing to the surface will not affect the surface
but will instead trigger a @samp{CAIRO_STATUS_SURFACE_FINISHED} error.

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

@table @var
@item surface
the @code{<cairo-surface-t>} to finish

@end table

@end deffn

@deffn Function cairo-surface-flush  (@var{surface}@tie{}@code{<cairo-surface-t>})
Do any pending drawing for the surface and also restore any temporary
modifications 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.

@table @var
@item surface
a @code{<cairo-surface-t>}

@end table

@end deffn

@deffn Function cairo-surface-get-device  (@var{surface}@tie{}@code{<cairo-surface-t>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-device-t >})
This function returns the device for a @var{surface}. See
@code{<cairo-device-t>}.

@table @var
@item surface
a @code{<cairo-surface-t>}

@item ret
The device for @var{surface} or @samp{@code{#f}} if the surface does not
have an associated device.

@end table

Since 1.10

@end deffn

@deffn Function cairo-surface-get-font-options  (@var{surface}@tie{}@code{<cairo-surface-t>}) (@var{options}@tie{}@code{<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 @code{cairo-scaled-font-create}.

@table @var
@item surface
a @code{<cairo-surface-t>}

@item options
a @code{<cairo-font-options-t>} object into which to store the retrieved
options. All existing values are overwritten

@end table

@end deffn

@deffn Function cairo-surface-get-content  (@var{surface}@tie{}@code{<cairo-surface-t>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-content-t>})
This function returns the content type of @var{surface} which indicates
whether the surface contains color and/or alpha information. See
@code{<cairo-content-t>}.

@table @var
@item surface
a @code{<cairo-surface-t>}

@item ret
The content type of @var{surface}.

@end table

Since 1.2

@end deffn

@deffn Function cairo-surface-mark-dirty  (@var{surface}@tie{}@code{<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 @code{cairo-surface-flush} before doing such drawing.

@table @var
@item surface
a @code{<cairo-surface-t>}

@end table

@end deffn

@deffn Function cairo-surface-mark-dirty-rectangle  (@var{surface}@tie{}@code{<cairo-surface-t>}) (@var{x}@tie{}@code{<int>}) (@var{y}@tie{}@code{<int>}) (@var{width}@tie{}@code{<int>}) (@var{height}@tie{}@code{<int>})
Like @code{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.

@table @var
@item surface
a @code{<cairo-surface-t>}

@item x
X coordinate of dirty rectangle

@item y
Y coordinate of dirty rectangle

@item width
width of dirty rectangle

@item height
height of dirty rectangle

@end table

@end deffn

@deffn Function cairo-surface-set-device-offset  (@var{surface}@tie{}@code{<cairo-surface-t>}) (@var{x-offset}@tie{}@code{<double>}) (@var{y-offset}@tie{}@code{<double>})
Sets an offset that is added to the device coordinates determined by the
CTM when drawing to @var{surface}. One use case for this function is
when we want to create a @code{<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 @code{cairo-translate} isn't sufficient to do this,
since functions like @code{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.

@table @var
@item surface
a @code{<cairo-surface-t>}

@item x-offset
the offset in the X direction, in device units

@item y-offset
the offset in the Y direction, in device units

@end table

@end deffn

@deffn Function cairo-surface-get-device-offset  (@var{surface}@tie{}@code{<cairo-surface-t>}) @result{}@tie{} (@var{x-offset}@tie{}@code{<double>}) (@var{y-offset}@tie{}@code{<double>})
This function returns the previous device offset set by
@code{cairo-surface-set-device-offset}.

@table @var
@item surface
a @code{<cairo-surface-t>}

@item x-offset
the offset in the X direction, in device units

@item y-offset
the offset in the Y direction, in device units

@end table

Since 1.2

@end deffn

@deffn Function cairo-surface-get-type  (@var{surface}@tie{}@code{<cairo-surface-t>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-surface-type-t>})
This function returns the type of the backend used to create a surface.
See @code{<cairo-surface-type-t>} for available types.

@table @var
@item surface
a @code{<cairo-surface-t>}

@item ret
The type of @var{surface}.

@end table

Since 1.2

@end deffn

@deffn Function cairo-surface-copy-page  (@var{surface}@tie{}@code{<cairo-surface-t>})
Emits the current page for backends that support multiple pages, but
doesn't clear it, so that the contents of the current page will be
retained for the next page. Use @code{cairo-surface-show-page} if you
want to get an empty page after the emission.

There is a convenience function for this that takes a @code{<cairo-t>},
namely @code{cairo-copy-page}.

@table @var
@item surface
a @code{<cairo-surface-t>}

@end table

Since 1.6

@end deffn

@deffn Function cairo-surface-show-page  (@var{surface}@tie{}@code{<cairo-surface-t>})
Emits and clears the current page for backends that support multiple
pages. Use @code{cairo-surface-copy-page} if you don't want to clear the
page.

There is a convenience function for this that takes a @code{<cairo-t>},
namely @code{cairo-show-page}.

@table @var
@item surface
a @code{<cairo--surface-t>}

@end table

Since 1.6

@end deffn

@deffn Function cairo-surface-has-show-text-glyphs  (@var{surface}@tie{}@code{<cairo-surface-t>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-bool-t>})
Returns whether the surface supports sophisticated
@code{cairo-show-text-glyphs} operations. That is, whether it actually
uses the provided text and cluster data to a
@code{cairo-show-text-glyphs} call.

Note: Even if this function returns @samp{@code{#f}}, a
@code{cairo-show-text-glyphs} operation targeted at @var{surface} will
still succeed. It just will act like a @code{cairo-show-glyphs}
operation. Users can use this function to avoid computing UTF-8 text and
cluster mapping if the target surface does not use it.

@table @var
@item surface
a @code{<cairo-surface-t>}

@item ret
@samp{@code{#t}} if @var{surface} supports
@code{cairo-show-text-glyphs}, @samp{@code{#f}} otherwise

@end table

Since 1.8

@end deffn

@deffn Function cairo-surface-get-mime-data (@var{surface}@tie{}@code{<cairo-surface-t>}) (@var{mime-type}@tie{}@code{<string>}) @result{}@tie{} (@var{ret}@tie{}@code{<bytevector>})
Return data previously associated with the surface with the given
@var{mime-type}.

@table @var
@item surface
a @code{<cairo-surface-t>}

@item mime-type
a string denoting the MIME type, for example @code{"image/jpeg"},
@code{"image/png"}, @code{"image/jp2"}, or @code{"text/x-uri"}

@item ret
@code{#f} if no data was associated with the surface, otherwise a
fresh bytevector holding a copy of the data

@end table

Since 1.11

@end deffn

@deffn Function cairo-surface-set-mime-data (@var{surface}@tie{}@code{<cairo-surface-t>}) (@var{mime-type}@tie{}@code{<string>}) (@var{data}@tie{}@code{<bytevector>})
Associate image data with a surface with the given @var{mime-type}.

Attach an image in the format @var{mime_type} to @var{surface}. To
remove the data from a surface, call this function with same mime type
and @code{#f} for @var{data}.

The attached image (or filename) data can later be used by backends
which support it (currently: PDF, PS, SVG and Win32 Printing surfaces)
to emit this data instead of making a snapshot of the @var{surface}.
This approach tends to be faster and requires less memory and disk
space.

See corresponding backend surface docs for details about which MIME
types it can handle. Caution: the associated MIME data will be
discarded if you draw on the surface afterwards. Use this function
with care.

Even if a backend supports a MIME type, that does not mean cairo
will always be able to use the attached MIME data. For example, if
the backend does not natively support the compositing operation used
to apply the MIME data to the backend. In that case, the MIME data
will be ignored. Therefore, to apply an image in all cases, it is best
to create an image surface which contains the decoded image data and
then attach the MIME data to that. This ensures the image will always
be used while still allowing the MIME data to be used whenever
possible.

@table @var
@item surface
a @code{<cairo-surface-t>}

@item mime-type
a string denoting the MIME type, for example @code{"image/jpeg"},
@code{"image/png"}, @code{"image/jp2"}, or @code{"text/x-uri"}

@item data
a bytevector of data to associate with the surface, or @code{#f} to
remove the association

@end table

Since 1.11

@end deffn

@c %end of fragment
