[maemo-commits] [maemo-commits] r17464 - in projects/haf/trunk/clutter: clutter clutter/cogl/gl clutter/cogl/gles debian
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Thu Feb 19 12:21:54 EET 2009
- Previous message: [maemo-commits] r17463 - projects/haf/trunk/libmatchbox2/matchbox/core
- Next message: [maemo-commits] r17465 - projects/haf/trunk/gtk+
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: gw Date: 2009-02-19 12:21:53 +0200 (Thu, 19 Feb 2009) New Revision: 17464 Modified: projects/haf/trunk/clutter/clutter/clutter-color.c projects/haf/trunk/clutter/clutter/clutter-color.h projects/haf/trunk/clutter/clutter/cogl/gl/cogl.c projects/haf/trunk/clutter/clutter/cogl/gles/cogl.c projects/haf/trunk/clutter/debian/changelog Log: * Moved changes from 0.8.4 clutter-color to this branch * Properly set up PVRTC texture compressiion support flag Modified: projects/haf/trunk/clutter/clutter/clutter-color.c =================================================================== --- projects/haf/trunk/clutter/clutter/clutter-color.c 2009-02-19 09:30:59 UTC (rev 17463) +++ projects/haf/trunk/clutter/clutter/clutter-color.c 2009-02-19 10:21:53 UTC (rev 17464) @@ -35,6 +35,7 @@ #endif #include <pango/pango-attributes.h> +#include <gobject/gvaluecollector.h> #include "clutter-main.h" #include "clutter-color.h" @@ -150,7 +151,7 @@ ClutterFixed red, green, blue; ClutterFixed min, max, delta; ClutterFixed h, l, s; - + g_return_if_fail (src != NULL); red = CLUTTER_INT_TO_FIXED (src->red) / 255; @@ -235,7 +236,7 @@ { ClutterFixed h, l, s; ClutterFixed m1, m2; - + g_return_if_fail (dest != NULL); l = luminance; @@ -321,9 +322,9 @@ guint8 *saturation) { ClutterFixed h, l, s; - + clutter_color_to_hlsx (src, &h, &l, &s); - + if (hue) *hue = (guint8) CFX_INT (h * 255) / 360; @@ -365,7 +366,7 @@ * @src: a #ClutterColor * @dest: return location for the shaded color * @shade: the shade factor to apply - * + * * Shades @src by the factor of @shade and saves the modified * color into @dest. */ @@ -382,7 +383,7 @@ * @src: a #ClutterColor * @dest: return location for the shaded color * @shade: #ClutterFixed the shade factor to apply - * + * * Fixed point version of clutter_color_shade(). * * Shades @src by the factor of @shade and saves the modified @@ -399,7 +400,7 @@ g_return_if_fail (src != NULL); g_return_if_fail (dest != NULL); - + clutter_color_to_hlsx (src, &h, &l, &s); l = CFX_MUL (l, shade); @@ -413,7 +414,7 @@ s = CFX_ONE; else if (s < 0) s = 0; - + clutter_color_from_hlsx (dest, h, l, s); dest->alpha = src->alpha; } @@ -431,7 +432,7 @@ clutter_color_to_pixel (const ClutterColor *src) { g_return_val_if_fail (src != NULL, 0); - + return (src->alpha | src->blue << 8 | src->green << 16 | src->red << 24); } @@ -461,8 +462,8 @@ * @dest: return location for a #ClutterColor * * Parses a string definition of a color, filling the - * <structfield>red</structfield>, <structfield>green</structfield>, - * <structfield>blue</structfield> and <structfield>alpha</structfield> + * <structfield>red</structfield>, <structfield>green</structfield>, + * <structfield>blue</structfield> and <structfield>alpha</structfield> * channels of @dest. If alpha is not specified it will be set full opaque. * The color in @dest is not allocated. * @@ -509,7 +510,7 @@ } } } - + /* Fall back to pango for named colors - note pango does not handle alpha */ if (pango_color_parse (&pango_color, color)) { @@ -592,7 +593,7 @@ clutter_color_copy (const ClutterColor *color) { ClutterColor *result; - + g_return_val_if_fail (color != NULL, NULL); result = g_slice_new (ClutterColor); @@ -612,24 +613,305 @@ void clutter_color_free (ClutterColor *color) { - g_return_if_fail (color != NULL); - + if (G_LIKELY (color)) g_slice_free (ClutterColor, color); } +/** + * clutter_color_new: + * @red: red component of the color, between 0 and 255 + * @green: green component of the color, between 0 and 255 + * @blue: blue component of the color, between 0 and 255 + * @alpha: alpha component of the color, between 0 and 255 + * + * Creates a new #ClutterColor with the given values. + * + * Return value: the newly allocated color. Use clutter_color_free() + * when done + * + * Since: 0.8.4 + */ +ClutterColor * +clutter_color_new (guint8 red, + guint8 green, + guint8 blue, + guint8 alpha) +{ + ClutterColor *color; + + color = g_slice_new (ClutterColor); + + color->red = MIN (red, 255); + color->green = MIN (green, 255); + color->blue = MIN (blue, 255); + color->alpha = MIN (alpha, 255); + + return color; +} + +static void +clutter_value_transform_color_string (const GValue *src, + GValue *dest) +{ + gchar *string = clutter_color_to_string (src->data[0].v_pointer); + + g_value_take_string (dest, string); +} + +static void +clutter_value_transform_string_color (const GValue *src, + GValue *dest) +{ + ClutterColor color = { 0, }; + + clutter_color_parse (g_value_get_string (src), &color); + + clutter_value_set_color (dest, &color); +} + GType clutter_color_get_type (void) { - static GType our_type = 0; - - if (!our_type) - our_type = g_boxed_type_register_static (I_("ClutterColor"), + static GType _clutter_color_type = 0; + + if (G_UNLIKELY (_clutter_color_type == 0)) + { + _clutter_color_type = + g_boxed_type_register_static (I_("ClutterColor"), (GBoxedCopyFunc) clutter_color_copy, (GBoxedFreeFunc) clutter_color_free); - return our_type; + + g_value_register_transform_func (_clutter_color_type, G_TYPE_STRING, + clutter_value_transform_color_string); + g_value_register_transform_func (G_TYPE_STRING, _clutter_color_type, + clutter_value_transform_string_color); + } + + return _clutter_color_type; } +static void +clutter_value_init_color (GValue *value) +{ + value->data[0].v_pointer = NULL; +} + +static void +clutter_value_free_color (GValue *value) +{ + if (!(value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS)) + clutter_color_free (value->data[0].v_pointer); +} + +static void +clutter_value_copy_color (const GValue *src, + GValue *dest) +{ + dest->data[0].v_pointer = clutter_color_copy (src->data[0].v_pointer); +} + +static gpointer +clutter_value_peek_color (const GValue *value) +{ + return value->data[0].v_pointer; +} + +static gchar * +clutter_value_collect_color (GValue *value, + guint n_collect_values, + GTypeCValue *collect_values, + guint collect_flags) +{ + if (!collect_values[0].v_pointer) + value->data[0].v_pointer = NULL; + else + { + if (collect_flags & G_VALUE_NOCOPY_CONTENTS) + { + value->data[0].v_pointer = collect_values[0].v_pointer; + value->data[1].v_uint = G_VALUE_NOCOPY_CONTENTS; + } + else + { + value->data[0].v_pointer = + clutter_color_copy (collect_values[0].v_pointer); + } + } + + return NULL; +} + +static gchar * +clutter_value_lcopy_color (const GValue *value, + guint n_collect_values, + GTypeCValue *collect_values, + guint collect_flags) +{ + ClutterColor **color_p = collect_values[0].v_pointer; + + if (!color_p) + return g_strdup_printf ("value location for `%s' passed as NULL", + G_VALUE_TYPE_NAME (value)); + + if (!value->data[0].v_pointer) + *color_p = NULL; + else + { + if (collect_flags & G_VALUE_NOCOPY_CONTENTS) + *color_p = value->data[0].v_pointer; + else + *color_p = clutter_color_copy (value->data[0].v_pointer); + } + + return NULL; +} + /** + * clutter_value_set_color: + * @value: a #GValue initialized to #CLUTTER_TYPE_COLOR + * @color: the color to set + * + * Sets @value to @color. + * + * Since: 0.8.4 + */ +void +clutter_value_set_color (GValue *value, + ClutterColor *color) +{ + g_return_if_fail (CLUTTER_VALUE_HOLDS_COLOR (value)); + + value->data[0].v_pointer = clutter_color_copy (color); +} + +/** + * clutter_value_get_color: + * @value: a #GValue initialized to #CLUTTER_TYPE_COLOR + * + * Gets the #ClutterColor contained in @value. + * + * Return value: the colors inside the passed #GValue + * + * Since: 0.8.4 + */ +const ClutterColor * +clutter_value_get_color (const GValue *value) +{ + g_return_val_if_fail (CLUTTER_VALUE_HOLDS_COLOR (value), NULL); + + return value->data[0].v_pointer; +} + +static void +param_color_init (GParamSpec *pspec) +{ + ClutterParamSpecColor *cspec = CLUTTER_PARAM_SPEC_COLOR (pspec); + + cspec->default_value = NULL; +} + +static void +param_color_finalize (GParamSpec *pspec) +{ + ClutterParamSpecColor *cspec = CLUTTER_PARAM_SPEC_COLOR (pspec); + + clutter_color_free (cspec->default_value); +} + +static void +param_color_set_default (GParamSpec *pspec, + GValue *value) +{ + value->data[0].v_pointer = CLUTTER_PARAM_SPEC_COLOR (pspec)->default_value; + value->data[1].v_uint = G_VALUE_NOCOPY_CONTENTS; +} + +static gint +param_color_values_cmp (GParamSpec *pspec, + const GValue *value1, + const GValue *value2) +{ + guint32 color1, color2; + + color1 = clutter_color_to_pixel (value1->data[0].v_pointer); + color2 = clutter_color_to_pixel (value2->data[0].v_pointer); + + if (color1 < color2) + return -1; + else if (color1 == color2) + return 0; + else + return 1; +} + +static const GTypeValueTable _clutter_color_value_table = { + clutter_value_init_color, + clutter_value_free_color, + clutter_value_copy_color, + clutter_value_peek_color, + "p", + clutter_value_collect_color, + "p", + clutter_value_lcopy_color +}; + +GType +clutter_param_color_get_type (void) +{ + static GType pspec_type = 0; + + if (G_UNLIKELY (pspec_type == 0)) + { + const GParamSpecTypeInfo pspec_info = { + sizeof (ClutterParamSpecColor), + 16, + param_color_init, + CLUTTER_TYPE_COLOR, + param_color_finalize, + param_color_set_default, + NULL, + param_color_values_cmp, + }; + + pspec_type = g_param_type_register_static (I_("ClutterParamSpecColor"), + &pspec_info); + } + + return pspec_type; +} + +/** + * clutter_param_spec_color: + * @name: name of the property + * @nick: short name + * @blurb: description (can be translatable) + * @default_value: default value + * @flags: flags for the param spec + * + * Creates a #GParamSpec for properties using #ClutterColor. + * + * Return value: the newly created #GParamSpec + * + * Since: 0.8.4 + */ +GParamSpec * +clutter_param_spec_color (const gchar *name, + const gchar *nick, + const gchar *blurb, + const ClutterColor *default_value, + GParamFlags flags) +{ + ClutterParamSpecColor *cspec; + + cspec = g_param_spec_internal (CLUTTER_TYPE_PARAM_COLOR, + name, nick, blurb, flags); + + cspec->default_value = clutter_color_copy (default_value); + + return G_PARAM_SPEC (cspec); +} + +/** * clutter_color_interp: * * Interpolates between @src1 and @src2 by @amt. @@ -645,7 +927,7 @@ { gint r,g,b,a; gint namt = 255-amt; - + r = ((src1->red * namt) + (src2->red * amt)) >> 8; g = ((src1->green * namt) + (src2->green * amt)) >> 8; b = ((src1->blue * namt) + (src2->blue * amt)) >> 8; @@ -668,7 +950,7 @@ * clutter_color_diff: * * Returns the difference between @src1 and @src2 - * This is not geometric distance in colour space, it's just + * This is not geometric distance in colour space, it's just * a fast bodge. * * Since: 0.8.2-maemo @@ -676,9 +958,9 @@ gint clutter_color_diff (const ClutterColor *src1, const ClutterColor *src2) { - return - abs((gint)src1->red - (gint)src2->red) + - abs((gint)src1->green - (gint)src2->green) + - abs((gint)src1->blue - (gint)src2->blue) + + return + abs((gint)src1->red - (gint)src2->red) + + abs((gint)src1->green - (gint)src2->green) + + abs((gint)src1->blue - (gint)src2->blue) + abs((gint)src1->alpha - (gint)src2->alpha); } Modified: projects/haf/trunk/clutter/clutter/clutter-color.h =================================================================== --- projects/haf/trunk/clutter/clutter/clutter-color.h 2009-02-19 09:30:59 UTC (rev 17463) +++ projects/haf/trunk/clutter/clutter/clutter-color.h 2009-02-19 10:21:53 UTC (rev 17464) @@ -111,6 +111,50 @@ gint clutter_color_diff (const ClutterColor *src1, const ClutterColor *src2); + + + +#define CLUTTER_TYPE_PARAM_COLOR (clutter_param_color_get_type ()) +#define CLUTTER_PARAM_SPEC_COLOR(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), CLUTTER_TYPE_PARAM_COLOR, ClutterParamSpecColor)) +#define CLUTTER_IS_PARAM_SPEC_COLOR(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), CLUTTER_TYPE_PARAM_COLOR)) +#define CLUTTER_VALUE_HOLDS_COLOR(x) (G_VALUE_HOLDS ((x), CLUTTER_TYPE_COLOR)) + +/** + * CLUTTER_VALUE_HOLDS_COLOR: + * @x: a #GValue + * + * Evaluates to %TRUE if @x holds a #ClutterColor<!-- -->. + * + * Since: 1.0 + */ + +typedef struct _ClutterParamSpecColor ClutterParamSpecColor; + +/** + * ClutterParamSpecColor: + * @default_value: default color value + */ +struct _ClutterParamSpecColor +{ + /*< private >*/ + GParamSpec parent_instance; + + /*< public >*/ + ClutterColor *default_value; +}; + +GType clutter_param_color_get_type (void) G_GNUC_CONST; + +void clutter_value_set_color (GValue *value, + ClutterColor *color); +const ClutterColor *clutter_value_get_color (const GValue *value); + +GParamSpec *clutter_param_spec_color (const gchar *name, + const gchar *nick, + const gchar *blurb, + const ClutterColor *default_value, + GParamFlags flags); + G_END_DECLS -#endif +#endif /* _HAVE_CLUTTER_COLOR_H */ Modified: projects/haf/trunk/clutter/clutter/cogl/gl/cogl.c =================================================================== --- projects/haf/trunk/clutter/clutter/cogl/gl/cogl.c 2009-02-19 09:30:59 UTC (rev 17463) +++ projects/haf/trunk/clutter/clutter/cogl/gl/cogl.c 2009-02-19 10:21:53 UTC (rev 17464) @@ -975,6 +975,11 @@ } #endif + if (cogl_check_extension ("GL_IMG_texture_compression_pvrtc", gl_extensions)) + { + flags |= COGL_FEATURE_TEXTURE_PVRTC; + } + if (cogl_check_extension ("GL_EXT_packed_pixel", gl_extensions)) { flags |= COGL_FEATURE_PACKED_PIXEL; Modified: projects/haf/trunk/clutter/clutter/cogl/gles/cogl.c =================================================================== --- projects/haf/trunk/clutter/clutter/cogl/gles/cogl.c 2009-02-19 09:30:59 UTC (rev 17463) +++ projects/haf/trunk/clutter/clutter/cogl/gles/cogl.c 2009-02-19 10:21:53 UTC (rev 17464) @@ -836,9 +836,12 @@ { ClutterFeatureFlags flags = 0; int max_clip_planes = 0; + const gchar *gl_extensions; _COGL_GET_CONTEXT (ctx, NO_RETVAL); + gl_extensions = (const gchar*) glGetString (GL_EXTENSIONS); + ctx->num_stencil_bits = 0; GE( cogl_wrap_glGetIntegerv (GL_STENCIL_BITS, &ctx->num_stencil_bits) ); if (ctx->num_stencil_bits > 0) @@ -852,6 +855,11 @@ flags |= COGL_FEATURE_SHADERS_GLSL | COGL_FEATURE_OFFSCREEN | COGL_FEATURE_TEXTURE_NPOT; #endif + if (cogl_check_extension ("GL_IMG_texture_compression_pvrtc", gl_extensions)) + { + flags |= COGL_FEATURE_TEXTURE_PVRTC; + } + ctx->feature_flags = flags; ctx->features_cached = TRUE; } Modified: projects/haf/trunk/clutter/debian/changelog =================================================================== --- projects/haf/trunk/clutter/debian/changelog 2009-02-19 09:30:59 UTC (rev 17463) +++ projects/haf/trunk/clutter/debian/changelog 2009-02-19 10:21:53 UTC (rev 17464) @@ -5,6 +5,8 @@ behaviour). * committed patch from http://bugzilla.openedhand.com/show_bug.cgi?id=1228 * Added conversion to A8 that got missed out of conversion code + * Moved changes from 0.8.4 clutter-color to this branch + * Properly set up PVRTC texture compressiion support flag -- Gordon Williams <gordon.williams at collabora.co.uk> Sat, 14 Feb 2009 14:15:52 +0200
- Previous message: [maemo-commits] r17463 - projects/haf/trunk/libmatchbox2/matchbox/core
- Next message: [maemo-commits] r17465 - projects/haf/trunk/gtk+
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]