| 1 |
|
| 2 |
@c %start of fragment |
| 3 |
|
| 4 |
@node cairo_surface_t |
| 5 |
@chapter cairo_surface_t |
| 6 |
Base class for surfaces |
| 7 |
|
| 8 |
@section Overview |
| 9 |
@code{<cairo-surface>} is the abstract type representing all different |
| 10 |
drawing targets that cairo can render to. The actual drawings are |
| 11 |
performed using a cairo @dfn{context}. |
| 12 |
|
| 13 |
A cairo surface is created by using @dfn{backend}-specific constructors, |
| 14 |
typically of the form cairo_@emph{backend}@code{-surface-create}. |
| 15 |
|
| 16 |
Most surface types allow accessing the surface without using Cairo |
| 17 |
functions. If you do this, keep in mind that it is mandatory that you |
| 18 |
call @code{cairo-surface-flush} before reading from or writing to the |
| 19 |
surface and that you must use @code{cairo-surface-mark-dirty} after |
| 20 |
modifying it. Note that for other surface types it might be necessary to |
| 21 |
acquire the surface's device first. See @code{cairo-device-acquire} for |
| 22 |
a discussion of devices. |
| 23 |
|
| 24 |
@c (title "Directly modifying an image surface") |
| 25 |
@example |
| 26 |
|
| 27 |
void |
| 28 |
modify_image_surface (cairo_surface_t *surface) |
| 29 |
@{ |
| 30 |
unsigned char *data; |
| 31 |
int width, height, stride; |
| 32 |
|
| 33 |
// flush to ensure all writing to the image was done |
| 34 |
cairo_surface_flush (surface); |
| 35 |
|
| 36 |
// modify the image |
| 37 |
data = cairo_image_surface_get_data (surface); |
| 38 |
width = cairo_image_surface_get_width (surface); |
| 39 |
height = cairo_image_surface_get_height (surface); |
| 40 |
stride = cairo_image_surface_get_stride (surface); |
| 41 |
modify_image_data (data, width, height, stride); |
| 42 |
|
| 43 |
// mark the image dirty so Cairo clears its caches. |
| 44 |
cairo_surface_mark_dirty (surface); |
| 45 |
@} |
| 46 |
@end example |
| 47 |
|
| 48 |
@section Usage |
| 49 |
@include defuns-cairo-surface.xml.texi |
| 50 |
|
| 51 |
@c %end of fragment |