[clutter-color] Use a different hls->rgb algorithm + use floating point

Using test-cogl-vertex-buffer as a test case which is CPU bound due to
hls -> rgb conversions this alternative algorithm looked to be ~10%
faster when tested on an X61s Lenovo.
This commit is contained in:
Robert Bragg
2009-03-17 00:01:56 +00:00
parent 567a96c96a
commit bb93a98762
2 changed files with 100 additions and 228 deletions

View File

@@ -41,6 +41,8 @@
#define HSL_OFFSET 0.5 /* the hue that we map an amplitude of 0 too */
#define HSL_SCALE 0.25
#define USE_CLUTTER_COLOR 1
typedef struct _TestState
{
ClutterActor *dummy;
@@ -52,6 +54,7 @@ typedef struct _TestState
ClutterTimeline *timeline;
} TestState;
#ifndef USE_CLUTTER_COLOR
/* This algorithm is adapted from the book:
* Fundamentals of Interactive Computer Graphics by Foley and van Dam
*/
@@ -105,6 +108,7 @@ hsl_to_rgb (float h, float s, float l,
*g = clr[1] * 255.0;
*b = clr[2] * 255.0;
}
#endif
static void
frame_cb (ClutterTimeline *timeline,
@@ -152,7 +156,11 @@ frame_cb (ClutterTimeline *timeline,
s = 0.5;
l = 0.25 + (period_progress_sin + 1.0) / 4.0;
color = &state->quad_mesh_colors[4 * vert_index];
#ifdef USE_CLUTTER_COLOR
clutter_color_from_hls ((ClutterColor *)color, h * 360.0, l, s);
#else
hsl_to_rgb (h, s, l, &color[0], &color[1], &color[2]);
#endif
}
cogl_vertex_buffer_add (state->buffer,