1 #include "evas_common.h"
2 #include "evas_engine.h"
5 static Evas_List *ddpool = NULL;
7 static int ddmemlimit = 10 * 1024 * 1024;
8 static int ddcountlimit = 32;
10 static DD_Output_Buffer *
11 _find_ddob(int depth, int w, int h, void *data)
15 DD_Output_Buffer *ddob = NULL;
21 if (bpp == 3) bpp = 4;
22 lbytes = (((w * bpp) + 3) / 4) * 4;
24 for (l = ddpool; l; l = l->next)
26 DD_Output_Buffer *ddob2;
29 if (ddob2->depth != depth)
31 if (ddob2->psize == sz)
39 return evas_software_ddraw_output_buffer_new(depth, w, h, data);
42 ddpool = evas_list_remove_list(ddpool, ddl);
46 ddsize -= ddob->psize * (ddob->depth / 8);
52 _unfind_ddob(DD_Output_Buffer *ddob)
54 ddpool = evas_list_prepend(ddpool, ddob);
55 ddsize += ddob->psize * ddob->depth / 8;
56 while ((ddsize > (ddmemlimit)) ||
57 (evas_list_count(ddpool) > ddcountlimit))
61 xl = evas_list_last(ddpool);
68 ddpool = evas_list_remove_list(ddpool, xl);
69 evas_software_ddraw_output_buffer_free(ddob);
78 DD_Output_Buffer *ddob;
81 ddpool = evas_list_remove_list(ddpool, ddpool);
82 evas_software_ddraw_output_buffer_free(ddob);
88 evas_software_ddraw_outbuf_init(void)
93 evas_software_ddraw_outbuf_free(Outbuf *buf)
98 evas_software_ddraw_shutdown(buf);
103 evas_software_ddraw_outbuf_setup(int width,
112 buf = (Outbuf *)calloc(1, sizeof(Outbuf));
117 buf->height = height;
121 if (!evas_software_ddraw_init(window, w_depth, buf))
128 Gfx_Func_Convert conv_func;
129 DD_Output_Buffer *ddob;
131 ddob = evas_software_ddraw_output_buffer_new(w_depth, 1, 1, NULL);
136 if (evas_software_ddraw_masks_get(buf))
138 if ((rotation == 0) || (rotation == 180))
139 conv_func = evas_common_convert_func_get(0,
142 evas_software_ddraw_output_buffer_depth (ddob),
148 else if ((rotation == 90) || (rotation == 270))
149 conv_func = evas_common_convert_func_get(0,
152 evas_software_ddraw_output_buffer_depth (ddob),
160 evas_software_ddraw_output_buffer_free(ddob);
164 fprintf(stderr, ".[ Evas Error ].\n"
167 " RGB format mask: %08x, %08x, %08x\n"
168 " Not supported by and compiled in converters!\n"
182 evas_software_ddraw_outbuf_reconfigure(Outbuf *buf,
188 if ((width == buf->width) && (height == buf->height) &&
189 (rotation == buf->rot) && (depth == buf->depth))
192 buf->height = height;
194 evas_software_ddraw_surface_resize(buf);
198 evas_software_ddraw_outbuf_new_region_for_update(Outbuf *buf,
213 obr = calloc(1, sizeof(Outbuf_Region));
223 if ((buf->rot == 0) &&
224 (buf->priv.mask.r == 0xff0000) &&
225 (buf->priv.mask.g == 0x00ff00) &&
226 (buf->priv.mask.b == 0x0000ff))
228 obr->ddob = _find_ddob(buf->priv.dd.depth, w, h, NULL);
229 /* obr->ddob = evas_software_x11_x_output_buffer_new(buf->priv.dd.disp, */
230 /* buf->priv.dd.vis, */
231 /* buf->priv.dd.depth, */
235 im = (RGBA_Image *)evas_cache_image_data(evas_common_image_cache_get(),
237 (DATA32 *) evas_software_ddraw_output_buffer_data(obr->ddob, &bpl),
238 alpha, EVAS_COLORSPACE_ARGB8888);
239 im->extended_info = obr;
243 im = (RGBA_Image *) evas_cache_image_empty(evas_common_image_cache_get());
244 im->cache_entry.flags.alpha |= alpha ? 1 : 0;
245 evas_cache_image_surface_alloc(&im->cache_entry, w, h);
246 im->extended_info = obr;
247 if ((buf->rot == 0) || (buf->rot == 180))
248 obr->ddob = _find_ddob(buf->priv.dd.depth, w, h, NULL);
250 obr->ddob = evas_software_x11_x_output_buffer_new(buf->priv.dd.disp,
257 else if ((buf->rot == 90) || (buf->rot == 270))
258 obr->ddob = _find_ddob(buf->priv.dd.depth, h, w, NULL);
260 obr->ddob = evas_software_x11_x_output_buffer_new(buf->priv.dd.disp,
269 buf->priv.pending_writes = evas_list_append(buf->priv.pending_writes, im);
274 evas_software_ddraw_outbuf_push_updated_region(Outbuf *buf,
281 Gfx_Func_Convert conv_func;
288 obr = update->extended_info;
290 if ((buf->rot == 0) || (buf->rot == 180))
291 conv_func = evas_common_convert_func_get(0, w, h,
292 evas_software_ddraw_output_buffer_depth(obr->ddob),
298 else if ((buf->rot == 90) || (buf->rot == 270))
299 conv_func = evas_common_convert_func_get(0, h, w,
300 evas_software_ddraw_output_buffer_depth(obr->ddob),
304 PAL_MODE_NONE, buf->rot);
305 if (!conv_func) return;
307 data = evas_software_ddraw_output_buffer_data(obr->ddob, &bpl);
308 src_data = update->image.data;
314 else if (buf->rot == 90)
317 obr->y = buf->width - x - w;
319 else if (buf->rot == 180)
321 obr->x = buf->width - x - w;
322 obr->y = buf->height - y - h;
324 else if (buf->rot == 270)
326 obr->x = buf->height - y - h;
329 if ((buf->rot == 0) || (buf->rot == 180))
334 else if ((buf->rot == 90) || (buf->rot == 270))
340 if (data != src_data)
341 conv_func(src_data, data,
343 bpl / ((evas_software_ddraw_output_buffer_depth(obr->ddob) / 8)) - obr->width,
352 evas_software_ddraw_outbuf_free_region_for_update(Outbuf *buf,
355 /* no need to do anything - they are cleaned up on flush */
359 evas_software_ddraw_outbuf_flush(Outbuf *buf)
368 /* lock the back surface */
369 if (!(ddraw_data = evas_software_ddraw_lock(buf,
376 /* copy safely the images that need to be drawn onto the back surface */
377 for (l = buf->priv.pending_writes; l; l = l->next)
381 DD_Output_Buffer *ddob;
384 obr = im->extended_info;
386 evas_software_ddraw_output_buffer_paste(ddob,
396 /* unlock the back surface and flip the surface */
397 evas_software_ddraw_unlock_and_flip(buf);
400 while (buf->priv.prev_pending_writes)
405 im = buf->priv.prev_pending_writes->data;
406 buf->priv.prev_pending_writes =
407 evas_list_remove_list(buf->priv.prev_pending_writes,
408 buf->priv.prev_pending_writes);
409 obr = im->extended_info;
410 evas_cache_image_drop((Image_Entry *)im);
411 if (obr->ddob) _unfind_ddob(obr->ddob);
413 if (obr->ddob) evas_software_x11_x_output_buffer_free(obr->ddob);
417 buf->priv.prev_pending_writes = buf->priv.pending_writes;
418 buf->priv.pending_writes = NULL;
420 evas_common_cpu_end_opt();
424 evas_software_ddraw_outbuf_idle_flush(Outbuf *buf)
426 while (buf->priv.prev_pending_writes)
431 im = buf->priv.prev_pending_writes->data;
432 buf->priv.prev_pending_writes =
433 evas_list_remove_list(buf->priv.prev_pending_writes,
434 buf->priv.prev_pending_writes);
435 obr = im->extended_info;
436 evas_cache_image_drop((Image_Entry *)im);
437 if (obr->ddob) _unfind_ddob(obr->ddob);
444 evas_software_ddraw_outbuf_width_get(Outbuf *buf)
450 evas_software_ddraw_outbuf_height_get(Outbuf *buf)
456 evas_software_ddraw_outbuf_depth_get(Outbuf *buf)
462 evas_software_ddraw_outbuf_rot_get(Outbuf *buf)