mirror of
https://github.com/brl/mutter.git
synced 2024-12-29 14:22:13 +00: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
64 lines
1.6 KiB
C
64 lines
1.6 KiB
C
#include <cogl/cogl.h>
|
|
|
|
/* These will be redefined in config.h */
|
|
#undef COGL_ENABLE_EXPERIMENTAL_2_0_API
|
|
#undef COGL_ENABLE_EXPERIMENTAL_API
|
|
|
|
#include "test-utils.h"
|
|
#include "config.h"
|
|
|
|
/* I'm writing this on the train after having dinner at a churrascuria. */
|
|
#define MAGIC_CHUNK_O_DATA ((void *) 0xdeadbeef)
|
|
|
|
static GMainLoop *loop;
|
|
|
|
gboolean
|
|
timeout (void *user_data)
|
|
{
|
|
g_assert (!"timeout not reached");
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
void
|
|
callback (CoglFence *fence,
|
|
void *user_data)
|
|
{
|
|
int fb_width = cogl_framebuffer_get_width (test_fb);
|
|
int fb_height = cogl_framebuffer_get_height (test_fb);
|
|
|
|
test_utils_check_pixel (test_fb, fb_width - 1, fb_height - 1, 0x00ff0000);
|
|
g_assert (user_data == MAGIC_CHUNK_O_DATA && "callback data not mangled");
|
|
|
|
g_main_loop_quit (loop);
|
|
}
|
|
|
|
void
|
|
test_fence (void)
|
|
{
|
|
GSource *cogl_source;
|
|
int fb_width = cogl_framebuffer_get_width (test_fb);
|
|
int fb_height = cogl_framebuffer_get_height (test_fb);
|
|
CoglFenceClosure *closure;
|
|
|
|
cogl_source = cogl_glib_source_new (test_ctx, G_PRIORITY_DEFAULT);
|
|
g_source_attach (cogl_source, NULL);
|
|
loop = g_main_loop_new (NULL, TRUE);
|
|
|
|
cogl_framebuffer_orthographic (test_fb, 0, 0, fb_width, fb_height, -1, 100);
|
|
cogl_framebuffer_clear4f (test_fb, COGL_BUFFER_BIT_COLOR,
|
|
0.0f, 1.0f, 0.0f, 0.0f);
|
|
|
|
closure = cogl_framebuffer_add_fence_callback (test_fb,
|
|
callback,
|
|
MAGIC_CHUNK_O_DATA);
|
|
g_assert (closure != NULL);
|
|
|
|
g_timeout_add_seconds (5, timeout, NULL);
|
|
|
|
g_main_loop_run (loop);
|
|
|
|
if (cogl_test_verbose ())
|
|
g_print ("OK\n");
|
|
}
|