mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 00:20:42 -05:00
6436cd073d
This declares the interface types CoglFramebuffer, CoglBuffer, CoglTexture, CoglMetaTexture and CoglPrimitiveTexture as void when including the public cogl.h header so that users don't have to use lots of C type casts between instance types and interface types. This also removes all of the COGL_XYZ() type cast macros since they do nothing more than compile time type casting but it's less readable if you haven't seen that coding pattern before. Unlike with gobject based apis that use per-type macros for casting and performing runtime type checking we instead prefer to do our runtime type checking internally within the front-end public apis when objects are passed into Cogl. This greatly reduces the verbosity for users of the api and may help reduce the chance of excessive runtime type checking that can sometimes be a problem. (cherry picked from commit 248a76f5eac7e5ae4fb45208577f9a55360812a7) Since we can't break the 1.x api this version of the patch actually defines compatible NOP macros within deprecated/cogl-type-casts.h
46 lines
1.3 KiB
C
46 lines
1.3 KiB
C
#include <math.h>
|
|
#include <string.h>
|
|
|
|
#include <cogl/cogl.h>
|
|
|
|
#include "test-utils.h"
|
|
|
|
#define cogl_assert_float(a, b) \
|
|
do { \
|
|
if (fabsf ((a) - (b)) >= 0.0001f) \
|
|
g_assert_cmpfloat ((a), ==, (b)); \
|
|
} while (0)
|
|
|
|
void
|
|
test_color_hsl (void)
|
|
{
|
|
CoglColor color;
|
|
float hue, saturation, luminance;
|
|
|
|
cogl_color_init_from_4ub(&color, 108, 198, 78, 255);
|
|
cogl_color_to_hsl(&color, &hue, &saturation, &luminance);
|
|
|
|
cogl_assert_float(hue, 105.f);
|
|
cogl_assert_float(saturation, 0.512821);
|
|
cogl_assert_float(luminance, 0.541176);
|
|
|
|
memset(&color, 0, sizeof (CoglColor));
|
|
cogl_color_init_from_hsl(&color, hue, saturation, luminance);
|
|
|
|
g_assert_cmpint (cogl_color_get_red_byte (&color), ==, 108);
|
|
g_assert_cmpint (cogl_color_get_green_byte (&color), ==, 198);
|
|
g_assert_cmpint (cogl_color_get_blue_byte (&color), ==, 78);
|
|
g_assert_cmpint (cogl_color_get_alpha_byte (&color), ==, 255);
|
|
|
|
memset(&color, 0, sizeof (CoglColor));
|
|
cogl_color_init_from_hsl(&color, hue, 0, luminance);
|
|
|
|
cogl_assert_float (cogl_color_get_red_float (&color), luminance);
|
|
cogl_assert_float (cogl_color_get_green_float (&color), luminance);
|
|
cogl_assert_float (cogl_color_get_blue_float (&color), luminance);
|
|
cogl_assert_float (cogl_color_get_alpha_float (&color), 1.0f);
|
|
|
|
if (cogl_test_verbose ())
|
|
g_print ("OK\n");
|
|
}
|