1 #include "evas_common_soft8.h"
2 #include "evas_soft8_scanline_blend.c"
4 static always_inline void
5 _glyph_pt_mask_solid_solid(DATA8 * dst, const DATA8 gry8, const DATA8 * mask)
13 *dst = GRY_8_BLEND_UNMUL(gry8, *dst, alpha);
18 _glyph_scanline_mask_solid_solid(DATA8 * dst,
19 int size, const DATA8 gry8, const DATA8 * mask)
26 end = start + (size & ~3);
34 _glyph_pt_mask_solid_solid(start, gry8, mask);
39 end = start + (size & 3);
40 for (; start < end; start++, mask++)
41 _glyph_pt_mask_solid_solid(start, gry8, mask);
44 static always_inline void
45 _glyph_pt_mask_transp_solid(DATA8 * dst,
46 DATA8 gry8, DATA8 alpha, const DATA8 * mask)
52 alpha = (alpha * rel_alpha) >> 8;
58 *dst = GRY_8_BLEND((gry8 * rel_alpha) >> 8, *dst, alpha);
62 _glyph_scanline_mask_transp_solid(DATA8 * dst,
65 const DATA8 rel_alpha, const DATA8 * mask)
72 end = start + (size & ~3);
80 _glyph_pt_mask_transp_solid(start, gry8, rel_alpha, mask);
85 end = start + (size & 3);
86 for (; start < end; start++, mask++)
87 _glyph_pt_mask_transp_solid(start, gry8, rel_alpha, mask);
91 _calc_ext(const Soft8_Image * dst, const RGBA_Draw_Context * dc,
94 EINA_RECTANGLE_SET(ext, 0, 0, dst->cache_entry.w, dst->cache_entry.h);
100 EINA_RECTANGLE_SET(ext, dc->clip.x, dc->clip.y, dc->clip.w, dc->clip.h);
112 v = dst->cache_entry.w - ext->x;
116 v = dst->cache_entry.h - ext->y;
123 _glyph_scanline(Soft8_Image * dst, const DATA8 * p_mask,
124 const Eina_Rectangle ext, int dx, int dy, int max_x, int max_y,
125 int w, DATA8 alpha, const DATA8 gry8)
127 int size, in_x, in_w;
130 if ((dx >= max_x) || (dy < ext.y) || (dy >= max_y))
137 in_w += (dx + w) - max_x;
147 p_pixels = dst->pixels + (dy * dst->stride) + dx;
153 _glyph_scanline_mask_solid_solid(p_pixels, size, gry8, p_mask);
155 _glyph_scanline_mask_transp_solid
156 (p_pixels, size, gry8, alpha, p_mask);
161 _glyph_pt_mask_solid_solid(p_pixels, gry8, p_mask);
163 _glyph_pt_mask_transp_solid(p_pixels, gry8, alpha, p_mask);
168 _soft8_font_glyph_draw_grayscale(Soft8_Image * dst,
169 RGBA_Draw_Context * dc __UNUSED__,
170 RGBA_Font_Glyph * fg __UNUSED__, int x, int y,
171 DATA8 alpha, DATA8 gry8,
172 const Eina_Rectangle ext, int bw, int bh,
173 int bpitch, const DATA8 * bitmap)
177 max_x = ext.x + ext.w;
178 max_y = ext.y + ext.h;
180 for (i = 0; i < bh; i++, bitmap += bpitch)
181 _glyph_scanline(dst, bitmap, ext, x, y + i, max_x, max_y, bw,
186 _glyph_create_mask_line(DATA8 * mask, const DATA8 * bitmap, int w)
188 const DATA8 bitrepl[2] = { 0x0, 0xff };
191 for (i = 0; i < w; i += 8, bitmap++)
203 for (j = size - 1; j >= 0; j--, mask++)
204 *mask = bitrepl[(bits >> j) & 0x1];
209 _soft8_font_glyph_draw_mono(Soft8_Image * dst,
210 RGBA_Draw_Context * dc __UNUSED__,
211 RGBA_Font_Glyph * fg __UNUSED__, int x, int y,
212 DATA8 alpha, DATA8 gry8, const Eina_Rectangle ext,
213 int bw, int bh, int bpitch, const DATA8 * bitmap)
218 max_x = ext.x + ext.w;
219 max_y = ext.y + ext.h;
221 mask = alloca(bpitch);
222 for (i = 0; i < bh; i++, bitmap += bpitch)
224 _glyph_create_mask_line(mask, bitmap, bw);
225 _glyph_scanline(dst, mask, ext, x, y + i, max_x, max_y, bw,
231 soft8_font_glyph_draw(void *data, void *dest __UNUSED__, void *context,
232 RGBA_Font_Glyph * fg, int x, int y)
235 RGBA_Draw_Context *dc;
237 DATA8 alpha, r, g, b;
245 alpha = A_VAL(&dc->col.col);
249 gry8 = GRY_8_FROM_RGB(&dc->col.col);
252 * if (r > alpha) r = alpha;
253 * if (g > alpha) g = alpha;
254 * if (b > alpha) b = alpha;
256 * gry8 = GRY_8_FROM_COMPONENTS(r, g, b);
259 bitmap = fg->glyph_out->bitmap.buffer;
260 bh = fg->glyph_out->bitmap.rows;
261 bw = fg->glyph_out->bitmap.width;
262 bpitch = fg->glyph_out->bitmap.pitch;
266 _calc_ext(dst, dc, &ext);
268 if ((fg->glyph_out->bitmap.num_grays == 256) &&
269 (fg->glyph_out->bitmap.pixel_mode == ft_pixel_mode_grays))
270 _soft8_font_glyph_draw_grayscale(dst, dc, fg, x, y, alpha, gry8,
271 ext, bw, bh, bpitch, bitmap);
273 _soft8_font_glyph_draw_mono(dst, dc, fg, x, y, alpha, gry8,
274 ext, bw, bh, bpitch, bitmap);
278 soft8_font_glyph_new(void *data __UNUSED__, RGBA_Font_Glyph * fg __UNUSED__)
280 return (void *)1; /* core requires != NULL to work */
284 soft8_font_glyph_free(void *ext_dat __UNUSED__)