[librsvg] Don't export private function _rsvg_size_callback



commit ac8d26c9c6b7f5f86fa8600f6daf4e5f356f3190
Author: Christian Persch <chpe gnome org>
Date:   Thu Jan 26 19:33:02 2012 +0100

    Don't export private function _rsvg_size_callback
    
    Move it to its own file, and include that in rsvg-convert and the tests.

 Makefile.am          |   10 ++++-
 librsvg.def          |    1 -
 rsvg-convert.c       |    1 +
 rsvg-file-util.c     |   80 +-------------------------------------
 rsvg-private.h       |   21 +----------
 rsvg-size-callback.c |  103 ++++++++++++++++++++++++++++++++++++++++++++++++++
 rsvg-size-callback.h |   52 +++++++++++++++++++++++++
 test-display.c       |    1 +
 tests/Makefile.am    |    4 +-
 tests/rsvg-test.c    |    1 +
 10 files changed, 172 insertions(+), 102 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index c94fe31..2053259 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -65,6 +65,8 @@ librsvg_ RSVG_API_MAJOR_VERSION@_la_SOURCES = \
 	rsvg.c			\
 	rsvg-gobject.c		\
 	rsvg-file-util.c	\
+	rsvg-size-callback.c	\
+	rsvg-size-callback.h	\
 	rsvg-xml.c		\
 	rsvg-xml.h		\
 	rsvg.h			\
@@ -108,7 +110,10 @@ dist_man_MANS = rsvg.1
 endif
 
 rsvg_convert_SOURCES = \
-	rsvg-convert.c
+	rsvg-convert.c \
+	rsvg-size-callback.c \
+	rsvg-size-callback.h \
+	$(NULL)
 
 rsvg_convert_CPPFLAGS = \
 	-I$(top_srcdir) 			\
@@ -129,7 +134,8 @@ rsvg_convert_LDADD = \
 	$(LIBM)
 
 rsvg_view_3_SOURCES = \
-	test-display.c
+	test-display.c \
+	rsvg-size-callback.h
 
 rsvg_view_3_CPPFLAGS = \
 	-I$(top_srcdir) 			\
diff --git a/librsvg.def b/librsvg.def
index 79373ee..b58f831 100644
--- a/librsvg.def
+++ b/librsvg.def
@@ -34,7 +34,6 @@ rsvg_pixbuf_from_file_at_zoom_with_max
 rsvg_handle_render_cairo
 rsvg_handle_render_cairo_sub
 rsvg_handle_get_type
-_rsvg_size_callback
 _rsvg_register_types
 rsvg_defs_lookup
 rsvg_pixbuf_from_data_with_size_data
diff --git a/rsvg-convert.c b/rsvg-convert.c
index 60f59ed..f26fd87 100644
--- a/rsvg-convert.c
+++ b/rsvg-convert.c
@@ -39,6 +39,7 @@
 #include "rsvg.h"
 #include "rsvg-cairo.h"
 #include "rsvg-private.h"
+#include "rsvg-size-callback.h"
 
 #ifdef CAIRO_HAS_PS_SURFACE
 #include <cairo-ps.h>
diff --git a/rsvg-file-util.c b/rsvg-file-util.c
index 39cfe2b..8636b07 100644
--- a/rsvg-file-util.c
+++ b/rsvg-file-util.c
@@ -37,95 +37,19 @@
 #include "rsvg.h"
 #include "rsvg-private.h"
 #include "rsvg-io.h"
+#include "rsvg-size-callback.h"
 
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <math.h>
 
 #define SVG_BUFFER_SIZE (1024 * 8)
 
-void
-_rsvg_size_callback (int *width, int *height, gpointer data)
-{
-    struct RsvgSizeCallbackData *real_data = (struct RsvgSizeCallbackData *) data;
-    double zoomx, zoomy, zoom;
-
-    int in_width, in_height;
-
-    in_width = *width;
-    in_height = *height;
-
-    switch (real_data->type) {
-    case RSVG_SIZE_ZOOM:
-        if (*width < 0 || *height < 0)
-            return;
-
-        *width = floor (real_data->x_zoom * *width + 0.5);
-        *height = floor (real_data->y_zoom * *height + 0.5);
-        break;
-
-    case RSVG_SIZE_ZOOM_MAX:
-        if (*width < 0 || *height < 0)
-            return;
-
-        *width = floor (real_data->x_zoom * *width + 0.5);
-        *height = floor (real_data->y_zoom * *height + 0.5);
-
-        if (*width > real_data->width || *height > real_data->height) {
-            zoomx = (double) real_data->width / *width;
-            zoomy = (double) real_data->height / *height;
-            zoom = MIN (zoomx, zoomy);
-
-            *width = floor (zoom * *width + 0.5);
-            *height = floor (zoom * *height + 0.5);
-        }
-        break;
-
-    case RSVG_SIZE_WH_MAX:
-        if (*width < 0 || *height < 0)
-            return;
-
-        zoomx = (double) real_data->width / *width;
-        zoomy = (double) real_data->height / *height;
-        if (zoomx < 0)
-            zoom = zoomy;
-        else if (zoomy < 0)
-            zoom = zoomx;
-        else
-            zoom = MIN (zoomx, zoomy);
-
-        *width = floor (zoom * *width + 0.5);
-        *height = floor (zoom * *height + 0.5);
-        break;
-
-    case RSVG_SIZE_WH:
-        if (real_data->width != -1)
-            *width = real_data->width;
-        if (real_data->height != -1)
-            *height = real_data->height;
-        break;
-
-    default:
-        g_assert_not_reached ();
-    }
-
-    if (real_data->keep_aspect_ratio) {
-        int out_min = MIN (*width, *height);
-
-        if (out_min == *width) {
-            *height = in_height * ((double) *width / (double) in_width);
-        } else {
-            *width = in_width * ((double) *height / (double) in_height);
-        }
-    }
-}
-
 /* private */
 GdkPixbuf *
 rsvg_pixbuf_from_data_with_size_data (const guchar * buff,
                                       size_t len,
-                                      struct RsvgSizeCallbackData *data,
+                                      /* RsvgSizeCallbackData */ gpointer data,
                                       const char *base_uri, GError ** error)
 {
     RsvgHandle *handle;
diff --git a/rsvg-private.h b/rsvg-private.h
index eaaae2d..c524948 100644
--- a/rsvg-private.h
+++ b/rsvg-private.h
@@ -248,28 +248,9 @@ typedef struct {
 } RsvgBbox;
 
 typedef enum {
-    RSVG_SIZE_ZOOM,
-    RSVG_SIZE_WH,
-    RSVG_SIZE_WH_MAX,
-    RSVG_SIZE_ZOOM_MAX
-} RsvgSizeType;
-
-typedef enum {
     objectBoundingBox, userSpaceOnUse
 } RsvgCoordUnits;
 
-struct RsvgSizeCallbackData {
-    RsvgSizeType type;
-    double x_zoom;
-    double y_zoom;
-    gint width;
-    gint height;
-
-    gboolean keep_aspect_ratio;
-};
-
-void _rsvg_size_callback (int *width, int *height, gpointer data);
-
 typedef enum {
     RSVG_NODE_TYPE_INVALID = 0,
 
@@ -355,7 +336,7 @@ void                 rsvg_property_bag_enumerate (RsvgPropertyBag * bag, RsvgPro
 
 GdkPixbuf *rsvg_pixbuf_from_data_with_size_data (const guchar * buff,
                                                  size_t len,
-                                                 struct RsvgSizeCallbackData *data,
+                                                 gpointer data,
                                                  const char *base_uri, GError ** error);
 
 gboolean     rsvg_eval_switch_attributes	(RsvgPropertyBag * atts, gboolean * p_has_cond);
diff --git a/rsvg-size-callback.c b/rsvg-size-callback.c
new file mode 100644
index 0000000..d8a114f
--- /dev/null
+++ b/rsvg-size-callback.c
@@ -0,0 +1,103 @@
+/*
+   Copyright (C) 2000 Eazel, Inc.
+   Copyright (C) 2002 Dom Lachowicz <cinamod hotmail com>
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with this program; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.
+
+   Author: Raph Levien <raph artofcode com>
+*/
+
+#include "config.h"
+
+#include "rsvg-size-callback.h"
+
+#include <math.h>
+
+void
+_rsvg_size_callback (int *width, int *height, gpointer data)
+{
+    struct RsvgSizeCallbackData *real_data = (struct RsvgSizeCallbackData *) data;
+    double zoomx, zoomy, zoom;
+
+    int in_width, in_height;
+
+    in_width = *width;
+    in_height = *height;
+
+    switch (real_data->type) {
+    case RSVG_SIZE_ZOOM:
+        if (*width < 0 || *height < 0)
+            return;
+
+        *width = floor (real_data->x_zoom * *width + 0.5);
+        *height = floor (real_data->y_zoom * *height + 0.5);
+        break;
+
+    case RSVG_SIZE_ZOOM_MAX:
+        if (*width < 0 || *height < 0)
+            return;
+
+        *width = floor (real_data->x_zoom * *width + 0.5);
+        *height = floor (real_data->y_zoom * *height + 0.5);
+
+        if (*width > real_data->width || *height > real_data->height) {
+            zoomx = (double) real_data->width / *width;
+            zoomy = (double) real_data->height / *height;
+            zoom = MIN (zoomx, zoomy);
+
+            *width = floor (zoom * *width + 0.5);
+            *height = floor (zoom * *height + 0.5);
+        }
+        break;
+
+    case RSVG_SIZE_WH_MAX:
+        if (*width < 0 || *height < 0)
+            return;
+
+        zoomx = (double) real_data->width / *width;
+        zoomy = (double) real_data->height / *height;
+        if (zoomx < 0)
+            zoom = zoomy;
+        else if (zoomy < 0)
+            zoom = zoomx;
+        else
+            zoom = MIN (zoomx, zoomy);
+
+        *width = floor (zoom * *width + 0.5);
+        *height = floor (zoom * *height + 0.5);
+        break;
+
+    case RSVG_SIZE_WH:
+        if (real_data->width != -1)
+            *width = real_data->width;
+        if (real_data->height != -1)
+            *height = real_data->height;
+        break;
+
+    default:
+        g_assert_not_reached ();
+    }
+
+    if (real_data->keep_aspect_ratio) {
+        int out_min = MIN (*width, *height);
+
+        if (out_min == *width) {
+            *height = in_height * ((double) *width / (double) in_width);
+        } else {
+            *width = in_width * ((double) *height / (double) in_height);
+        }
+    }
+}
diff --git a/rsvg-size-callback.h b/rsvg-size-callback.h
new file mode 100644
index 0000000..70507d0
--- /dev/null
+++ b/rsvg-size-callback.h
@@ -0,0 +1,52 @@
+/*
+   Copyright (C) 2000 Eazel, Inc.
+   Copyright (C) 2002 Dom Lachowicz <cinamod hotmail com>
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with this program; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.
+
+   Author: Raph Levien <raph artofcode com>
+*/
+
+#ifndef RSVG_SIZE_CALLBACK_H
+#define RSVG_SIZE_CALLBACK_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+typedef enum {
+    RSVG_SIZE_ZOOM,
+    RSVG_SIZE_WH,
+    RSVG_SIZE_WH_MAX,
+    RSVG_SIZE_ZOOM_MAX
+} RsvgSizeType;
+
+struct RsvgSizeCallbackData {
+    RsvgSizeType type;
+    double x_zoom;
+    double y_zoom;
+    gint width;
+    gint height;
+
+    gboolean keep_aspect_ratio;
+};
+
+G_GNUC_INTERNAL
+void _rsvg_size_callback (int *width, int *height, gpointer data);
+
+G_END_DECLS
+
+#endif /* RSVG_SIZE_CALLBACK_H */
diff --git a/test-display.c b/test-display.c
index 3f86768..073719d 100644
--- a/test-display.c
+++ b/test-display.c
@@ -21,6 +21,7 @@
 #include "rsvg.h"
 #include "rsvg-cairo.h"
 #include "rsvg-private.h"
+#include "rsvg-size-callback.h"
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3b9f2cf..4ea1eb4 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -30,7 +30,9 @@ DISTCLEANFILES = rsvg-test.html			\
 
 libtest_utils_la_SOURCES = 				\
 	test-utils.c	   				\
-	test-utils.h
+	test-utils.h					\
+	$(top_srcdir)/rsvg-size-callback.c		\
+	$(top_srcdir)/rsvg-size-callback.h
 
 EXTRA_DIST =						\
 	fixtures/crash/bug620238.svg			\
diff --git a/tests/rsvg-test.c b/tests/rsvg-test.c
index e2b8aee..60183d2 100644
--- a/tests/rsvg-test.c
+++ b/tests/rsvg-test.c
@@ -42,6 +42,7 @@
 #include "rsvg.h"
 #include "rsvg-cairo.h"
 #include "rsvg-private.h"
+#include "rsvg-size-callback.h"
 
 #include "pdiff.h"
 



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