aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/evas/src/modules/engines/wayland_shm/evas_outbuf.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/evas/src/modules/engines/wayland_shm/evas_outbuf.c')
-rw-r--r--libraries/evas/src/modules/engines/wayland_shm/evas_outbuf.c100
1 files changed, 100 insertions, 0 deletions
diff --git a/libraries/evas/src/modules/engines/wayland_shm/evas_outbuf.c b/libraries/evas/src/modules/engines/wayland_shm/evas_outbuf.c
new file mode 100644
index 0000000..490a978
--- /dev/null
+++ b/libraries/evas/src/modules/engines/wayland_shm/evas_outbuf.c
@@ -0,0 +1,100 @@
1#include "evas_common.h"
2#include "evas_engine.h"
3
4void
5evas_outbuf_free(Outbuf *ob)
6{
7 if (!ob) return;
8 if (ob->priv.buffer) evas_cache_image_drop(&ob->priv.buffer->cache_entry);
9 free(ob);
10}
11
12void
13evas_outbuf_resize(Outbuf *ob, int w, int h)
14{
15 if (!ob) return;
16 if ((ob->w == w) && (ob->h == h)) return;
17 ob->w = w;
18 ob->h = h;
19 if (ob->priv.buffer) evas_cache_image_drop(&ob->priv.buffer->cache_entry);
20 ob->priv.buffer = NULL;
21}
22
23Outbuf *
24evas_outbuf_setup(int w, int h, int rot, void *dest)
25{
26 Outbuf *ob = NULL;
27
28 if (!(ob = calloc(1, sizeof(Outbuf)))) return NULL;
29
30 ob->w = w;
31 ob->h = h;
32 ob->rotation = rot;
33 ob->priv.dest = dest;
34
35 ob->priv.buffer =
36 (RGBA_Image *)evas_cache_image_data(evas_common_image_cache_get(),
37 w, h, ob->priv.dest,
38 1, EVAS_COLORSPACE_ARGB8888);
39
40 return ob;
41}
42
43RGBA_Image *
44evas_outbuf_new_region_for_update(Outbuf *ob, int x, int y, int w, int h, int *cx, int *cy, int *cw, int *ch)
45{
46 if (ob->priv.buffer)
47 {
48 *cx = x; *cy = y; *cw = w; *ch = h;
49 return ob->priv.buffer;
50 }
51 else
52 {
53 RGBA_Image *im;
54
55 *cx = 0; *cy = 0; *cw = w; *ch = h;
56 im = (RGBA_Image *)evas_cache_image_empty(evas_common_image_cache_get());
57 if (im)
58 {
59 im->cache_entry.flags.alpha = 1;
60 im = (RGBA_Image *)evas_cache_image_size_set(&im->cache_entry, w, h);
61 }
62
63 return im;
64 }
65
66 return NULL;
67}
68
69void
70evas_outbuf_push_updated_region(Outbuf *ob, RGBA_Image *update, int x __UNUSED__, int y, int w, int h)
71{
72 if (!ob->priv.dest) return;
73 if (!ob->priv.buffer)
74 {
75 Gfx_Func_Copy func;
76
77 func = evas_common_draw_func_copy_get(w, 0);
78 if (func)
79 {
80 DATA32 *dst, *src;
81 int yy = 0, bytes = 0;
82
83 bytes = ((w * sizeof(int)) * h);
84 for (yy = 0; yy < h; yy++)
85 {
86 src = update->image.data + (yy * update->cache_entry.w);
87 dst = (DATA32 *)((DATA8 *)(ob->priv.dest) +
88 ((y + yy) * bytes));
89 func(src, dst, w);
90 }
91 }
92 }
93}
94
95void
96evas_outbuf_free_region_for_update(Outbuf *ob, RGBA_Image *update)
97{
98 if (!ob) return;
99 if (update != ob->priv.buffer) evas_cache_image_drop(&update->cache_entry);
100}