rsvg-paint-server.h 7.08 KB
Newer Older
1 2
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set sw=4 sts=4 ts=4 expandtab: */
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
/*
   rsvg-paint-server.h : RSVG colors

   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>
*/
26 27 28 29

#ifndef RSVG_PAINT_SERVER_H
#define RSVG_PAINT_SERVER_H

30
#include <glib.h>
31
#include <cairo.h>
32

33 34 35
G_BEGIN_DECLS 

typedef struct _RsvgGradientStop RsvgGradientStop;
36 37 38
typedef struct _RsvgGradientStops RsvgGradientStops;
typedef struct _RsvgLinearGradient RsvgLinearGradient;
typedef struct _RsvgRadialGradient RsvgRadialGradient;
39
typedef struct _RsvgPattern RsvgPattern;
40
typedef struct _RsvgSolidColor RsvgSolidColor;
41 42 43 44 45 46

typedef struct _RsvgPaintServer RsvgPaintServer;

typedef struct _RsvgPSCtx RsvgPSCtx;

struct _RsvgGradientStop {
47 48
    double offset;
    guint32 rgba;
49
    gboolean is_valid;
50 51 52
};

struct _RsvgLinearGradient {
53
    gboolean obj_bbox;
Christian Persch's avatar
Christian Persch committed
54
    cairo_matrix_t affine; /* user space to actual at time of gradient def */
55
    cairo_extend_t spread;
56
    RsvgLength x1, y1, x2, y2;
57 58 59 60 61 62 63
    gboolean hasx1;
    gboolean hasy1;
    gboolean hasx2;
    gboolean hasy2;
    gboolean hasbbox;
    gboolean hastransform;
    gboolean hasspread;
64
    char *fallback;
65 66 67
};

struct _RsvgRadialGradient {
68
    gboolean obj_bbox;
Christian Persch's avatar
Christian Persch committed
69
    cairo_matrix_t affine; /* user space to actual at time of gradient def */
70
    cairo_extend_t spread;
71
    RsvgLength cx, cy, r, fx, fy;
72 73 74 75 76 77 78 79
    gboolean hascx;
    gboolean hascy;
    gboolean hasr;
    gboolean hasfx;
    gboolean hasfy;
    gboolean hasbbox;
    gboolean hastransform;
    gboolean hasspread;
80
    char *fallback;
81 82
};

83
/* This is a Rust gradient from rust/src/gradient.rs */
84 85 86 87 88 89 90 91 92 93 94 95 96
typedef struct _Gradient Gradient;

/* Implemented in rust/src/gradient.rs */
G_GNUC_INTERNAL
Gradient *gradient_linear_new (RsvgLength     *x1,
                               RsvgLength     *y1,
                               RsvgLength     *x2,
                               RsvgLength     *y2,
                               gboolean       *obj_bbox,
                               cairo_matrix_t *affine,
                               cairo_extend_t *extend,
                               const char     *fallback_name);

97 98 99 100 101 102 103 104 105 106 107 108
/* Implemented in rust/src/gradient.rs */
G_GNUC_INTERNAL
Gradient *gradient_radial_new (RsvgLength     *cx,
                               RsvgLength     *cy,
                               RsvgLength     *r,
                               RsvgLength     *fx,
                               RsvgLength     *fy,
                               gboolean       *obj_bbox,
                               cairo_matrix_t *affine,
                               cairo_extend_t *extend,
                               const char     *fallback_name);

109 110 111 112
/* Implemented in rust/src/gradient.rs */
G_GNUC_INTERNAL
void gradient_destroy (Gradient *gradient);

113
/* Implemented in rust/src/gradient.rs */
114 115 116 117 118
G_GNUC_INTERNAL
void gradient_add_color_stop (Gradient *gradient,
                              double    offset,
                              guint32   rgba);

119 120 121 122 123 124 125 126 127 128
/* Implemented in rust/src/gradient.rs */
G_GNUC_INTERNAL
void gradient_resolve_fallbacks_and_set_pattern (Gradient       *gradient,
                                                 RsvgDrawingCtx *draw_ctx,
                                                 guint8          opacity,
                                                 RsvgBbox        bbox);

G_GNUC_INTERNAL
Gradient *rsvg_gradient_node_to_rust_gradient (RsvgNode *node);

129
struct _RsvgPattern {
130 131
    gboolean obj_cbbox;
    gboolean obj_bbox;
Christian Persch's avatar
Christian Persch committed
132
    cairo_matrix_t affine; /* user space to actual at time of gradient def */
133 134
    RsvgLength x, y, width, height;
    RsvgViewBox vbox;
135
    guint32 preserve_aspect_ratio;
136 137 138 139 140 141 142 143 144
    int hasx:1;
    int hasy:1;
    int hasvbox:1;
    int haswidth:1;
    int hasheight:1;
    int hasaspect:1;
    int hascbox:1;
    int hasbbox:1;
    int hastransform:1;
145
    char *fallback;
146 147
};

148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
/* This is a Rust pattern from rust/src/pattern.rs */
typedef struct _Pattern Pattern;

/* Implemented in rust/src/pattern.rs */
G_GNUC_INTERNAL
Pattern *
pattern_new (RsvgLength     *x,
             RsvgLength     *y,
             RsvgLength     *width,
             RsvgLength     *height,
             gboolean       *obj_bbox,
             gboolean       *obj_cbbox,
             RsvgViewBox    *vbox,
             cairo_matrix_t *affine,
             guint32        *preserve_aspect_ratio,
             const char     *fallback_name,
             RsvgNode       *node);

/* Implemented in rust/src/pattern.rs */
G_GNUC_INTERNAL
void pattern_destroy (Pattern *pattern);

/* Implemented in rust/src/pattern.rs */
G_GNUC_INTERNAL
172 173 174
gboolean pattern_resolve_fallbacks_and_set_pattern (Pattern        *pattern,
                                                    RsvgDrawingCtx *draw_ctx,
                                                    RsvgBbox        bbox);
175 176 177 178 179 180 181 182

G_GNUC_INTERNAL
Pattern *rsvg_pattern_node_to_rust_pattern (RsvgNode *node);

G_GNUC_INTERNAL
gboolean rsvg_pattern_node_has_children (RsvgNode *node);


183 184
struct _RsvgSolidColor {
    gboolean currentcolor;
185
    guint32 argb;
186 187
};

188
typedef struct _RsvgSolidColor RsvgPaintServerColor;
189 190
typedef enum _RsvgPaintServerType RsvgPaintServerType;
typedef union _RsvgPaintServerCore RsvgPaintServerCore;
191 192 193 194 195 196 197
typedef struct _RsvgPaintServerIri RsvgPaintServerIri;

struct _RsvgPaintServerIri {
    char *iri_str;
    gboolean has_alternate;
    RsvgSolidColor alternate;
};
198 199

union _RsvgPaintServerCore {
200
    RsvgSolidColor *color;
201
    RsvgPaintServerIri *iri;
202 203 204
};

enum _RsvgPaintServerType {
205
    RSVG_PAINT_SERVER_SOLID,
206
    RSVG_PAINT_SERVER_IRI
207 208 209
};

struct _RsvgPaintServer {
210 211 212
    int refcnt;
    RsvgPaintServerType type;
    RsvgPaintServerCore core;
213 214
};

215
/* Create a new paint server based on a specification string. */
216
G_GNUC_INTERNAL
217
RsvgPaintServer	    *rsvg_paint_server_parse    (gboolean *inherit, const char *str);
218
G_GNUC_INTERNAL
219
void                 rsvg_paint_server_ref      (RsvgPaintServer * ps);
220
G_GNUC_INTERNAL
221
void                 rsvg_paint_server_unref    (RsvgPaintServer * ps);
222

223
G_GNUC_INTERNAL
224
RsvgNode *rsvg_new_linear_gradient  (const char *element_name, RsvgNode *parent);
225
G_GNUC_INTERNAL
226
RsvgNode *rsvg_new_radial_gradient  (const char *element_name, RsvgNode *parent);
227
G_GNUC_INTERNAL
228
RsvgNode *rsvg_new_stop	        (const char *element_name, RsvgNode *parent);
229
G_GNUC_INTERNAL
230
RsvgNode *rsvg_new_pattern      (const char *element_name, RsvgNode *parent);
231

232

233
G_END_DECLS
234

235
#endif