[aisleriot] Remove GdkPixbuf rendering



commit fd6f09ba7750afa923c2419b165cf1f084768001
Author: Christian Persch <chpe gnome org>
Date:   Mon Apr 25 17:57:58 2011 +0200

    Remove GdkPixbuf rendering
    
    Only the cairo rendering is used, so remove the obsolete code.

 src/lib/ar-card-theme-kde.c |   54 -------------------
 src/lib/ar-card-theme-svg.c |   50 -----------------
 src/lib/ar-preimage.c       |  124 -------------------------------------------
 src/lib/ar-preimage.h       |   11 ----
 4 files changed, 0 insertions(+), 239 deletions(-)
---
diff --git a/src/lib/ar-card-theme-kde.c b/src/lib/ar-card-theme-kde.c
index 9edb00c..d4499fe 100644
--- a/src/lib/ar-card-theme-kde.c
+++ b/src/lib/ar-card-theme-kde.c
@@ -312,59 +312,6 @@ ar_card_theme_kde_get_card_aspect (ArCardTheme* card_theme)
   return card_extents->width / card_extents->height;
 }
 
-static GdkPixbuf *
-ar_card_theme_kde_get_card_pixbuf (ArCardTheme *card_theme,
-                                   int card_id)
-{
-  ArCardThemePreimage *preimage_card_theme = (ArCardThemePreimage *) card_theme;
-  ArCardThemeKDE *theme = (ArCardThemeKDE *) card_theme;
-  ArPreimage *preimage = preimage_card_theme->cards_preimage;
-  GdkPixbuf *subpixbuf;
-  double card_width, card_height;
-  double width, height;
-  double zoomx, zoomy;
-  char node[32];
-  cairo_rectangle_t *card_extents;
-
-  if (G_UNLIKELY (card_id == AR_CARD_SLOT)) {
-    subpixbuf = ar_preimage_render (preimage_card_theme->slot_preimage,
-                                       preimage_card_theme->card_size.width,
-                                       preimage_card_theme->card_size.height);
-
-    return subpixbuf;
-  }
-
-  ar_card_get_node_by_id_snprintf (node, sizeof (node), card_id);
-
-  card_extents = ar_card_theme_kde_get_card_extents (theme, card_id, node);
-  if (!card_extents)
-    return NULL;
-
-  card_width = ((double) ar_preimage_get_width (preimage)) / N_COLS;
-  card_height = ((double) ar_preimage_get_height (preimage)) / N_ROWS;
-
-  width = preimage_card_theme->card_size.width;
-  height = preimage_card_theme->card_size.height;
-
-  zoomx = width / card_width;
-  zoomy = height / card_height;
-
-//   zoomx = width / card_extents->width;
-//   zoomy = height / card_extents->height;
-
-  subpixbuf = ar_preimage_render_sub (preimage,
-                                         node,
-                                         preimage_card_theme->card_size.width,
-                                         preimage_card_theme->card_size.height,
-                                         -card_extents->x, -card_extents->y,
-                                         zoomx, zoomy);
-
-  ar_debug_print (AR_DEBUG_CARD_THEME,
-                      "Returning %p\n", subpixbuf);
-
-  return subpixbuf;
-}
-
 static void
 ar_card_theme_kde_paint_card (ArCardTheme *card_theme,
                               cairo_t *cr,
@@ -570,7 +517,6 @@ ar_card_theme_kde_class_init (ArCardThemeKDEClass * klass)
 
   theme_class->load = ar_card_theme_kde_load;
   theme_class->get_card_aspect = ar_card_theme_kde_get_card_aspect;
-  theme_class->get_card_pixbuf = ar_card_theme_kde_get_card_pixbuf;
   theme_class->paint_card = ar_card_theme_kde_paint_card;
 
   g_object_class_install_property
diff --git a/src/lib/ar-card-theme-svg.c b/src/lib/ar-card-theme-svg.c
index ad2d059..5f83cce 100644
--- a/src/lib/ar-card-theme-svg.c
+++ b/src/lib/ar-card-theme-svg.c
@@ -50,55 +50,6 @@ struct _ArCardThemeSVG {
 
 G_DEFINE_TYPE (ArCardThemeSVG, ar_card_theme_svg, AR_TYPE_CARD_THEME_PREIMAGE);
 
-static GdkPixbuf *
-ar_card_theme_svg_get_card_pixbuf (ArCardTheme *card_theme,
-                                      int card_id)
-{
-  ArCardThemePreimage *preimage_card_theme = (ArCardThemePreimage *) card_theme;
-  ArPreimage *preimage = preimage_card_theme->cards_preimage;
-  GdkPixbuf *subpixbuf;
-  int suit, rank;
-  double card_width, card_height;
-  double width, height;
-  double offsetx, offsety;
-  double zoomx, zoomy;
-  char node[32];
-
-  if (G_UNLIKELY (card_id == AR_CARD_SLOT)) {
-    subpixbuf = ar_preimage_render (preimage_card_theme->slot_preimage,
-                                       preimage_card_theme->card_size.width,
-                                       preimage_card_theme->card_size.height);
-
-    return subpixbuf;
-  }
-
-  suit = card_id / 13;
-  rank = card_id % 13;
-
-  card_width = ((double) ar_preimage_get_width (preimage)) / N_COLS;
-  card_height = ((double) ar_preimage_get_height (preimage)) / N_ROWS;
-
-  width = preimage_card_theme->card_size.width - 2 * DELTA;
-  height = preimage_card_theme->card_size.height - 2 * DELTA;
-
-  offsetx = -((double) rank) * card_width + DELTA;
-  offsety = -((double) suit) * card_height + DELTA;
-
-  zoomx = width / card_width;
-  zoomy = height / card_height;
-
-  ar_card_get_node_by_suit_and_rank_snprintf (node, sizeof (node), suit, rank);
-
-  subpixbuf = ar_preimage_render_sub (preimage,
-                                         node,
-                                         preimage_card_theme->card_size.width,
-                                         preimage_card_theme->card_size.height,
-                                         offsetx, offsety,
-                                         zoomx, zoomy);
-
-  return subpixbuf;
-}
-
 static void
 ar_card_theme_svg_paint_card (ArCardTheme *card_theme,
                               cairo_t *cr,
@@ -202,7 +153,6 @@ ar_card_theme_svg_class_init (ArCardThemeSVGClass * klass)
   theme_class->get_theme_info = ar_card_theme_svg_class_get_theme_info;
   theme_class->foreach_theme_dir = ar_card_theme_svg_class_foreach_theme_dir;
 
-  theme_class->get_card_pixbuf = ar_card_theme_svg_get_card_pixbuf;
   theme_class->paint_card = ar_card_theme_svg_paint_card;
 }
 
diff --git a/src/lib/ar-preimage.c b/src/lib/ar-preimage.c
index 5d2b3fc..9ab4899 100644
--- a/src/lib/ar-preimage.c
+++ b/src/lib/ar-preimage.c
@@ -73,38 +73,6 @@ ar_preimage_class_init (ArPreimageClass * klass)
 }
 
 /**
- * ar_preimage_render:
- * @preimage: the image to render
- * @width: the desired width
- * @height: the desired height
- *
- * Creates a #GdkPixbuf from @preimage's image at the specified
- * @width and @height.
- *
- * Returns: (transfer full): the new #GdkPixbuf
- **/
-GdkPixbuf *
-ar_preimage_render (ArPreimage * preimage, gint width, gint height)
-{
-  GdkPixbuf *pixbuf;
-
-  g_return_val_if_fail (width > 0 && height > 0, NULL);
-  g_return_val_if_fail (preimage != NULL, NULL);
-
-    pixbuf = ar_preimage_render_sub (preimage,
-                                        NULL,
-                                        width,
-                                        height,
-                                        0.0, 0.0,
-                                        ((double) width) /
-                                        ((double) preimage->width),
-                                        ((double) height) /
-                                        ((double) preimage->height));
-
-  return pixbuf;
-}
-
-/**
  * ar_preimage_render_cairo:
  * @preimage:
  * @cr:
@@ -135,40 +103,6 @@ ar_preimage_render_cairo (ArPreimage * preimage,
                                      ((double) preimage->height));
 }
 
-/* This routine is copied from librsvg:
-   Copyright © 2005 Dom Lachowicz <cinamod hotmail com>
-   Copyright © 2005 Caleb Moore <c moore student unsw edu au>
-   Copyright © 2005 Red Hat, Inc.
- */
-static void
-cairo_pixels_to_pixbuf (guint8 * pixels, int rowstride, int height)
-{
-  int row;
-
-  /* un-premultiply data */
-  for (row = 0; row < height; row++) {
-    guint8 *row_data = (pixels + (row * rowstride));
-    int i;
-
-    for (i = 0; i < rowstride; i += 4) {
-      guint8 *b = &row_data[i];
-      guint32 pixel;
-      guint8 alpha;
-
-      memcpy (&pixel, b, sizeof (guint32));
-      alpha = (pixel & 0xff000000) >> 24;
-      if (alpha == 0) {
-        b[0] = b[1] = b[2] = b[3] = 0;
-      } else {
-        b[0] = (((pixel & 0xff0000) >> 16) * 255 + alpha / 2) / alpha;
-        b[1] = (((pixel & 0x00ff00) >> 8) * 255 + alpha / 2) / alpha;
-        b[2] = (((pixel & 0x0000ff) >> 0) * 255 + alpha / 2) / alpha;
-        b[3] = alpha;
-      }
-    }
-  }
-}
-
 /**
  * ar_preimage_render_cairo_sub:
  * @preimage:
@@ -221,64 +155,6 @@ ar_preimage_render_cairo_sub (ArPreimage * preimage,
 }
 
 /**
- * ar_preimage_render_sub:
- * @preimage:
- * @node: a SVG node ID (starting with "#"), or %NULL
- * @width: the width of the clip region
- * @height: the height of the clip region
- * @xoffset: the x offset of the clip region
- * @yoffset: the y offset of the clip region
- * @xzoom: the x zoom factor
- * @yzoom: the y zoom factor
- *
- * Creates a #GdkPixbuf with the dimensions @width by @height,
- * and renders the subimage of @preimage specified by @node to it,
- * transformed by @xzoom, @yzoom and offset by @xoffset and @yoffset,
- * clipped to @width and @height.
- * If @node is NULL, the whole image is rendered into tha clip region.
- *
- * Returns: (transfer full) (allow-none): a new #GdkPixbuf, or %NULL if there was an error or @preimage
- * isn't a scalable SVG image
- */
-GdkPixbuf *
-ar_preimage_render_sub (ArPreimage * preimage,
-                           const char *node,
-                           int width,
-                           int height,
-                           double xoffset,
-                           double yoffset, double xzoom, double yzoom)
-{
-  int rowstride;
-  guint8 *data;
-  cairo_surface_t *surface;
-  cairo_t *cr;
-
-  rowstride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, width);
-
-  data = g_try_malloc0 (rowstride * height);
-  if (!data)
-    return NULL;
-
-  surface = cairo_image_surface_create_for_data (data,
-                                                 CAIRO_FORMAT_ARGB32,
-                                                 width, height, rowstride);
-  cr = cairo_create (surface);
-  ar_preimage_render_cairo_sub (preimage, cr, node, width, height,
-                                   xoffset, yoffset, xzoom, yzoom);
-  cairo_destroy (cr);
-  cairo_surface_destroy (surface);
-  cairo_pixels_to_pixbuf (data, rowstride, height);
-
-  return gdk_pixbuf_new_from_data (data,
-                                   GDK_COLORSPACE_RGB,
-                                   TRUE,
-                                   8,
-                                   width, height,
-                                   rowstride,
-                                   (GdkPixbufDestroyNotify) g_free, data);
-}
-
-/**
  * ar_preimage_new_from_file:
  * @filename:
  * @error: a location for a #GError
diff --git a/src/lib/ar-preimage.h b/src/lib/ar-preimage.h
index 1d6b14d..187c85c 100644
--- a/src/lib/ar-preimage.h
+++ b/src/lib/ar-preimage.h
@@ -51,22 +51,11 @@ ArPreimage *ar_preimage_new_from_file (const gchar * filename,
 void ar_preimage_set_font_options (ArPreimage * preimage,
                                       const cairo_font_options_t *font_options);
 
-GdkPixbuf *ar_preimage_render (ArPreimage * preimage,
-                                  gint width,
-                                  gint height);
 void ar_preimage_render_cairo (ArPreimage * preimage,
                                   cairo_t *cr,
                                   gint width,
                                   gint height);
 
-GdkPixbuf *ar_preimage_render_sub (ArPreimage * preimage,
-                                      const char *node,
-                                      int width,
-                                      int height,
-                                      double xoffset,
-                                      double yoffset,
-                                      double xzoom, double yzoom);
-
 void ar_preimage_render_cairo_sub (ArPreimage * preimage,
                                       cairo_t *cr,
                                       const char *node,



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