summaryrefslogtreecommitdiff
path: root/src/lib/evas/canvas/efl_canvas_surface_tbm.c
blob: 9a9fd541983531653c9eea787bd1c7f71d01b96d (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
#include "efl_canvas_surface.h"

#define MY_CLASS EFL_CANVAS_SURFACE_TBM_CLASS

typedef struct _Efl_Canvas_Surface_Tbm_Data
{
   Efl_Canvas_Surface_Data *base;
} Efl_Canvas_Surface_Tbm_Data;

EOLIAN static Eo *
_efl_canvas_surface_tbm_eo_base_constructor(Eo *eo, Efl_Canvas_Surface_Tbm_Data *pd)
{
   Evas_Object_Protected_Data *obj;

   eo = eo_constructor(eo_super(eo, MY_CLASS));
   obj = eo_data_scope_get(eo, EFL_CANVAS_OBJECT_CLASS);
   if (!obj) return NULL;

   if (!ENFN->image_native_init(ENDT, EVAS_NATIVE_SURFACE_TBM))
     {
        ERR("TBM is not supported on this platform");
        return NULL;
     }

   pd->base = eo_data_ref(eo, EFL_CANVAS_SURFACE_MIXIN);
   pd->base->surf.type = EVAS_NATIVE_SURFACE_TBM;
   return eo;
}

EOLIAN static void
_efl_canvas_surface_tbm_eo_base_destructor(Eo *eo, Efl_Canvas_Surface_Tbm_Data *pd)
{
   Evas_Object_Protected_Data *obj;

   obj = eo_data_scope_get(eo, EFL_CANVAS_OBJECT_CLASS);

   ENFN->image_native_shutdown(ENDT, EVAS_NATIVE_SURFACE_TBM);
   eo_data_unref(eo, pd->base);
   eo_destructor(eo);
}

EOLIAN static Eina_Bool
_efl_canvas_surface_tbm_efl_canvas_surface_native_buffer_set(Eo *eo, Efl_Canvas_Surface_Tbm_Data *pd, void *buffer)
{
   pd->base->surf.data.tbm.buffer = buffer;
   if (!_evas_image_native_surface_set(eo, &pd->base->surf))
     {
        ERR("failed to set native buffer");
        pd->base->buffer = NULL;
        return EINA_FALSE;
     }
   pd->base->buffer = buffer;
   return EINA_TRUE;
}

#include "efl_canvas_surface_tbm.eo.c"