summaryrefslogtreecommitdiff
path: root/src/lib/ector
diff options
context:
space:
mode:
authorHermet Park <hermetpark@gmail.com>2019-09-17 12:01:25 +0900
committerHermet Park <hermetpark@gmail.com>2019-09-17 12:03:25 +0900
commit24ed24a9db3cb947084ce446b0b1c130852071d5 (patch)
tree4f908c179c2afd7b3f02aead2f4ab6550f2b6710 /src/lib/ector
parent9dc7643f93c126f399c87dd9de4afd4395b01679 (diff)
ector: refer exact stride size for jumping buffer lines.
Actual buffer and used width size could be different, stride must be referred.
Diffstat (limited to 'src/lib/ector')
-rw-r--r--src/lib/ector/software/ector_software_rasterizer.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/lib/ector/software/ector_software_rasterizer.c b/src/lib/ector/software/ector_software_rasterizer.c
index 8cd0854..fd59686 100644
--- a/src/lib/ector/software/ector_software_rasterizer.c
+++ b/src/lib/ector/software/ector_software_rasterizer.c
@@ -40,6 +40,7 @@ _comp_matte_alpha(int count, const SW_FT_Span *spans, void *user_data)
40 const int pix_stride = sd->raster_buffer->stride / 4; 40 const int pix_stride = sd->raster_buffer->stride / 4;
41 Ector_Software_Buffer_Base_Data *comp = sd->comp; 41 Ector_Software_Buffer_Base_Data *comp = sd->comp;
42 if (!comp || !comp->pixels.u32) return; 42 if (!comp || !comp->pixels.u32) return;
43 const int comp_stride = comp->stride / 4;
43 44
44 // multiply the color with mul_col if any 45 // multiply the color with mul_col if any
45 uint32_t color = DRAW_MUL4_SYM(sd->color, sd->mul_col); 46 uint32_t color = DRAW_MUL4_SYM(sd->color, sd->mul_col);
@@ -58,7 +59,7 @@ _comp_matte_alpha(int count, const SW_FT_Span *spans, void *user_data)
58 { 59 {
59 uint32_t *target = buffer + ((pix_stride * spans->y) + spans->x); 60 uint32_t *target = buffer + ((pix_stride * spans->y) + spans->x);
60 uint32_t *mtarget = 61 uint32_t *mtarget =
61 mbuffer + ((comp->generic->w * spans->y) + spans->x); 62 mbuffer + ((comp_stride * spans->y) + spans->x);
62 uint32_t *temp = tbuffer; 63 uint32_t *temp = tbuffer;
63 memset(temp, 0x00, sizeof(uint32_t) * spans->len); 64 memset(temp, 0x00, sizeof(uint32_t) * spans->len);
64 comp_func(temp, spans->len, color, spans->coverage); 65 comp_func(temp, spans->len, color, spans->coverage);
@@ -84,6 +85,7 @@ _comp_matte_alpha_inv(int count, const SW_FT_Span *spans, void *user_data)
84 const int pix_stride = sd->raster_buffer->stride / 4; 85 const int pix_stride = sd->raster_buffer->stride / 4;
85 Ector_Software_Buffer_Base_Data *comp = sd->comp; 86 Ector_Software_Buffer_Base_Data *comp = sd->comp;
86 if (!comp || !comp->pixels.u32) return; 87 if (!comp || !comp->pixels.u32) return;
88 const int comp_stride = comp->stride / 4;
87 89
88 // multiply the color with mul_col if any 90 // multiply the color with mul_col if any
89 uint32_t color = DRAW_MUL4_SYM(sd->color, sd->mul_col); 91 uint32_t color = DRAW_MUL4_SYM(sd->color, sd->mul_col);
@@ -102,7 +104,7 @@ _comp_matte_alpha_inv(int count, const SW_FT_Span *spans, void *user_data)
102 { 104 {
103 uint32_t *target = buffer + ((pix_stride * spans->y) + spans->x); 105 uint32_t *target = buffer + ((pix_stride * spans->y) + spans->x);
104 uint32_t *mtarget = 106 uint32_t *mtarget =
105 mbuffer + ((comp->generic->w * spans->y) + spans->x); 107 mbuffer + ((comp_stride * spans->y) + spans->x);
106 uint32_t *temp = tbuffer; 108 uint32_t *temp = tbuffer;
107 memset(temp, 0x00, sizeof(uint32_t) * spans->len); 109 memset(temp, 0x00, sizeof(uint32_t) * spans->len);
108 comp_func(temp, spans->len, color, spans->coverage); 110 comp_func(temp, spans->len, color, spans->coverage);
@@ -128,6 +130,7 @@ _comp_mask_add(int count, const SW_FT_Span *spans, void *user_data)
128 Span_Data *sd = user_data; 130 Span_Data *sd = user_data;
129 Ector_Software_Buffer_Base_Data *comp = sd->comp; 131 Ector_Software_Buffer_Base_Data *comp = sd->comp;
130 if (!comp || !comp->pixels.u32) return; 132 if (!comp || !comp->pixels.u32) return;
133 const int comp_stride = comp->stride / 4;
131 134
132 uint32_t color = DRAW_MUL4_SYM(sd->color, sd->mul_col); 135 uint32_t color = DRAW_MUL4_SYM(sd->color, sd->mul_col);
133 RGBA_Comp_Func_Solid comp_func = efl_draw_func_solid_span_get(sd->op, color); 136 RGBA_Comp_Func_Solid comp_func = efl_draw_func_solid_span_get(sd->op, color);
@@ -138,7 +141,7 @@ _comp_mask_add(int count, const SW_FT_Span *spans, void *user_data)
138 141
139 while (count--) 142 while (count--)
140 { 143 {
141 uint32_t *mtarget = mbuffer + ((comp->generic->w * spans->y) + spans->x); 144 uint32_t *mtarget = mbuffer + ((comp_stride * spans->y) + spans->x);
142 memset(ttarget, 0x00, sizeof(uint32_t) * spans->len); 145 memset(ttarget, 0x00, sizeof(uint32_t) * spans->len);
143 comp_func(ttarget, spans->len, color, spans->coverage); 146 comp_func(ttarget, spans->len, color, spans->coverage);
144 for (int i = 0; i < spans->len; i++) 147 for (int i = 0; i < spans->len; i++)
@@ -153,6 +156,7 @@ _comp_mask_sub(int count, const SW_FT_Span *spans, void *user_data)
153 Span_Data *sd = user_data; 156 Span_Data *sd = user_data;
154 Ector_Software_Buffer_Base_Data *comp = sd->comp; 157 Ector_Software_Buffer_Base_Data *comp = sd->comp;
155 if (!comp || !comp->pixels.u32) return; 158 if (!comp || !comp->pixels.u32) return;
159 const int comp_stride = comp->stride / 4;
156 160
157 uint32_t color = DRAW_MUL4_SYM(sd->color, sd->mul_col); 161 uint32_t color = DRAW_MUL4_SYM(sd->color, sd->mul_col);
158 RGBA_Comp_Func_Solid comp_func = efl_draw_func_solid_span_get(sd->op, color); 162 RGBA_Comp_Func_Solid comp_func = efl_draw_func_solid_span_get(sd->op, color);
@@ -163,7 +167,7 @@ _comp_mask_sub(int count, const SW_FT_Span *spans, void *user_data)
163 167
164 while (count--) 168 while (count--)
165 { 169 {
166 uint32_t *mtarget = mbuffer + ((comp->generic->w * spans->y) + spans->x); 170 uint32_t *mtarget = mbuffer + ((comp_stride * spans->y) + spans->x);
167 memset(ttarget, 0x00, sizeof(uint32_t) * spans->len); 171 memset(ttarget, 0x00, sizeof(uint32_t) * spans->len);
168 comp_func(ttarget, spans->len, color, spans->coverage); 172 comp_func(ttarget, spans->len, color, spans->coverage);
169 for (int i = 0; i < spans->len; i++) 173 for (int i = 0; i < spans->len; i++)
@@ -179,6 +183,7 @@ _comp_mask_ins(int count, const SW_FT_Span *spans, void *user_data)
179 Span_Data *sd = user_data; 183 Span_Data *sd = user_data;
180 Ector_Software_Buffer_Base_Data *comp = sd->comp; 184 Ector_Software_Buffer_Base_Data *comp = sd->comp;
181 if (!comp || !comp->pixels.u32) return; 185 if (!comp || !comp->pixels.u32) return;
186 const int comp_stride = comp->stride / 4;
182 187
183 uint32_t color = DRAW_MUL4_SYM(sd->color, sd->mul_col); 188 uint32_t color = DRAW_MUL4_SYM(sd->color, sd->mul_col);
184 RGBA_Comp_Func_Solid comp_func = efl_draw_func_solid_span_get(sd->op, color); 189 RGBA_Comp_Func_Solid comp_func = efl_draw_func_solid_span_get(sd->op, color);
@@ -195,7 +200,7 @@ _comp_mask_ins(int count, const SW_FT_Span *spans, void *user_data)
195 y == (unsigned int)spans->y && count > 0) 200 y == (unsigned int)spans->y && count > 0)
196 { 201 {
197 memset(ttarget, 0x00, sizeof(uint32_t) * spans->len); 202 memset(ttarget, 0x00, sizeof(uint32_t) * spans->len);
198 uint32_t *mtarget = mbuffer + ((comp->generic->w * spans->y) + spans->x); 203 uint32_t *mtarget = mbuffer + ((comp_stride * spans->y) + spans->x);
199 comp_func(ttarget, spans->len, color, spans->coverage); 204 comp_func(ttarget, spans->len, color, spans->coverage);
200 for (int c = 0; c < spans->len; c++) 205 for (int c = 0; c < spans->len; c++)
201 mtarget[c] = draw_mul_256(ttarget[c]>>24, mtarget[c]); 206 mtarget[c] = draw_mul_256(ttarget[c]>>24, mtarget[c]);
@@ -205,7 +210,7 @@ _comp_mask_ins(int count, const SW_FT_Span *spans, void *user_data)
205 } 210 }
206 else 211 else
207 { 212 {
208 mbuffer[x + (comp->generic->w * y)] = (0x00FFFFFF & mbuffer[x + (comp->generic->w * y)]); 213 mbuffer[x + (comp_stride * y)] = (0x00FFFFFF & mbuffer[x + (comp_stride * y)]);
209 } 214 }
210 } 215 }
211 } 216 }
@@ -218,6 +223,7 @@ _comp_mask_diff(int count, const SW_FT_Span *spans, void *user_data)
218 Span_Data *sd = user_data; 223 Span_Data *sd = user_data;
219 Ector_Software_Buffer_Base_Data *comp = sd->comp; 224 Ector_Software_Buffer_Base_Data *comp = sd->comp;
220 if (!comp || !comp->pixels.u32) return; 225 if (!comp || !comp->pixels.u32) return;
226 const int comp_stride = comp->stride / 4;
221 227
222 uint32_t color = DRAW_MUL4_SYM(sd->color, sd->mul_col); 228 uint32_t color = DRAW_MUL4_SYM(sd->color, sd->mul_col);
223 RGBA_Comp_Func_Solid comp_func = efl_draw_func_solid_span_get(sd->op, color); 229 RGBA_Comp_Func_Solid comp_func = efl_draw_func_solid_span_get(sd->op, color);
@@ -229,7 +235,7 @@ _comp_mask_diff(int count, const SW_FT_Span *spans, void *user_data)
229 while (count--) 235 while (count--)
230 { 236 {
231 memset(ttarget, 0x00, sizeof(uint32_t) * spans->len); 237 memset(ttarget, 0x00, sizeof(uint32_t) * spans->len);
232 uint32_t *mtarget = mbuffer + ((comp->generic->w * spans->y) + spans->x); 238 uint32_t *mtarget = mbuffer + ((comp_stride * spans->y) + spans->x);
233 comp_func(ttarget, spans->len, color, spans->coverage); 239 comp_func(ttarget, spans->len, color, spans->coverage);
234 for (int i = 0; i < spans->len; i++) 240 for (int i = 0; i < spans->len; i++)
235 mtarget[i] = draw_mul_256(0xFF - (mtarget[i]>>24), ttarget[i]) + draw_mul_256(0xFF - (ttarget[i]>>24), mtarget[i]); 241 mtarget[i] = draw_mul_256(0xFF - (mtarget[i]>>24), ttarget[i]) + draw_mul_256(0xFF - (ttarget[i]>>24), mtarget[i]);
@@ -296,6 +302,7 @@ _blend_gradient_alpha(int count, const SW_FT_Span *spans, void *user_data)
296 302
297 Ector_Software_Buffer_Base_Data *comp = sd->comp; 303 Ector_Software_Buffer_Base_Data *comp = sd->comp;
298 uint32_t *mbuffer = comp->pixels.u32; 304 uint32_t *mbuffer = comp->pixels.u32;
305 const int comp_stride = comp->stride / 4;
299 306
300 // move to the offset location 307 // move to the offset location
301 buffer = sd->raster_buffer->pixels.u32 + ((pix_stride * sd->offy) + sd->offx); 308 buffer = sd->raster_buffer->pixels.u32 + ((pix_stride * sd->offy) + sd->offx);
@@ -303,7 +310,7 @@ _blend_gradient_alpha(int count, const SW_FT_Span *spans, void *user_data)
303 while (count--) 310 while (count--)
304 { 311 {
305 uint32_t *target = buffer + ((pix_stride * spans->y) + spans->x); 312 uint32_t *target = buffer + ((pix_stride * spans->y) + spans->x);
306 uint32_t *mtarget = mbuffer + ((comp->generic->w * spans->y) + spans->x); 313 uint32_t *mtarget = mbuffer + ((comp_stride * spans->y) + spans->x);
307 int length = spans->len; 314 int length = spans->len;
308 315
309 while (length) 316 while (length)
@@ -345,6 +352,7 @@ _blend_gradient_alpha_inv(int count, const SW_FT_Span *spans, void *user_data)
345 352
346 Ector_Software_Buffer_Base_Data *comp = sd->comp; 353 Ector_Software_Buffer_Base_Data *comp = sd->comp;
347 uint32_t *mbuffer = comp->pixels.u32; 354 uint32_t *mbuffer = comp->pixels.u32;
355 const int comp_stride = comp->stride / 4;
348 356
349 // move to the offset location 357 // move to the offset location
350 buffer = sd->raster_buffer->pixels.u32 + ((pix_stride * sd->offy) + sd->offx); 358 buffer = sd->raster_buffer->pixels.u32 + ((pix_stride * sd->offy) + sd->offx);
@@ -352,7 +360,7 @@ _blend_gradient_alpha_inv(int count, const SW_FT_Span *spans, void *user_data)
352 while (count--) 360 while (count--)
353 { 361 {
354 uint32_t *target = buffer + ((pix_stride * spans->y) + spans->x); 362 uint32_t *target = buffer + ((pix_stride * spans->y) + spans->x);
355 uint32_t *mtarget = mbuffer + ((comp->generic->w * spans->y) + spans->x); 363 uint32_t *mtarget = mbuffer + ((comp_stride * spans->y) + spans->x);
356 int length = spans->len; 364 int length = spans->len;
357 365
358 while (length) 366 while (length)