aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/evas/canvas/evas_vg_image.c
blob: 523c1fc09841cf5ad46b1d7d00f9067d2c9c67b9 (plain) (blame)
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
#include "evas_common_private.h"
#include "evas_private.h"

#include <strings.h>

#include "evas_vg_private.h"

typedef struct _Evas_VG_Image_Data Evas_VG_Image_Data;
struct _Evas_VG_Image_Data
{
   // FIXME: only manipulate Eina_File internally.
   Eina_File *f;
   Eina_Stringshare *key;

   int x, y;
   unsigned int w, h;
};

static void
_evas_vg_image_position_set(Eo *obj, Evas_VG_Image_Data *pd, int x, int y)
{
   pd->x = x;
   pd->y = y;

   _evas_vg_node_changed(obj);
}

static void
_evas_vg_image_position_get(Eo *obj, Evas_VG_Image_Data *pd, int *x, int *y)
{
   if (x) *x = pd->x;
   if (y) *y = pd->y;
}

static void
_evas_vg_image_size_set(Eo *obj, Evas_VG_Image_Data *pd,
                        unsigned int w, unsigned int h)
{
   pd->w = w;
   pd->h = h;

   _evas_vg_node_changed(obj);
}

static void
_evas_vg_image_size_get(Eo *obj, Evas_VG_Image_Data *pd,
                        unsigned int *w, unsigned int *h)
{
   if (w) *w = pd->w;
   if (h) *h = pd->h;
}

static Eina_Bool
_evas_vg_image_efl_file_mmap_set(Eo *obj EINA_UNUSED, Evas_VG_Image_Data *pd,
                                 const Eina_File *f, const char *key)
{
   Eina_File *tmp = pd->f;

   pd->f = eina_file_dup(f);
   eina_file_close(tmp);
   eina_stringshare_replace(&pd->key, key);

   _evas_vg_node_changed(obj);

   return EINA_TRUE;
}

static void
_evas_vg_image_efl_file_mmap_get(Eo *obj EINA_UNUSED, Evas_VG_Image_Data *pd,
                                 const Eina_File **f, const char **key)
{
   if (f) *f = pd->f;
   if (key) *key = pd->key;
}

static Eina_Bool
_evas_vg_image_efl_file_file_set(Eo *obj, Evas_VG_Image_Data *pd,
                                 const char *file, const char *key)
{
   Eina_File *tmp;
   Eina_Bool r;

   tmp = eina_file_open(file, EINA_FALSE);
   r = _evas_vg_image_efl_file_mmap_set(obj, pd, tmp, key);
   eina_file_close(tmp);

   return r;
}

static void
_evas_vg_image_efl_file_file_get(Eo *obj EINA_UNUSED, Evas_VG_Image_Data *pd,
                                 const char **file, const char **key)
{
   if (file) *file = eina_file_filename_get(pd->f);
   if (key) *key = pd->key;
}

static void
_evas_vg_image_eo_base_constructor(Eo *obj, Evas_VG_Image_Data *pd)
{
   eo_error_set(obj);
}

static void
_evas_vg_image_eo_base_destructor(Eo *obj, Evas_VG_Image_Data *pd)
{
   eo_error_set(obj);
}

#include "evas_vg_image.eo.c"