glsl2: Add and use new variable mode ir_var_temporary
[mesa/nouveau-pmpeg.git] / src / gallium / state_trackers / vega / path_utils.h
blobc2b3221dc5373c96bb4caec2fe566c41bde49b6b
1 /**************************************************************************
3 * Copyright 2009 VMware, Inc. All Rights Reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sub license, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial portions
15 * of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
20 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
21 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 **************************************************************************/
27 #ifndef PATH_UTILS_H
28 #define PATH_UTILS_H
30 #include "VG/openvg.h"
32 #define SEGMENT_COMMAND(command) /* Extract segment type */ \
33 ((command) & 0x1e)
34 #define SEGMENT_ABS_REL(command) /* Extract absolute/relative bit */ \
35 ((command) & 0x1)
37 static INLINE VGint size_for_datatype(VGPathDatatype datatype)
39 switch(datatype) {
40 case VG_PATH_DATATYPE_S_8:
41 return 1;
42 case VG_PATH_DATATYPE_S_16:
43 return 2;
44 case VG_PATH_DATATYPE_S_32:
45 return 4;
46 case VG_PATH_DATATYPE_F:
47 return 4;
48 default:
49 assert(!"unknown datatype");
51 return 0;
54 static INLINE VGint num_elements_for_segments(const VGubyte *segments,
55 VGint num_segments)
57 VGint i;
58 VGint count = 0;
60 for (i = 0; i < num_segments; ++i) {
61 VGubyte segment = segments[i];
62 VGint command = SEGMENT_COMMAND(segment);
63 switch(command) {
64 case VG_CLOSE_PATH:
65 break;
66 case VG_MOVE_TO:
67 count += 2;
68 break;
69 case VG_LINE_TO:
70 count += 2;
71 break;
72 case VG_HLINE_TO:
73 count += 1;
74 break;
75 case VG_VLINE_TO:
76 count += 1;
77 break;
78 case VG_QUAD_TO:
79 count += 4;
80 break;
81 case VG_CUBIC_TO:
82 count += 6;
83 break;
84 case VG_SQUAD_TO:
85 count += 2;
86 break;
87 case VG_SCUBIC_TO:
88 count += 4;
89 break;
90 case VG_SCCWARC_TO:
91 count += 5;
92 break;
93 case VG_SCWARC_TO:
94 count += 5;
95 break;
96 case VG_LCCWARC_TO:
97 count += 5;
98 break;
99 case VG_LCWARC_TO:
100 count += 5;
101 break;
102 default:
103 assert(!"Unknown segment!");
106 return count;
109 #endif