project: use cairo_surface_t when possible

We can avoid an entire roundtrip from surface > pixbuf > surface
if we simply pass the surface to GtkImage. We also save quite
a bunch of debug lines.
This commit is contained in:
Georges Basile Stavracas Neto
2017-03-17 10:14:25 -03:00
parent 478db350e3
commit cf6cdfd2aa
8 changed files with 59 additions and 59 deletions
+10 -19
View File
@@ -187,13 +187,12 @@ gcal_get_month_name (gint i)
*
* Returns: (Transfer full): An instance of {@link GdkPixbuf} to be freed with g_object_unref()
**/
GdkPixbuf*
gcal_get_pixbuf_from_color (GdkRGBA *color,
gint size)
cairo_surface_t*
gcal_get_surface_from_color (GdkRGBA *color,
gint size)
{
cairo_surface_t *surface;
cairo_t *cr;
GdkPixbuf *pix;
/* TODO: review size here, maybe not hardcoded */
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, size, size);
@@ -207,22 +206,17 @@ gcal_get_pixbuf_from_color (GdkRGBA *color,
cairo_rectangle (cr, 0, 0, size, size);
cairo_fill (cr);
cairo_destroy (cr);
pix = gdk_pixbuf_get_from_surface (surface,
0, 0,
size, size);
cairo_surface_destroy (surface);
return pix;
return surface;
}
GdkPixbuf*
get_circle_pixbuf_from_color (GdkRGBA *color,
gint size)
cairo_surface_t*
get_circle_surface_from_color (GdkRGBA *color,
gint size)
{
cairo_surface_t *surface;
cairo_t *cr;
GdkPixbuf *pix;
/* TODO: review size here, maybe not hardcoded */
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, size, size);
cr = cairo_create (surface);
@@ -234,11 +228,8 @@ get_circle_pixbuf_from_color (GdkRGBA *color,
cairo_arc (cr, size / 2.0, size / 2.0, size / 2.0, 0., 2 * M_PI);
cairo_fill (cr);
cairo_destroy (cr);
pix = gdk_pixbuf_get_from_surface (surface,
0, 0,
size, size);
cairo_surface_destroy (surface);
return pix;
return surface;
}
void