summaryrefslogtreecommitdiff
path: root/legacy/evas/src/lib/canvas/evas_object_gradient2.c
blob: 6511aa5409e608adacfc76004399715d2f32fadf (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
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
#include "evas_common.h"
#include "evas_private.h"

typedef struct _Evas_Object_Gradient2      Evas_Object_Gradient2;

struct _Evas_Object_Gradient2
{
   DATA32            magic;

   struct {
      struct {
         Evas_Common_Transform  transform;
         int         spread;
      } fill;
      unsigned char    gradient_opaque : 1;
   } cur, prev;

   unsigned char     gradient_changed : 1;
};


/**
 * @addtogroup Evas_Object_Gradient2_Group
 * @{
 */

/**
 * Inserts a color stop to the given evas gradient object.
 *
 * The @p pos parameter determines where along the unit interval
 * [0,1] the color is to be inserted. The r,g,b,a data are assumed
 * input as being NON-PREMULTIPLIED.
 *
 * @param   obj      The given evas gradient object.
 * @param   r        Red component of the given color.
 * @param   g        Green component of the given color.
 * @param   b        Blue component of the given color.
 * @param   a        Alpha component of the given color.
 * @param   pos      The pos in [0,1] of this stop.
 */
EAPI void
evas_object_gradient2_color_np_stop_insert(Evas_Object *obj, int r, int g, int b, int a, float pos)
{
   Evas_Object_Gradient2 *og;
   void *engine_data;

   MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
   return;
   MAGIC_CHECK_END();
   og = (Evas_Object_Gradient2 *)(obj->object_data);
   MAGIC_CHECK(og, Evas_Object_Gradient2, MAGIC_OBJ_GRADIENT);
   return;
   MAGIC_CHECK_END();
   engine_data = obj->func->engine_data_get(obj);
   if (engine_data)
     {
#ifdef EVAS_FRAME_QUEUING
        evas_common_pipe_op_grad2_flush(engine_data);
#endif

        obj->layer->evas->engine.func->gradient2_color_np_stop_insert(obj->layer->evas->engine.data.output,
                           engine_data,
                           r, g, b, a, pos);
     }
   og->gradient_changed = 1;
   evas_object_change(obj);
}

/**
 * Deletes all stops set for the given evas gradient object or any set data.
 * @param   obj The given evas gradient object.
 */
EAPI void
evas_object_gradient2_clear(Evas_Object *obj)
{
   Evas_Object_Gradient2 *og;
   void *engine_data;

   MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
   return;
   MAGIC_CHECK_END();
   og = (Evas_Object_Gradient2 *)(obj->object_data);
   MAGIC_CHECK(og, Evas_Object_Gradient2, MAGIC_OBJ_GRADIENT);
   return;
   MAGIC_CHECK_END();
   engine_data = obj->func->engine_data_get(obj);
   if (engine_data)
     {
#ifdef EVAS_FRAME_QUEUING
        evas_common_pipe_op_grad2_flush(engine_data);
#endif
        obj->layer->evas->engine.func->gradient2_clear(obj->layer->evas->engine.data.output,
                        engine_data);
     }
   og->gradient_changed = 1;
   og->cur.gradient_opaque = 0;
   evas_object_change(obj);
}


/**
 * Sets the tiling mode for the given evas gradient object's fill.
 * @param   obj   The given evas gradient object.
 * @param   spread One of EVAS_TEXTURE_REFLECT, EVAS_TEXTURE_REPEAT,
 * EVAS_TEXTURE_RESTRICT, or EVAS_TEXTURE_PAD.
 */
EAPI void
evas_object_gradient2_fill_spread_set(Evas_Object *obj, int spread)
{
   Evas_Object_Gradient2 *og;

   MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
   return;
   MAGIC_CHECK_END();
   og = (Evas_Object_Gradient2 *)(obj->object_data);
   MAGIC_CHECK(og, Evas_Object_Gradient2, MAGIC_OBJ_GRADIENT);
   return;
   MAGIC_CHECK_END();
   if (spread == og->cur.fill.spread) return;
   og->cur.fill.spread = spread;
   og->gradient_changed = 1;
   evas_object_change(obj);
}

/**
 * Retrieves the spread (tiling mode) for the given gradient object's fill.
 * @param   obj The given evas gradient object.
 * @return  The current spread mode of the gradient object.
 */
EAPI int
evas_object_gradient2_fill_spread_get(const Evas_Object *obj)
{
   Evas_Object_Gradient2 *og;

   MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
   return EVAS_TEXTURE_REPEAT;
   MAGIC_CHECK_END();
   og = (Evas_Object_Gradient2 *)(obj->object_data);
   MAGIC_CHECK(og, Evas_Object_Gradient2, MAGIC_OBJ_GRADIENT);
   return EVAS_TEXTURE_REPEAT;
   MAGIC_CHECK_END();
   return og->cur.fill.spread;
}

/* FIXME: To be documented*/
EAPI void
evas_object_gradient2_fill_transform_set (Evas_Object *obj, Evas_Transform *t)
{
   Evas_Object_Gradient2 *og;

   MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
   return;
   MAGIC_CHECK_END();
   og = (Evas_Object_Gradient2 *)(obj->object_data);
   MAGIC_CHECK(og, Evas_Object_Gradient2, MAGIC_OBJ_GRADIENT);
   return;
   MAGIC_CHECK_END();
   if (!t)
     {
	og->cur.fill.transform.mxx = 1;
	og->cur.fill.transform.mxy = 0;
	og->cur.fill.transform.mxz = 0;
	og->cur.fill.transform.myx = 0;
	og->cur.fill.transform.myy = 1;
	og->cur.fill.transform.myz = 0;
	og->cur.fill.transform.mzx = 0;
	og->cur.fill.transform.mzy = 0;
	og->cur.fill.transform.mzz = 1;

	og->gradient_changed = 1;
	evas_object_change(obj);
	return;
     }
   if ( (og->cur.fill.transform.mxx == t->mxx) ||
	 (og->cur.fill.transform.mxy == t->mxy) ||
	 (og->cur.fill.transform.mxy == t->mxy) ||
	 (og->cur.fill.transform.mxy == t->mxy) ||
	 (og->cur.fill.transform.mxy == t->mxy) ||
	 (og->cur.fill.transform.mxy == t->mxy) ||
	 (og->cur.fill.transform.mxy == t->mxy) ||
	 (og->cur.fill.transform.mxy == t->mxy) ||
	 (og->cur.fill.transform.mxy == t->mxy) )
	    return;

   og->cur.fill.transform.mxx = t->mxx;
   og->cur.fill.transform.mxy = t->mxy;
   og->cur.fill.transform.mxz = t->mxz;
   og->cur.fill.transform.myx = t->myx;
   og->cur.fill.transform.myy = t->myy;
   og->cur.fill.transform.myz = t->myz;
   og->cur.fill.transform.mzx = t->mzx;
   og->cur.fill.transform.mzy = t->mzy;
   og->cur.fill.transform.mzz = t->mzz;

   og->gradient_changed = 1;
   evas_object_change(obj);
}

/* FIXME: To be documented*/
EAPI void
evas_object_gradient2_fill_transform_get (const Evas_Object *obj, Evas_Transform *t)
{
   Evas_Object_Gradient2 *og;

   MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
   return;
   MAGIC_CHECK_END();
   og = (Evas_Object_Gradient2 *)(obj->object_data);
   MAGIC_CHECK(og, Evas_Object_Gradient2, MAGIC_OBJ_GRADIENT);
   return;
   MAGIC_CHECK_END();
   if (t)
     {
        t->mxx = og->cur.fill.transform.mxx;
        t->mxy = og->cur.fill.transform.mxy;
        t->mxz = og->cur.fill.transform.mxz;
        t->myx = og->cur.fill.transform.myx;
        t->myy = og->cur.fill.transform.myy;
        t->myz = og->cur.fill.transform.myz;
        t->mzx = og->cur.fill.transform.mzx;
        t->mzy = og->cur.fill.transform.mzy;
        t->mzz = og->cur.fill.transform.mzz;
     }
}



/**
 * @}
 */

#include "evas_object_gradient2_linear.c"
#include "evas_object_gradient2_radial.c"