mirror of
https://github.com/brl/mutter.git
synced 2024-12-29 06:12:14 +00:00
c823bf9c83
* clutter/cogl/cogl-color.h: * clutter/cogl/cogl-path.h: * clutter/cogl/cogl-types.h: * clutter/cogl/common/cogl-color.c: Deprecated cogl_color() in favour of cogl_set_source_color() and friends; store the CoglColor components as unsigned bytes instead of fixed point normalized values; add functions for allocating, copying and freeing CoglColor, for use of language bindings. * clutter/cogl/cogl.h.in: * clutter/cogl/cogl-deprecated.h: Added cogl-deprecated.h, an header file containing the deprecation symbols similar to clutter-deprecated.h. * clutter/cogl/gl/Makefile.am: * clutter/cogl/gl/cogl-texture.c: * clutter/cogl/gl/cogl.c: * clutter/cogl/gles/Makefile.am: * clutter/cogl/gles/cogl-texture.c: * clutter/cogl/gles/cogl.c: Update the GL and GLES implementations of COGL after the CoglColor changes. * clutter/clutter-actor.c: * clutter/clutter-clone-texture.c: * clutter/clutter-entry.c: * clutter/clutter-label.c: * clutter/clutter-rectangle.c: * clutter/clutter-texture.c: Do not use CoglColor whenever it is possible, and use cogl_set_source_color4ub() instead. * clutter/pango/cogl-pango-render.c: Ditto as above. * doc/reference/clutter/subclassing-ClutterActor.xml: * doc/reference/cogl/cogl-sections.txt: Update the documentation. * tests/interactive/test-cogl-offscreen.c: * tests/interactive/test-cogl-primitives.c: * tests/interactive/test-cogl-tex-convert.c: * tests/interactive/test-cogl-tex-foreign.c: * tests/interactive/test-cogl-tex-getset.c: * tests/interactive/test-cogl-tex-polygon.c: * tests/interactive/test-cogl-tex-tile.c: * tests/interactive/test-paint-wrapper.c: Drop the usage of CoglColor whenever it is possible.
170 lines
3.3 KiB
C
170 lines
3.3 KiB
C
#ifdef HAVE_CONFIG_H
|
|
#include "config.h"
|
|
#endif
|
|
|
|
#include "cogl-color.h"
|
|
#include "cogl-fixed.h"
|
|
|
|
CoglColor *
|
|
cogl_color_new (void)
|
|
{
|
|
return g_slice_new (CoglColor);
|
|
}
|
|
|
|
CoglColor *
|
|
cogl_color_copy (const CoglColor *color)
|
|
{
|
|
if (G_LIKELY (color))
|
|
return g_slice_dup (CoglColor, color);
|
|
|
|
return NULL;
|
|
}
|
|
|
|
void
|
|
cogl_color_free (CoglColor *color)
|
|
{
|
|
if (G_LIKELY (color))
|
|
g_slice_free (CoglColor, color);
|
|
}
|
|
|
|
void
|
|
cogl_color_set_from_4ub (CoglColor *dest,
|
|
guint8 red,
|
|
guint8 green,
|
|
guint8 blue,
|
|
guint8 alpha)
|
|
{
|
|
g_return_if_fail (dest != NULL);
|
|
|
|
dest->red = red;
|
|
dest->green = green;
|
|
dest->blue = blue;
|
|
dest->alpha = alpha;
|
|
}
|
|
|
|
void
|
|
cogl_color_set_from_4d (CoglColor *dest,
|
|
gdouble red,
|
|
gdouble green,
|
|
gdouble blue,
|
|
gdouble alpha)
|
|
{
|
|
g_return_if_fail (dest != NULL);
|
|
|
|
dest->red = 255 * red;
|
|
dest->green = 255 * green;
|
|
dest->blue = 255 * blue;
|
|
dest->alpha = 255 * alpha;
|
|
}
|
|
|
|
void
|
|
cogl_color_set_from_4x (CoglColor *dest,
|
|
CoglFixed red,
|
|
CoglFixed green,
|
|
CoglFixed blue,
|
|
CoglFixed alpha)
|
|
{
|
|
g_return_if_fail (dest != NULL);
|
|
|
|
dest->red = COGL_FIXED_TO_INT (red * 255);
|
|
dest->green = COGL_FIXED_TO_INT (green * 255);
|
|
dest->blue = COGL_FIXED_TO_INT (blue * 255);
|
|
dest->alpha = COGL_FIXED_TO_INT (alpha * 255);
|
|
}
|
|
|
|
unsigned char
|
|
cogl_color_get_red_byte (const CoglColor *color)
|
|
{
|
|
return color->red;
|
|
}
|
|
|
|
float
|
|
cogl_color_get_red_float (const CoglColor *color)
|
|
{
|
|
return (float) color->red / 255.0;
|
|
}
|
|
|
|
CoglFixed
|
|
cogl_color_get_red (const CoglColor *color)
|
|
{
|
|
return COGL_FIXED_FROM_FLOAT ((float) color->red / 255.0);
|
|
}
|
|
|
|
unsigned char
|
|
cogl_color_get_green_byte (const CoglColor *color)
|
|
{
|
|
return color->green;
|
|
}
|
|
|
|
float
|
|
cogl_color_get_green_float (const CoglColor *color)
|
|
{
|
|
return (float) color->green / 255.0;
|
|
}
|
|
|
|
CoglFixed
|
|
cogl_color_get_green (const CoglColor *color)
|
|
{
|
|
return COGL_FIXED_FROM_FLOAT ((float) color->green / 255.0);
|
|
}
|
|
|
|
unsigned char
|
|
cogl_color_get_blue_byte (const CoglColor *color)
|
|
{
|
|
return color->blue;
|
|
}
|
|
|
|
float
|
|
cogl_color_get_blue_float (const CoglColor *color)
|
|
{
|
|
return (float) color->blue / 255.0;
|
|
}
|
|
|
|
CoglFixed
|
|
cogl_color_get_blue (const CoglColor *color)
|
|
{
|
|
return COGL_FIXED_FROM_FLOAT ((float) color->blue / 255.0);
|
|
}
|
|
|
|
unsigned char
|
|
cogl_color_get_alpha_byte (const CoglColor *color)
|
|
{
|
|
return color->alpha;
|
|
}
|
|
|
|
float
|
|
cogl_color_get_alpha_float (const CoglColor *color)
|
|
{
|
|
return (float) color->alpha / 255.0;
|
|
}
|
|
|
|
CoglFixed
|
|
cogl_color_get_alpha (const CoglColor *color)
|
|
{
|
|
return COGL_FIXED_FROM_FLOAT ((float) color->alpha / 255.0);
|
|
}
|
|
|
|
void
|
|
cogl_set_source_color4ub (guint8 red,
|
|
guint8 green,
|
|
guint8 blue,
|
|
guint8 alpha)
|
|
{
|
|
CoglColor c = { 0, };
|
|
|
|
cogl_color_set_from_4ub (&c, red, green, blue, alpha);
|
|
cogl_set_source_color (&c);
|
|
}
|
|
|
|
void
|
|
cogl_set_source_color4x (CoglFixed red,
|
|
CoglFixed green,
|
|
CoglFixed blue,
|
|
CoglFixed alpha)
|
|
{
|
|
CoglColor c = { 0, };
|
|
|
|
cogl_color_set_from_4x (&c, red, green, blue, alpha);
|
|
cogl_set_source_color (&c);
|
|
}
|