Change prototype to match cairo_set_source_surface().
2005-05-07 Owen Taylor <otaylor@redhat.com> * gdk/gdkpixbuf-render.c gdk/gdkpixbuf.h (gdk_pixbuf_set_as_cairo_source): Change prototype to match cairo_set_source_surface(). * gdk/gdkdraw.c gdk/gdkgc.c gdk/gdkpixbuf-render.c gdk/gdkwindow.c gtk/gtkhsv.c tests/testcairo.c.
This commit is contained in:
@ -1,3 +1,11 @@
|
|||||||
|
2005-05-07 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gdk/gdkpixbuf-render.c gdk/gdkpixbuf.h (gdk_pixbuf_set_as_cairo_source):
|
||||||
|
Change prototype to match cairo_set_source_surface().
|
||||||
|
|
||||||
|
* gdk/gdkdraw.c gdk/gdkgc.c gdk/gdkpixbuf-render.c gdk/gdkwindow.c
|
||||||
|
gtk/gtkhsv.c tests/testcairo.c.
|
||||||
|
|
||||||
2005-05-06 Federico Mena Quintero <federico@ximian.com>
|
2005-05-06 Federico Mena Quintero <federico@ximian.com>
|
||||||
|
|
||||||
Merged from gtk-2-6:
|
Merged from gtk-2-6:
|
||||||
|
|||||||
@ -1,3 +1,11 @@
|
|||||||
|
2005-05-07 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gdk/gdkpixbuf-render.c gdk/gdkpixbuf.h (gdk_pixbuf_set_as_cairo_source):
|
||||||
|
Change prototype to match cairo_set_source_surface().
|
||||||
|
|
||||||
|
* gdk/gdkdraw.c gdk/gdkgc.c gdk/gdkpixbuf-render.c gdk/gdkwindow.c
|
||||||
|
gtk/gtkhsv.c tests/testcairo.c.
|
||||||
|
|
||||||
2005-05-06 Federico Mena Quintero <federico@ximian.com>
|
2005-05-06 Federico Mena Quintero <federico@ximian.com>
|
||||||
|
|
||||||
Merged from gtk-2-6:
|
Merged from gtk-2-6:
|
||||||
|
|||||||
@ -1,3 +1,11 @@
|
|||||||
|
2005-05-07 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gdk/gdkpixbuf-render.c gdk/gdkpixbuf.h (gdk_pixbuf_set_as_cairo_source):
|
||||||
|
Change prototype to match cairo_set_source_surface().
|
||||||
|
|
||||||
|
* gdk/gdkdraw.c gdk/gdkgc.c gdk/gdkpixbuf-render.c gdk/gdkwindow.c
|
||||||
|
gtk/gtkhsv.c tests/testcairo.c.
|
||||||
|
|
||||||
2005-05-06 Federico Mena Quintero <federico@ximian.com>
|
2005-05-06 Federico Mena Quintero <federico@ximian.com>
|
||||||
|
|
||||||
Merged from gtk-2-6:
|
Merged from gtk-2-6:
|
||||||
|
|||||||
@ -884,16 +884,16 @@ real_draw_glyphs (GdkDrawable *drawable,
|
|||||||
|
|
||||||
if (matrix)
|
if (matrix)
|
||||||
{
|
{
|
||||||
cairo_matrix_t *cairo_matrix;
|
cairo_matrix_t cairo_matrix;
|
||||||
|
|
||||||
cairo_matrix = cairo_matrix_create ();
|
cairo_matrix.xx = matrix->xx;
|
||||||
cairo_matrix_set_affine (cairo_matrix,
|
cairo_matrix.yx = matrix->yx;
|
||||||
matrix->xx, matrix->yx,
|
cairo_matrix.xy = matrix->xy;
|
||||||
matrix->xy, matrix->yy,
|
cairo_matrix.yy = matrix->yy;
|
||||||
matrix->x0, matrix->y0);
|
cairo_matrix.x0 = matrix->x0;
|
||||||
|
cairo_matrix.y0 = matrix->y0;
|
||||||
|
|
||||||
cairo_set_matrix (cr, cairo_matrix);
|
cairo_set_matrix (cr, &cairo_matrix);
|
||||||
cairo_matrix_destroy (cairo_matrix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_move_to (cr, x, y);
|
cairo_move_to (cr, x, y);
|
||||||
@ -1304,11 +1304,9 @@ gdk_drawable_create_cairo_context (GdkDrawable *drawable)
|
|||||||
|
|
||||||
g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
|
g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
|
||||||
|
|
||||||
cr = cairo_create ();
|
|
||||||
|
|
||||||
surface = _gdk_drawable_ref_cairo_surface (drawable);
|
surface = _gdk_drawable_ref_cairo_surface (drawable);
|
||||||
if (surface)
|
cr = cairo_create (surface);
|
||||||
cairo_set_target_surface (cr, surface);
|
cairo_surface_destroy (surface);
|
||||||
|
|
||||||
return cr;
|
return cr;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1044,14 +1044,13 @@ make_stipple_tile_surface (cairo_t *cr,
|
|||||||
|
|
||||||
alpha_surface = _gdk_drawable_ref_cairo_surface (stipple);
|
alpha_surface = _gdk_drawable_ref_cairo_surface (stipple);
|
||||||
|
|
||||||
surface = cairo_surface_create_similar (cairo_get_target_surface (cr),
|
surface = cairo_surface_create_similar (cairo_get_target (cr),
|
||||||
CAIRO_FORMAT_ARGB32,
|
CAIRO_FORMAT_ARGB32,
|
||||||
width, height);
|
width, height);
|
||||||
|
|
||||||
tmp_cr = cairo_create ();
|
tmp_cr = cairo_create (surface);
|
||||||
cairo_set_target_surface (tmp_cr, surface);
|
|
||||||
|
|
||||||
cairo_set_operator (tmp_cr, CAIRO_OPERATOR_SRC);
|
cairo_set_operator (tmp_cr, CAIRO_OPERATOR_SOURCE);
|
||||||
|
|
||||||
if (background)
|
if (background)
|
||||||
gdk_cairo_set_source_color (tmp_cr, background);
|
gdk_cairo_set_source_color (tmp_cr, background);
|
||||||
|
|||||||
@ -333,14 +333,18 @@ gdk_pixbuf_render_pixmap_and_mask_for_colormap (GdkPixbuf *pixbuf,
|
|||||||
* gdk_pixbuf_set_as_cairo_source:
|
* gdk_pixbuf_set_as_cairo_source:
|
||||||
* @pixbuf: a #GdkPixbuf
|
* @pixbuf: a #GdkPixbuf
|
||||||
* @cr: a #Cairo context
|
* @cr: a #Cairo context
|
||||||
|
* @pixbuf_x: X coordinate of location to place upper left corner of @pixbuf
|
||||||
|
* @pixbuf_y: Y coordinate of location to place upper left corner of @pixbuf
|
||||||
*
|
*
|
||||||
* Sets the given pixbuf as the source pattern for the Cairo context.
|
* Sets the given pixbuf as the source pattern for the Cairo context.
|
||||||
* The pattern has an extend mode of %CAIRO_EXTEND_NONE and is aligned
|
* The pattern has an extend mode of %CAIRO_EXTEND_NONE and is aligned
|
||||||
* so that the origin of @pixbuf is at the current point.
|
* so that the origin of @pixbuf is @pixbuf_x, @pixbuf_y
|
||||||
**/
|
**/
|
||||||
void
|
void
|
||||||
gdk_pixbuf_set_as_cairo_source (GdkPixbuf *pixbuf,
|
gdk_pixbuf_set_as_cairo_source (GdkPixbuf *pixbuf,
|
||||||
cairo_t *cr)
|
cairo_t *cr,
|
||||||
|
double pixbuf_x,
|
||||||
|
double pixbuf_y)
|
||||||
{
|
{
|
||||||
gint width = gdk_pixbuf_get_width (pixbuf);
|
gint width = gdk_pixbuf_get_width (pixbuf);
|
||||||
gint height = gdk_pixbuf_get_height (pixbuf);
|
gint height = gdk_pixbuf_get_height (pixbuf);
|
||||||
@ -350,10 +354,7 @@ gdk_pixbuf_set_as_cairo_source (GdkPixbuf *pixbuf,
|
|||||||
guchar *cairo_pixels;
|
guchar *cairo_pixels;
|
||||||
cairo_format_t format;
|
cairo_format_t format;
|
||||||
cairo_surface_t *surface;
|
cairo_surface_t *surface;
|
||||||
cairo_pattern_t *pattern;
|
|
||||||
static const cairo_user_data_key_t key;
|
static const cairo_user_data_key_t key;
|
||||||
cairo_matrix_t *matrix;
|
|
||||||
double x, y;
|
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
if (n_channels == 3)
|
if (n_channels == 3)
|
||||||
@ -424,17 +425,7 @@ gdk_pixbuf_set_as_cairo_source (GdkPixbuf *pixbuf,
|
|||||||
cairo_pixels += 4 * width;
|
cairo_pixels += 4 * width;
|
||||||
}
|
}
|
||||||
|
|
||||||
pattern = cairo_pattern_create_for_surface (surface);
|
cairo_set_source_surface (cr, surface, pixbuf_x, pixbuf_y);
|
||||||
cairo_surface_destroy (surface);
|
|
||||||
|
|
||||||
cairo_current_point (cr, &x, &y);
|
|
||||||
matrix = cairo_matrix_create ();
|
|
||||||
cairo_matrix_translate (matrix, -x, -y);
|
|
||||||
cairo_pattern_set_matrix (pattern, matrix);
|
|
||||||
cairo_matrix_destroy (matrix);
|
|
||||||
|
|
||||||
cairo_set_source (cr, pattern);
|
|
||||||
cairo_pattern_destroy (pattern);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define __GDK_PIXBUF_RENDER_C__
|
#define __GDK_PIXBUF_RENDER_C__
|
||||||
|
|||||||
@ -81,7 +81,9 @@ GdkPixbuf *gdk_pixbuf_get_from_image (GdkPixbuf *dest,
|
|||||||
int height);
|
int height);
|
||||||
|
|
||||||
void gdk_pixbuf_set_as_cairo_source (GdkPixbuf *pixbuf,
|
void gdk_pixbuf_set_as_cairo_source (GdkPixbuf *pixbuf,
|
||||||
cairo_t *cr);
|
cairo_t *cr,
|
||||||
|
double pixbuf_x,
|
||||||
|
double pixbuf_y);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|||||||
@ -1748,10 +1748,9 @@ gdk_window_set_bg_pattern (GdkWindow *window,
|
|||||||
|
|
||||||
if (x_offset != 0 || y_offset)
|
if (x_offset != 0 || y_offset)
|
||||||
{
|
{
|
||||||
cairo_matrix_t *matrix = cairo_matrix_create ();
|
cairo_matrix_t matrix;
|
||||||
cairo_matrix_translate (matrix, x_offset, y_offset);
|
cairo_matrix_init_translate (&matrix, x_offset, y_offset);
|
||||||
cairo_pattern_set_matrix (pattern, matrix);
|
cairo_pattern_set_matrix (pattern, &matrix);
|
||||||
cairo_matrix_destroy (matrix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
|
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
|
||||||
@ -1795,8 +1794,7 @@ gdk_window_clear_backing_rect (GdkWindow *window,
|
|||||||
if (GDK_WINDOW_DESTROYED (window))
|
if (GDK_WINDOW_DESTROYED (window))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cr = cairo_create ();
|
cr = cairo_create (paint->surface);
|
||||||
cairo_set_target_surface (cr, paint->surface);
|
|
||||||
|
|
||||||
gdk_window_set_bg_pattern (window, cr, 0, 0);
|
gdk_window_set_bg_pattern (window, cr, 0, 0);
|
||||||
|
|
||||||
|
|||||||
29
gtk/gtkhsv.c
29
gtk/gtkhsv.c
@ -917,26 +917,6 @@ gtk_hsv_motion (GtkWidget *widget,
|
|||||||
|
|
||||||
/* Redrawing */
|
/* Redrawing */
|
||||||
|
|
||||||
static void
|
|
||||||
set_source_surface (cairo_t *cr,
|
|
||||||
cairo_surface_t *surface)
|
|
||||||
{
|
|
||||||
cairo_pattern_t *pattern;
|
|
||||||
cairo_matrix_t *matrix;
|
|
||||||
double x, y;
|
|
||||||
|
|
||||||
pattern = cairo_pattern_create_for_surface (surface);
|
|
||||||
|
|
||||||
cairo_current_point (cr, &x, &y);
|
|
||||||
matrix = cairo_matrix_create ();
|
|
||||||
cairo_matrix_translate (matrix, -x, -y);
|
|
||||||
cairo_pattern_set_matrix (pattern, matrix);
|
|
||||||
cairo_matrix_destroy (matrix);
|
|
||||||
|
|
||||||
cairo_set_source (cr, pattern);
|
|
||||||
cairo_pattern_destroy (pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Paints the hue ring */
|
/* Paints the hue ring */
|
||||||
static void
|
static void
|
||||||
paint_ring (GtkHSV *hsv,
|
paint_ring (GtkHSV *hsv,
|
||||||
@ -1018,8 +998,7 @@ paint_ring (GtkHSV *hsv,
|
|||||||
/* Now draw the value marker onto the source image, so that it
|
/* Now draw the value marker onto the source image, so that it
|
||||||
* will get properly clipped at the edges of the ring
|
* will get properly clipped at the edges of the ring
|
||||||
*/
|
*/
|
||||||
source_cr = cairo_create ();
|
source_cr = cairo_create (source);
|
||||||
cairo_set_target_surface (source_cr, source);
|
|
||||||
|
|
||||||
r = priv->h;
|
r = priv->h;
|
||||||
g = 1.0;
|
g = 1.0;
|
||||||
@ -1042,8 +1021,7 @@ paint_ring (GtkHSV *hsv,
|
|||||||
|
|
||||||
cairo_save (cr);
|
cairo_save (cr);
|
||||||
|
|
||||||
cairo_move_to (cr, x, y);
|
cairo_set_source_surface (cr, source, x, y);
|
||||||
set_source_surface (cr, source);
|
|
||||||
cairo_surface_destroy (source);
|
cairo_surface_destroy (source);
|
||||||
|
|
||||||
cairo_set_line_width (cr, priv->ring_width);
|
cairo_set_line_width (cr, priv->ring_width);
|
||||||
@ -1220,8 +1198,7 @@ paint_triangle (GtkHSV *hsv,
|
|||||||
|
|
||||||
/* Draw a triangle with the image as a source */
|
/* Draw a triangle with the image as a source */
|
||||||
|
|
||||||
cairo_move_to (cr, x, y);
|
cairo_set_source_surface (cr, source, x, y);
|
||||||
set_source_surface (cr, source);
|
|
||||||
cairo_surface_destroy (source);
|
cairo_surface_destroy (source);
|
||||||
|
|
||||||
cairo_move_to (cr, x1, y1);
|
cairo_move_to (cr, x1, y1);
|
||||||
|
|||||||
@ -29,10 +29,7 @@ oval_path (cairo_t *cr,
|
|||||||
double xc, double yc,
|
double xc, double yc,
|
||||||
double xr, double yr)
|
double xr, double yr)
|
||||||
{
|
{
|
||||||
cairo_matrix_t *matrix;
|
cairo_save (cr);
|
||||||
|
|
||||||
matrix = cairo_matrix_create ();
|
|
||||||
cairo_current_matrix (cr, matrix);
|
|
||||||
|
|
||||||
cairo_translate (cr, xc, yc);
|
cairo_translate (cr, xc, yc);
|
||||||
cairo_scale (cr, 1.0, yr / xr);
|
cairo_scale (cr, 1.0, yr / xr);
|
||||||
@ -43,8 +40,7 @@ oval_path (cairo_t *cr,
|
|||||||
0, 2 * G_PI);
|
0, 2 * G_PI);
|
||||||
cairo_close_path (cr);
|
cairo_close_path (cr);
|
||||||
|
|
||||||
cairo_set_matrix (cr, matrix);
|
cairo_restore (cr);
|
||||||
cairo_matrix_destroy (matrix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a path that is a circular oval with radii xr, yr at xc,
|
/* Create a path that is a circular oval with radii xr, yr at xc,
|
||||||
@ -125,25 +121,26 @@ draw (cairo_t *cr,
|
|||||||
int height)
|
int height)
|
||||||
{
|
{
|
||||||
cairo_surface_t *overlay, *punch, *circles;
|
cairo_surface_t *overlay, *punch, *circles;
|
||||||
|
cairo_t *overlay_cr, *punch_cr, *circles_cr;
|
||||||
|
|
||||||
/* Fill the background */
|
/* Fill the background */
|
||||||
double radius = 0.5 * (width < height ? width : height) - 10;
|
double radius = 0.5 * (width < height ? width : height) - 10;
|
||||||
double xc = width / 2.;
|
double xc = width / 2.;
|
||||||
double yc = height / 2.;
|
double yc = height / 2.;
|
||||||
|
|
||||||
overlay = cairo_surface_create_similar (cairo_current_target_surface (cr),
|
overlay = cairo_surface_create_similar (cairo_get_target (cr),
|
||||||
CAIRO_FORMAT_ARGB32,
|
CAIRO_FORMAT_ARGB32,
|
||||||
width, height);
|
width, height);
|
||||||
if (overlay == NULL)
|
if (overlay == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
punch = cairo_surface_create_similar (cairo_current_target_surface (cr),
|
punch = cairo_surface_create_similar (cairo_get_target (cr),
|
||||||
CAIRO_FORMAT_A8,
|
CAIRO_FORMAT_A8,
|
||||||
width, height);
|
width, height);
|
||||||
if (punch == NULL)
|
if (punch == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
circles = cairo_surface_create_similar (cairo_current_target_surface (cr),
|
circles = cairo_surface_create_similar (cairo_get_target (cr),
|
||||||
CAIRO_FORMAT_ARGB32,
|
CAIRO_FORMAT_ARGB32,
|
||||||
width, height);
|
width, height);
|
||||||
if (circles == NULL)
|
if (circles == NULL)
|
||||||
@ -151,47 +148,39 @@ draw (cairo_t *cr,
|
|||||||
|
|
||||||
fill_checks (cr, 0, 0, width, height);
|
fill_checks (cr, 0, 0, width, height);
|
||||||
|
|
||||||
cairo_save (cr);
|
|
||||||
cairo_set_target_surface (cr, overlay);
|
|
||||||
cairo_identity_matrix (cr);
|
|
||||||
|
|
||||||
/* Draw a black circle on the overlay
|
/* Draw a black circle on the overlay
|
||||||
*/
|
*/
|
||||||
cairo_set_source_rgb (cr, 0., 0., 0.);
|
overlay_cr = cairo_create (overlay);
|
||||||
oval_path (cr, xc, yc, radius, radius);
|
cairo_set_source_rgb (overlay_cr, 0., 0., 0.);
|
||||||
cairo_fill (cr);
|
oval_path (overlay_cr, xc, yc, radius, radius);
|
||||||
|
cairo_fill (overlay_cr);
|
||||||
cairo_save (cr);
|
|
||||||
cairo_set_target_surface (cr, punch);
|
|
||||||
|
|
||||||
/* Draw 3 circles to the punch surface, then cut
|
/* Draw 3 circles to the punch surface, then cut
|
||||||
* that out of the main circle in the overlay
|
* that out of the main circle in the overlay
|
||||||
*/
|
*/
|
||||||
draw_3circles (cr, xc, yc, radius, 1.0);
|
punch_cr = cairo_create (punch);
|
||||||
|
draw_3circles (punch_cr, xc, yc, radius, 1.0);
|
||||||
|
cairo_destroy (punch_cr);
|
||||||
|
|
||||||
cairo_restore (cr);
|
cairo_set_operator (overlay_cr, CAIRO_OPERATOR_DEST_OUT);
|
||||||
|
cairo_set_source_surface (overlay_cr, punch, 0, 0);
|
||||||
cairo_set_operator (cr, CAIRO_OPERATOR_OUT_REVERSE);
|
cairo_paint (overlay_cr);
|
||||||
cairo_set_source_surface (cr, punch, 0, 0);
|
|
||||||
cairo_paint (cr);
|
|
||||||
|
|
||||||
/* Now draw the 3 circles in a subgroup again
|
/* Now draw the 3 circles in a subgroup again
|
||||||
* at half intensity, and use OperatorAdd to join up
|
* at half intensity, and use OperatorAdd to join up
|
||||||
* without seams.
|
* without seams.
|
||||||
*/
|
*/
|
||||||
cairo_save (cr);
|
circles_cr = cairo_create (circles);
|
||||||
cairo_set_target_surface (cr, circles);
|
|
||||||
|
cairo_set_operator (circles_cr, CAIRO_OPERATOR_OVER);
|
||||||
|
draw_3circles (circles_cr, xc, yc, radius, 0.5);
|
||||||
|
cairo_destroy (circles_cr);
|
||||||
|
|
||||||
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
|
cairo_set_operator (overlay_cr, CAIRO_OPERATOR_ADD);
|
||||||
draw_3circles (cr, xc, yc, radius, 0.5);
|
cairo_set_source_surface (overlay_cr, circles, 0, 0);
|
||||||
|
cairo_paint (overlay_cr);
|
||||||
|
|
||||||
cairo_restore (cr);
|
cairo_destroy (overlay_cr);
|
||||||
|
|
||||||
cairo_set_operator (cr, CAIRO_OPERATOR_ADD);
|
|
||||||
cairo_set_source_surface (cr, circles, 0, 0);
|
|
||||||
cairo_paint (cr);
|
|
||||||
|
|
||||||
cairo_restore (cr);
|
|
||||||
|
|
||||||
cairo_set_source_surface (cr, overlay, 0, 0);
|
cairo_set_source_surface (cr, overlay, 0, 0);
|
||||||
cairo_paint (cr);
|
cairo_paint (cr);
|
||||||
|
|||||||
Reference in New Issue
Block a user