App

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

Blender_protected.cpp
Go to the documentation of this file.
1
7 #include "Blender.hpp"
8
9 #include <iostream>
10
11 namespace app {
12
13 Blender::Blender() {}
14 Blender::~Blender() {}
15
16 /* Takto vypadá expandované makro, co je níže:
17 blendf_argb_sd Blender::getBlendFunction_argb_sd(BlendMode mode) {
18 switch (mode) {
19 case BLEND_MODE_NORMAL:
20 return Blender::blend_normal_argb_sd;
21 break;
22 case BLEND_MODE_DISSOLVE:
23 return Blender::blend_normal_argb_sd;
24 break;
25
26 case BLEND_MODE_BEHIND:
27 return Blender::blend_normal_argb_sd;
28 break;
29 case BLEND_MODE_CLEAR:
30 return Blender::blend_normal_argb_sd;
31 break;
32
33 case BLEND_MODE_DARKEN:
34 return Blender::blend_darken_argb_sd;
35 break;
36 case BLEND_MODE_MULTIPLY:
37 return Blender::blend_multiply_argb_sd;
38 break;
39 case BLEND_MODE_COLOR_BURN:
40 return Blender::blend_normal_argb_sd;
41 break;
42 case BLEND_MODE_LINEAR_BURN:
43 return Blender::blend_normal_argb_sd;
44 break;
45 case BLEND_MODE_DARKER_COLOR:
46 return Blender::blend_normal_argb_sd;
47 break;
48
49 case BLEND_MODE_LIGHTEN:
50 return Blender::blend_normal_argb_sd;
51 break;
52 case BLEND_MODE_SCREEN:
53 return Blender::blend_normal_argb_sd;
54 break;
55 case BLEND_MODE_COLOR_DODGE:
56 return Blender::blend_normal_argb_sd;
57 break;
58 case BLEND_MODE_LINEAR_DODGE_ADD:
59 return Blender::blend_normal_argb_sd;
60 break;
61 case BLEND_MODE_LIGHTER_COLOR:
62 return Blender::blend_normal_argb_sd;
63 break;
64
65 case BLEND_MODE_OVERLAY:
66 return Blender::blend_normal_argb_sd;
67 break;
68 case BLEND_MODE_SOFT_LIGHT:
69 return Blender::blend_normal_argb_sd;
70 break;
71 case BLEND_MODE_HARD_LIGHT:
72 return Blender::blend_normal_argb_sd;
73 break;
74 case BLEND_MODE_VIVID_LIGHT:
75 return Blender::blend_normal_argb_sd;
76 break;
77 case BLEND_MODE_LINEAR_LIGHT:
78 return Blender::blend_normal_argb_sd;
79 break;
80 case BLEND_MODE_PIN_LIGHT:
81 return Blender::blend_normal_argb_sd;
82 break;
83 case BLEND_MODE_HARD_MIX:
84 return Blender::blend_normal_argb_sd;
85 break;
86
87 case BLEND_MODE_DIFFERENCE:
88 return Blender::blend_normal_argb_sd;
89 break;
90 case BLEND_MODE_EXCLUSION:
91 return Blender::blend_normal_argb_sd;
92 break;
93 case BLEND_MODE_SUBTRACT:
94 return Blender::blend_normal_argb_sd;
95 break;
96 case BLEND_MODE_DIVIDE:
97 return Blender::blend_normal_argb_sd;
98 break;
99
100 case BLEND_MODE_HUE:
101 return Blender::blend_normal_argb_sd;
102 break;
103 case BLEND_MODE_SATURATION:
104 return Blender::blend_normal_argb_sd;
105 break;
106 case BLEND_MODE_COLOR:
107 return Blender::blend_normal_argb_sd;
108 break;
109 case BLEND_MODE_LUMINOSITY:
110 return Blender::blend_normal_argb_sd;
111 break;
112 default:
113 return 0;
114 break;
115 }
116 }
117 */
118
119 DEFINE_ARGB_FUNCTION_SELECTOR(sd)
120 DEFINE_ARGB_FUNCTION_SELECTOR(sda)
121 DEFINE_ARGB_FUNCTION_SELECTOR(sdm)
122 DEFINE_ARGB_FUNCTION_SELECTOR(sdma)
123 DEFINE_ARGB_FUNCTION_SELECTOR(cdm)
124 DEFINE_ARGB_FUNCTION_SELECTOR(cd)
125
126 int Blender::blend_add_onech_sd(PARAMS_SD) {
127 FOREACH(d, dstAreaEnd, dstAreaRowEnd,
128 ADD_ONECH_SD(s, d),
129 AREA_INCREMENT_SD(s, d, dstAreaRowEnd, dstByteWidth, srcByteOffset, dstByteOffset)
130 )
131 return 1;
132 }
133
134 int Blender::blend_add_onech_sda(PARAMS_SDA) {
135 FOREACH(d, dstAreaEnd, dstAreaRowEnd,
136 ADD_ONECH_SDA(s, d, alpha),
137 AREA_INCREMENT_SD(s, d, dstAreaRowEnd, dstByteWidth, srcByteOffset, dstByteOffset)
138 )
139 return 1;
140 }
141
142 int Blender::blend_add_onech_sdm(PARAMS_SDM) {
143 FOREACH(d, dstAreaEnd, dstAreaRowEnd,
144 ADD_ONECH_SDM(s, d, m),
145 AREA_INCREMENT_SDM(s, d, m, dstAreaRowEnd, dstByteWidth, srcByteOffset, dstByteOffset, mskByteOffset)
146 )
147 return 1;
148 }
149
150 int Blender::blend_add_onech_sdma(PARAMS_SDMA) {
151 FOREACH(d, dstAreaEnd, dstAreaRowEnd,
152 ADD_ONECH_SDMA(s, d, m, alpha),
153 AREA_INCREMENT_SDM(s, d, m, dstAreaRowEnd, dstByteWidth, srcByteOffset, dstByteOffset, mskByteOffset)
154 )
155 return 1;
156 }
157
158 int Blender::blend_remove_onech_sd(PARAMS_SD) {
159 FOREACH(d, dstAreaEnd, dstAreaRowEnd,
160 REM_ONECH_SD(s, d),
161 AREA_INCREMENT_SD(s, d, dstAreaRowEnd, dstByteWidth, srcByteOffset, dstByteOffset)
162 )
163 return 1;
164 }
165
166 int Blender::blend_remove_onech_sda(PARAMS_SDA) {
167 FOREACH(d, dstAreaEnd, dstAreaRowEnd,
168 REM_ONECH_SDA(s, d, alpha),
169 AREA_INCREMENT_SD(s, d, dstAreaRowEnd, dstByteWidth, srcByteOffset, dstByteOffset)
170 )
171 return 1;
172 }
173
174 int Blender::blend_remove_onech_sdm(PARAMS_SDM) {
175 FOREACH(d, dstAreaEnd, dstAreaRowEnd,
176 REM_ONECH_SDM(s, d, m),
177 AREA_INCREMENT_SDM(s, d, m, dstAreaRowEnd, dstByteWidth, srcByteOffset, dstByteOffset, mskByteOffset)
178 )
179 return 1;
180 }
181
182 int Blender::blend_remove_onech_sdma(PARAMS_SDMA) {
183 FOREACH(d, dstAreaEnd, dstAreaRowEnd,
184 REM_ONECH_SDMA(s, d, m, alpha),
185 AREA_INCREMENT_SDM(s, d, m, dstAreaRowEnd, dstByteWidth, srcByteOffset, dstByteOffset, mskByteOffset)
186 )
187 return 1;
188 }
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204 int Blender::blend_add_argb_sd(PARAMS_SD) {
205 FOREACH(d, dstAreaEnd, dstAreaRowEnd,
206 ADD_RGBA_SD(s, d),
207 AREA_INCREMENT_SD(s, d, dstAreaRowEnd, dstByteWidth, srcByteOffset, dstByteOffset)
208 )
209 return 1;
210 }
211 int Blender::blend_add_argb_sda(PARAMS_SDA) {
212 FOREACH(d, dstAreaEnd, dstAreaRowEnd,
213 ADD_RGBA_SDA(s, d, alpha),
214 AREA_INCREMENT_SD(s, d, dstAreaRowEnd, dstByteWidth, srcByteOffset, dstByteOffset)
215 )
216 return 1;
217 }
218 int Blender::blend_add_argb_sdm(PARAMS_SDM) {
219 FOREACH(d, dstAreaEnd, dstAreaRowEnd,
220 ADD_RGBA_SDM(s, d, m),
221 AREA_INCREMENT_SDM(s, d, m, dstAreaRowEnd, dstByteWidth, srcByteOffset, dstByteOffset, mskByteOffset)
222 )
223 return 1;
224 }
225 int Blender::blend_add_argb_sdma(PARAMS_SDMA) {
226 FOREACH(d, dstAreaEnd, dstAreaRowEnd,
227 ADD_RGBA_SDMA(s, d, m, alpha),
228 AREA_INCREMENT_SDM(s, d, m, dstAreaRowEnd, dstByteWidth, srcByteOffset, dstByteOffset, mskByteOffset)
229 )
230 return 1;
231 }
232 int Blender::blend_remove_argb_sd(PARAMS_SD) {
233 FOREACH(d, dstAreaEnd, dstAreaRowEnd,
234 REM_RGBA_SD(s, d),
235 AREA_INCREMENT_SD(s, d, dstAreaRowEnd, dstByteWidth, srcByteOffset, dstByteOffset)
236 )
237 return 1;
238 }
239 int Blender::blend_remove_argb_sda(PARAMS_SDA) {
240 FOREACH(d, dstAreaEnd, dstAreaRowEnd,
241 REM_RGBA_SDA(s, d, alpha),
242 AREA_INCREMENT_SD(s, d, dstAreaRowEnd, dstByteWidth, srcByteOffset, dstByteOffset)
243 )
244 return 1;
245 }
246 int Blender::blend_remove_argb_sdm(PARAMS_SDM) {
247 FOREACH(d, dstAreaEnd, dstAreaRowEnd,
248 REM_RGBA_SDM(s, d, m),
249 AREA_INCREMENT_SDM(s, d, m, dstAreaRowEnd, dstByteWidth, srcByteOffset, dstByteOffset, mskByteOffset)
250 )
251 return 1;
252 }
253 int Blender::blend_remove_argb_sdma(PARAMS_SDMA) {
254 FOREACH(d, dstAreaEnd, dstAreaRowEnd,
255 REM_RGBA_SDMA(s, d, m, alpha),
256 AREA_INCREMENT_SDM(s, d, m, dstAreaRowEnd, dstByteWidth, srcByteOffset, dstByteOffset, mskByteOffset)
257 )
258 return 1;
259 }
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295 /* Takto vypadá expandované makro, co je níže:
296 int Blender::blend_normal_argb_sd(uchar *s, uchar *d, uchar *dstAreaEnd,
297 uchar * dstAreaRowEnd, int dstByteWidth, int srcByteOffset,
298 int dstByteOffset) {
299 while (d < dstAreaEnd) {
300 while (d < dstAreaRowEnd) {
301 double sa = *(s + 3) / 255.0;
302 double da = *(d + 3) / 255.0;
303 double sac = 1 - sa;
304 double ra = sa + da * sac;
305 *d = ((*s * sa + *d * da * sac) / ra + 0.5);
306 s++;
307 d++;
308 *d = ((*s * sa + *d * da * sac) / ra + 0.5);
309 s++;
310 d++;
311 *d = ((*s * sa + *d * da * sac) / ra + 0.5);
312 s++;
313 d++;
314 *d = ra * 255 + 0.5;
315 s++;
316 d++;
317 }
318 s += srcByteOffset;
319 d += dstByteOffset;
320 dstAreaRowEnd += dstByteWidth;
321 }
322 return 1;
323 }
324
325 int Blender::blend_normal_argb_sda(uchar *s, uchar *d, uchar *dstAreaEnd,
326 uchar *dstAreaRowEnd, int dstByteWidth, int srcByteOffset,
327 int dstByteOffset, double alpha) {
328 while (d < dstAreaEnd) {
329 while (d < dstAreaRowEnd) {
330 double sa = *(s + 3) * alpha / 255.0;
331 double da = *(d + 3) / 255.0;
332 double sac = 1 - sa;
333 double ra = sa + da * sac;
334 *d = ((*s * sa + *d * da * sac) / ra + 0.5);
335 s++;
336 d++;
337 *d = ((*s * sa + *d * da * sac) / ra + 0.5);
338 s++;
339 d++;
340 *d = ((*s * sa + *d * da * sac) / ra + 0.5);
341 s++;
342 d++;
343 *d = ra * 255 + 0.5;
344 s++;
345 d++;
346 }
347 s += srcByteOffset;
348 d += dstByteOffset;
349 dstAreaRowEnd += dstByteWidth;
350 }
351 return 1;
352 }
353
354 int Blender::blend_normal_argb_sdm(uchar *s, uchar *d, uchar *m,
355 uchar *dstAreaEnd, uchar *dstAreaRowEnd, int dstByteWidth,
356 int srcByteOffset, int dstByteOffset, int mskByteOffset) {
357 while (d < dstAreaEnd) {
358 while (d < dstAreaRowEnd) {
359 double sa = *(s + 3) * *m / 65025.0;
360 double da = *(d + 3) / 255.0;
361 double sac = 1 - sa;
362 double ra = sa + da * sac;
363 m++;
364 *d = ((*s * sa + *d * da * sac) / ra + 0.5);
365 s++;
366 d++;
367 *d = ((*s * sa + *d * da * sac) / ra + 0.5);
368 s++;
369 d++;
370 *d = ((*s * sa + *d * da * sac) / ra + 0.5);
371 s++;
372 d++;
373 *d = ra * 255 + 0.5;
374 s++;
375 d++;
376 }
377 s += srcByteOffset;
378 d += dstByteOffset;
379 m += mskByteOffset;
380 dstAreaRowEnd += dstByteWidth;
381 }
382 return 1;
383 }
384
385 int Blender::blend_normal_argb_sdma(uchar *s, uchar *d, uchar *m,
386 uchar *dstAreaEnd, uchar *dstAreaRowEnd, int dstByteWidth,
387 int srcByteOffset, int dstByteOffset, int mskByteOffset, double alpha) {
388 while (d < dstAreaEnd) {
389 while (d < dstAreaRowEnd) {
390 double sa = *(s + 3) * *m * alpha / 65025.0;
391 double da = *(d + 3) / 255.0;
392 double sac = 1 - sa;
393 double ra = sa + da * sac;
394 m++;
395 *d = ((*s * sa + *d * da * sac) / ra + 0.5);
396 s++;
397 d++;
398 *d = ((*s * sa + *d * da * sac) / ra + 0.5);
399 s++;
400 d++;
401 *d = ((*s * sa + *d * da * sac) / ra + 0.5);
402 s++;
403 d++;
404 *d = ra * 255 + 0.5;
405 s++;
406 d++;
407 }
408 s += srcByteOffset;
409 d += dstByteOffset;
410 m += mskByteOffset;
411 dstAreaRowEnd += dstByteWidth;
412 }
413 return 1;
414 }
415
416 int Blender::blend_normal_argb_cdm(uchar *c, uchar *d, uchar *m,
417 uchar *dstAreaEnd, uchar *dstAreaRowEnd, int dstByteWidth, int clrbpp,
418 int dstByteOffset, int mskByteOffset) {
419 while (d < dstAreaEnd) {
420 while (d < dstAreaRowEnd) {
421 double sa = *(c + 3) * *m / 65025.0;
422 double da = *(d + 3) / 255.0;
423 double sac = 1 - sa;
424 double ra = sa + da * sac;
425 m++;
426 *d = ((*c * sa + *d * da * sac) / ra + 0.5);
427 c++;
428 d++;
429 *d = ((*c * sa + *d * da * sac) / ra + 0.5);
430 c++;
431 d++;
432 *d = ((*c * sa + *d * da * sac) / ra + 0.5);
433 c++;
434 d++;
435 *d = ra * 255 + 0.5;
436 c++;
437 d++;
438 c -= clrbpp;
439 }
440 d += dstByteOffset;
441 m += mskByteOffset;
442 dstAreaRowEnd += dstByteWidth;
443 }
444 return 1;
445 }
446 */
447
448
449
450
451
452
453
454
455 DEFINE_BLEND_FUNCTIONS(normal,NORMAL)
456
457 DEFINE_BLEND_FUNCTIONS_COMPLEX(behind, BEHIND)
458
459 DEFINE_BLEND_FUNCTIONS_COMPLEX(clear, CLEAR)
460
461 DEFINE_BLEND_FUNCTIONS(darken,DARKEN)
462 DEFINE_BLEND_FUNCTIONS(multiply,MULTIPLY)
463 DEFINE_BLEND_FUNCTIONS(colorBurn,COLOR_BURN)
464 DEFINE_BLEND_FUNCTIONS(linearBurn,LINEAR_BURN)
465 DEFINE_BLEND_FUNCTIONS(darkerColor,DARKER_COLOR) // NEIMPLEMENTOVÁNO
466
467 DEFINE_BLEND_FUNCTIONS(lighten,LIGHTEN)
468 DEFINE_BLEND_FUNCTIONS(screen,SCREEN)
469 DEFINE_BLEND_FUNCTIONS(colorDodge,COLOR_DODGE)
470 DEFINE_BLEND_FUNCTIONS(linearDodgeAdd,LINEAR_DODGE_ADD)
471 DEFINE_BLEND_FUNCTIONS(lighterColor,LIGHTER_COLOR)
472
473 DEFINE_BLEND_FUNCTIONS(overlay, OVERLAY)
474 DEFINE_BLEND_FUNCTIONS(softLight, SOFT_LIGHT)
475 DEFINE_BLEND_FUNCTIONS(hardLight, HARD_LIGHT)
476 DEFINE_BLEND_FUNCTIONS(vividLight, VIVID_LIGHT)
477 DEFINE_BLEND_FUNCTIONS(linearLight, LINEAR_LIGHT)
478 DEFINE_BLEND_FUNCTIONS(pinLight, PIN_LIGHT)
479 DEFINE_BLEND_FUNCTIONS(hardMix, HARD_MIX)
480
481 DEFINE_BLEND_FUNCTIONS(difference, DIFFERENCE)
482 DEFINE_BLEND_FUNCTIONS(exclusion, EXCLUSION)
483 DEFINE_BLEND_FUNCTIONS(subtract, SUBTRACT)
484 DEFINE_BLEND_FUNCTIONS(divide, DIVIDE)
485
486 DEFINE_BLEND_FUNCTIONS(hue, HUE)
487 DEFINE_BLEND_FUNCTIONS(saturation, SATURATION)
488 DEFINE_BLEND_FUNCTIONS(color, COLOR)
489 DEFINE_BLEND_FUNCTIONS(luminosity, LUMINOSITY)
490
491 } /* namespace app */