2011-02-22 13:25:29 -05:00
|
|
|
/*
|
|
|
|
* Cogl
|
|
|
|
*
|
2014-02-21 20:28:54 -05:00
|
|
|
* A Low Level GPU Graphics and Utilities API
|
2011-02-22 13:25:29 -05:00
|
|
|
*
|
|
|
|
* Copyright (C) 2011 Intel Corporation.
|
|
|
|
*
|
2014-02-21 20:28:54 -05:00
|
|
|
* Permission is hereby granted, free of charge, to any person
|
|
|
|
* obtaining a copy of this software and associated documentation
|
|
|
|
* files (the "Software"), to deal in the Software without
|
|
|
|
* restriction, including without limitation the rights to use, copy,
|
|
|
|
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
|
|
* of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
2011-02-22 13:25:29 -05:00
|
|
|
*
|
2014-02-21 20:28:54 -05:00
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
2011-02-22 13:25:29 -05:00
|
|
|
*
|
2014-02-21 20:28:54 -05:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
2011-02-22 13:25:29 -05:00
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Robert Bragg <robert@linux.intel.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <glib.h>
|
2012-09-26 15:32:36 -04:00
|
|
|
#include <string.h>
|
2011-02-22 13:25:29 -05:00
|
|
|
|
2011-10-13 17:34:30 -04:00
|
|
|
#include "cogl-util.h"
|
2011-02-22 13:25:29 -05:00
|
|
|
#include "cogl-types.h"
|
|
|
|
#include "cogl-private.h"
|
|
|
|
#include "cogl-context-private.h"
|
|
|
|
#include "cogl-winsys-private.h"
|
2011-05-17 10:00:38 -04:00
|
|
|
#include "cogl-winsys-stub-private.h"
|
2011-02-22 13:25:29 -05:00
|
|
|
#include "cogl-framebuffer-private.h"
|
2011-10-13 16:31:04 -04:00
|
|
|
#include "cogl-onscreen-private.h"
|
2011-10-17 12:55:35 -04:00
|
|
|
#ifdef COGL_HAS_XLIB_SUPPORT
|
|
|
|
#include "cogl-clutter-xlib.h"
|
|
|
|
#endif
|
2012-02-17 20:19:17 -05:00
|
|
|
#include "cogl-clutter.h"
|
2011-02-22 13:25:29 -05:00
|
|
|
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
CoglBool
|
2011-02-22 13:25:29 -05:00
|
|
|
cogl_clutter_check_extension (const char *name, const char *ext)
|
|
|
|
{
|
2012-09-26 15:32:36 -04:00
|
|
|
char *end;
|
|
|
|
int name_len, n;
|
|
|
|
|
|
|
|
if (name == NULL || ext == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
end = (char*)(ext + strlen(ext));
|
|
|
|
|
|
|
|
name_len = strlen(name);
|
|
|
|
|
|
|
|
while (ext < end)
|
|
|
|
{
|
|
|
|
n = strcspn(ext, " ");
|
|
|
|
|
|
|
|
if ((name_len == n) && (!strncmp(name, ext, n)))
|
|
|
|
return TRUE;
|
|
|
|
ext += (n + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2011-02-22 13:25:29 -05:00
|
|
|
}
|
|
|
|
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
CoglBool
|
2010-11-05 08:28:33 -04:00
|
|
|
cogl_clutter_winsys_has_feature (CoglWinsysFeature feature)
|
|
|
|
{
|
|
|
|
return _cogl_winsys_has_feature (feature);
|
|
|
|
}
|
|
|
|
|
2011-02-22 13:25:29 -05:00
|
|
|
void
|
|
|
|
cogl_onscreen_clutter_backend_set_size (int width, int height)
|
|
|
|
{
|
|
|
|
CoglFramebuffer *framebuffer;
|
|
|
|
|
|
|
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
|
|
|
2011-05-17 10:00:38 -04:00
|
|
|
if (_cogl_context_get_winsys (ctx) != _cogl_winsys_stub_get_vtable ())
|
2011-02-22 13:25:29 -05:00
|
|
|
return;
|
|
|
|
|
|
|
|
framebuffer = COGL_FRAMEBUFFER (ctx->window_buffer);
|
|
|
|
|
|
|
|
_cogl_framebuffer_winsys_update_size (framebuffer, width, height);
|
|
|
|
}
|
2010-11-05 08:28:33 -04:00
|
|
|
|
|
|
|
#ifdef COGL_HAS_XLIB_SUPPORT
|
|
|
|
XVisualInfo *
|
|
|
|
cogl_clutter_winsys_xlib_get_visual_info (void)
|
|
|
|
{
|
2011-02-25 06:29:08 -05:00
|
|
|
const CoglWinsysVtable *winsys;
|
|
|
|
|
|
|
|
_COGL_GET_CONTEXT (ctx, NULL);
|
|
|
|
|
|
|
|
winsys = _cogl_context_get_winsys (ctx);
|
|
|
|
|
2011-05-10 08:51:41 -04:00
|
|
|
/* This should only be called for xlib contexts */
|
2011-10-13 17:34:30 -04:00
|
|
|
_COGL_RETURN_VAL_IF_FAIL (winsys->xlib_get_visual_info != NULL, NULL);
|
2011-05-10 08:51:41 -04:00
|
|
|
|
2011-02-25 06:29:08 -05:00
|
|
|
return winsys->xlib_get_visual_info ();
|
2010-11-05 08:28:33 -04:00
|
|
|
}
|
|
|
|
#endif
|