Top |
Functions
cairo_surface_t * | gdk_surface_create_similar_surface () |
void | gdk_cairo_set_source_rgba () |
void | gdk_cairo_set_source_pixbuf () |
void | gdk_cairo_rectangle () |
void | gdk_cairo_region () |
cairo_region_t * | gdk_cairo_region_create_from_surface () |
void | gdk_cairo_draw_from_gl () |
Description
Cairo is a graphics library that supports vector graphics and image compositing that can be used with GDK and GTK.
GDK does not wrap the cairo API, instead it allows to create cairo contexts which can be used to draw on GdkSurfaces. Additional functions allow use GdkRectangles with cairo and to use GdkRGBAs, GdkPixbufs and GdkSurfaces as sources for drawing operations.
Functions
gdk_surface_create_similar_surface ()
cairo_surface_t * gdk_surface_create_similar_surface (GdkSurface *surface
,cairo_content_t content
,int width
,int height
);
Create a new surface that is as compatible as possible with the
given surface
. For example the new surface will have the same
fallback resolution and font options as surface
. Generally, the new
surface will also use the same backend as surface
, 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.)
Parameters
surface |
surface to make new surface similar to |
|
content |
the content for the new surface |
|
width |
width of the new surface |
|
height |
height of the new surface |
Returns
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.
gdk_cairo_set_source_rgba ()
void gdk_cairo_set_source_rgba (cairo_t *cr
,const GdkRGBA *rgba
);
Sets the specified GdkRGBA as the source color of cr
.
gdk_cairo_set_source_pixbuf ()
void gdk_cairo_set_source_pixbuf (cairo_t *cr
,const GdkPixbuf *pixbuf
,double pixbuf_x
,double pixbuf_y
);
Sets the given pixbuf as the source pattern for cr
.
The pattern has an extend mode of CAIRO_EXTEND_NONE
and is aligned
so that the origin of pixbuf
is pixbuf_x
, pixbuf_y
.
gdk_cairo_rectangle ()
void gdk_cairo_rectangle (cairo_t *cr
,const GdkRectangle *rectangle
);
Adds the given rectangle to the current path of cr
.
gdk_cairo_region ()
void gdk_cairo_region (cairo_t *cr
,const cairo_region_t *region
);
Adds the given region to the current path of cr
.
gdk_cairo_region_create_from_surface ()
cairo_region_t *
gdk_cairo_region_create_from_surface (cairo_surface_t *surface
);
Creates region that describes covers the area where the given
surface
is more than 50% opaque.
This function takes into account device offsets that might be
set with cairo_surface_set_device_offset()
.
gdk_cairo_draw_from_gl ()
void gdk_cairo_draw_from_gl (cairo_t *cr
,GdkSurface *surface
,int source
,int source_type
,int buffer_scale
,int x
,int y
,int width
,int height
);
This is the main way to draw GL content in GTK. It takes a render buffer ID
(source_type
== GL_RENDERBUFFER) or a texture id (source_type
== GL_TEXTURE)
and draws it onto cr
with an OVER operation, respecting the current clip.
The top left corner of the rectangle specified by x
, y
, width
and height
will be drawn at the current (0,0) position of the cairo_t.
This will work for *all* cairo_t, as long as surface
is realized, but the
fallback implementation that reads back the pixels from the buffer may be
used in the general case. In the case of direct drawing to a surface with
no special effects applied to cr
it will however use a more efficient
approach.
For GL_RENDERBUFFER the code will always fall back to software for buffers with alpha components, so make sure you use GL_TEXTURE if using alpha.
Calling this may change the current GL context.
Parameters
cr |
a cairo context |
|
surface |
The surface we're rendering for (not necessarily into) |
|
source |
The GL ID of the source buffer |
|
source_type |
The type of the |
|
buffer_scale |
The scale-factor that the |
|
x |
The source x position in |
|
y |
The source y position in |
|
width |
The width of the region to draw |
|
height |
The height of the region to draw |