Commit e00163d2 authored by Emmanuel Pacaud's avatar Emmanuel Pacaud Committed by Emmanuel Pacaud

Indentation fix, using: indent -kr -nut -pcs -psl -i4 -l100

2007-01-12  Emmanuel Pacaud <emmanuel.pacaud@lapp.in2p3.fr>

	Indentation fix, using: indent -kr -nut -pcs -psl -i4 -l100


svn path=/trunk/; revision=1088
parent 26b00e86
2007-01-12 Emmanuel Pacaud <emmanuel.pacaud@lapp.in2p3.fr>
Indentation fix, using: indent -kr -nut -pcs -psl -i4 -l100
2007-01-12 Emmanuel Pacaud <emmanuel.pacaud@lapp.in2p3.fr>
Add support for porterduff comp-op operators and for enable-background.
......
#include "librsvg-features.h"
/* General initialization hooks */
const unsigned int librsvg_major_version=LIBRSVG_MAJOR_VERSION,
librsvg_minor_version=LIBRSVG_MINOR_VERSION,
librsvg_micro_version=LIBRSVG_MICRO_VERSION;
const unsigned int librsvg_major_version = LIBRSVG_MAJOR_VERSION,
librsvg_minor_version = LIBRSVG_MINOR_VERSION, librsvg_micro_version = LIBRSVG_MICRO_VERSION;
const char *librsvg_version = LIBRSVG_VERSION;
......@@ -40,15 +40,15 @@
void
_rsvg_affine_invert (double dst[6], const double src[6])
{
double r_det;
double r_det;
r_det = 1.0 / (src[0] * src[3] - src[1] * src[2]);
dst[0] = src[3] * r_det;
dst[1] = -src[1] * r_det;
dst[2] = -src[2] * r_det;
dst[3] = src[0] * r_det;
dst[4] = -src[4] * dst[0] - src[5] * dst[2];
dst[5] = -src[4] * dst[1] - src[5] * dst[3];
r_det = 1.0 / (src[0] * src[3] - src[1] * src[2]);
dst[0] = src[3] * r_det;
dst[1] = -src[1] * r_det;
dst[2] = -src[2] * r_det;
dst[3] = src[0] * r_det;
dst[4] = -src[4] * dst[0] - src[5] * dst[2];
dst[5] = -src[4] * dst[1] - src[5] * dst[3];
}
/**
......@@ -66,12 +66,12 @@ _rsvg_affine_invert (double dst[6], const double src[6])
void
_rsvg_affine_flip (double dst_affine[6], const double src_affine[6], int horz, int vert)
{
dst_affine[0] = horz ? - src_affine[0] : src_affine[0];
dst_affine[1] = horz ? - src_affine[1] : src_affine[1];
dst_affine[2] = vert ? - src_affine[2] : src_affine[2];
dst_affine[3] = vert ? - src_affine[3] : src_affine[3];
dst_affine[4] = horz ? - src_affine[4] : src_affine[4];
dst_affine[5] = vert ? - src_affine[5] : src_affine[5];
dst_affine[0] = horz ? -src_affine[0] : src_affine[0];
dst_affine[1] = horz ? -src_affine[1] : src_affine[1];
dst_affine[2] = vert ? -src_affine[2] : src_affine[2];
dst_affine[3] = vert ? -src_affine[3] : src_affine[3];
dst_affine[4] = horz ? -src_affine[4] : src_affine[4];
dst_affine[5] = vert ? -src_affine[5] : src_affine[5];
}
#define EPSILON 1e-6
......@@ -92,20 +92,20 @@ _rsvg_affine_flip (double dst_affine[6], const double src_affine[6], int horz, i
void
_rsvg_affine_multiply (double dst[6], const double src1[6], const double src2[6])
{
double d0, d1, d2, d3, d4, d5;
double d0, d1, d2, d3, d4, d5;
d0 = src1[0] * src2[0] + src1[1] * src2[2];
d1 = src1[0] * src2[1] + src1[1] * src2[3];
d2 = src1[2] * src2[0] + src1[3] * src2[2];
d3 = src1[2] * src2[1] + src1[3] * src2[3];
d4 = src1[4] * src2[0] + src1[5] * src2[2] + src2[4];
d5 = src1[4] * src2[1] + src1[5] * src2[3] + src2[5];
dst[0] = d0;
dst[1] = d1;
dst[2] = d2;
dst[3] = d3;
dst[4] = d4;
dst[5] = d5;
d0 = src1[0] * src2[0] + src1[1] * src2[2];
d1 = src1[0] * src2[1] + src1[1] * src2[3];
d2 = src1[2] * src2[0] + src1[3] * src2[2];
d3 = src1[2] * src2[1] + src1[3] * src2[3];
d4 = src1[4] * src2[0] + src1[5] * src2[2] + src2[4];
d5 = src1[4] * src2[1] + src1[5] * src2[3] + src2[5];
dst[0] = d0;
dst[1] = d1;
dst[2] = d2;
dst[3] = d3;
dst[4] = d4;
dst[5] = d5;
}
/**
......@@ -117,12 +117,12 @@ _rsvg_affine_multiply (double dst[6], const double src1[6], const double src2[6]
void
_rsvg_affine_identity (double dst[6])
{
dst[0] = 1;
dst[1] = 0;
dst[2] = 0;
dst[3] = 1;
dst[4] = 0;
dst[5] = 0;
dst[0] = 1;
dst[1] = 0;
dst[2] = 0;
dst[3] = 1;
dst[4] = 0;
dst[5] = 0;
}
......@@ -137,12 +137,12 @@ _rsvg_affine_identity (double dst[6])
void
_rsvg_affine_scale (double dst[6], double sx, double sy)
{
dst[0] = sx;
dst[1] = 0;
dst[2] = 0;
dst[3] = sy;
dst[4] = 0;
dst[5] = 0;
dst[0] = sx;
dst[1] = 0;
dst[2] = 0;
dst[3] = sy;
dst[4] = 0;
dst[5] = 0;
}
/**
......@@ -159,16 +159,16 @@ _rsvg_affine_scale (double dst[6], double sx, double sy)
void
_rsvg_affine_rotate (double dst[6], double theta)
{
double s, c;
double s, c;
s = sin (theta * M_PI / 180.0);
c = cos (theta * M_PI / 180.0);
dst[0] = c;
dst[1] = s;
dst[2] = -s;
dst[3] = c;
dst[4] = 0;
dst[5] = 0;
s = sin (theta * M_PI / 180.0);
c = cos (theta * M_PI / 180.0);
dst[0] = c;
dst[1] = s;
dst[2] = -s;
dst[3] = c;
dst[4] = 0;
dst[5] = 0;
}
/**
......@@ -183,15 +183,15 @@ _rsvg_affine_rotate (double dst[6], double theta)
void
_rsvg_affine_shear (double dst[6], double theta)
{
double t;
double t;
t = tan (theta * M_PI / 180.0);
dst[0] = 1;
dst[1] = 0;
dst[2] = t;
dst[3] = 1;
dst[4] = 0;
dst[5] = 0;
t = tan (theta * M_PI / 180.0);
dst[0] = 1;
dst[1] = 0;
dst[2] = t;
dst[3] = 1;
dst[4] = 0;
dst[5] = 0;
}
/**
......@@ -205,12 +205,12 @@ _rsvg_affine_shear (double dst[6], double theta)
void
_rsvg_affine_translate (double dst[6], double tx, double ty)
{
dst[0] = 1;
dst[1] = 0;
dst[2] = 0;
dst[3] = 1;
dst[4] = tx;
dst[5] = ty;
dst[0] = 1;
dst[1] = 0;
dst[2] = 0;
dst[3] = 1;
dst[4] = tx;
dst[5] = ty;
}
/**
......@@ -227,7 +227,7 @@ _rsvg_affine_translate (double dst[6], double tx, double ty)
double
_rsvg_affine_expansion (const double src[6])
{
return sqrt (fabs (src[0] * src[3] - src[1] * src[2]));
return sqrt (fabs (src[0] * src[3] - src[1] * src[2]));
}
/**
......@@ -243,8 +243,8 @@ _rsvg_affine_expansion (const double src[6])
int
_rsvg_affine_rectilinear (const double src[6])
{
return ((fabs (src[1]) < EPSILON && fabs (src[2]) < EPSILON) ||
(fabs (src[0]) < EPSILON && fabs (src[3]) < EPSILON));
return ((fabs (src[1]) < EPSILON && fabs (src[2]) < EPSILON) ||
(fabs (src[0]) < EPSILON && fabs (src[3]) < EPSILON));
}
/**
......@@ -260,10 +260,9 @@ _rsvg_affine_rectilinear (const double src[6])
int
_rsvg_affine_equal (double matrix1[6], double matrix2[6])
{
return (fabs (matrix1[0] - matrix2[0]) < EPSILON &&
fabs (matrix1[1] - matrix2[1]) < EPSILON &&
fabs (matrix1[2] - matrix2[2]) < EPSILON &&
fabs (matrix1[3] - matrix2[3]) < EPSILON &&
fabs (matrix1[4] - matrix2[4]) < EPSILON &&
fabs (matrix1[5] - matrix2[5]) < EPSILON);
return (fabs (matrix1[0] - matrix2[0]) < EPSILON &&
fabs (matrix1[1] - matrix2[1]) < EPSILON &&
fabs (matrix1[2] - matrix2[2]) < EPSILON &&
fabs (matrix1[3] - matrix2[3]) < EPSILON &&
fabs (matrix1[4] - matrix2[4]) < EPSILON && fabs (matrix1[5] - matrix2[5]) < EPSILON);
}
......@@ -29,19 +29,17 @@
static gboolean
rsvg_handle_fill_with_data (RsvgHandle * handle,
const guint8 *data,
gsize data_len,
GError **error)
const guint8 * data, gsize data_len, GError ** error)
{
rsvg_return_val_if_fail(data != NULL, FALSE, error);
rsvg_return_val_if_fail(data_len != 0, FALSE, error);
rsvg_return_val_if_fail (data != NULL, FALSE, error);
rsvg_return_val_if_fail (data_len != 0, FALSE, error);
if(!rsvg_handle_write (handle, data, data_len, error))
return FALSE;
if(!rsvg_handle_close(handle, error))
return FALSE;
if (!rsvg_handle_write (handle, data, data_len, error))
return FALSE;
if (!rsvg_handle_close (handle, error))
return FALSE;
return TRUE;
return TRUE;
}
/**
......@@ -55,22 +53,21 @@ rsvg_handle_fill_with_data (RsvgHandle * handle,
* Returns: A RsvgHandle or %NULL if an error occurs.
* Since: 2.14
*/
RsvgHandle * rsvg_handle_new_from_data (const guint8 *data,
gsize data_len,
GError **error)
RsvgHandle *
rsvg_handle_new_from_data (const guint8 * data, gsize data_len, GError ** error)
{
RsvgHandle * handle;
RsvgHandle *handle;
handle = rsvg_handle_new ();
handle = rsvg_handle_new ();
if(handle) {
if (!rsvg_handle_fill_with_data (handle, data, data_len, error)) {
g_object_unref(G_OBJECT(handle));
handle = NULL;
}
}
if (handle) {
if (!rsvg_handle_fill_with_data (handle, data, data_len, error)) {
g_object_unref (G_OBJECT (handle));
handle = NULL;
}
}
return handle;
return handle;
}
/**
......@@ -83,32 +80,31 @@ RsvgHandle * rsvg_handle_new_from_data (const guint8 *data,
* Returns: A RsvgHandle or %NULL if an error occurs.
* Since: 2.14
*/
RsvgHandle * rsvg_handle_new_from_file (const gchar *file_name,
GError **error)
RsvgHandle *
rsvg_handle_new_from_file (const gchar * file_name, GError ** error)
{
gchar * base_uri;
GByteArray *f;
RsvgHandle * handle = NULL;
rsvg_return_val_if_fail(file_name != NULL, NULL, error);
base_uri = rsvg_get_base_uri_from_filename(file_name);
f = _rsvg_acquire_xlink_href_resource (file_name, base_uri, error);
if (f)
{
handle = rsvg_handle_new ();
if (handle) {
rsvg_handle_set_base_uri (handle, base_uri);
if(!rsvg_handle_fill_with_data (handle, f->data, f->len, error)) {
g_object_unref (G_OBJECT (handle));
handle = NULL;
}
}
g_byte_array_free (f, TRUE);
}
g_free(base_uri);
return handle;
gchar *base_uri;
GByteArray *f;
RsvgHandle *handle = NULL;
rsvg_return_val_if_fail (file_name != NULL, NULL, error);
base_uri = rsvg_get_base_uri_from_filename (file_name);
f = _rsvg_acquire_xlink_href_resource (file_name, base_uri, error);
if (f) {
handle = rsvg_handle_new ();
if (handle) {
rsvg_handle_set_base_uri (handle, base_uri);
if (!rsvg_handle_fill_with_data (handle, f->data, f->len, error)) {
g_object_unref (G_OBJECT (handle));
handle = NULL;
}
}
g_byte_array_free (f, TRUE);
}
g_free (base_uri);
return handle;
}
This diff is collapsed.
......@@ -38,170 +38,164 @@
RsvgBpathDef *
rsvg_bpath_def_new (void)
{
RsvgBpathDef *bpd;
bpd = g_new (RsvgBpathDef, 1);
bpd->n_bpath = 0;
bpd->n_bpath_max = 16;
bpd->moveto_idx = -1;
bpd->bpath = g_new (RsvgBpath, bpd->n_bpath_max);
return bpd;
RsvgBpathDef *bpd;
bpd = g_new (RsvgBpathDef, 1);
bpd->n_bpath = 0;
bpd->n_bpath_max = 16;
bpd->moveto_idx = -1;
bpd->bpath = g_new (RsvgBpath, bpd->n_bpath_max);
return bpd;
}
RsvgBpathDef *
rsvg_bpath_def_new_from (RsvgBpath *path)
rsvg_bpath_def_new_from (RsvgBpath * path)
{
RsvgBpathDef *bpd;
int i;
g_return_val_if_fail (path != NULL, NULL);
for (i = 0; path[i].code != RSVG_END; i++)
;
if (i <= 0)
return rsvg_bpath_def_new ();
bpd = g_new (RsvgBpathDef, 1);
bpd->n_bpath = i;
bpd->n_bpath_max = i;
bpd->moveto_idx = -1;
bpd->bpath = g_new (RsvgBpath, i);
memcpy (bpd->bpath, path, i * sizeof (RsvgBpath));
return bpd;
RsvgBpathDef *bpd;
int i;
g_return_val_if_fail (path != NULL, NULL);
for (i = 0; path[i].code != RSVG_END; i++);
if (i <= 0)
return rsvg_bpath_def_new ();
bpd = g_new (RsvgBpathDef, 1);
bpd->n_bpath = i;
bpd->n_bpath_max = i;
bpd->moveto_idx = -1;
bpd->bpath = g_new (RsvgBpath, i);
memcpy (bpd->bpath, path, i * sizeof (RsvgBpath));
return bpd;
}
void
rsvg_bpath_def_free (RsvgBpathDef *bpd)
rsvg_bpath_def_free (RsvgBpathDef * bpd)
{
g_return_if_fail (bpd != NULL);
g_free (bpd->bpath);
g_free (bpd);
g_return_if_fail (bpd != NULL);
g_free (bpd->bpath);
g_free (bpd);
}
void
rsvg_bpath_def_moveto (RsvgBpathDef *bpd, double x, double y)
rsvg_bpath_def_moveto (RsvgBpathDef * bpd, double x, double y)
{
RsvgBpath *bpath;
int n_bpath;
g_return_if_fail (bpd != NULL);
/* if the last command was a moveto then change that last moveto instead of
creating a new one */
bpath = bpd->bpath;
n_bpath = bpd->n_bpath;
if (n_bpath > 0)
if (bpath[n_bpath - 1].code == RSVG_MOVETO_OPEN)
{
bpath[n_bpath - 1].x3 = x;
bpath[n_bpath - 1].y3 = y;
bpd->moveto_idx = n_bpath - 1;
return;
}
n_bpath = bpd->n_bpath++;
if (n_bpath == bpd->n_bpath_max)
bpd->bpath = g_realloc (bpd->bpath,
(bpd->n_bpath_max <<= 1) * sizeof (RsvgBpath));
bpath = bpd->bpath;
bpath[n_bpath].code = RSVG_MOVETO_OPEN;
bpath[n_bpath].x3 = x;
bpath[n_bpath].y3 = y;
bpd->moveto_idx = n_bpath;
RsvgBpath *bpath;
int n_bpath;
g_return_if_fail (bpd != NULL);
/* if the last command was a moveto then change that last moveto instead of
creating a new one */
bpath = bpd->bpath;
n_bpath = bpd->n_bpath;
if (n_bpath > 0)
if (bpath[n_bpath - 1].code == RSVG_MOVETO_OPEN) {
bpath[n_bpath - 1].x3 = x;
bpath[n_bpath - 1].y3 = y;
bpd->moveto_idx = n_bpath - 1;
return;
}
n_bpath = bpd->n_bpath++;
if (n_bpath == bpd->n_bpath_max)
bpd->bpath = g_realloc (bpd->bpath, (bpd->n_bpath_max <<= 1) * sizeof (RsvgBpath));
bpath = bpd->bpath;
bpath[n_bpath].code = RSVG_MOVETO_OPEN;
bpath[n_bpath].x3 = x;
bpath[n_bpath].y3 = y;
bpd->moveto_idx = n_bpath;
}
void
rsvg_bpath_def_lineto (RsvgBpathDef *bpd, double x, double y)
rsvg_bpath_def_lineto (RsvgBpathDef * bpd, double x, double y)
{
RsvgBpath *bpath;
int n_bpath;
g_return_if_fail (bpd != NULL);
g_return_if_fail (bpd->moveto_idx >= 0);
n_bpath = bpd->n_bpath++;
if (n_bpath == bpd->n_bpath_max)
bpd->bpath = g_realloc (bpd->bpath,
(bpd->n_bpath_max <<= 1) * sizeof (RsvgBpath));
bpath = bpd->bpath;
bpath[n_bpath].code = RSVG_LINETO;
bpath[n_bpath].x3 = x;
bpath[n_bpath].y3 = y;
RsvgBpath *bpath;
int n_bpath;
g_return_if_fail (bpd != NULL);
g_return_if_fail (bpd->moveto_idx >= 0);
n_bpath = bpd->n_bpath++;
if (n_bpath == bpd->n_bpath_max)
bpd->bpath = g_realloc (bpd->bpath, (bpd->n_bpath_max <<= 1) * sizeof (RsvgBpath));
bpath = bpd->bpath;
bpath[n_bpath].code = RSVG_LINETO;
bpath[n_bpath].x3 = x;
bpath[n_bpath].y3 = y;
}
void
rsvg_bpath_def_curveto (RsvgBpathDef *bpd, double x1, double y1, double x2, double y2, double x3, double y3)
rsvg_bpath_def_curveto (RsvgBpathDef * bpd, double x1, double y1, double x2, double y2, double x3,
double y3)
{
RsvgBpath *bpath;
int n_bpath;
g_return_if_fail (bpd != NULL);
g_return_if_fail (bpd->moveto_idx >= 0);
n_bpath = bpd->n_bpath++;
if (n_bpath == bpd->n_bpath_max)
bpd->bpath = g_realloc (bpd->bpath,
(bpd->n_bpath_max <<= 1) * sizeof (RsvgBpath));
bpath = bpd->bpath;
bpath[n_bpath].code = RSVG_CURVETO;
bpath[n_bpath].x1 = x1;
bpath[n_bpath].y1 = y1;
bpath[n_bpath].x2 = x2;
bpath[n_bpath].y2 = y2;
bpath[n_bpath].x3 = x3;
bpath[n_bpath].y3 = y3;
RsvgBpath *bpath;
int n_bpath;
g_return_if_fail (bpd != NULL);
g_return_if_fail (bpd->moveto_idx >= 0);
n_bpath = bpd->n_bpath++;
if (n_bpath == bpd->n_bpath_max)
bpd->bpath = g_realloc (bpd->bpath, (bpd->n_bpath_max <<= 1) * sizeof (RsvgBpath));
bpath = bpd->bpath;
bpath[n_bpath].code = RSVG_CURVETO;
bpath[n_bpath].x1 = x1;
bpath[n_bpath].y1 = y1;
bpath[n_bpath].x2 = x2;
bpath[n_bpath].y2 = y2;
bpath[n_bpath].x3 = x3;
bpath[n_bpath].y3 = y3;
}
static void
rsvg_bpath_def_replicate (RsvgBpathDef *bpd, int index)
rsvg_bpath_def_replicate (RsvgBpathDef * bpd, int index)
{
RsvgBpath *bpath;
int n_bpath;
n_bpath = bpd->n_bpath++;
if (n_bpath == bpd->n_bpath_max)
bpd->bpath = g_realloc (bpd->bpath,
(bpd->n_bpath_max <<= 1) * sizeof (RsvgBpath));
bpath = bpd->bpath;
bpath[n_bpath] = bpath[index];
RsvgBpath *bpath;
int n_bpath;
n_bpath = bpd->n_bpath++;
if (n_bpath == bpd->n_bpath_max)
bpd->bpath = g_realloc (bpd->bpath, (bpd->n_bpath_max <<= 1) * sizeof (RsvgBpath));
bpath = bpd->bpath;
bpath[n_bpath] = bpath[index];
}
void
rsvg_bpath_def_closepath (RsvgBpathDef *bpd)
rsvg_bpath_def_closepath (RsvgBpathDef * bpd)
{
RsvgBpath *bpath;
g_return_if_fail (bpd != NULL);
g_return_if_fail (bpd->moveto_idx >= 0);
g_return_if_fail (bpd->n_bpath > 0);
RsvgBpath *bpath;
rsvg_bpath_def_replicate (bpd, bpd->moveto_idx);
bpath = bpd->bpath;
g_return_if_fail (bpd != NULL);
g_return_if_fail (bpd->moveto_idx >= 0);
g_return_if_fail (bpd->n_bpath > 0);
bpath[bpd->n_bpath - 1].code = RSVG_MOVETO;
bpd->moveto_idx = bpd->n_bpath - 1;
rsvg_bpath_def_replicate (bpd, bpd->moveto_idx);
bpath = bpd->bpath;
bpath[bpd->n_bpath - 1].code = RSVG_MOVETO;
bpd->moveto_idx = bpd->n_bpath - 1;
}
void
rsvg_bpath_def_art_finish (RsvgBpathDef *bpd)
rsvg_bpath_def_art_finish (RsvgBpathDef * bpd)
{
int n_bpath;
g_return_if_fail (bpd != NULL);
n_bpath = bpd->n_bpath++;
if (n_bpath == bpd->n_bpath_max)
bpd->bpath = g_realloc (bpd->bpath,
(bpd->n_bpath_max <<= 1) * sizeof (RsvgBpath));
bpd->bpath[n_bpath].code = RSVG_END;
int n_bpath;
g_return_if_fail (bpd != NULL);
n_bpath = bpd->n_bpath++;
if (n_bpath == bpd->n_bpath_max)
bpd->bpath = g_realloc (bpd->bpath, (bpd->n_bpath_max <<= 1) * sizeof (RsvgBpath));
bpd->bpath[n_bpath].code = RSVG_END;
}
......@@ -28,55 +28,47 @@
#include <glib/gtypes.h>
G_BEGIN_DECLS
typedef enum {
RSVG_MOVETO,
RSVG_MOVETO_OPEN,
RSVG_CURVETO,
RSVG_LINETO,
RSVG_END
G_BEGIN_DECLS typedef enum {
RSVG_MOVETO,
RSVG_MOVETO_OPEN,
RSVG_CURVETO,
RSVG_LINETO,
RSVG_END
} RsvgPathcode;
typedef struct _RsvgBpath RsvgBpath;
struct _RsvgBpath {
/*< public >*/
RsvgPathcode code;
double x1;
double y1;
double x2;
double y2;
double x3;
double y3;
/*< public > */
RsvgPathcode code;
double x1;
double y1;
double x2;
double y2;
double x3;
double y3;
};
typedef struct _RsvgBpathDef RsvgBpathDef;
struct _RsvgBpathDef {
RsvgBpath *bpath;
int n_bpath;
int n_bpath_max;
int moveto_idx;
RsvgBpath *bpath;
int n_bpath;
int n_bpath_max;