summaryrefslogtreecommitdiff
path: root/src/modules/evas/engines/software_generic/evas_native_common.h
blob: 4121746fd7381203897b1f4deebd9902558a1f3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#ifndef _EVAS_NATIVE_COMMON_H
#define _EVAS_NATIVE_COMMON_H

#ifdef EAPI
# undef EAPI
#endif

#ifdef _WIN32
# ifdef EFL_BUILD
#  ifdef DLL_EXPORT
#   define EAPI __declspec(dllexport)
#  else
#   define EAPI
#  endif
# else
#  define EAPI __declspec(dllimport)
# endif
#else
# ifdef __GNUC__
#  if __GNUC__ >= 4
#   define EAPI __attribute__ ((visibility("default")))
#  else
#   define EAPI
#  endif
# else
#  define EAPI
# endif
#endif

//#include <Evas_Common.h>

#define EVAS_DMABUF_ATTRIBUTE_VERSION 1

struct dmabuf_attributes
{
  /* This must exactly match the struct in Enlightenment.
   * Wayland dmabuf is still an experimental protocol and may
   * change.  If the version doesn't match we won't even attempt
   * to read the struct.
   */
   int version;
   int32_t width;
   int32_t height;
   uint32_t format;
   uint32_t flags; /* enum zlinux_buffer_params_flags */
   int n_planes;
   int fd[4];
   uint32_t offset[4];
   uint32_t stride[4];
   uint64_t modifier[4];
};

typedef struct _Native Native;
struct _Native
{
   Evas_Native_Surface ns;
   union {
      /*  EVAS_NATIVE_SURFACE_X11 */
      struct
      {
         unsigned long     pixmap; /* Pixmap */
         void                     *visual;  /* Visual */
         void                     *display; /* Display */
         void                     *exim;    /* Ecore_X_Image or Evas_DRI_Image */

         void                     *buffer;
         void                     *config;   /* egl configuration or glx configuration */
         void                     *surface; /* egl surface or glx surface */
         unsigned char             multiple_buffer : 1; /* whether pixmap is multiple buffer */
      } x11; /**< Set this struct fields if surface data is SW X11 based. */

       /*  EVAS_NATIVE_SURFACE_WL */
      struct
      {
         void                     *wl_buf; /* struct wl_buffer */
         void                     *surface; /*egl surface*/
      } wl_surface; /**< Set this struct fields if surface data is Wayland based. */

       /*  EVAS_NATIVE_SURFACE_WL_DMABUF */
      struct
      {
         struct dmabuf_attributes attr; /* Plane attributes of buffer */
         void                     *resource; /* Wayland resource for buffer */

         // Run-time storage for bind/unbind
         size_t                   size; /* size of are when mmapped */
         void                     *ptr; /* data area when mmapped */
         void                     *image; /* EGLImage when bound for GL */
      } wl_surface_dmabuf; /**< Set this struct fields if surface data is Wayland dmabuf based. */

      /* EVAS_NATIVE_SURFACE_OPENGL */
      struct
      {
         void                     *surface; /*egl surface*/
      } opengl;

      /* EVAS_NATIVE_SURFACE_EVASGL */
      struct
      {
         void                     *surface; /*evas gl surface*/
      } evasgl;

      /*  EVAS_NATIVE_SURFACE_TBM */
      struct
      {
         void                     *buffer; /*tbm surface*/
         void                     *surface; /*egl surface*/
      } tbm;
   } ns_data; /**< Choose one union data according to your surface in Evas Engine. */
};

EAPI void *_evas_native_tbm_surface_image_set(void *data, void *image, void *native);
EAPI int _evas_native_tbm_surface_stride_get(void *data, void *native);
EAPI int _evas_native_tbm_init(void);
EAPI void _evas_native_tbm_shutdown(void);

void *_evas_native_dmabuf_surface_image_set(void *image, void *native);

typedef void *(*Evas_Native_Tbm_Surface_Image_Set_Call)(void *data, void *image, void *native);
typedef int (*Evas_Native_Tbm_Surface_Stride_Get_Call)(void *data, void *native);

#endif //_EVAS_NATIVE_COMMON_H