2 * Copyright (c) 2007 Ivan Leben
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.
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.
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
25 #include "shVectors.h"
31 /*------------------------------------------------
33 *------------------------------------------------*/
37 SH_RESOURCE_INVALID = 0,
39 SH_RESOURCE_PAINT = 2,
45 /* Surface info (since no EGL yet) */
56 VGMatrixMode matrixMode;
58 VGImageQuality imageQuality;
59 VGRenderingQuality renderingQuality;
60 VGBlendMode blendMode;
61 VGImageMode imageMode;
63 /* Scissor rectangles */
68 /* Stroke parameters */
69 SHfloat strokeLineWidth;
70 VGCapStyle strokeCapStyle;
71 VGJoinStyle strokeJoinStyle;
72 SHfloat strokeMiterLimit;
73 SHFloatArray strokeDashPattern;
74 SHfloat strokeDashPhase;
75 VGboolean strokeDashPhaseReset;
77 /* Edge fill color for vgConvolve and pattern paint */
78 SHColor tileFillColor;
80 /* Color for vgClear */
83 /* Color components layout inside pixel */
84 VGPixelLayout pixelLayout;
86 /* Source format for image filters */
87 VGboolean filterFormatLinear;
88 VGboolean filterFormatPremultiplied;
89 VGbitfield filterChannelMask;
92 SHMatrix3x3 pathTransform;
93 SHMatrix3x3 imageTransform;
94 SHMatrix3x3 fillTransform;
95 SHMatrix3x3 strokeTransform;
100 SHPaint defaultPaint;
109 /* Pointers to extensions */
110 SHint isGLAvailable_ClampToEdge;
111 SHint isGLAvailable_MirroredRepeat;
112 SHint isGLAvailable_Multitexture;
113 SHint isGLAvailable_TextureNonPowerOfTwo;
114 SH_PGLACTIVETEXTURE pglActiveTexture;
115 SH_PGLMULTITEXCOORD1F pglMultiTexCoord1f;
116 SH_PGLMULTITEXCOORD2F pglMultiTexCoord2f;
120 void VGContext_ctor(VGContext *c);
121 void VGContext_dtor(VGContext *c);
122 void shSetError(VGContext *c, VGErrorCode e);
123 SHint shIsValidPath(VGContext *c, VGHandle h);
124 SHint shIsValidPaint(VGContext *c, VGHandle h);
125 SHint shIsValidImage(VGContext *c, VGHandle h);
126 SHResourceType shGetResourceType(VGContext *c, VGHandle h);
127 VGContext* shGetContext();
129 /*----------------------------------------------------
130 * TODO: Add mutex locking/unlocking to these macros
131 * to assure sequentiallity in multithreading.
132 *----------------------------------------------------*/
136 #define VG_GETCONTEXT(RETVAL) \
137 VGContext *context = shGetContext(); \
138 if (!context) return RETVAL;
140 #define VG_RETURN(RETVAL) \
143 #define VG_RETURN_ERR(ERRORCODE, RETVAL) \
144 { shSetError(context,ERRORCODE); return RETVAL; }
146 #define VG_RETURN_ERR_IF(COND, ERRORCODE, RETVAL) \
147 { if (COND) {shSetError(context,ERRORCODE); return RETVAL;} }
149 /*-----------------------------------------------------------
150 * Same macros but no mutex handling - used by sub-functions
151 *-----------------------------------------------------------*/
155 #define SH_GETCONTEXT(RETVAL) \
156 VGContext *context = shGetContext(); \
157 if (!context) return RETVAL;
159 #define SH_RETURN(RETVAL) \
162 #define SH_RETURN_ERR(ERRORCODE, RETVAL) \
163 { shSetError(context,ERRORCODE); return RETVAL; }
165 #define SH_RETURN_ERR_IF(COND, ERRORCODE, RETVAL) \
166 { if (COND) {shSetError(context,ERRORCODE); return RETVAL;} }
169 #endif /* __SHCONTEXT_H */