/* Privates for Graphics Foundation. Copyright (C) 2001 Johan Rydberg. All Rights Reserved. This file is part of Crust. This program is free software; you can redistribute it and/or modify it under the terms of the GNU 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 General Public License for more details. You should have received a copy of the GNU 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. */ #ifndef __priv_h #define __priv_h 1 #include #include #include #include #include #include "GFGeometry.h" #include "GFColorSpace.h" #include "GFImage.h" #include "GFContext.h" #ifndef MAX # define MAX(a, b) (((a) > (b)) ? (a) : (b)) #endif /* MAX */ #ifndef MIN # define MIN(a, b) (((a) < (b)) ? (a) : (b)) #endif /* MIN */ /* We have two types of colorspaces; simple and complex. Simple colorspaces just converts the color specified in (colorspace, gstate) to a RGB value that is used when rendering. Complex colorspaces have hooks for rendering. */ enum { kGFColorSpaceTypeSimple, kGFColorSpaceTypeComplex }; struct GFColorSpace { /* Object instance. Only used for complex colorspaces. */ CFRuntimeBase _runtime_base; /* Type of colorspace; simple or complex. */ int colorspace_type; /* Number of components in the colorspace (not including alpha). */ int n_components; /* ??? comment. */ void (*render_fn) (GFColorSpaceRef colorspace, double value[], ArtRender *render); }; /* Class identifier for GFColorSpace class. */ extern CFTypeID _GFColorSpaceTypeID; /* Library private functions. */ extern GFColorSpaceRef _GFColorSpaceClone (GFColorSpaceRef template); /* Maximum number of components in a color for fill or stroke. */ #define MAX_COMPONENTS 8 /* Graphic state. Each context have a graphic state stack. Graphic states can be saved (pushed) and restored (poped) from it. Graphic state references are not visible to the user. But we use the Core Foundation runtime system for internal use. */ typedef struct GFGState *GFGStateRef; struct GFGState { CFRuntimeBase _runtime_base; /* Pointer to next state on stack. NULL if we're the last state on the stack. */ GFGStateRef next_on_stack; /* Current transformation matrix. Initial value: a matrix that transforms default user coordinates to device coordinates. */ double ctm [6]; /* Color spaces. Initial value: Gray/Gray. */ GFColorSpaceRef fill_space; GFColorSpaceRef stroke_space; /* Color values. Initial value: Black/Black. */ double fill_color [MAX_COMPONENTS]; double stroke_color [MAX_COMPONENTS]; /* Alpha value. Initial value: 1.0. */ double alpha_value; /* The thickness, in user space units, of paths to be stroked. Initial value: 1.0 */ double line_width; /* A code specifying the shape of the endpoints for any open path that is stroked. Initial value: square butt caps. */ int line_cap; /* A code specifying the joints between connected segments of a stroked path. Initial value: Mitered joins. */ int line_join; /* Maximum length of of mitered joins for stroked paths. Initial value: 10.0 */ double miter_limit; /* Flatness. Initial value: 0.5. */ double flatness; /* Dash pattern, intial value: No dash pattern. */ int dash_ndash; double *dash_data; double dash_phase; }; /* Create a new graphic state. SIZE is needed to construct the clipping path. */ extern GFGStateRef _GFGStateCreate (GFSize size); struct GFContext { CFRuntimeBase _runtime_base; /* Size of the context. */ GFPoint origin; GFSize size; /* Pointer to current graphic state. */ GFGStateRef gstate; /* Current drawing path. Must hold information about number of points in the path as well. */ ArtVpath *vpath; int vpath_n; int vpath_n_max; bool vpath_closed; int vpath_subpath; ArtBpath *bpath; int bpath_n; int bpath_n_max; /* The following members describe the image buffer that we render into. Right now we only support 8-bit components. */ /* Raster buffer. We render into this. */ void *dst_buffer; /* Number of components in raster colorspace. */ unsigned int n_components; /* Bits per component. We only support 8 bits right now. */ unsigned int n_bits_per_component; /* Alpha information. */ GFImageAlphaInfo alpha_info; }; /* Class identifier for GFContext class. */ extern CFTypeID _GFContextTypeID; extern GFContextRef _GFContextAllocate (void); #endif /* priv.h */