[librsvg] convert_no_alpha() - Removed; we only convert CAIRO_FORMAT_ARGB32 surfaces anyway



commit 87335856fbd2089cd1e9611ce63d29e0b41adcb6
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Dec 11 10:08:39 2018 -0600

    convert_no_alpha() - Removed; we only convert CAIRO_FORMAT_ARGB32 surfaces anyway

 librsvg/rsvg-pixbuf.c | 59 ++++++++++-----------------------------------------
 1 file changed, 11 insertions(+), 48 deletions(-)
---
diff --git a/librsvg/rsvg-pixbuf.c b/librsvg/rsvg-pixbuf.c
index dd78cff0..57877c32 100644
--- a/librsvg/rsvg-pixbuf.c
+++ b/librsvg/rsvg-pixbuf.c
@@ -270,69 +270,32 @@ convert_alpha (guchar *dest_data,
     }
 }
 
-static void
-convert_no_alpha (guchar *dest_data,
-                  int     dest_stride,
-                  guchar *src_data,
-                  int     src_stride,
-                  int     src_x,
-                  int     src_y,
-                  int     width,
-                  int     height)
-{
-    int x, y;
-
-    src_data += src_stride * src_y + src_x * 4;
-
-    for (y = 0; y < height; y++) {
-        guint32 *src = (guint32 *) src_data;
-
-        for (x = 0; x < width; x++) {
-            dest_data[x * 3 + 0] = src[x] >> 16;
-            dest_data[x * 3 + 1] = src[x] >>  8;
-            dest_data[x * 3 + 2] = src[x];
-        }
-
-        src_data += src_stride;
-        dest_data += dest_stride;
-    }
-}
-
 GdkPixbuf *
 rsvg_cairo_surface_to_pixbuf (cairo_surface_t *surface)
 {
-    cairo_content_t content;
     GdkPixbuf *dest;
     int width, height;
 
     /* General sanity checks */
     g_assert (cairo_surface_get_type (surface) == CAIRO_SURFACE_TYPE_IMAGE);
+    g_assert (cairo_image_surface_get_format (surface) == CAIRO_FORMAT_ARGB32);
 
     width = cairo_image_surface_get_width (surface);
     height = cairo_image_surface_get_height (surface);
     if (width == 0 || height == 0)
         return NULL;
 
-    content = cairo_surface_get_content (surface) | CAIRO_CONTENT_COLOR;
     dest = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
-                          !!(content & CAIRO_CONTENT_ALPHA),
-                          8,
-                          width, height);
-
-    if (gdk_pixbuf_get_has_alpha (dest))
-      convert_alpha (gdk_pixbuf_get_pixels (dest),
-                    gdk_pixbuf_get_rowstride (dest),
-                    cairo_image_surface_get_data (surface),
-                    cairo_image_surface_get_stride (surface),
-                    0, 0,
-                    width, height);
-    else
-      convert_no_alpha (gdk_pixbuf_get_pixels (dest),
-                        gdk_pixbuf_get_rowstride (dest),
-                        cairo_image_surface_get_data (surface),
-                        cairo_image_surface_get_stride (surface),
-                        0, 0,
-                        width, height);
+                           TRUE,
+                           8,
+                           width, height);
+
+    convert_alpha (gdk_pixbuf_get_pixels (dest),
+                   gdk_pixbuf_get_rowstride (dest),
+                   cairo_image_surface_get_data (surface),
+                   cairo_image_surface_get_stride (surface),
+                   0, 0,
+                   width, height);
 
     return dest;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]