painting/qcolor_p.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8 -
9 -
10static inline int h2i(char hex) -
11{ -
12 if (hex >= '0' && hex <= '9')
partially evaluated: hex >= '0'
TRUEFALSE
yes
Evaluation Count:335514
no
Evaluation Count:0
evaluated: hex <= '9'
TRUEFALSE
yes
Evaluation Count:177180
yes
Evaluation Count:158334
0-335514
13 return hex - '0';
executed: return hex - '0';
Execution Count:177180
177180
14 if (hex >= 'a' && hex <= 'f')
evaluated: hex >= 'a'
TRUEFALSE
yes
Evaluation Count:158288
yes
Evaluation Count:46
evaluated: hex <= 'f'
TRUEFALSE
yes
Evaluation Count:158283
yes
Evaluation Count:5
5-158288
15 return hex - 'a' + 10;
executed: return hex - 'a' + 10;
Execution Count:158283
158283
16 if (hex >= 'A' && hex <= 'F')
partially evaluated: hex >= 'A'
TRUEFALSE
yes
Evaluation Count:51
no
Evaluation Count:0
evaluated: hex <= 'F'
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:5
0-51
17 return hex - 'A' + 10;
executed: return hex - 'A' + 10;
Execution Count:46
46
18 return -1;
executed: return -1;
Execution Count:5
5
19} -
20 -
21static inline int hex2int(const char *s) -
22{ -
23 return (h2i(s[0]) << 4) | h2i(s[1]);
executed: return (h2i(s[0]) << 4) | h2i(s[1]);
Execution Count:167754
167754
24} -
25 -
26static inline int hex2int(char s) -
27{ -
28 int h = h2i(s); -
29 return (h << 4) | h;
executed: return (h << 4) | h;
Execution Count:6
6
30} -
31 -
32bool qt_get_hex_rgb(const char *name, QRgb *rgb) -
33{ -
34 if(name[0] != '#')
partially evaluated: name[0] != '#'
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:55920
0-55920
35 return false;
never executed: return false;
0
36 name++; -
37 int len = qstrlen(name); -
38 int r, g, b; -
39 if (len == 12) {
partially evaluated: len == 12
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:55920
0-55920
40 r = hex2int(name); -
41 g = hex2int(name + 4); -
42 b = hex2int(name + 8); -
43 } else if (len == 9) {
partially evaluated: len == 9
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:55920
never executed: }
0-55920
44 r = hex2int(name); -
45 g = hex2int(name + 3); -
46 b = hex2int(name + 6); -
47 } else if (len == 6) {
evaluated: len == 6
TRUEFALSE
yes
Evaluation Count:55918
yes
Evaluation Count:2
never executed: }
0-55918
48 r = hex2int(name); -
49 g = hex2int(name + 2); -
50 b = hex2int(name + 4); -
51 } else if (len == 3) {
partially evaluated: len == 3
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
executed: }
Execution Count:55918
0-55918
52 r = hex2int(name[0]); -
53 g = hex2int(name[1]); -
54 b = hex2int(name[2]); -
55 } else {
executed: }
Execution Count:2
2
56 r = g = b = -1; -
57 }
never executed: }
0
58 if ((uint)r > 255 || (uint)g > 255 || (uint)b > 255) {
partially evaluated: (uint)r > 255
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:55920
partially evaluated: (uint)g > 255
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:55920
evaluated: (uint)b > 255
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:55917
0-55920
59 *rgb = 0; -
60 return false;
executed: return false;
Execution Count:3
3
61 } -
62 *rgb = qRgb(r, g ,b); -
63 return true;
executed: return true;
Execution Count:55917
55917
64} -
65 -
66bool qt_get_hex_rgb(const QChar *str, int len, QRgb *rgb) -
67{ -
68 if (len > 13)
partially evaluated: len > 13
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:46
0-46
69 return false;
never executed: return false;
0
70 char tmp[16]; -
71 for(int i = 0; i < len; ++i)
evaluated: i < len
TRUEFALSE
yes
Evaluation Count:316
yes
Evaluation Count:46
46-316
72 tmp[i] = str[i].toLatin1();
executed: tmp[i] = str[i].toLatin1();
Execution Count:316
316
73 tmp[len] = 0; -
74 return qt_get_hex_rgb(tmp, rgb);
executed: return qt_get_hex_rgb(tmp, rgb);
Execution Count:46
46
75} -
76static const struct RGBData { -
77 const char *name; -
78 uint value; -
79} rgbTbl[] = { -
80 { "aliceblue", (0xff000000 | (240 << 16) | (248 << 8) | 255) }, -
81 { "antiquewhite", (0xff000000 | (250 << 16) | (235 << 8) | 215) }, -
82 { "aqua", (0xff000000 | (0 << 16) | (255 << 8) | 255) }, -
83 { "aquamarine", (0xff000000 | (127 << 16) | (255 << 8) | 212) }, -
84 { "azure", (0xff000000 | (240 << 16) | (255 << 8) | 255) }, -
85 { "beige", (0xff000000 | (245 << 16) | (245 << 8) | 220) }, -
86 { "bisque", (0xff000000 | (255 << 16) | (228 << 8) | 196) }, -
87 { "black", (0xff000000 | (0 << 16) | (0 << 8) | 0) }, -
88 { "blanchedalmond", (0xff000000 | (255 << 16) | (235 << 8) | 205) }, -
89 { "blue", (0xff000000 | (0 << 16) | (0 << 8) | 255) }, -
90 { "blueviolet", (0xff000000 | (138 << 16) | (43 << 8) | 226) }, -
91 { "brown", (0xff000000 | (165 << 16) | (42 << 8) | 42) }, -
92 { "burlywood", (0xff000000 | (222 << 16) | (184 << 8) | 135) }, -
93 { "cadetblue", (0xff000000 | (95 << 16) | (158 << 8) | 160) }, -
94 { "chartreuse", (0xff000000 | (127 << 16) | (255 << 8) | 0) }, -
95 { "chocolate", (0xff000000 | (210 << 16) | (105 << 8) | 30) }, -
96 { "coral", (0xff000000 | (255 << 16) | (127 << 8) | 80) }, -
97 { "cornflowerblue", (0xff000000 | (100 << 16) | (149 << 8) | 237) }, -
98 { "cornsilk", (0xff000000 | (255 << 16) | (248 << 8) | 220) }, -
99 { "crimson", (0xff000000 | (220 << 16) | (20 << 8) | 60) }, -
100 { "cyan", (0xff000000 | (0 << 16) | (255 << 8) | 255) }, -
101 { "darkblue", (0xff000000 | (0 << 16) | (0 << 8) | 139) }, -
102 { "darkcyan", (0xff000000 | (0 << 16) | (139 << 8) | 139) }, -
103 { "darkgoldenrod", (0xff000000 | (184 << 16) | (134 << 8) | 11) }, -
104 { "darkgray", (0xff000000 | (169 << 16) | (169 << 8) | 169) }, -
105 { "darkgreen", (0xff000000 | (0 << 16) | (100 << 8) | 0) }, -
106 { "darkgrey", (0xff000000 | (169 << 16) | (169 << 8) | 169) }, -
107 { "darkkhaki", (0xff000000 | (189 << 16) | (183 << 8) | 107) }, -
108 { "darkmagenta", (0xff000000 | (139 << 16) | (0 << 8) | 139) }, -
109 { "darkolivegreen", (0xff000000 | (85 << 16) | (107 << 8) | 47) }, -
110 { "darkorange", (0xff000000 | (255 << 16) | (140 << 8) | 0) }, -
111 { "darkorchid", (0xff000000 | (153 << 16) | (50 << 8) | 204) }, -
112 { "darkred", (0xff000000 | (139 << 16) | (0 << 8) | 0) }, -
113 { "darksalmon", (0xff000000 | (233 << 16) | (150 << 8) | 122) }, -
114 { "darkseagreen", (0xff000000 | (143 << 16) | (188 << 8) | 143) }, -
115 { "darkslateblue", (0xff000000 | (72 << 16) | (61 << 8) | 139) }, -
116 { "darkslategray", (0xff000000 | (47 << 16) | (79 << 8) | 79) }, -
117 { "darkslategrey", (0xff000000 | (47 << 16) | (79 << 8) | 79) }, -
118 { "darkturquoise", (0xff000000 | (0 << 16) | (206 << 8) | 209) }, -
119 { "darkviolet", (0xff000000 | (148 << 16) | (0 << 8) | 211) }, -
120 { "deeppink", (0xff000000 | (255 << 16) | (20 << 8) | 147) }, -
121 { "deepskyblue", (0xff000000 | (0 << 16) | (191 << 8) | 255) }, -
122 { "dimgray", (0xff000000 | (105 << 16) | (105 << 8) | 105) }, -
123 { "dimgrey", (0xff000000 | (105 << 16) | (105 << 8) | 105) }, -
124 { "dodgerblue", (0xff000000 | (30 << 16) | (144 << 8) | 255) }, -
125 { "firebrick", (0xff000000 | (178 << 16) | (34 << 8) | 34) }, -
126 { "floralwhite", (0xff000000 | (255 << 16) | (250 << 8) | 240) }, -
127 { "forestgreen", (0xff000000 | (34 << 16) | (139 << 8) | 34) }, -
128 { "fuchsia", (0xff000000 | (255 << 16) | (0 << 8) | 255) }, -
129 { "gainsboro", (0xff000000 | (220 << 16) | (220 << 8) | 220) }, -
130 { "ghostwhite", (0xff000000 | (248 << 16) | (248 << 8) | 255) }, -
131 { "gold", (0xff000000 | (255 << 16) | (215 << 8) | 0) }, -
132 { "goldenrod", (0xff000000 | (218 << 16) | (165 << 8) | 32) }, -
133 { "gray", (0xff000000 | (128 << 16) | (128 << 8) | 128) }, -
134 { "green", (0xff000000 | (0 << 16) | (128 << 8) | 0) }, -
135 { "greenyellow", (0xff000000 | (173 << 16) | (255 << 8) | 47) }, -
136 { "grey", (0xff000000 | (128 << 16) | (128 << 8) | 128) }, -
137 { "honeydew", (0xff000000 | (240 << 16) | (255 << 8) | 240) }, -
138 { "hotpink", (0xff000000 | (255 << 16) | (105 << 8) | 180) }, -
139 { "indianred", (0xff000000 | (205 << 16) | (92 << 8) | 92) }, -
140 { "indigo", (0xff000000 | (75 << 16) | (0 << 8) | 130) }, -
141 { "ivory", (0xff000000 | (255 << 16) | (255 << 8) | 240) }, -
142 { "khaki", (0xff000000 | (240 << 16) | (230 << 8) | 140) }, -
143 { "lavender", (0xff000000 | (230 << 16) | (230 << 8) | 250) }, -
144 { "lavenderblush", (0xff000000 | (255 << 16) | (240 << 8) | 245) }, -
145 { "lawngreen", (0xff000000 | (124 << 16) | (252 << 8) | 0) }, -
146 { "lemonchiffon", (0xff000000 | (255 << 16) | (250 << 8) | 205) }, -
147 { "lightblue", (0xff000000 | (173 << 16) | (216 << 8) | 230) }, -
148 { "lightcoral", (0xff000000 | (240 << 16) | (128 << 8) | 128) }, -
149 { "lightcyan", (0xff000000 | (224 << 16) | (255 << 8) | 255) }, -
150 { "lightgoldenrodyellow", (0xff000000 | (250 << 16) | (250 << 8) | 210) }, -
151 { "lightgray", (0xff000000 | (211 << 16) | (211 << 8) | 211) }, -
152 { "lightgreen", (0xff000000 | (144 << 16) | (238 << 8) | 144) }, -
153 { "lightgrey", (0xff000000 | (211 << 16) | (211 << 8) | 211) }, -
154 { "lightpink", (0xff000000 | (255 << 16) | (182 << 8) | 193) }, -
155 { "lightsalmon", (0xff000000 | (255 << 16) | (160 << 8) | 122) }, -
156 { "lightseagreen", (0xff000000 | (32 << 16) | (178 << 8) | 170) }, -
157 { "lightskyblue", (0xff000000 | (135 << 16) | (206 << 8) | 250) }, -
158 { "lightslategray", (0xff000000 | (119 << 16) | (136 << 8) | 153) }, -
159 { "lightslategrey", (0xff000000 | (119 << 16) | (136 << 8) | 153) }, -
160 { "lightsteelblue", (0xff000000 | (176 << 16) | (196 << 8) | 222) }, -
161 { "lightyellow", (0xff000000 | (255 << 16) | (255 << 8) | 224) }, -
162 { "lime", (0xff000000 | (0 << 16) | (255 << 8) | 0) }, -
163 { "limegreen", (0xff000000 | (50 << 16) | (205 << 8) | 50) }, -
164 { "linen", (0xff000000 | (250 << 16) | (240 << 8) | 230) }, -
165 { "magenta", (0xff000000 | (255 << 16) | (0 << 8) | 255) }, -
166 { "maroon", (0xff000000 | (128 << 16) | (0 << 8) | 0) }, -
167 { "mediumaquamarine", (0xff000000 | (102 << 16) | (205 << 8) | 170) }, -
168 { "mediumblue", (0xff000000 | (0 << 16) | (0 << 8) | 205) }, -
169 { "mediumorchid", (0xff000000 | (186 << 16) | (85 << 8) | 211) }, -
170 { "mediumpurple", (0xff000000 | (147 << 16) | (112 << 8) | 219) }, -
171 { "mediumseagreen", (0xff000000 | (60 << 16) | (179 << 8) | 113) }, -
172 { "mediumslateblue", (0xff000000 | (123 << 16) | (104 << 8) | 238) }, -
173 { "mediumspringgreen", (0xff000000 | (0 << 16) | (250 << 8) | 154) }, -
174 { "mediumturquoise", (0xff000000 | (72 << 16) | (209 << 8) | 204) }, -
175 { "mediumvioletred", (0xff000000 | (199 << 16) | (21 << 8) | 133) }, -
176 { "midnightblue", (0xff000000 | (25 << 16) | (25 << 8) | 112) }, -
177 { "mintcream", (0xff000000 | (245 << 16) | (255 << 8) | 250) }, -
178 { "mistyrose", (0xff000000 | (255 << 16) | (228 << 8) | 225) }, -
179 { "moccasin", (0xff000000 | (255 << 16) | (228 << 8) | 181) }, -
180 { "navajowhite", (0xff000000 | (255 << 16) | (222 << 8) | 173) }, -
181 { "navy", (0xff000000 | (0 << 16) | (0 << 8) | 128) }, -
182 { "oldlace", (0xff000000 | (253 << 16) | (245 << 8) | 230) }, -
183 { "olive", (0xff000000 | (128 << 16) | (128 << 8) | 0) }, -
184 { "olivedrab", (0xff000000 | (107 << 16) | (142 << 8) | 35) }, -
185 { "orange", (0xff000000 | (255 << 16) | (165 << 8) | 0) }, -
186 { "orangered", (0xff000000 | (255 << 16) | (69 << 8) | 0) }, -
187 { "orchid", (0xff000000 | (218 << 16) | (112 << 8) | 214) }, -
188 { "palegoldenrod", (0xff000000 | (238 << 16) | (232 << 8) | 170) }, -
189 { "palegreen", (0xff000000 | (152 << 16) | (251 << 8) | 152) }, -
190 { "paleturquoise", (0xff000000 | (175 << 16) | (238 << 8) | 238) }, -
191 { "palevioletred", (0xff000000 | (219 << 16) | (112 << 8) | 147) }, -
192 { "papayawhip", (0xff000000 | (255 << 16) | (239 << 8) | 213) }, -
193 { "peachpuff", (0xff000000 | (255 << 16) | (218 << 8) | 185) }, -
194 { "peru", (0xff000000 | (205 << 16) | (133 << 8) | 63) }, -
195 { "pink", (0xff000000 | (255 << 16) | (192 << 8) | 203) }, -
196 { "plum", (0xff000000 | (221 << 16) | (160 << 8) | 221) }, -
197 { "powderblue", (0xff000000 | (176 << 16) | (224 << 8) | 230) }, -
198 { "purple", (0xff000000 | (128 << 16) | (0 << 8) | 128) }, -
199 { "red", (0xff000000 | (255 << 16) | (0 << 8) | 0) }, -
200 { "rosybrown", (0xff000000 | (188 << 16) | (143 << 8) | 143) }, -
201 { "royalblue", (0xff000000 | (65 << 16) | (105 << 8) | 225) }, -
202 { "saddlebrown", (0xff000000 | (139 << 16) | (69 << 8) | 19) }, -
203 { "salmon", (0xff000000 | (250 << 16) | (128 << 8) | 114) }, -
204 { "sandybrown", (0xff000000 | (244 << 16) | (164 << 8) | 96) }, -
205 { "seagreen", (0xff000000 | (46 << 16) | (139 << 8) | 87) }, -
206 { "seashell", (0xff000000 | (255 << 16) | (245 << 8) | 238) }, -
207 { "sienna", (0xff000000 | (160 << 16) | (82 << 8) | 45) }, -
208 { "silver", (0xff000000 | (192 << 16) | (192 << 8) | 192) }, -
209 { "skyblue", (0xff000000 | (135 << 16) | (206 << 8) | 235) }, -
210 { "slateblue", (0xff000000 | (106 << 16) | (90 << 8) | 205) }, -
211 { "slategray", (0xff000000 | (112 << 16) | (128 << 8) | 144) }, -
212 { "slategrey", (0xff000000 | (112 << 16) | (128 << 8) | 144) }, -
213 { "snow", (0xff000000 | (255 << 16) | (250 << 8) | 250) }, -
214 { "springgreen", (0xff000000 | (0 << 16) | (255 << 8) | 127) }, -
215 { "steelblue", (0xff000000 | (70 << 16) | (130 << 8) | 180) }, -
216 { "tan", (0xff000000 | (210 << 16) | (180 << 8) | 140) }, -
217 { "teal", (0xff000000 | (0 << 16) | (128 << 8) | 128) }, -
218 { "thistle", (0xff000000 | (216 << 16) | (191 << 8) | 216) }, -
219 { "tomato", (0xff000000 | (255 << 16) | (99 << 8) | 71) }, -
220 { "transparent", 0 }, -
221 { "turquoise", (0xff000000 | (64 << 16) | (224 << 8) | 208) }, -
222 { "violet", (0xff000000 | (238 << 16) | (130 << 8) | 238) }, -
223 { "wheat", (0xff000000 | (245 << 16) | (222 << 8) | 179) }, -
224 { "white", (0xff000000 | (255 << 16) | (255 << 8) | 255) }, -
225 { "whitesmoke", (0xff000000 | (245 << 16) | (245 << 8) | 245) }, -
226 { "yellow", (0xff000000 | (255 << 16) | (255 << 8) | 0) }, -
227 { "yellowgreen", (0xff000000 | (154 << 16) | (205 << 8) | 50) } -
228}; -
229 -
230static const int rgbTblSize = sizeof(rgbTbl) / sizeof(RGBData); -
231 -
232 -
233 -
234inline bool operator<(const char *name, const RGBData &data) -
235{ return qstrcmp(name, data.name) < 0; }
executed: return qstrcmp(name, data.name) < 0;
Execution Count:249
249
236inline bool operator<(const RGBData &data, const char *name) -
237{ return qstrcmp(data.name, name) < 0; }
executed: return qstrcmp(data.name, name) < 0;
Execution Count:1787
1787
238 -
239static bool get_named_rgb(const char *name_no_space, QRgb *rgb) -
240{ -
241 QByteArray name = QByteArray(name_no_space).toLower(); -
242 const RGBData *r = qBinaryFind(rgbTbl, rgbTbl + rgbTblSize, name.constData()); -
243 if (r != rgbTbl + rgbTblSize) {
evaluated: r != rgbTbl + rgbTblSize
TRUEFALSE
yes
Evaluation Count:248
yes
Evaluation Count:1
1-248
244 *rgb = r->value; -
245 return true;
executed: return true;
Execution Count:248
248
246 } -
247 return false;
executed: return false;
Execution Count:1
1
248} -
249 -
250bool qt_get_named_rgb(const char *name, QRgb* rgb) -
251{ -
252 int len = int(strlen(name)); -
253 if(len > 255)
never evaluated: len > 255
0
254 return false;
never executed: return false;
0
255 char name_no_space[256]; -
256 int pos = 0; -
257 for(int i = 0; i < len; i++) {
never evaluated: i < len
0
258 if(name[i] != '\t' && name[i] != ' ')
never evaluated: name[i] != '\t'
never evaluated: name[i] != ' '
0
259 name_no_space[pos++] = name[i];
never executed: name_no_space[pos++] = name[i];
0
260 }
never executed: }
0
261 name_no_space[pos] = 0; -
262 -
263 return get_named_rgb(name_no_space, rgb);
never executed: return get_named_rgb(name_no_space, rgb);
0
264} -
265 -
266bool qt_get_named_rgb(const QChar *name, int len, QRgb *rgb) -
267{ -
268 if(len > 255)
partially evaluated: len > 255
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:249
0-249
269 return false;
never executed: return false;
0
270 char name_no_space[256]; -
271 int pos = 0; -
272 for(int i = 0; i < len; i++) {
evaluated: i < len
TRUEFALSE
yes
Evaluation Count:1787
yes
Evaluation Count:249
249-1787
273 if(name[i] != QLatin1Char('\t') && name[i] != QLatin1Char(' '))
partially evaluated: name[i] != QLatin1Char('\t')
TRUEFALSE
yes
Evaluation Count:1787
no
Evaluation Count:0
evaluated: name[i] != QLatin1Char(' ')
TRUEFALSE
yes
Evaluation Count:1783
yes
Evaluation Count:4
0-1787
274 name_no_space[pos++] = name[i].toLatin1();
executed: name_no_space[pos++] = name[i].toLatin1();
Execution Count:1783
1783
275 }
executed: }
Execution Count:1787
1787
276 name_no_space[pos] = 0; -
277 return get_named_rgb(name_no_space, rgb);
executed: return get_named_rgb(name_no_space, rgb);
Execution Count:249
249
278} -
279 -
280 -
281uint qt_get_rgb_val(const char *name) -
282{ -
283 QRgb r = 0; -
284 qt_get_named_rgb(name,&r); -
285 return r;
never executed: return r;
0
286} -
287 -
288QStringList qt_get_colornames() -
289{ -
290 int i = 0; -
291 QStringList lst; -
292 for (i = 0; i < rgbTblSize; i++)
evaluated: i < rgbTblSize
TRUEFALSE
yes
Evaluation Count:148
yes
Evaluation Count:1
1-148
293 lst << QLatin1String(rgbTbl[i].name);
executed: lst << QLatin1String(rgbTbl[i].name);
Execution Count:148
148
294 return lst;
executed: return lst;
Execution Count:1
1
295} -
296 -
297 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial