2 * Copyright (c) 2021 Samsung Electronics Co., Ltd. All rights reserved.
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:
11 * The above copyright notice and this permission notice shall be included in all
12 * copies or substantial portions of the Software.
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
23 float _dudx = dudx, _dvdx = dvdx;
24 float _dxdya = dxdya, _dxdyb = dxdyb, _dudya = dudya, _dvdya = dvdya;
25 float _xa = xa, _xb = xb, _ua = ua, _va = va;
26 auto sbuf = image->data;
27 auto dbuf = surface->buffer;
28 int sw = static_cast<int>(image->stride);
30 int dw = surface->stride;
31 int x1, x2, x, y, ar, ab, iru, irv, px;
40 //Range exception handling
41 if (ystart >= region.max.y) return;
42 if (ystart < region.min.y) ystart = region.min.y;
43 if (yend > region.max.y) yend = region.max.y;
45 //Loop through all lines in the segment
52 //Range exception handling
53 if (x1 < region.min.x) x1 = region.min.x;
54 if (x2 > region.max.x) x2 = region.max.x;
56 if ((x2 - x1) < 1) goto next;
57 if ((x1 >= region.max.x) || (x2 <= region.min.x)) goto next;
59 //Perform subtexel pre-stepping on UV
64 buf = dbuf + ((y * dw) + x1);
69 cmp = &surface->compositor->image.data[y * surface->compositor->image.stride + x1];
71 //Draw horizontal line
76 ar = (int)(255 * (1 - modff(u, &iptr)));
77 ab = (int)(255 * (1 - modff(v, &iptr)));
80 px = *(sbuf + (vv * sw) + uu);
82 /* horizontal interpolate */
85 int px2 = *(sbuf + (vv * sw) + iru);
86 px = INTERPOLATE(ar, px, px2);
88 /* vertical interpolate */
91 int px2 = *(sbuf + (irv * sw) + uu);
93 /* horizontal interpolate */
95 /* bottom right pixel */
96 int px3 = *(sbuf + (irv * sw) + iru);
97 px2 = INTERPOLATE(ar, px2, px3);
99 px = INTERPOLATE(ab, px, px2);
101 #if defined(TEXMAP_MASKING) && defined(TEXMAP_TRANSLUCENT)
102 auto src = ALPHA_BLEND(px, _multiplyAlpha(opacity, blendMethod(*cmp)));
103 #elif defined(TEXMAP_MASKING)
104 auto src = ALPHA_BLEND(px, blendMethod(*cmp));
105 #elif defined(TEXMAP_TRANSLUCENT)
106 auto src = ALPHA_BLEND(px, opacity);
110 *buf = src + ALPHA_BLEND(*buf, surface->blender.ialpha(src));
112 #ifdef TEXMAP_MASKING
115 //Step UV horizontally
120 //Step along both edges