* Boston, MA 02111-1307, USA.
*/
-#include "gdkcairo.h"
+#include "config.h"
-#include <math.h>
+#include "gdkcairo.h"
-#include "gdkdrawable.h"
#include "gdkinternals.h"
+#include <math.h>
/**
* SECTION:cairo_interaction
*
* <link href="http://cairographics.org">Cairo</link> is a graphics
* library that supports vector graphics and image compositing that
- * can be used with GDK. Since 2.8, GTK+ does most of its drawing
- * using Cairo.
+ * can be used with GDK. GTK+ does all of its drawing using Cairo.
*
* GDK does not wrap the Cairo API, instead it allows to create Cairo
- * contexts which can be used to draw on #GdkDrawables. Additional
- * functions allow to convert GDK's rectangles and regions into
- * Cairo paths and to use pixbufs as sources for drawing operations.
+ * contexts which can be used to draw on #GdkWindows. Additional
+ * functions allow use #GdkRectangles with cairo and to use #GdkColors,
+ * #GdkPixbufs and #GdkWindows as sources for drawing operations.
*/
-/**
- * gdk_cairo_create:
- * @drawable: a #GdkDrawable
- *
- * Creates a Cairo context for drawing to @drawable.
- *
- * <note><para>
- * Note that due to double-buffering, Cairo contexts created
- * in a GTK+ expose event handler cannot be cached and reused
- * between different expose events.
- * </para></note>
- *
- * Return value: A newly created Cairo context. Free with
- * cairo_destroy() when you are done drawing.
- *
- * Since: 2.8
- **/
-cairo_t *
-gdk_cairo_create (GdkDrawable *drawable)
-{
- cairo_surface_t *surface;
- cairo_t *cr;
-
- g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
-
- surface = _gdk_drawable_ref_cairo_surface (drawable);
- cr = cairo_create (surface);
-
- if (GDK_DRAWABLE_GET_CLASS (drawable)->set_cairo_clip)
- GDK_DRAWABLE_GET_CLASS (drawable)->set_cairo_clip (drawable, cr);
-
- cairo_surface_destroy (surface);
-
- return cr;
-}
-
-/**
- * gdk_cairo_reset_clip:
- * @cr: a #cairo_t
- * @drawable: a #GdkDrawable
- *
- * Resets the clip region for a Cairo context created by gdk_cairo_create().
- *
- * This resets the clip region to the "empty" state for the given drawable.
- * This is required for non-native windows since a direct call to
- * cairo_reset_clip() would unset the clip region inherited from the
- * drawable (i.e. the window clip region), and thus let you e.g.
- * draw outside your window.
- *
- * This is rarely needed though, since most code just create a new cairo_t
- * using gdk_cairo_create() each time they want to draw something.
- *
- * Since: 2.18
- **/
-void
-gdk_cairo_reset_clip (cairo_t *cr,
- GdkDrawable *drawable)
-{
- cairo_reset_clip (cr);
-
- if (GDK_DRAWABLE_GET_CLASS (drawable)->set_cairo_clip)
- GDK_DRAWABLE_GET_CLASS (drawable)->set_cairo_clip (drawable, cr);
-}
-
/**
* gdk_cairo_get_clip_rectangle:
* @cr: a cairo context
* gdk_cairo_set_source_color:
* @cr: a #cairo_t
* @color: a #GdkColor
- *
+ *
* Sets the specified #GdkColor as the source color of @cr.
*
* Since: 2.8
color->blue / 65535.);
}
+/**
+ * gdk_cairo_set_source_rgba:
+ * @cr: a #cairo_t
+ * @rgba: a #GdkRGBA
+ *
+ * Sets the specified #GdkRGBA as the source color of @cr.
+ *
+ * Since: 3.0
+ **/
+void
+gdk_cairo_set_source_rgba (cairo_t *cr,
+ const GdkRGBA *rgba)
+{
+ g_return_if_fail (cr != NULL);
+ g_return_if_fail (rgba != NULL);
+
+ cairo_set_source_rgba (cr,
+ rgba->red,
+ rgba->green,
+ rgba->blue,
+ rgba->alpha);
+}
+
/**
* gdk_cairo_rectangle:
* @cr: a #cairo_t
g_return_if_fail (cr != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
- surface = _gdk_drawable_ref_cairo_surface (GDK_DRAWABLE (window));
+ surface = _gdk_window_ref_cairo_surface (window);
cairo_set_source_surface (cr, surface, x, y);
cairo_surface_destroy (surface);
}
cr = cairo_create (surface);
cairo_clip_extents (cr, &x1, &y1, &x2, &y2);
+ cairo_destroy (cr);
x1 = floor (x1);
y1 = floor (y1);
* is more than 50% opaque. This function takes into account device
* offsets that might be set with cairo_surface_set_device_offset().
*
- * Returns: A new region
- **/
+ * Returns: A #cairo_region_t. This must be freed with cairo_region_destroy()
+ * when you are done.
+ */
cairo_region_t *
gdk_cairo_region_create_from_surface (cairo_surface_t *surface)
{