aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/evas/src/lib/engines/common_8/evas_soft8_rectangle.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/evas/src/lib/engines/common_8/evas_soft8_rectangle.c')
-rw-r--r--libraries/evas/src/lib/engines/common_8/evas_soft8_rectangle.c125
1 files changed, 125 insertions, 0 deletions
diff --git a/libraries/evas/src/lib/engines/common_8/evas_soft8_rectangle.c b/libraries/evas/src/lib/engines/common_8/evas_soft8_rectangle.c
new file mode 100644
index 0000000..150f262
--- /dev/null
+++ b/libraries/evas/src/lib/engines/common_8/evas_soft8_rectangle.c
@@ -0,0 +1,125 @@
1#include "evas_common_soft8.h"
2#include "evas_soft8_scanline_fill.c"
3
4static inline int
5_is_empty_rectangle(const Eina_Rectangle * r)
6{
7 return (r->w < 1) || (r->h < 1);
8}
9
10static inline void
11_soft8_rectangle_draw_solid_solid(Soft8_Image * dst, int offset, int w, int h,
12 DATA8 gry8)
13{
14 DATA8 *dst_itr;
15 int i;
16
17 dst_itr = dst->pixels + offset;
18
19 for (i = 0; i < h; i++, dst_itr += dst->stride)
20 _soft8_scanline_fill_solid_solid(dst_itr, w, gry8);
21}
22
23static inline void
24_soft8_rectangle_draw_transp_solid(Soft8_Image * dst, int offset, int w, int h,
25 DATA8 gry8, DATA8 alpha)
26{
27 DATA8 *dst_itr;
28 int i;
29
30 dst_itr = dst->pixels + offset;
31 alpha++;
32
33 for (i = 0; i < h; i++, dst_itr += dst->stride)
34 _soft8_scanline_fill_transp_solid(dst_itr, w, gry8, alpha);
35}
36
37static void
38_soft8_rectangle_draw_int(Soft8_Image * dst, RGBA_Draw_Context * dc,
39 Eina_Rectangle dr)
40{
41 int dst_offset;
42
43 if (_is_empty_rectangle(&dr))
44 return;
45 RECTS_CLIP_TO_RECT(dr.x, dr.y, dr.w, dr.h, 0, 0, dst->cache_entry.w,
46 dst->cache_entry.h);
47 if (_is_empty_rectangle(&dr))
48 return;
49
50 if (dc->clip.use)
51 RECTS_CLIP_TO_RECT(dr.x, dr.y, dr.w, dr.h, dc->clip.x,
52 dc->clip.y, dc->clip.w, dc->clip.h);
53 if (_is_empty_rectangle(&dr))
54 return;
55 if (A_VAL(&dc->col.col) == 0)
56 return;
57
58 dst_offset = dr.x + (dr.y * dst->stride);
59
60 if (!dst->cache_entry.flags.alpha)
61 {
62 DATA8 gry8;
63 DATA8 alpha;
64
65 alpha = A_VAL(&dc->col.col);
66 gry8 = GRY_8_FROM_RGB(&dc->col.col);
67
68 if (alpha == 0xff)
69 _soft8_rectangle_draw_solid_solid(dst, dst_offset, dr.w, dr.h, gry8);
70 else if (alpha > 0)
71 _soft8_rectangle_draw_transp_solid
72 (dst, dst_offset, dr.w, dr.h, gry8, alpha);
73 }
74 else
75 ERR("Unsupported feature: drawing rectangle to non-opaque destination.");
76}
77
78void
79evas_common_soft8_rectangle_draw(Soft8_Image * dst, RGBA_Draw_Context * dc,
80 int x, int y, int w, int h)
81{
82 Eina_Rectangle dr;
83 Cutout_Rects *rects;
84 Cutout_Rect *r;
85 struct RGBA_Draw_Context_clip c_bkp;
86 int i;
87
88 /* handle cutouts here! */
89 EINA_RECTANGLE_SET(&dr, x, y, w, h);
90
91 if (_is_empty_rectangle(&dr))
92 return;
93 if (!
94 (RECTS_INTERSECT
95 (dr.x, dr.y, dr.w, dr.h, 0, 0, dst->cache_entry.w, dst->cache_entry.h)))
96 return;
97
98 /* no cutouts - cut right to the chase */
99 if (!dc->cutout.rects)
100 {
101 _soft8_rectangle_draw_int(dst, dc, dr);
102 return;
103 }
104
105 c_bkp = dc->clip;
106
107 evas_common_draw_context_clip_clip(dc, 0, 0, dst->cache_entry.w,
108 dst->cache_entry.h);
109 evas_common_draw_context_clip_clip(dc, x, y, w, h);
110 /* our clip is 0 size.. abort */
111 if ((dc->clip.w <= 0) || (dc->clip.h <= 0))
112 {
113 dc->clip = c_bkp;
114 return;
115 }
116 rects = evas_common_draw_context_apply_cutouts(dc);
117 for (i = 0; i < rects->active; ++i)
118 {
119 r = rects->rects + i;
120 evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h);
121 _soft8_rectangle_draw_int(dst, dc, dr);
122 }
123 evas_common_draw_context_apply_clear_cutouts(rects);
124 dc->clip = c_bkp;
125}