aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/evas/canvas/evas_canvas3d_primitive.c
blob: dce1bcfa06b4abfb295be470cde3daa674fba490 (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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#include "evas_common_private.h"
#include "evas_private.h"

#define MY_CLASS EVAS_CANVAS3D_PRIMITIVE_CLASS

static inline void
_primitive_init(Evas_Canvas3D_Primitive_Data *pd)
{
   pd->form = EVAS_CANVAS3D_MESH_PRIMITIVE_NONE;
   pd->ratio = 3.0;
   pd->precision = 10;
   pd->surface = NULL;
   pd->tex_scale.x = 1.0;
   pd->tex_scale.y = 1.0;
}

EAPI Evas_Canvas3D_Primitive *
evas_canvas3d_primitive_add(Evas *e)
{
   MAGIC_CHECK(e, Evas, MAGIC_EVAS);
   return NULL;
   MAGIC_CHECK_END();
   return efl_add(MY_CLASS, e);
}

EOLIAN static Eo *
_evas_canvas3d_primitive_efl_object_constructor(Eo *obj, Evas_Canvas3D_Primitive_Data *pd)
{
   obj = efl_constructor(efl_super(obj, MY_CLASS));
   evas_canvas3d_object_type_set(obj, EVAS_CANVAS3D_OBJECT_TYPE_PRIMITIVE);
   _primitive_init(pd);

   return obj;
}

EOLIAN static void
_evas_canvas3d_primitive_efl_object_destructor(Eo *obj, Evas_Canvas3D_Primitive_Data *pd EINA_UNUSED)
{
   efl_destructor(efl_super(obj, MY_CLASS));
}

EOLIAN static void
_evas_canvas3d_primitive_form_set(Eo *obj EINA_UNUSED,
                            Evas_Canvas3D_Primitive_Data *pd,
                            Evas_Canvas3D_Mesh_Primitive form)
{
   if (form >= EVAS_CANVAS3D_MESH_PRIMITIVE_COUNT)
     {
        ERR("Wrong form of primitive.");
        return;
     }

   if (pd->form != form)
     pd->form = form;
}

EOLIAN static Evas_Canvas3D_Mesh_Primitive
_evas_canvas3d_primitive_form_get(Eo *obj EINA_UNUSED,
                            Evas_Canvas3D_Primitive_Data *pd)
{
   return pd->form;
}

EOLIAN static void
_evas_canvas3d_primitive_mode_set(Eo *obj EINA_UNUSED,
                            Evas_Canvas3D_Primitive_Data *pd,
                            Evas_Canvas3D_Primitive_Mode mode)
{
   if (pd->mode != mode)
     pd->mode = mode;
}

EOLIAN static Evas_Canvas3D_Primitive_Mode
_evas_canvas3d_primitive_mode_get(Eo *obj EINA_UNUSED,
                            Evas_Canvas3D_Primitive_Data *pd)
{
   return pd->mode;
}

EOLIAN static void
_evas_canvas3d_primitive_ratio_set(Eo *obj EINA_UNUSED,
                             Evas_Canvas3D_Primitive_Data *pd,
                             Evas_Real ratio)
{
   pd->ratio = ratio;
}

EOLIAN static Evas_Real
_evas_canvas3d_primitive_ratio_get(Eo *obj EINA_UNUSED,
                             Evas_Canvas3D_Primitive_Data *pd)
{
   return pd->ratio;
}

EOLIAN static void
_evas_canvas3d_primitive_precision_set(Eo *obj EINA_UNUSED,
                                 Evas_Canvas3D_Primitive_Data *pd,
                                 int precision)
{
   if ((precision < 3))
     {
        ERR("Precision of Evas_Canvas3D_Primitive cannot be less than 3.");
        return;
     }

   if ((precision >= 100))
     {
        ERR("%s\n%s",
            "Be careful with precision of Evas_Canvas3D_Primitive more than 100.",
            "It can give unacceptable result.");
     }

   if (pd->precision != precision)
     pd->precision = precision;
}

EOLIAN static int
_evas_canvas3d_primitive_precision_get(Eo *obj EINA_UNUSED,
                                 Evas_Canvas3D_Primitive_Data *pd)
{
   return pd->precision;
}

EOLIAN static void
_evas_canvas3d_primitive_surface_set(Eo *obj EINA_UNUSED,
                               Evas_Canvas3D_Primitive_Data *pd,
                               Evas_Canvas3D_Surface_Func surface_func)
{
   pd->surface = surface_func;
}

EOLIAN static void
_evas_canvas3d_primitive_tex_scale_set(Eo *obj EINA_UNUSED,
                                 Evas_Canvas3D_Primitive_Data *pd,
                                 Evas_Real x,
                                 Evas_Real y)
{
   if (!EINA_DBL_EQ(x, 0.0)) pd->tex_scale.x = x;
   if (!EINA_DBL_EQ(y, 0.0)) pd->tex_scale.y = y;
}

EOLIAN static void
_evas_canvas3d_primitive_tex_scale_get(Eo *obj EINA_UNUSED,
                                 Evas_Canvas3D_Primitive_Data *pd,
                                 Evas_Real *x,
                                 Evas_Real *y)
{
   if (x) *x = pd->tex_scale.x;
   if (y) *y = pd->tex_scale.y;
}

#include "canvas/evas_canvas3d_primitive.eo.c"