]> git.mxchange.org Git - simgear.git/blob - simgear/canvas/ShivaVG/src/shPath.h
Update for OpenSceneGraph 3.3.2 API changes.
[simgear.git] / simgear / canvas / ShivaVG / src / shPath.h
1 /*
2  * Copyright (c) 2007 Ivan Leben
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  * 
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  * 
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library in the file COPYING;
16  * if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18  *
19  */
20
21 #ifndef __SHPATH_H
22 #define __SHPATH_H
23
24 #include "shVectors.h"
25 #include "shArrays.h"
26
27 /* Helper structures for subdivision */
28 typedef struct {
29   SHVector2 p1;
30   SHVector2 p2;
31   SHVector2 p3;
32 } SHQuad;
33
34 typedef struct {
35   SHVector2 p1;
36   SHVector2 p2;
37   SHVector2 p3;
38   SHVector2 p4;
39 } SHCubic;
40
41 typedef struct {
42   SHVector2 p1;
43   SHVector2 p2;
44   SHfloat a1;
45   SHfloat a2;
46 } SHArc;
47
48 /* SHVertex */
49 typedef struct
50 {
51   SHVector2 point;
52   SHVector2 tangent;
53   SHfloat length;
54   SHuint flags;
55   
56 } SHVertex;
57
58 /* Vertex flags for contour definition */
59 #define SH_VERTEX_FLAG_CLOSE   (1 << 0)
60 #define SH_VERTEX_FLAG_SEGEND  (1 << 1)
61 #define SH_SEGMENT_TYPE_COUNT  13
62
63 /* Vertex array */
64 #define _ITEM_T SHVertex
65 #define _ARRAY_T SHVertexArray
66 #define _FUNC_T shVertexArray
67 #define _ARRAY_DECLARE
68 #include "shArrayBase.h"
69
70
71 /* SHPath */
72 typedef struct SHPath
73 {
74   /* Properties */
75   VGint format;
76   SHfloat scale;
77   SHfloat bias;
78   SHint segHint;
79   SHint dataHint;
80   VGbitfield caps;
81   VGPathDatatype datatype;
82   
83   /* Raw data */
84   SHuint8 *segs;
85   void *data;
86   SHint segCount;
87   SHint dataCount;
88
89   /* Subdivision */
90   SHVertexArray vertices;
91   SHVector2 min, max;
92   
93   /* Additional stroke geometry (dash vertices if
94      path dashed or triangle vertices if width > 1 */
95   SHVector2Array stroke;
96
97   /* Cache */
98   VGboolean      cacheDataValid;
99
100   VGboolean      cacheTransformInit;
101   SHMatrix3x3    cacheTransform;
102
103   VGboolean      cacheStrokeInit;
104   VGboolean      cacheStrokeTessValid;
105   SHfloat        cacheStrokeLineWidth;
106   VGCapStyle     cacheStrokeCapStyle;
107   VGJoinStyle    cacheStrokeJoinStyle;
108   SHfloat        cacheStrokeMiterLimit;
109   SHfloat        cacheStrokeDashPhase;
110   VGboolean      cacheStrokeDashPhaseReset;
111   
112 } SHPath;
113
114 void SHPath_ctor(SHPath *p);
115 void SHPath_dtor(SHPath *p);
116
117
118 /* Processing normalization flags */
119 #define SH_PROCESS_SIMPLIFY_LINES    (1 << 0)
120 #define SH_PROCESS_SIMPLIFY_CURVES   (1 << 1)
121 #define SH_PROCESS_CENTRALIZE_ARCS   (1 << 2)
122 #define SH_PROCESS_REPAIR_ENDS       (1 << 3)
123
124 /* Segment callback function type */
125 typedef void (*SegmentFunc) (SHPath *p, VGPathSegment segment,
126                              VGPathCommand originalCommand,
127                              SHfloat *data, void *userData);
128
129 /* Processes raw path data into normalized segments */
130 void shProcessPathData(SHPath *p, int flags,
131                        SegmentFunc callback,
132                        void *userData);
133
134
135 /* Pointer-to-path array */
136 #define _ITEM_T SHPath*
137 #define _ARRAY_T SHPathArray
138 #define _FUNC_T shPathArray
139 #define _ARRAY_DECLARE
140 #include "shArrayBase.h"
141
142 #endif /* __SHPATH_H */