summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorDongyeon Kim <dy5.kim@samsung.com>2015-02-03 20:35:41 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-02-10 14:48:22 +0900
commitdefcc1f2ace705de2abda836c0ee0cc545beabb9 (patch)
tree6ed4339e204c18d75860c1283580d786c078bcac /src/modules
parent72f3e684d90e115aacaa62f49c66821c4e90782f (diff)
evas/software_x11: implement native surface set for x11 type
Summary: implement native surface set for EVAS_NATIVE_SURFACE_X11 type on software_x11 backend. @feature Test Plan: local tests on PC Reviewers: jpeg, cedric, raster, Hermet Subscribers: wonsik, cedric Signed-off-by: Jean-Philippe Andre <jp.andre@samsung.com>
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/evas/engines/software_generic/evas_engine.c2
-rw-r--r--src/modules/evas/engines/software_x11/evas_engine.c83
-rw-r--r--src/modules/evas/engines/software_x11/evas_xlib_image.c111
-rw-r--r--src/modules/evas/engines/software_x11/evas_xlib_image.h15
4 files changed, 211 insertions, 0 deletions
diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c
index 50b3e98729..3c13f80cd2 100644
--- a/src/modules/evas/engines/software_generic/evas_engine.c
+++ b/src/modules/evas/engines/software_generic/evas_engine.c
@@ -1449,6 +1449,8 @@ eng_image_draw(void *data EINA_UNUSED, void *context, void *surface, void *image
1449 1449
1450 if (!image) return EINA_FALSE; 1450 if (!image) return EINA_FALSE;
1451 im = image; 1451 im = image;
1452 if (im->native.func.bind)
1453 im->native.func.bind(data, image, src_x, src_y, src_w, src_h);
1452 1454
1453 if (do_async) 1455 if (do_async)
1454 { 1456 {
diff --git a/src/modules/evas/engines/software_x11/evas_engine.c b/src/modules/evas/engines/software_x11/evas_engine.c
index 43601ef07a..fa74a38a40 100644
--- a/src/modules/evas/engines/software_x11/evas_engine.c
+++ b/src/modules/evas/engines/software_x11/evas_engine.c
@@ -1,5 +1,8 @@
1#include "evas_common_private.h" 1#include "evas_common_private.h"
2#include "evas_private.h" 2#include "evas_private.h"
3#ifdef EVAS_CSERVE2
4#include "evas_cs2_private.h"
5#endif
3 6
4#include "Evas_Engine_Software_X11.h" 7#include "Evas_Engine_Software_X11.h"
5#include "evas_engine.h" 8#include "evas_engine.h"
@@ -8,6 +11,7 @@
8# include "evas_xlib_outbuf.h" 11# include "evas_xlib_outbuf.h"
9# include "evas_xlib_swapbuf.h" 12# include "evas_xlib_swapbuf.h"
10# include "evas_xlib_color.h" 13# include "evas_xlib_color.h"
14# include "evas_xlib_image.h"
11#endif 15#endif
12 16
13#ifdef BUILD_ENGINE_SOFTWARE_XCB 17#ifdef BUILD_ENGINE_SOFTWARE_XCB
@@ -616,6 +620,83 @@ eng_canvas_alpha_get(void *data, void *context EINA_UNUSED)
616 (re->outbuf_alpha_get(re->generic.ob)); 620 (re->outbuf_alpha_get(re->generic.ob));
617} 621}
618 622
623static void *
624eng_image_native_set(void *data EINA_UNUSED, void *image, void *native)
625{
626 Render_Engine *re = (Render_Engine *)data;
627 Evas_Native_Surface *ns = native;
628 RGBA_Image *im = image, *im2 = NULL;
629 Image_Entry *ie = image;
630
631 if (!im || !ns) return im;
632
633 if (ns)
634 {
635 if (ns->type == EVAS_NATIVE_SURFACE_X11)
636 {
637 if (im->native.data)
638 {
639 //image have native surface already
640 Evas_Native_Surface *ens = im->native.data;
641
642 if ((ens->type == ns->type) &&
643 (ens->data.x11.visual == ns->data.x11.visual) &&
644 (ens->data.x11.pixmap == ns->data.x11.pixmap))
645 return im;
646 }
647 }
648 }
649 else
650 {
651 return im;
652 }
653
654 if ((!ns) && (!im->native.data)) return im;
655
656 //create new im and clean already existed im even though ns = NULL
657 im2 = (RGBA_Image *)evas_cache_image_data(evas_common_image_cache_get(),
658 ie->w, ie->h, NULL, ie->flags.alpha,
659 EVAS_COLORSPACE_ARGB8888);
660 if (im->native.data)
661 {
662 if (im->native.func.free)
663 im->native.func.free(im->native.func.data, im);
664 }
665
666#ifdef EVAS_CSERVE2
667 if (evas_cserve2_use_get() && evas_cache2_image_cached(&im->cache_entry))
668 evas_cache2_image_close(&im->cache_entry);
669 else
670#endif
671 evas_cache_image_drop(&im->cache_entry);
672 im = im2;
673
674 if (!ns) return im;
675
676#ifdef BUILD_ENGINE_SOFTWARE_XLIB
677 if (ns->type == EVAS_NATIVE_SURFACE_X11)
678 {
679 return evas_xlib_image_native_set(re->generic.ob, im, ns);
680 }
681#endif
682
683 return im;
684}
685
686static void *
687eng_image_native_get(void *data EINA_UNUSED, void *image)
688{
689#ifdef BUILD_ENGINE_SOFTWARE_XLIB
690 RGBA_Image *im = image;
691 Native *n;
692 if (!im) return NULL;
693 n = im->native.data;
694 if (!n) return NULL;
695 return &(n->ns);
696#endif
697 return NULL;
698}
699
619 700
620/* module advertising code */ 701/* module advertising code */
621static int 702static int
@@ -645,6 +726,8 @@ module_open(Evas_Module *em)
645 ORD(setup); 726 ORD(setup);
646 ORD(canvas_alpha_get); 727 ORD(canvas_alpha_get);
647 ORD(output_free); 728 ORD(output_free);
729 ORD(image_native_set);
730 ORD(image_native_get);
648 731
649 /* now advertise out own api */ 732 /* now advertise out own api */
650 em->functions = (void *)(&func); 733 em->functions = (void *)(&func);
diff --git a/src/modules/evas/engines/software_x11/evas_xlib_image.c b/src/modules/evas/engines/software_x11/evas_xlib_image.c
new file mode 100644
index 0000000000..9514df450e
--- /dev/null
+++ b/src/modules/evas/engines/software_x11/evas_xlib_image.c
@@ -0,0 +1,111 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "evas_common_private.h"
6#include "evas_xlib_image.h"
7
8static void
9evas_xlib_image_update(void *data EINA_UNUSED, void *image, int x, int y, int w, int h)
10{
11 RGBA_Image *im = image;
12 Native *n = im->native.data;
13 char *pix;
14 int bpl, rows, bpp;
15
16 if (ecore_x_image_get(n->exim, n->pixmap, 0, 0, x, y, w, h))
17 {
18 pix = ecore_x_image_data_get(n->exim, &bpl, &rows, &bpp);
19 if (!ecore_x_image_is_argb32_get(n->exim))
20 {
21 if (!im->image.data)
22 im->image.data = (DATA32 *)malloc(im->cache_entry.w * im->cache_entry.h * sizeof(DATA32));
23 Ecore_X_Colormap colormap = ecore_x_default_colormap_get(ecore_x_display_get(), ecore_x_default_screen_get());
24 ecore_x_image_to_argb_convert(pix, bpp, bpl, colormap, n->visual,
25 x, y, w, h,
26 im->image.data, (w * sizeof(int)), 0, 0);
27 }
28 else
29 {
30 im->image.data = (DATA32 *)pix;
31 }
32 }
33}
34
35static void
36_native_bind_cb(void *data EINA_UNUSED, void *image, int x, int y, int w, int h)
37{
38 RGBA_Image *im = image;
39 Native *n = im->native.data;
40
41 if ((n) && (n->ns.type == EVAS_NATIVE_SURFACE_X11))
42 {
43 evas_xlib_image_update(data, image, x, y, w, h);
44 }
45}
46
47static void
48_native_free_cb(void *data EINA_UNUSED, void *image)
49{
50 RGBA_Image *im = image;
51 Native *n = im->native.data;
52
53 if (n->exim)
54 {
55 ecore_x_image_free(n->exim);
56 n->exim = NULL;
57 }
58 n->visual = NULL;
59
60 im->native.data = NULL;
61 im->native.func.data = NULL;
62 im->native.func.bind = NULL;
63 im->native.func.free = NULL;
64 im->image.data = NULL;
65 free(n);
66}
67
68void *
69evas_xlib_image_native_set(void *data, void *image, void *native)
70{
71 RGBA_Image *im = image;
72 Evas_Native_Surface *ns = native;
73 Native *n = NULL;
74 Ecore_X_Image *exim = NULL;
75 Visual *vis = NULL;
76 Pixmap pm = 0;
77 int w, h, depth;
78
79 if ((ns) && (ns->type == EVAS_NATIVE_SURFACE_X11))
80 {
81 vis = ns->data.x11.visual;
82 pm = ns->data.x11.pixmap;
83
84 depth = ecore_x_drawable_depth_get(pm);
85
86 w = im->cache_entry.w;
87 h = im->cache_entry.h;
88
89 exim = ecore_x_image_new(w, h, vis, depth);
90 if (!exim)
91 {
92 ERR("ecore_x_image_new failed.");
93 return NULL;
94 }
95
96 n = calloc(1, sizeof(Native));
97 if (!n) return NULL;
98
99 memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface));
100 n->pixmap = pm;
101 n->visual = vis;
102 n->exim = exim;
103 im->native.data = n;
104 im->native.func.data = NULL;
105 im->native.func.bind = _native_bind_cb;
106 im->native.func.free = _native_free_cb;
107
108 evas_xlib_image_update(data, image, 0, 0, w, h);
109 }
110 return im;
111}
diff --git a/src/modules/evas/engines/software_x11/evas_xlib_image.h b/src/modules/evas/engines/software_x11/evas_xlib_image.h
new file mode 100644
index 0000000000..36a62258c4
--- /dev/null
+++ b/src/modules/evas/engines/software_x11/evas_xlib_image.h
@@ -0,0 +1,15 @@
1#include "evas_engine.h"
2#include <Ecore_X.h>
3
4typedef struct _Native Native;
5
6struct _Native
7{
8 Evas_Native_Surface ns;
9 Pixmap pixmap;
10 Visual *visual;
11
12 Ecore_X_Image *exim;
13};
14
15void *evas_xlib_image_native_set(void *data, void *image, void *native);