Debian Codegraph @

thirdparty/thorvg/src/renderer/sw_engine/tvgSwCommon.h

raw symbols SCIP
1 /*
2 * Copyright (c) 2020 - 2024 the ThorVG project. All rights reserved.
3
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10
11 * The above copyright notice and this permission notice shall be included in all
12 * copies or substantial portions of the Software.
13
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23 #ifndef _TVG_SW_COMMON_H_
24 #define _TVG_SW_COMMON_H_
25
26 #include "tvgCommon.h"
27 #include "tvgMath.h"
28 #include "tvgRender.h"
29
30 #define SW_CURVE_TYPE_POINT 0
31 #define SW_CURVE_TYPE_CUBIC 1
32 #define SW_ANGLE_PI (180L << 16)
33 #define SW_ANGLE_2PI (SW_ANGLE_PI << 1)
34 #define SW_ANGLE_PI2 (SW_ANGLE_PI >> 1)
35
36 using SwCoord = signed long;
37 using SwFixed = signed long long;
38 #define SW_COLOR_TABLE 1024
39
40
41 static inline float TO_FLOAT(SwCoord val)
42 {
43 return static_cast<float>(val) / 64.0f;
44 }
45
46 struct SwPoint
47 {
48 SwCoord x, y;
49
50 SwPoint& operator+=(const SwPoint& rhs)
51 {
52 x += rhs.x;
53 y += rhs.y;
54 return *this;
55 }
56
57 SwPoint operator+(const SwPoint& rhs) const
58 {
59 return {x + rhs.x, y + rhs.y};
60 }
61
62 SwPoint operator-(const SwPoint& rhs) const
63 {
64 return {x - rhs.x, y - rhs.y};
65 }
66
67 bool operator==(const SwPoint& rhs) const
68 {
69 return (x == rhs.x && y == rhs.y);
70 }
71
72 bool operator!=(const SwPoint& rhs) const
73 {
74 return (x != rhs.x || y != rhs.y);
75 }
76
77 bool zero() const
78 {
79 if (x == 0 && y == 0) return true;
80 else return false;
81 }
82
83 bool small() const
84 {
85 //2 is epsilon...
86 if (abs(x) < 2 && abs(y) < 2) return true;
87 else return false;
88 }
89
90 Point toPoint() const
91 {
92 return {TO_FLOAT(x), TO_FLOAT(y)};
93 }
94 };
95
96 struct SwSize
97 {
98 SwCoord w, h;
99 };
100
101 struct SwOutline
102 {
103 Array<SwPoint> pts; //the outline's points
104 Array<uint32_t> cntrs; //the contour end points
105 Array<uint8_t> types; //curve type
106 Array<bool> closed; //opened or closed path?
107 FillRule fillRule;
108 };
109
110 struct SwSpan
111 {
112 uint16_t x, y;
113 uint16_t len;
114 uint8_t coverage;
115 };
116
117 struct SwRle
118 {
119 SwSpan *spans;
120 uint32_t alloc;
121 uint32_t size;
122 };
123
124 struct SwBBox
125 {
126 SwPoint min, max;
127
128 void reset()
129 {
130 min.x = min.y = max.x = max.y = 0;
131 }
132
133 int32_t w() const { return max.x - min.x; }
134 int32_t h() const { return max.y - min.y; }
135 };
136
137 using Area = long;
138
139 struct SwCell
140 {
141 int32_t x;
142 int32_t cover;
143 Area area;
144 SwCell *next;
145 };
146
147 struct SwFill
148 {
149 struct SwLinear {
150 float dx, dy;
151 float offset;
152 };
153
154 struct SwRadial {
155 float a11, a12, a13;
156 float a21, a22, a23;
157 float fx, fy, fr;
158 float dx, dy, dr;
159 float invA, a;
160 };
161
162 union {
163 SwLinear linear;
164 SwRadial radial;
165 };
166
167 uint32_t ctable[SW_COLOR_TABLE];
168 FillSpread spread;
169
170 bool solid = false; //solid color fill with the last color from colorStops
171 bool translucent;
172 };
173
174 struct SwStrokeBorder
175 {
176 uint32_t ptsCnt;
177 uint32_t maxPts;
178 SwPoint* pts;
179 uint8_t* tags;
180 int32_t start; //index of current sub-path start point
181 bool movable; //true: for ends of lineto borders
182 };
183
184 struct SwStroke
185 {
186 SwFixed angleIn;
187 SwFixed angleOut;
188 SwPoint center;
189 SwFixed lineLength;
190 SwFixed subPathAngle;
191 SwPoint ptStartSubPath;
192 SwFixed subPathLineLength;
193 SwFixed width;
194 SwFixed miterlimit;
195
196 StrokeCap cap;
197 StrokeJoin join;
198 StrokeJoin joinSaved;
199 SwFill* fill = nullptr;
200
201 SwStrokeBorder borders[2];
202
203 float sx, sy;
204
205 bool firstPt;
206 bool closedSubPath;
207 bool handleWideStrokes;
208 };
209
210 struct SwDashStroke
211 {
212 SwOutline* outline = nullptr;
213 float curLen = 0;
214 int32_t curIdx = 0;
215 Point ptStart = {0, 0};
216 Point ptCur = {0, 0};
217 float* pattern = nullptr;
218 uint32_t cnt = 0;
219 bool curOpGap = false;
220 bool move = true;
221 };
222
223 struct SwShape
224 {
225 SwOutline* outline = nullptr;
226 SwStroke* stroke = nullptr;
227 SwFill* fill = nullptr;
228 SwRle* rle = nullptr;
229 SwRle* strokeRle = nullptr;
230 SwBBox bbox; //Keep it boundary without stroke region. Using for optimal filling.
231
232 bool fastTrack = false; //Fast Track: axis-aligned rectangle without any clips?
233 };
234
235 struct SwImage
236 {
237 SwOutline* outline = nullptr;
238 SwRle* rle = nullptr;
239 union {
240 pixel_t* data; //system based data pointer
241 uint32_t* buf32; //for explicit 32bits channels
242 uint8_t* buf8; //for explicit 8bits grayscale
243 };
244 uint32_t w, h, stride;
245 int32_t ox = 0; //offset x
246 int32_t oy = 0; //offset y
247 float scale;
248 uint8_t channelSize;
249
250 bool direct = false; //draw image directly (with offset)
251 bool scaled = false; //draw scaled image
252 };
253
254 typedef uint8_t(*SwMask)(uint8_t s, uint8_t d, uint8_t a); //src, dst, alpha
255 typedef uint32_t(*SwBlender)(uint32_t s, uint32_t d, uint8_t a); //src, dst, alpha
256 typedef uint32_t(*SwJoin)(uint8_t r, uint8_t g, uint8_t b, uint8_t a); //color channel join
257 typedef uint8_t(*SwAlpha)(uint8_t*); //blending alpha
258
259 struct SwCompositor;
260
261 struct SwSurface : RenderSurface
262 {
263 SwJoin join;
264 SwAlpha alphas[4]; //Alpha:2, InvAlpha:3, Luma:4, InvLuma:5
265 SwBlender blender = nullptr; //blender (optional)
266 SwCompositor* compositor = nullptr; //compositor (optional)
267 BlendMethod blendMethod = BlendMethod::Normal;
268
269 SwAlpha alpha(CompositeMethod method)
270 {
271 auto idx = (int)(method) - 2; //0: None, 1: ClipPath
272 return alphas[idx > 3 ? 0 : idx]; //CompositeMethod has only four Matting methods.
273 }
274
275 SwSurface()
276 {
277 }
278
279 SwSurface(const SwSurface* rhs) : RenderSurface(rhs)
280 {
281 join = rhs->join;
282 memcpy(alphas, rhs->alphas, sizeof(alphas));
283 blender = rhs->blender;
284 compositor = rhs->compositor;
285 blendMethod = rhs->blendMethod;
286 }
287 };
288
289 struct SwCompositor : RenderCompositor
290 {
291 SwSurface* recoverSfc; //Recover surface when composition is started
292 SwCompositor* recoverCmp; //Recover compositor when composition is done
293 SwImage image;
294 SwBBox bbox;
295 bool valid;
296 };
297
298 struct SwCellPool
299 {
300 #define DEFAULT_POOL_SIZE 16368
301
302 uint32_t size;
303 SwCell* buffer;
304
305 SwCellPool() : size(DEFAULT_POOL_SIZE), buffer((SwCell*)malloc(DEFAULT_POOL_SIZE)) {}
306 ~SwCellPool() { free(buffer); }
307 };
308
309 struct SwMpool
310 {
311 SwOutline* outline;
312 SwOutline* strokeOutline;
313 SwCellPool* cellPool;
314 unsigned allocSize;
315 };
316
317 static inline SwCoord TO_SWCOORD(float val)
318 {
319 return SwCoord(val * 64.0f);
320 }
321
322 static inline uint32_t JOIN(uint8_t c0, uint8_t c1, uint8_t c2, uint8_t c3)
323 {
324 return (c0 << 24 | c1 << 16 | c2 << 8 | c3);
325 }
326
327 static inline uint32_t ALPHA_BLEND(uint32_t c, uint32_t a)
328 {
329 ++a;
330 return (((((c >> 8) & 0x00ff00ff) * a) & 0xff00ff00) + ((((c & 0x00ff00ff) * a) >> 8) & 0x00ff00ff));
331 }
332
333 static inline uint32_t INTERPOLATE(uint32_t s, uint32_t d, uint8_t a)
334 {
335 return (((((((s >> 8) & 0xff00ff) - ((d >> 8) & 0xff00ff)) * a) + (d & 0xff00ff00)) & 0xff00ff00) + ((((((s & 0xff00ff) - (d & 0xff00ff)) * a) >> 8) + (d & 0xff00ff)) & 0xff00ff));
336 }
337
338 static inline uint8_t INTERPOLATE8(uint8_t s, uint8_t d, uint8_t a)
339 {
340 return (((s) * (a) + 0xff) >> 8) + (((d) * ~(a) + 0xff) >> 8);
341 }
342
343 static inline SwCoord HALF_STROKE(float width)
344 {
345 return TO_SWCOORD(width * 0.5f);
346 }
347
348 static inline uint8_t A(uint32_t c)
349 {
350 return ((c) >> 24);
351 }
352
353 static inline uint8_t IA(uint32_t c)
354 {
355 return (~(c) >> 24);
356 }
357
358 static inline uint8_t C1(uint32_t c)
359 {
360 return ((c) >> 16);
361 }
362
363 static inline uint8_t C2(uint32_t c)
364 {
365 return ((c) >> 8);
366 }
367
368 static inline uint8_t C3(uint32_t c)
369 {
370 return (c);
371 }
372
373 static inline uint32_t opBlendInterp(uint32_t s, uint32_t d, uint8_t a)
374 {
375 return INTERPOLATE(s, d, a);
376 }
377
378 static inline uint32_t opBlendNormal(uint32_t s, uint32_t d, uint8_t a)
379 {
380 auto t = ALPHA_BLEND(s, a);
381 return t + ALPHA_BLEND(d, IA(t));
382 }
383
384 static inline uint32_t opBlendPreNormal(uint32_t s, uint32_t d, TVG_UNUSED uint8_t a)
385 {
386 return s + ALPHA_BLEND(d, IA(s));
387 }
388
389 static inline uint32_t opBlendSrcOver(uint32_t s, TVG_UNUSED uint32_t d, TVG_UNUSED uint8_t a)
390 {
391 return s;
392 }
393
394 //TODO: BlendMethod could remove the alpha parameter.
395 static inline uint32_t opBlendDifference(uint32_t s, uint32_t d, TVG_UNUSED uint8_t a)
396 {
397 //if (s > d) => s - d
398 //else => d - s
399 auto c1 = (C1(s) > C1(d)) ? (C1(s) - C1(d)) : (C1(d) - C1(s));
400 auto c2 = (C2(s) > C2(d)) ? (C2(s) - C2(d)) : (C2(d) - C2(s));
401 auto c3 = (C3(s) > C3(d)) ? (C3(s) - C3(d)) : (C3(d) - C3(s));
402 return JOIN(255, c1, c2, c3);
403 }
404
405 static inline uint32_t opBlendExclusion(uint32_t s, uint32_t d, TVG_UNUSED uint8_t a)
406 {
407 // (s + d) - (2 * s * d)
408 auto c1 = C1(s) + C1(d) - 2 * MULTIPLY(C1(s), C1(d));
409 tvg::clamp(c1, 0, 255);
410 auto c2 = C2(s) + C2(d) - 2 * MULTIPLY(C2(s), C2(d));
411 tvg::clamp(c2, 0, 255);
412 auto c3 = C3(s) + C3(d) - 2 * MULTIPLY(C3(s), C3(d));
413 tvg::clamp(c3, 0, 255);
414 return JOIN(255, c1, c2, c3);
415 }
416
417 static inline uint32_t opBlendAdd(uint32_t s, uint32_t d, TVG_UNUSED uint8_t a)
418 {
419 // s + d
420 auto c1 = std::min(C1(s) + C1(d), 255);
421 auto c2 = std::min(C2(s) + C2(d), 255);
422 auto c3 = std::min(C3(s) + C3(d), 255);
423 return JOIN(255, c1, c2, c3);
424 }
425
426 static inline uint32_t opBlendScreen(uint32_t s, uint32_t d, TVG_UNUSED uint8_t a)
427 {
428 // s + d - s * d
429 auto c1 = C1(s) + C1(d) - MULTIPLY(C1(s), C1(d));
430 auto c2 = C2(s) + C2(d) - MULTIPLY(C2(s), C2(d));
431 auto c3 = C3(s) + C3(d) - MULTIPLY(C3(s), C3(d));
432 return JOIN(255, c1, c2, c3);
433 }
434
435 static inline uint32_t opBlendMultiply(uint32_t s, uint32_t d, TVG_UNUSED uint8_t a)
436 {
437 // s * d
438 auto c1 = MULTIPLY(C1(s), C1(d));
439 auto c2 = MULTIPLY(C2(s), C2(d));
440 auto c3 = MULTIPLY(C3(s), C3(d));
441 return JOIN(255, c1, c2, c3);
442 }
443
444 static inline uint32_t opBlendOverlay(uint32_t s, uint32_t d, TVG_UNUSED uint8_t a)
445 {
446 // if (2 * d < da) => 2 * s * d,
447 // else => 1 - 2 * (1 - s) * (1 - d)
448 auto c1 = (C1(d) < 128) ? std::min(255, 2 * MULTIPLY(C1(s), C1(d))) : (255 - std::min(255, 2 * MULTIPLY(255 - C1(s), 255 - C1(d))));
449 auto c2 = (C2(d) < 128) ? std::min(255, 2 * MULTIPLY(C2(s), C2(d))) : (255 - std::min(255, 2 * MULTIPLY(255 - C2(s), 255 - C2(d))));
450 auto c3 = (C3(d) < 128) ? std::min(255, 2 * MULTIPLY(C3(s), C3(d))) : (255 - std::min(255, 2 * MULTIPLY(255 - C3(s), 255 - C3(d))));
451 return JOIN(255, c1, c2, c3);
452 }
453
454 static inline uint32_t opBlendDarken(uint32_t s, uint32_t d, TVG_UNUSED uint8_t a)
455 {
456 // min(s, d)
457 auto c1 = std::min(C1(s), C1(d));
458 auto c2 = std::min(C2(s), C2(d));
459 auto c3 = std::min(C3(s), C3(d));
460 return JOIN(255, c1, c2, c3);
461 }
462
463 static inline uint32_t opBlendLighten(uint32_t s, uint32_t d, TVG_UNUSED uint8_t a)
464 {
465 // max(s, d)
466 auto c1 = std::max(C1(s), C1(d));
467 auto c2 = std::max(C2(s), C2(d));
468 auto c3 = std::max(C3(s), C3(d));
469 return JOIN(255, c1, c2, c3);
470 }
471
472 static inline uint32_t opBlendColorDodge(uint32_t s, uint32_t d, TVG_UNUSED uint8_t a)
473 {
474 // d / (1 - s)
475 s = 0xffffffff - s;
476 auto c1 = C1(d) == 0 ? 0 : (C1(s) == 0 ? 255 : std::min(C1(d) * 255 / C1(s), 255));
477 auto c2 = C2(d) == 0 ? 0 : (C2(s) == 0 ? 255 : std::min(C2(d) * 255 / C2(s), 255));
478 auto c3 = C3(d) == 0 ? 0 : (C3(s) == 0 ? 255 : std::min(C3(d) * 255 / C3(s), 255));
479 return JOIN(255, c1, c2, c3);
480 }
481
482 static inline uint32_t opBlendColorBurn(uint32_t s, uint32_t d, TVG_UNUSED uint8_t a)
483 {
484 // 1 - (1 - d) / s
485 auto id = 0xffffffff - d;
486 auto c1 = C1(d) == 255 ? 255 : (C1(s) == 0 ? 0 : 255 - std::min(C1(id) * 255 / C1(s), 255));
487 auto c2 = C2(d) == 255 ? 255 : (C2(s) == 0 ? 0 : 255 - std::min(C2(id) * 255 / C2(s), 255));
488 auto c3 = C3(d) == 255 ? 255 : (C3(s) == 0 ? 0 : 255 - std::min(C3(id) * 255 / C3(s), 255));
489
490 return JOIN(255, c1, c2, c3);
491 }
492
493 static inline uint32_t opBlendHardLight(uint32_t s, uint32_t d, TVG_UNUSED uint8_t a)
494 {
495 // if (s < sa), (2 * s * d)
496 // else (sa * da) - 2 * (da - s) * (sa - d)
497 auto c1 = (C1(s) < 128) ? std::min(255, 2 * MULTIPLY(C1(s), C1(d))) : (255 - std::min(255, 2 * MULTIPLY(255 - C1(s), 255 - C1(d))));
498 auto c2 = (C2(s) < 128) ? std::min(255, 2 * MULTIPLY(C2(s), C2(d))) : (255 - std::min(255, 2 * MULTIPLY(255 - C2(s), 255 - C2(d))));
499 auto c3 = (C3(s) < 128) ? std::min(255, 2 * MULTIPLY(C3(s), C3(d))) : (255 - std::min(255, 2 * MULTIPLY(255 - C3(s), 255 - C3(d))));
500 return JOIN(255, c1, c2, c3);
501 }
502
503 static inline uint32_t opBlendSoftLight(uint32_t s, uint32_t d, TVG_UNUSED uint8_t a)
504 {
505 //(255 - 2 * s) * (d * d) + (2 * s * b)
506 auto c1 = MULTIPLY(255 - std::min(255, 2 * C1(s)), MULTIPLY(C1(d), C1(d))) + std::min(255, 2 * MULTIPLY(C1(s), C1(d)));
507 auto c2 = MULTIPLY(255 - std::min(255, 2 * C2(s)), MULTIPLY(C2(d), C2(d))) + std::min(255, 2 * MULTIPLY(C2(s), C2(d)));
508 auto c3 = MULTIPLY(255 - std::min(255, 2 * C3(s)), MULTIPLY(C3(d), C3(d))) + std::min(255, 2 * MULTIPLY(C3(s), C3(d)));
509 return JOIN(255, c1, c2, c3);
510 }
511
512
513 int64_t mathMultiply(int64_t a, int64_t b);
514 int64_t mathDivide(int64_t a, int64_t b);
515 int64_t mathMulDiv(int64_t a, int64_t b, int64_t c);
516 void mathRotate(SwPoint& pt, SwFixed angle);
517 SwFixed mathTan(SwFixed angle);
518 SwFixed mathAtan(const SwPoint& pt);
519 SwFixed mathCos(SwFixed angle);
520 SwFixed mathSin(SwFixed angle);
521 void mathSplitCubic(SwPoint* base);
522 void mathSplitLine(SwPoint* base);
523 SwFixed mathDiff(SwFixed angle1, SwFixed angle2);
524 SwFixed mathLength(const SwPoint& pt);
525 int mathCubicAngle(const SwPoint* base, SwFixed& angleIn, SwFixed& angleMid, SwFixed& angleOut);
526 SwFixed mathMean(SwFixed angle1, SwFixed angle2);
527 SwPoint mathTransform(const Point* to, const Matrix& transform);
528 bool mathUpdateOutlineBBox(const SwOutline* outline, const SwBBox& clipRegion, SwBBox& renderRegion, bool fastTrack);
529 bool mathClipBBox(const SwBBox& clipper, SwBBox& clippee);
530
531 void shapeReset(SwShape* shape);
532 bool shapePrepare(SwShape* shape, const RenderShape* rshape, const Matrix& transform, const SwBBox& clipRegion, SwBBox& renderRegion, SwMpool* mpool, unsigned tid, bool hasComposite);
533 bool shapePrepared(const SwShape* shape);
534 bool shapeGenRle(SwShape* shape, const RenderShape* rshape, SwMpool* mpool, unsigned tid, bool antiAlias);
535 void shapeDelOutline(SwShape* shape, SwMpool* mpool, uint32_t tid);
536 void shapeResetStroke(SwShape* shape, const RenderShape* rshape, const Matrix& transform);
537 bool shapeGenStrokeRle(SwShape* shape, const RenderShape* rshape, const Matrix& transform, const SwBBox& clipRegion, SwBBox& renderRegion, SwMpool* mpool, unsigned tid);
538 void shapeFree(SwShape* shape);
539 void shapeDelStroke(SwShape* shape);
540 bool shapeGenFillColors(SwShape* shape, const Fill* fill, const Matrix& transform, SwSurface* surface, uint8_t opacity, bool ctable);
541 bool shapeGenStrokeFillColors(SwShape* shape, const Fill* fill, const Matrix& transform, SwSurface* surface, uint8_t opacity, bool ctable);
542 void shapeResetFill(SwShape* shape);
543 void shapeResetStrokeFill(SwShape* shape);
544 void shapeDelFill(SwShape* shape);
545 void shapeDelStrokeFill(SwShape* shape);
546
547 void strokeReset(SwStroke* stroke, const RenderShape* shape, const Matrix& transform);
548 bool strokeParseOutline(SwStroke* stroke, const SwOutline& outline);
549 SwOutline* strokeExportOutline(SwStroke* stroke, SwMpool* mpool, unsigned tid);
550 void strokeFree(SwStroke* stroke);
551
552 bool imagePrepare(SwImage* image, const Matrix& transform, const SwBBox& clipRegion, SwBBox& renderRegion, SwMpool* mpool, unsigned tid);
553 bool imageGenRle(SwImage* image, const SwBBox& renderRegion, SwMpool* mpool, unsigned tid, bool antiAlias);
554 void imageDelOutline(SwImage* image, SwMpool* mpool, uint32_t tid);
555 void imageReset(SwImage* image);
556 void imageFree(SwImage* image);
557
558 bool fillGenColorTable(SwFill* fill, const Fill* fdata, const Matrix& transform, SwSurface* surface, uint8_t opacity, bool ctable);
559 const Fill::ColorStop* fillFetchSolid(const SwFill* fill, const Fill* fdata);
560 void fillReset(SwFill* fill);
561 void fillFree(SwFill* fill);
562
563 //OPTIMIZE_ME: Skip the function pointer access
564 void fillLinear(const SwFill* fill, uint8_t* dst, uint32_t y, uint32_t x, uint32_t len, SwMask maskOp, uint8_t opacity); //composite masking ver.
565 void fillLinear(const SwFill* fill, uint8_t* dst, uint32_t y, uint32_t x, uint32_t len, uint8_t* cmp, SwMask maskOp, uint8_t opacity); //direct masking ver.
566 void fillLinear(const SwFill* fill, uint32_t* dst, uint32_t y, uint32_t x, uint32_t len, SwBlender op, uint8_t a); //blending ver.
567 void fillLinear(const SwFill* fill, uint32_t* dst, uint32_t y, uint32_t x, uint32_t len, SwBlender op, SwBlender op2, uint8_t a); //blending + BlendingMethod(op2) ver.
568 void fillLinear(const SwFill* fill, uint32_t* dst, uint32_t y, uint32_t x, uint32_t len, uint8_t* cmp, SwAlpha alpha, uint8_t csize, uint8_t opacity); //matting ver.
569
570 void fillRadial(const SwFill* fill, uint8_t* dst, uint32_t y, uint32_t x, uint32_t len, SwMask op, uint8_t a); //composite masking ver.
571 void fillRadial(const SwFill* fill, uint8_t* dst, uint32_t y, uint32_t x, uint32_t len, uint8_t* cmp, SwMask op, uint8_t a) ; //direct masking ver.
572 void fillRadial(const SwFill* fill, uint32_t* dst, uint32_t y, uint32_t x, uint32_t len, SwBlender op, uint8_t a); //blending ver.
573 void fillRadial(const SwFill* fill, uint32_t* dst, uint32_t y, uint32_t x, uint32_t len, SwBlender op, SwBlender op2, uint8_t a); //blending + BlendingMethod(op2) ver.
574 void fillRadial(const SwFill* fill, uint32_t* dst, uint32_t y, uint32_t x, uint32_t len, uint8_t* cmp, SwAlpha alpha, uint8_t csize, uint8_t opacity); //matting ver.
575
576 SwRle* rleRender(SwRle* rle, const SwOutline* outline, const SwBBox& renderRegion, SwMpool* mpool, unsigned tid, bool antiAlias);
577 SwRle* rleRender(const SwBBox* bbox);
578 void rleFree(SwRle* rle);
579 void rleReset(SwRle* rle);
580 void rleMerge(SwRle* rle, SwRle* clip1, SwRle* clip2);
581 bool rleClip(SwRle* rle, const SwRle* clip);
582 bool rleClip(SwRle* rle, const SwBBox* clip);
583
584 SwMpool* mpoolInit(uint32_t threads);
585 bool mpoolTerm(SwMpool* mpool);
586 bool mpoolClear(SwMpool* mpool);
587 SwOutline* mpoolReqOutline(SwMpool* mpool, unsigned idx);
588 void mpoolRetOutline(SwMpool* mpool, unsigned idx);
589 SwOutline* mpoolReqStrokeOutline(SwMpool* mpool, unsigned idx);
590 void mpoolRetStrokeOutline(SwMpool* mpool, unsigned idx);
591 SwOutline* mpoolReqDashOutline(SwMpool* mpool, unsigned idx);
592 void mpoolRetDashOutline(SwMpool* mpool, unsigned idx);
593 SwCellPool* mpoolReqCellPool(SwMpool* mpool, unsigned idx);
594
595 bool rasterCompositor(SwSurface* surface);
596 bool rasterGradientShape(SwSurface* surface, SwShape* shape, const Fill* fdata, uint8_t opacity);
597 bool rasterShape(SwSurface* surface, SwShape* shape, uint8_t r, uint8_t g, uint8_t b, uint8_t a);
598 bool rasterTexmapPolygon(SwSurface* surface, const SwImage& image, const Matrix& transform, const SwBBox& bbox, uint8_t opacity);
599 bool rasterScaledImage(SwSurface* surface, const SwImage& image, const Matrix& transform, const SwBBox& bbox, uint8_t opacity);
600 bool rasterDirectImage(SwSurface* surface, const SwImage& image, const SwBBox& bbox, uint8_t opacity);
601 bool rasterScaledRleImage(SwSurface* surface, const SwImage& image, const Matrix& transform, const SwBBox& bbox, uint8_t opacity);
602 bool rasterDirectRleImage(SwSurface* surface, const SwImage& image, uint8_t opacity);
603 bool rasterStroke(SwSurface* surface, SwShape* shape, uint8_t r, uint8_t g, uint8_t b, uint8_t a);
604 bool rasterGradientStroke(SwSurface* surface, SwShape* shape, const Fill* fdata, uint8_t opacity);
605 bool rasterClear(SwSurface* surface, uint32_t x, uint32_t y, uint32_t w, uint32_t h, pixel_t val = 0);
606 void rasterPixel32(uint32_t *dst, uint32_t val, uint32_t offset, int32_t len);
607 void rasterTranslucentPixel32(uint32_t* dst, uint32_t* src, uint32_t len, uint8_t opacity);
608 void rasterPixel32(uint32_t* dst, uint32_t* src, uint32_t len, uint8_t opacity);
609 void rasterGrayscale8(uint8_t *dst, uint8_t val, uint32_t offset, int32_t len);
610 void rasterXYFlip(uint32_t* src, uint32_t* dst, int32_t stride, int32_t w, int32_t h, const SwBBox& bbox, bool flipped);
611 void rasterUnpremultiply(RenderSurface* surface);
612 void rasterPremultiply(RenderSurface* surface);
613 bool rasterConvertCS(RenderSurface* surface, ColorSpace to);
614 uint32_t rasterUnpremultiply(uint32_t data);
615
616 bool effectGaussianBlur(SwCompositor* cmp, SwSurface* surface, const RenderEffectGaussianBlur* params);
617 bool effectGaussianBlurRegion(RenderEffectGaussianBlur* effect);
618 void effectGaussianBlurUpdate(RenderEffectGaussianBlur* effect, const Matrix& transform);
619 bool effectDropShadow(SwCompositor* cmp, SwSurface* surfaces[2], const RenderEffectDropShadow* params, bool direct);
620 bool effectDropShadowRegion(RenderEffectDropShadow* effect);
621 void effectDropShadowUpdate(RenderEffectDropShadow* effect, const Matrix& transform);
622 void effectFillUpdate(RenderEffectFill* effect);
623 bool effectFill(SwCompositor* cmp, const RenderEffectFill* params, bool direct);
624 void effectTintUpdate(RenderEffectTint* effect);
625 bool effectTint(SwCompositor* cmp, const RenderEffectTint* params, bool direct);
626 void effectTritoneUpdate(RenderEffectTritone* effect);
627 bool effectTritone(SwCompositor* cmp, const RenderEffectTritone* params, bool direct);
628
629 #endif /* _TVG_SW_COMMON_H_ */