From: Enlightenment S. <no-...@en...> - 2009-11-04 23:20:46
|
Log: + Remove trailing whitespaces + Add an etch_init|shutdown + Add a global domain for etch Author: turran Date: 2009-11-04 15:20:33 -0800 (Wed, 04 Nov 2009) New Revision: 43459 Modified: trunk/PROTO/etch/src/bin/etch_test.c trunk/PROTO/etch/src/include/Etch.h trunk/PROTO/etch/src/include/etch_private.h trunk/PROTO/etch/src/lib/etch.c trunk/PROTO/etch/src/lib/etch_animation.c trunk/PROTO/etch/src/lib/etch_time.c Modified: trunk/PROTO/etch/src/bin/etch_test.c =================================================================== --- trunk/PROTO/etch/src/bin/etch_test.c 2009-11-04 22:57:09 UTC (rev 43458) +++ trunk/PROTO/etch/src/bin/etch_test.c 2009-11-04 23:20:33 UTC (rev 43459) @@ -35,17 +35,17 @@ { struct sigaction sact; struct itimerval value; - + /* create the timer callback */ sact.sa_flags = 0; sact.sa_handler = timer_signal_cb; - + value.it_interval.tv_sec = 0; value.it_interval.tv_usec = 33333; /* every 33333 (1/30fps) usecs */ value.it_value.tv_sec = 0; value.it_value.tv_usec = 500000; /* wait 500 usecs, before triggering the first event */ sigaction(SIGALRM, &sact, NULL); - setitimer(ITIMER_REAL, &value, NULL); + setitimer(ITIMER_REAL, &value, NULL); } void animation_uint32_setup(Etch *e) @@ -53,7 +53,7 @@ Etch_Animation *ea; Etch_Animation_Keyframe *ek; Etch_Data data; - + ea = etch_animation_add(e, ETCH_UINT32, _uint32_cb, NULL, NULL, NULL); /* first keyframe */ ek = etch_animation_keyframe_add(ea); @@ -85,7 +85,7 @@ data.data.u32 = 15; etch_animation_keyframe_value_set(ek, &data); etch_animation_keyframe_time_set(ek, 2, 0); - + ek = etch_animation_keyframe_add(ea); etch_animation_keyframe_type_set(ek, ETCH_ANIMATION_DISCRETE); data.data.u32 = 25; @@ -151,7 +151,7 @@ int main(void) { Etch *e; - + e = etch_new(); etch_timer_fps_set(e, 30); animation_uint32_setup(e); Modified: trunk/PROTO/etch/src/include/Etch.h =================================================================== --- trunk/PROTO/etch/src/include/Etch.h 2009-11-04 22:57:09 UTC (rev 43458) +++ trunk/PROTO/etch/src/include/Etch.h 2009-11-04 23:20:33 UTC (rev 43459) @@ -39,6 +39,9 @@ * of animations. * @{ */ +EAPI void etch_init(void); +EAPI void etch_shutdown(void); + typedef struct _Etch Etch; /**< Etch Opaque Handler */ EAPI Etch * etch_new(void); EAPI void etch_delete(Etch *e); @@ -91,7 +94,7 @@ * An Etch_Animation is a container of keyframes which are named * Etch_Keyframes, every keyframe defines the way to interpolate * two values, the previous keyframe final value and the current - * keyframe value. + * keyframe value. * @{ */ typedef struct _Etch_Animation Etch_Animation; /**< Animation Opaque Handler */ @@ -113,7 +116,7 @@ typedef void (*Etch_Animation_State_Callback)(Etch_Animation *a, void *data); EAPI Etch_Animation * etch_animation_add(Etch *e, Etch_Data_Type dtype, - Etch_Animation_Callback cb, + Etch_Animation_Callback cb, Etch_Animation_State_Callback start, Etch_Animation_State_Callback stop, void *data); Modified: trunk/PROTO/etch/src/include/etch_private.h =================================================================== --- trunk/PROTO/etch/src/include/etch_private.h 2009-11-04 22:57:09 UTC (rev 43458) +++ trunk/PROTO/etch/src/include/etch_private.h 2009-11-04 23:20:33 UTC (rev 43459) @@ -31,6 +31,12 @@ #include "Eina.h" +#define ERR(...) EINA_LOG_DOM_ERR(etch_log, __VA_ARGS__) +#define WRN(...) EINA_LOG_DOM_WARN(etch_log, __VA_ARGS__) +#define DBG(...) EINA_LOG_DOM_DBG(etch_log, __VA_ARGS__) + +extern int etch_log; + /* * Abstract implementation of the internal timer implementation */ Modified: trunk/PROTO/etch/src/lib/etch.c =================================================================== --- trunk/PROTO/etch/src/lib/etch.c 2009-11-04 22:57:09 UTC (rev 43458) +++ trunk/PROTO/etch/src/lib/etch.c 2009-11-04 23:20:33 UTC (rev 43459) @@ -30,6 +30,8 @@ *============================================================================*/ #define DEFAULT_FPS 30 +static _init_count = 0; + static void _fps_to_time(unsigned long frame, unsigned long *time) { /* giving a frame transform it to secs|usec representation */ @@ -114,11 +116,34 @@ /*============================================================================* * Global * *============================================================================*/ - +int etch_log = -1; /*============================================================================* * API * *============================================================================*/ /** + * Initialize Etch. You must call this function before any other call to any + * etch function. + */ +EAPI void etch_init(void) +{ + if (_init_count) goto done; + eina_init(); + etch_log = eina_log_domain_register("etch", NULL); +done: + _init_count++; +} +/** + * Shutdown Etch. + */ +EAPI void etch_shutdown(void) +{ + if (_init_count != 1) goto done; + eina_log_domain_unregister(etch_log); + eina_shutdown(); +done: + _init_count--; +} +/** * Create a new Etch instance. * @return The Etch instance */ Modified: trunk/PROTO/etch/src/lib/etch_animation.c =================================================================== --- trunk/PROTO/etch/src/lib/etch_animation.c 2009-11-04 22:57:09 UTC (rev 43458) +++ trunk/PROTO/etch/src/lib/etch_animation.c 2009-11-04 23:20:33 UTC (rev 43459) @@ -181,6 +181,11 @@ /* store old value */ old = a->curr; /* interpolate the new value */ + if (!_interpolators[a->dtype]) + { + WRN("No interpolator available for type %d\n", a->dtype); + return; + } ifnc = _interpolators[a->dtype]->funcs[start->type]; if (!ifnc) return; Modified: trunk/PROTO/etch/src/lib/etch_time.c =================================================================== --- trunk/PROTO/etch/src/lib/etch_time.c 2009-11-04 22:57:09 UTC (rev 43458) +++ trunk/PROTO/etch/src/lib/etch_time.c 2009-11-04 23:20:33 UTC (rev 43459) @@ -36,12 +36,12 @@ t->usecs = USECS_MAX; } -/* make this function return a 1.31 fixed point variable */ +/* make this function return a 1.31 fixed point variable */ double etch_time_interpolate(Etch_Time *first, Etch_Time *last, Etch_Time *curr) { Etch_Time tmp1, tmp2; double d1, d2; - + //m = (curr - start->time)/(end->time - start->time); etch_time_sub(last, first, &tmp1); etch_time_sub(curr, first, &tmp2); |