summaryrefslogtreecommitdiff
path: root/src/modules/evas/engines/software_gdi/evas_outbuf.c
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2018-02-07 22:10:24 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2018-02-07 22:20:20 +0900
commitd54f0f66cf1faca39816ed9daf7656fb4819d96e (patch)
tree2ac4fa83a78928a27023ea5bb419cdabb906c3aa /src/modules/evas/engines/software_gdi/evas_outbuf.c
parent000d43b29e2cfff039e46c7de676f33dbdeb6949 (diff)
Evas: remove depth usage in GDI and DirectDraw engines
Test Plan: compilation and elementary_test Reviewers: raster Reviewed By: raster Subscribers: cedric, raster Differential Revision: https://phab.enlightenment.org/D5792
Diffstat (limited to 'src/modules/evas/engines/software_gdi/evas_outbuf.c')
-rw-r--r--src/modules/evas/engines/software_gdi/evas_outbuf.c168
1 files changed, 25 insertions, 143 deletions
diff --git a/src/modules/evas/engines/software_gdi/evas_outbuf.c b/src/modules/evas/engines/software_gdi/evas_outbuf.c
index 68a1a3e..e23cabe 100644
--- a/src/modules/evas/engines/software_gdi/evas_outbuf.c
+++ b/src/modules/evas/engines/software_gdi/evas_outbuf.c
@@ -1,89 +1,6 @@
1#include "evas_common_private.h" 1#include "evas_common_private.h"
2#include "evas_engine.h" 2#include "evas_engine.h"
3 3
4
5static Eina_List *gdipool = NULL;
6static int gdisize = 0;
7static int gdimemlimit = 10 * 1024 * 1024;
8static int gdicountlimit = 32;
9
10static Gdi_Output_Buffer *
11_find_gdiob(HDC dc, BITMAPINFO_GDI *bitmap_info, int depth, int w, int h, void *data)
12{
13 Eina_List *l = NULL;
14 Eina_List *gdil = NULL;
15 Gdi_Output_Buffer *gdiob = NULL;
16 Gdi_Output_Buffer *gdiob2;
17 int sz;
18 int lbytes;
19 int bpp;
20
21 bpp = depth >> 3;
22 if (bpp == 3) bpp = 4;
23 lbytes = (((w * bpp) + 3) / 4) * 4;
24 sz = lbytes * h;
25 EINA_LIST_FOREACH(gdipool, l, gdiob2)
26 {
27 if ((gdiob2->dc != dc) ||
28 (gdiob2->bitmap_info != bitmap_info) ||
29 (gdiob2->depth != depth))
30 continue;
31 if (gdiob2->psize == sz)
32 {
33 gdiob = gdiob2;
34 gdil = l;
35 goto have_gdiob;
36 }
37 }
38 if (!gdiob)
39 return evas_software_gdi_output_buffer_new(dc, bitmap_info, depth, w, h, data);
40
41 have_gdiob:
42 gdipool = eina_list_remove_list(gdipool, gdil);
43 gdiob->width = w;
44 gdiob->height = h;
45 gdiob->pitch = lbytes;
46 gdisize -= gdiob->psize * (gdiob->depth >> 3);
47
48 return gdiob;
49}
50
51static void
52_unfind_gdiob(Gdi_Output_Buffer *gdiob)
53{
54 gdipool = eina_list_prepend(gdipool, gdiob);
55 gdisize += gdiob->psize * (gdiob->depth >> 3);
56 while ((gdisize > (gdimemlimit)) ||
57 ((int)eina_list_count(gdipool) > gdicountlimit))
58 {
59 Eina_List *xl;
60
61 xl = eina_list_last(gdipool);
62 if (!xl)
63 {
64 gdisize = 0;
65 break;
66 }
67 gdiob = xl->data;
68 gdipool = eina_list_remove_list(gdipool, xl);
69 evas_software_gdi_output_buffer_free(gdiob);
70 }
71}
72
73static void
74_clear_gdiob()
75{
76 while (gdipool)
77 {
78 Gdi_Output_Buffer *gdiob;
79
80 gdiob = gdipool->data;
81 gdipool = eina_list_remove_list(gdipool, gdipool);
82 evas_software_gdi_output_buffer_free(gdiob);
83 }
84 gdisize = 0;
85}
86
87void 4void
88evas_software_gdi_outbuf_init(void) 5evas_software_gdi_outbuf_init(void)
89{ 6{
@@ -104,7 +21,8 @@ evas_software_gdi_outbuf_free(Outbuf *buf)
104 buf->priv.pending_writes = eina_list_remove_list(buf->priv.pending_writes, buf->priv.pending_writes); 21 buf->priv.pending_writes = eina_list_remove_list(buf->priv.pending_writes, buf->priv.pending_writes);
105 obr = im->extended_info; 22 obr = im->extended_info;
106 evas_cache_image_drop(&im->cache_entry); 23 evas_cache_image_drop(&im->cache_entry);
107 if (obr->gdiob) _unfind_gdiob(obr->gdiob); 24 if (obr->gdiob)
25 evas_software_gdi_output_buffer_free(obr->gdiob);
108/* if (obr->mxob) _unfind_xob(obr->mxob, 0); */ 26/* if (obr->mxob) _unfind_xob(obr->mxob, 0); */
109 free(obr); 27 free(obr);
110 } 28 }
@@ -119,9 +37,7 @@ Outbuf *
119evas_software_gdi_outbuf_setup(int width, 37evas_software_gdi_outbuf_setup(int width,
120 int height, 38 int height,
121 int rotation, 39 int rotation,
122 Outbuf_Depth depth,
123 HWND window, 40 HWND window,
124 int w_depth,
125 unsigned int borderless, 41 unsigned int borderless,
126 unsigned int fullscreen, 42 unsigned int fullscreen,
127 unsigned int region, 43 unsigned int region,
@@ -136,13 +52,12 @@ evas_software_gdi_outbuf_setup(int width,
136 52
137 buf->width = width; 53 buf->width = width;
138 buf->height = height; 54 buf->height = height;
139 buf->depth = depth;
140 buf->rot = rotation; 55 buf->rot = rotation;
141 56
142 buf->priv.mask_dither = mask_dither; 57 buf->priv.mask_dither = mask_dither;
143 buf->priv.destination_alpha = destination_alpha; 58 buf->priv.destination_alpha = destination_alpha;
144 59
145 if (!evas_software_gdi_init(window, w_depth, borderless, fullscreen, region, buf)) 60 if (!evas_software_gdi_init(window, borderless, fullscreen, region, buf))
146 { 61 {
147 free(buf); 62 free(buf);
148 return NULL; 63 return NULL;
@@ -152,7 +67,7 @@ evas_software_gdi_outbuf_setup(int width,
152 Gfx_Func_Convert conv_func; 67 Gfx_Func_Convert conv_func;
153 Gdi_Output_Buffer *gdiob; 68 Gdi_Output_Buffer *gdiob;
154 69
155 gdiob = evas_software_gdi_output_buffer_new(buf->priv.gdi.dc, buf->priv.gdi.bitmap_info, w_depth, 1, 1, NULL); 70 gdiob = evas_software_gdi_output_buffer_new(buf->priv.gdi.dc, buf->priv.gdi.bitmap_info, 1, 1, NULL);
156 71
157 conv_func = NULL; 72 conv_func = NULL;
158 if (gdiob) 73 if (gdiob)
@@ -161,7 +76,7 @@ evas_software_gdi_outbuf_setup(int width,
161 conv_func = evas_common_convert_func_get(0, 76 conv_func = evas_common_convert_func_get(0,
162 width, 77 width,
163 height, 78 height,
164 evas_software_gdi_output_buffer_depth (gdiob), 79 32,
165 buf->priv.gdi.bitmap_info->masks[0], 80 buf->priv.gdi.bitmap_info->masks[0],
166 buf->priv.gdi.bitmap_info->masks[1], 81 buf->priv.gdi.bitmap_info->masks[1],
167 buf->priv.gdi.bitmap_info->masks[2], 82 buf->priv.gdi.bitmap_info->masks[2],
@@ -171,7 +86,7 @@ evas_software_gdi_outbuf_setup(int width,
171 conv_func = evas_common_convert_func_get(0, 86 conv_func = evas_common_convert_func_get(0,
172 height, 87 height,
173 width, 88 width,
174 evas_software_gdi_output_buffer_depth (gdiob), 89 32,
175 buf->priv.gdi.bitmap_info->masks[0], 90 buf->priv.gdi.bitmap_info->masks[0],
176 buf->priv.gdi.bitmap_info->masks[1], 91 buf->priv.gdi.bitmap_info->masks[1],
177 buf->priv.gdi.bitmap_info->masks[2], 92 buf->priv.gdi.bitmap_info->masks[2],
@@ -184,11 +99,10 @@ evas_software_gdi_outbuf_setup(int width,
184 { 99 {
185 ERR(".[ soft_gdi engine Error ]." 100 ERR(".[ soft_gdi engine Error ]."
186 " {" 101 " {"
187 " At depth %i:" 102 " At depth 32:"
188 " RGB format mask: %08lx, %08lx, %08lx" 103 " RGB format mask: %08lx, %08lx, %08lx"
189 " Not supported by and compiled in converters!" 104 " Not supported by and compiled in converters!"
190 " }", 105 " }",
191 buf->priv.gdi.depth,
192 buf->priv.gdi.bitmap_info->masks[0], 106 buf->priv.gdi.bitmap_info->masks[0],
193 buf->priv.gdi.bitmap_info->masks[1], 107 buf->priv.gdi.bitmap_info->masks[1],
194 buf->priv.gdi.bitmap_info->masks[2]); 108 buf->priv.gdi.bitmap_info->masks[2]);
@@ -204,10 +118,10 @@ evas_software_gdi_outbuf_reconfigure(Outbuf *buf,
204 int width, 118 int width,
205 int height, 119 int height,
206 int rotation, 120 int rotation,
207 Outbuf_Depth depth) 121 Outbuf_Depth depth EINA_UNUSED)
208{ 122{
209 if ((width == buf->width) && (height == buf->height) && 123 if ((width == buf->width) && (height == buf->height) &&
210 (rotation == buf->rot) && (depth == buf->depth)) 124 (rotation == buf->rot))
211 return; 125 return;
212 buf->width = width; 126 buf->width = width;
213 buf->height = height; 127 buf->height = height;
@@ -249,15 +163,9 @@ evas_software_gdi_outbuf_new_region_for_update(Outbuf *buf,
249 (buf->priv.gdi.bitmap_info->masks[1] == 0x00ff00) && 163 (buf->priv.gdi.bitmap_info->masks[1] == 0x00ff00) &&
250 (buf->priv.gdi.bitmap_info->masks[2] == 0x0000ff)) 164 (buf->priv.gdi.bitmap_info->masks[2] == 0x0000ff))
251 { 165 {
252 obr->gdiob = _find_gdiob(buf->priv.gdi.dc, 166 obr->gdiob = evas_software_gdi_output_buffer_new(buf->priv.gdi.dc,
253 buf->priv.gdi.bitmap_info, 167 buf->priv.gdi.bitmap_info,
254 buf->priv.gdi.depth, 168 w, h, NULL);
255 w, h, NULL);
256/* obr->gdiob = evas_software_gdi_output_buffer_new(buf->priv.gdi.dc, */
257/* buf->priv.gdi.bitmap_info, */
258/* buf->priv.gdi.depth, */
259/* w, h, */
260/* NULL); */
261 im = (RGBA_Image *)evas_cache_image_data(evas_common_image_cache_get(), 169 im = (RGBA_Image *)evas_cache_image_data(evas_common_image_cache_get(),
262 w, h, 170 w, h,
263 (DATA32 *)evas_software_gdi_output_buffer_data(obr->gdiob, &bpl), 171 (DATA32 *)evas_software_gdi_output_buffer_data(obr->gdiob, &bpl),
@@ -276,31 +184,13 @@ evas_software_gdi_outbuf_new_region_for_update(Outbuf *buf,
276 evas_cache_image_surface_alloc(&im->cache_entry, w, h); 184 evas_cache_image_surface_alloc(&im->cache_entry, w, h);
277 im->extended_info = obr; 185 im->extended_info = obr;
278 if ((buf->rot == 0) || (buf->rot == 180)) 186 if ((buf->rot == 0) || (buf->rot == 180))
279 obr->gdiob = _find_gdiob(buf->priv.gdi.dc, 187 obr->gdiob = evas_software_gdi_output_buffer_new(buf->priv.gdi.dc,
280 buf->priv.gdi.bitmap_info, 188 buf->priv.gdi.bitmap_info,
281 buf->priv.gdi.depth, 189 w, h, NULL);
282 w, h, NULL);
283/*
284 obr->gdiob = evas_software_x11_x_output_buffer_new(buf->priv.dd.disp,
285 buf->priv.dd.vis,
286 buf->priv.dd.depth,
287 w, h,
288 use_shm,
289 NULL);
290 */
291 else if ((buf->rot == 90) || (buf->rot == 270)) 190 else if ((buf->rot == 90) || (buf->rot == 270))
292 obr->gdiob = _find_gdiob(buf->priv.gdi.dc, 191 obr->gdiob = evas_software_gdi_output_buffer_new(buf->priv.gdi.dc,
293 buf->priv.gdi.bitmap_info, 192 buf->priv.gdi.bitmap_info,
294 buf->priv.gdi.depth, 193 h, w, NULL);
295 h, w, NULL);
296/*
297 obr->gdiob = evas_software_x11_x_output_buffer_new(buf->priv.dd.disp,
298 buf->priv.dd.vis,
299 buf->priv.dd.depth,
300 h, w,
301 use_shm,
302 NULL);
303 */
304/* if (buf->priv.gdi.mask) */ 194/* if (buf->priv.gdi.mask) */
305/* obr->mgdiob = _find_gdiob(buf->priv.gdi.dc, */ 195/* obr->mgdiob = _find_gdiob(buf->priv.gdi.dc, */
306/* buf->priv.gdi.bitmap_info, */ 196/* buf->priv.gdi.bitmap_info, */
@@ -336,16 +226,14 @@ evas_software_gdi_outbuf_push_updated_region(Outbuf *buf,
336 obr = update->extended_info; 226 obr = update->extended_info;
337 227
338 if ((buf->rot == 0) || (buf->rot == 180)) 228 if ((buf->rot == 0) || (buf->rot == 180))
339 conv_func = evas_common_convert_func_get(0, w, h, 229 conv_func = evas_common_convert_func_get(0, w, h, 32,
340 evas_software_gdi_output_buffer_depth(obr->gdiob),
341 buf->priv.gdi.bitmap_info->masks[0], 230 buf->priv.gdi.bitmap_info->masks[0],
342 buf->priv.gdi.bitmap_info->masks[1], 231 buf->priv.gdi.bitmap_info->masks[1],
343 buf->priv.gdi.bitmap_info->masks[2], 232 buf->priv.gdi.bitmap_info->masks[2],
344 PAL_MODE_NONE, 233 PAL_MODE_NONE,
345 buf->rot); 234 buf->rot);
346 else if ((buf->rot == 90) || (buf->rot == 270)) 235 else if ((buf->rot == 90) || (buf->rot == 270))
347 conv_func = evas_common_convert_func_get(0, h, w, 236 conv_func = evas_common_convert_func_get(0, h, w, 32,
348 evas_software_gdi_output_buffer_depth(obr->gdiob),
349 buf->priv.gdi.bitmap_info->masks[0], 237 buf->priv.gdi.bitmap_info->masks[0],
350 buf->priv.gdi.bitmap_info->masks[1], 238 buf->priv.gdi.bitmap_info->masks[1],
351 buf->priv.gdi.bitmap_info->masks[2], 239 buf->priv.gdi.bitmap_info->masks[2],
@@ -389,7 +277,7 @@ evas_software_gdi_outbuf_push_updated_region(Outbuf *buf,
389 if (data != src_data) 277 if (data != src_data)
390 conv_func(src_data, data, 278 conv_func(src_data, data,
391 0, 279 0,
392 bpl / (evas_software_gdi_output_buffer_depth(obr->gdiob) >> 3) - obr->width, 280 bpl / 4 - obr->width,
393 obr->width, 281 obr->width,
394 obr->height, 282 obr->height,
395 x, 283 x,
@@ -580,9 +468,9 @@ evas_software_gdi_outbuf_flush(Outbuf *buf, Tilebuf_Rect *surface_damage EINA_UN
580 buf->priv.prev_pending_writes); 468 buf->priv.prev_pending_writes);
581 obr = im->extended_info; 469 obr = im->extended_info;
582 evas_cache_image_drop(&im->cache_entry); 470 evas_cache_image_drop(&im->cache_entry);
583 if (obr->gdiob) _unfind_gdiob(obr->gdiob); 471 if (obr->gdiob)
472 evas_software_gdi_output_buffer_free(obr->gdiob);
584/* if (obr->mgdiob) _unfind_gdiob(obr->mgdiob); */ 473/* if (obr->mgdiob) _unfind_gdiob(obr->mgdiob); */
585/* if (obr->gdiob) evas_software_x11_x_output_buffer_free(obr->gdiob); */
586 free(obr); 474 free(obr);
587 } 475 }
588 buf->priv.prev_pending_writes = buf->priv.pending_writes; 476 buf->priv.prev_pending_writes = buf->priv.pending_writes;
@@ -605,11 +493,11 @@ evas_software_gdi_outbuf_idle_flush(Outbuf *buf)
605 buf->priv.prev_pending_writes); 493 buf->priv.prev_pending_writes);
606 obr = im->extended_info; 494 obr = im->extended_info;
607 evas_cache_image_drop((Image_Entry *)im); 495 evas_cache_image_drop((Image_Entry *)im);
608 if (obr->gdiob) _unfind_gdiob(obr->gdiob); 496 if (obr->gdiob)
497 evas_software_gdi_output_buffer_free(obr->gdiob);
609/* if (obr->mxob) _unfind_xob(obr->mxob, 0); */ 498/* if (obr->mxob) _unfind_xob(obr->mxob, 0); */
610 free(obr); 499 free(obr);
611 } 500 }
612 _clear_gdiob();
613} 501}
614 502
615int 503int
@@ -624,12 +512,6 @@ evas_software_gdi_outbuf_height_get(Outbuf *buf)
624 return buf->height; 512 return buf->height;
625} 513}
626 514
627Outbuf_Depth
628evas_software_gdi_outbuf_depth_get(Outbuf *buf)
629{
630 return buf->depth;
631}
632
633int 515int
634evas_software_gdi_outbuf_rot_get(Outbuf *buf) 516evas_software_gdi_outbuf_rot_get(Outbuf *buf)
635{ 517{