Compare commits

..

1 Commits

Author SHA1 Message Date
Niels De Graef
e04cbddf92 cogl: Don't use GL_ALPHA
It was deprecated in OpenGL and it isn't even a valid value anymore for
functions like `glTextImage2D()` in OpenGL 4.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/612
2019-06-12 09:21:09 +02:00
285 changed files with 6203 additions and 8944 deletions

View File

@@ -1111,7 +1111,7 @@ _clutter_backend_reset_cogl_framebuffer (ClutterBackend *backend)
{
if (backend->dummy_onscreen == COGL_INVALID_HANDLE)
{
GError *internal_error = NULL;
CoglError *internal_error = NULL;
backend->dummy_onscreen = cogl_onscreen_new (backend->cogl_context, 1, 1);
@@ -1119,7 +1119,7 @@ _clutter_backend_reset_cogl_framebuffer (ClutterBackend *backend)
&internal_error))
{
g_critical ("Unable to create dummy onscreen: %s", internal_error->message);
g_error_free (internal_error);
cogl_error_free (internal_error);
return;
}
}

View File

@@ -13,7 +13,7 @@ G_BEGIN_DECLS
/*** END file-header ***/
/*** BEGIN file-production ***/
/* enumerations from "@basename@" */
/* enumerations from "@filename@" */
/*** END file-production ***/
/*** BEGIN value-header ***/

View File

@@ -974,6 +974,8 @@ typedef enum /*< prefix=CLUTTER_SCROLL >*/
/**
* ClutterStageState:
* @CLUTTER_STAGE_STATE_FULLSCREEN: Fullscreen mask
* @CLUTTER_STAGE_STATE_OFFSCREEN: Offscreen mask (deprecated)
* @CLUTTER_STAGE_STATE_ACTIVATED: Activated mask
*
* Stage state masks, used by the #ClutterEvent of type %CLUTTER_STAGE_STATE.
@@ -982,6 +984,8 @@ typedef enum /*< prefix=CLUTTER_SCROLL >*/
*/
typedef enum
{
CLUTTER_STAGE_STATE_FULLSCREEN = (1 << 1),
CLUTTER_STAGE_STATE_OFFSCREEN = (1 << 2),
CLUTTER_STAGE_STATE_ACTIVATED = (1 << 3)
} ClutterStageState;
@@ -991,6 +995,7 @@ typedef enum
* @CLUTTER_FEATURE_TEXTURE_YUV: Set if YUV based textures supported.
* @CLUTTER_FEATURE_TEXTURE_READ_PIXELS: Set if texture pixels can be read.
* @CLUTTER_FEATURE_STAGE_STATIC: Set if stage size if fixed (i.e framebuffer)
* @CLUTTER_FEATURE_STAGE_USER_RESIZE: Set if stage is able to be user resized.
* @CLUTTER_FEATURE_STAGE_CURSOR: Set if stage has a graphical cursor.
* @CLUTTER_FEATURE_SHADERS_GLSL: Set if the backend supports GLSL shaders.
* @CLUTTER_FEATURE_OFFSCREEN: Set if the backend supports offscreen rendering.
@@ -1008,6 +1013,7 @@ typedef enum
CLUTTER_FEATURE_TEXTURE_YUV = (1 << 4),
CLUTTER_FEATURE_TEXTURE_READ_PIXELS = (1 << 5),
CLUTTER_FEATURE_STAGE_STATIC = (1 << 6),
CLUTTER_FEATURE_STAGE_USER_RESIZE = (1 << 7),
CLUTTER_FEATURE_STAGE_CURSOR = (1 << 8),
CLUTTER_FEATURE_SHADERS_GLSL = (1 << 9),
CLUTTER_FEATURE_OFFSCREEN = (1 << 10),

View File

@@ -2552,7 +2552,7 @@ _clutter_process_event_details (ClutterActor *stage,
break;
case CLUTTER_STAGE_STATE:
/* focus - forward to stage */
/* fullscreen / focus - forward to stage */
event->any.source = stage;
if (!_clutter_event_process_filters (event))
clutter_stage_event (CLUTTER_STAGE (stage), event);

View File

@@ -43,6 +43,11 @@ void clutter_stage_capture_into (ClutterStage *stage,
cairo_rectangle_int_t *rect,
uint8_t *data);
CLUTTER_EXPORT
ClutterStageView * clutter_stage_get_view_at (ClutterStage *stage,
float x,
float y);
CLUTTER_EXPORT
void clutter_stage_freeze_updates (ClutterStage *stage);

View File

@@ -40,7 +40,6 @@ void _clutter_stage_paint_view (ClutterStage
ClutterStageView *view,
const cairo_rectangle_int_t *clip);
void _clutter_stage_emit_after_paint (ClutterStage *stage);
void _clutter_stage_set_window (ClutterStage *stage,
ClutterStageWindow *stage_window);
ClutterStageWindow *_clutter_stage_get_window (ClutterStage *stage);
@@ -118,6 +117,7 @@ void _clutter_stage_remove_touch_drag_actor (ClutterStage *st
ClutterStageState _clutter_stage_get_state (ClutterStage *stage);
gboolean _clutter_stage_is_activated (ClutterStage *stage);
gboolean _clutter_stage_is_fullscreen (ClutterStage *stage);
gboolean _clutter_stage_update_state (ClutterStage *stage,
ClutterStageState unset_state,
ClutterStageState set_state);

View File

@@ -1,37 +0,0 @@
/*
* Copyright (C) 2019 Red Hat Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __CLUTTER_STAGE_VIEW_PRIVATE_H__
#define __CLUTTER_STAGE_VIEW_PRIVATE_H__
#include "clutter/clutter-stage-view.h"
void clutter_stage_view_blit_offscreen (ClutterStageView *view,
const cairo_rectangle_int_t *clip);
gboolean clutter_stage_view_is_dirty_viewport (ClutterStageView *view);
void clutter_stage_view_set_dirty_viewport (ClutterStageView *view,
gboolean dirty);
gboolean clutter_stage_view_is_dirty_projection (ClutterStageView *view);
void clutter_stage_view_set_dirty_projection (ClutterStageView *view,
gboolean dirty);
#endif /* __CLUTTER_STAGE_VIEW_PRIVATE_H__ */

View File

@@ -18,7 +18,6 @@
#include "clutter-build-config.h"
#include "clutter/clutter-stage-view.h"
#include "clutter/clutter-stage-view-private.h"
#include <cairo-gobject.h>
#include <math.h>
@@ -62,14 +61,6 @@ clutter_stage_view_get_layout (ClutterStageView *view,
*rect = priv->layout;
}
/**
* clutter_stage_view_get_framebuffer:
* @view: a #ClutterStageView
*
* Retrieves the framebuffer of @view to draw to.
*
* Returns: (transfer none): a #CoglFramebuffer
*/
CoglFramebuffer *
clutter_stage_view_get_framebuffer (ClutterStageView *view)
{
@@ -82,14 +73,6 @@ clutter_stage_view_get_framebuffer (ClutterStageView *view)
return priv->framebuffer;
}
/**
* clutter_stage_view_get_onscreen:
* @view: a #ClutterStageView
*
* Retrieves the onscreen framebuffer of @view if available.
*
* Returns: (transfer none): a #CoglFramebuffer
*/
CoglFramebuffer *
clutter_stage_view_get_onscreen (ClutterStageView *view)
{

View File

@@ -18,10 +18,6 @@
#ifndef __CLUTTER_STAGE_VIEW_H__
#define __CLUTTER_STAGE_VIEW_H__
#if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
#error "Only <clutter/clutter.h> can be included directly."
#endif
#include <cairo.h>
#include <glib-object.h>
#include <cogl/cogl.h>
@@ -61,9 +57,22 @@ void clutter_stage_view_transform_to_onscreen (ClutterStageView *vie
gfloat *x,
gfloat *y);
void clutter_stage_view_blit_offscreen (ClutterStageView *view,
const cairo_rectangle_int_t *clip);
CLUTTER_EXPORT
float clutter_stage_view_get_scale (ClutterStageView *view);
gboolean clutter_stage_view_is_dirty_viewport (ClutterStageView *view);
void clutter_stage_view_set_dirty_viewport (ClutterStageView *view,
gboolean dirty);
gboolean clutter_stage_view_is_dirty_projection (ClutterStageView *view);
void clutter_stage_view_set_dirty_projection (ClutterStageView *view,
gboolean dirty);
CLUTTER_EXPORT
void clutter_stage_view_get_offscreen_transformation_matrix (ClutterStageView *view,
CoglMatrix *matrix);

View File

@@ -62,6 +62,16 @@ _clutter_stage_window_set_title (ClutterStageWindow *window,
iface->set_title (window, title);
}
void
_clutter_stage_window_set_fullscreen (ClutterStageWindow *window,
gboolean is_fullscreen)
{
ClutterStageWindowInterface *iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
if (iface->set_fullscreen)
iface->set_fullscreen (window, is_fullscreen);
}
void
_clutter_stage_window_set_cursor_visible (ClutterStageWindow *window,
gboolean is_visible)
@@ -72,6 +82,14 @@ _clutter_stage_window_set_cursor_visible (ClutterStageWindow *window,
iface->set_cursor_visible (window, is_visible);
}
void
_clutter_stage_window_set_user_resizable (ClutterStageWindow *window,
gboolean is_resizable)
{
CLUTTER_STAGE_WINDOW_GET_IFACE (window)->set_user_resizable (window,
is_resizable);
}
gboolean
_clutter_stage_window_realize (ClutterStageWindow *window)
{

View File

@@ -30,8 +30,12 @@ struct _ClutterStageWindowInterface
void (* set_title) (ClutterStageWindow *stage_window,
const gchar *title);
void (* set_fullscreen) (ClutterStageWindow *stage_window,
gboolean is_fullscreen);
void (* set_cursor_visible) (ClutterStageWindow *stage_window,
gboolean cursor_visible);
void (* set_user_resizable) (ClutterStageWindow *stage_window,
gboolean is_resizable);
gboolean (* realize) (ClutterStageWindow *stage_window);
void (* unrealize) (ClutterStageWindow *stage_window);
@@ -79,8 +83,12 @@ ClutterActor * _clutter_stage_window_get_wrapper (ClutterStageWindow *
void _clutter_stage_window_set_title (ClutterStageWindow *window,
const gchar *title);
void _clutter_stage_window_set_fullscreen (ClutterStageWindow *window,
gboolean is_fullscreen);
void _clutter_stage_window_set_cursor_visible (ClutterStageWindow *window,
gboolean is_visible);
void _clutter_stage_window_set_user_resizable (ClutterStageWindow *window,
gboolean is_resizable);
gboolean _clutter_stage_window_realize (ClutterStageWindow *window);
void _clutter_stage_window_unrealize (ClutterStageWindow *window);

View File

@@ -72,7 +72,6 @@
#include "clutter-private.h"
#include "clutter-stage-manager-private.h"
#include "clutter-stage-private.h"
#include "clutter-stage-view-private.h"
#include "clutter-private.h"
#include "cogl/cogl.h"
@@ -149,13 +148,13 @@ struct _ClutterStagePrivate
gpointer paint_data;
GDestroyNotify paint_notify;
cairo_rectangle_int_t view_clip;
int update_freeze_count;
guint relayout_pending : 1;
guint redraw_pending : 1;
guint is_fullscreen : 1;
guint is_cursor_visible : 1;
guint is_user_resizable : 1;
guint use_fog : 1;
guint throttle_motion_events : 1;
guint use_alpha : 1;
@@ -171,9 +170,12 @@ enum
PROP_0,
PROP_COLOR,
PROP_FULLSCREEN_SET,
PROP_OFFSCREEN,
PROP_CURSOR_VISIBLE,
PROP_PERSPECTIVE,
PROP_TITLE,
PROP_USER_RESIZABLE,
PROP_USE_FOG,
PROP_FOG,
PROP_USE_ALPHA,
@@ -184,11 +186,12 @@ enum
enum
{
FULLSCREEN,
UNFULLSCREEN,
ACTIVATE,
DEACTIVATE,
DELETE_EVENT,
AFTER_PAINT,
PAINT_VIEW,
PRESENTED,
LAST_SIGNAL
@@ -401,37 +404,40 @@ clutter_stage_allocate (ClutterActor *self,
flags | CLUTTER_DELEGATE_LAYOUT);
/* Ensure the window is sized correctly */
if (priv->min_size_changed)
if (!priv->is_fullscreen)
{
gfloat min_width, min_height;
gboolean min_width_set, min_height_set;
if (priv->min_size_changed)
{
gfloat min_width, min_height;
gboolean min_width_set, min_height_set;
g_object_get (G_OBJECT (self),
"min-width", &min_width,
"min-width-set", &min_width_set,
"min-height", &min_height,
"min-height-set", &min_height_set,
NULL);
g_object_get (G_OBJECT (self),
"min-width", &min_width,
"min-width-set", &min_width_set,
"min-height", &min_height,
"min-height-set", &min_height_set,
NULL);
if (!min_width_set)
min_width = 1;
if (!min_height_set)
min_height = 1;
if (!min_width_set)
min_width = 1;
if (!min_height_set)
min_height = 1;
if (width < min_width)
width = min_width;
if (height < min_height)
height = min_height;
if (width < min_width)
width = min_width;
if (height < min_height)
height = min_height;
priv->min_size_changed = FALSE;
}
priv->min_size_changed = FALSE;
}
if (window_size.width != CLUTTER_NEARBYINT (width) ||
window_size.height != CLUTTER_NEARBYINT (height))
{
_clutter_stage_window_resize (priv->impl,
CLUTTER_NEARBYINT (width),
CLUTTER_NEARBYINT (height));
if (window_size.width != CLUTTER_NEARBYINT (width) ||
window_size.height != CLUTTER_NEARBYINT (height))
{
_clutter_stage_window_resize (priv->impl,
CLUTTER_NEARBYINT (width),
CLUTTER_NEARBYINT (height));
}
}
}
else
@@ -685,20 +691,7 @@ _clutter_stage_paint_view (ClutterStage *stage,
COGL_TRACE_BEGIN_SCOPED (ClutterStagePaintView, "Paint (view)");
priv->view_clip = *clip;
if (g_signal_has_handler_pending (stage, stage_signals[PAINT_VIEW],
0, TRUE))
g_signal_emit (stage, stage_signals[PAINT_VIEW], 0, view);
else
CLUTTER_STAGE_GET_CLASS (stage)->paint_view (stage, view);
priv->view_clip = (cairo_rectangle_int_t) { 0 };
}
void
_clutter_stage_emit_after_paint (ClutterStage *stage)
{
clutter_stage_do_paint_view (stage, view, clip);
g_signal_emit (stage, stage_signals[AFTER_PAINT], 0);
}
@@ -854,6 +847,40 @@ clutter_stage_real_deactivate (ClutterStage *stage)
clutter_stage_emit_key_focus_event (stage, FALSE);
}
static void
clutter_stage_real_fullscreen (ClutterStage *stage)
{
ClutterStagePrivate *priv = stage->priv;
cairo_rectangle_int_t geom;
ClutterActorBox box;
/* we need to force an allocation here because the size
* of the stage might have been changed by the backend
*
* this is a really bad solution to the issues caused by
* the fact that fullscreening the stage on the X11 backends
* is really an asynchronous operation
*/
_clutter_stage_window_get_geometry (priv->impl, &geom);
box.x1 = 0;
box.y1 = 0;
box.x2 = geom.width;
box.y2 = geom.height;
/* we need to blow the caching on the Stage size, given that
* we're about to force an allocation, because if anything
* ends up querying the size of the stage during the allocate()
* call, like constraints or signal handlers, we'll get into an
* inconsistent state: the stage will report the old cached size,
* but the allocation will be updated anyway.
*/
clutter_actor_set_size (CLUTTER_ACTOR (stage), -1.0, -1.0);
clutter_actor_allocate (CLUTTER_ACTOR (stage),
&box,
CLUTTER_ALLOCATION_NONE);
}
void
_clutter_stage_queue_event (ClutterStage *stage,
ClutterEvent *event,
@@ -1691,6 +1718,11 @@ clutter_stage_set_property (GObject *object,
clutter_value_get_color (value));
break;
case PROP_OFFSCREEN:
if (g_value_get_boolean (value))
g_warning ("Offscreen stages are currently not supported\n");
break;
case PROP_CURSOR_VISIBLE:
if (g_value_get_boolean (value))
clutter_stage_show_cursor (stage);
@@ -1706,6 +1738,10 @@ clutter_stage_set_property (GObject *object,
clutter_stage_set_title (stage, g_value_get_string (value));
break;
case PROP_USER_RESIZABLE:
clutter_stage_set_user_resizable (stage, g_value_get_boolean (value));
break;
case PROP_USE_FOG:
clutter_stage_set_use_fog (stage, g_value_get_boolean (value));
break;
@@ -1756,6 +1792,14 @@ clutter_stage_get_property (GObject *gobject,
}
break;
case PROP_OFFSCREEN:
g_value_set_boolean (value, FALSE);
break;
case PROP_FULLSCREEN_SET:
g_value_set_boolean (value, priv->is_fullscreen);
break;
case PROP_CURSOR_VISIBLE:
g_value_set_boolean (value, priv->is_cursor_visible);
break;
@@ -1768,6 +1812,10 @@ clutter_stage_get_property (GObject *gobject,
g_value_set_string (value, priv->title);
break;
case PROP_USER_RESIZABLE:
g_value_set_boolean (value, priv->is_user_resizable);
break;
case PROP_USE_FOG:
g_value_set_boolean (value, priv->use_fog);
break;
@@ -1862,16 +1910,6 @@ clutter_stage_finalize (GObject *object)
G_OBJECT_CLASS (clutter_stage_parent_class)->finalize (object);
}
static void
clutter_stage_real_paint_view (ClutterStage *stage,
ClutterStageView *view)
{
ClutterStagePrivate *priv = stage->priv;
const cairo_rectangle_int_t *clip = &priv->view_clip;
clutter_stage_do_paint_view (stage, view, clip);
}
static void
clutter_stage_class_init (ClutterStageClass *klass)
{
@@ -1901,8 +1939,42 @@ clutter_stage_class_init (ClutterStageClass *klass)
actor_class->queue_redraw = clutter_stage_real_queue_redraw;
actor_class->apply_transform = clutter_stage_real_apply_transform;
klass->paint_view = clutter_stage_real_paint_view;
/**
* ClutterStage:fullscreen:
*
* Whether the stage should be fullscreen or not.
*
* This property is set by calling clutter_stage_set_fullscreen()
* but since the actual implementation is delegated to the backend
* you should connect to the notify::fullscreen-set signal in order
* to get notification if the fullscreen state has been successfully
* achieved.
*
* Since: 1.0
*/
pspec = g_param_spec_boolean ("fullscreen-set",
P_("Fullscreen Set"),
P_("Whether the main stage is fullscreen"),
FALSE,
CLUTTER_PARAM_READABLE);
g_object_class_install_property (gobject_class,
PROP_FULLSCREEN_SET,
pspec);
/**
* ClutterStage:offscreen:
*
* Whether the stage should be rendered in an offscreen buffer.
*
* Deprecated: 1.10: This property does not do anything.
*/
pspec = g_param_spec_boolean ("offscreen",
P_("Offscreen"),
P_("Whether the main stage should be rendered offscreen"),
FALSE,
CLUTTER_PARAM_READWRITE | G_PARAM_DEPRECATED);
g_object_class_install_property (gobject_class,
PROP_OFFSCREEN,
pspec);
/**
* ClutterStage:cursor-visible:
*
@@ -1916,6 +1988,21 @@ clutter_stage_class_init (ClutterStageClass *klass)
g_object_class_install_property (gobject_class,
PROP_CURSOR_VISIBLE,
pspec);
/**
* ClutterStage:user-resizable:
*
* Whether the stage is resizable via user interaction.
*
* Since: 0.4
*/
pspec = g_param_spec_boolean ("user-resizable",
P_("User Resizable"),
P_("Whether the stage is able to be resized via user interaction"),
FALSE,
CLUTTER_PARAM_READWRITE);
g_object_class_install_property (gobject_class,
PROP_USER_RESIZABLE,
pspec);
/**
* ClutterStage:color:
*
@@ -2063,6 +2150,39 @@ clutter_stage_class_init (ClutterStageClass *klass)
CLUTTER_PARAM_READWRITE);
g_object_class_install_property (gobject_class, PROP_ACCEPT_FOCUS, pspec);
/**
* ClutterStage::fullscreen:
* @stage: the stage which was fullscreened
*
* The ::fullscreen signal is emitted when the stage is made fullscreen.
*
* Since: 0.6
*/
stage_signals[FULLSCREEN] =
g_signal_new (I_("fullscreen"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (ClutterStageClass, fullscreen),
NULL, NULL,
_clutter_marshal_VOID__VOID,
G_TYPE_NONE, 0);
/**
* ClutterStage::unfullscreen:
* @stage: the stage which has left a fullscreen state.
*
* The ::unfullscreen signal is emitted when the stage leaves a fullscreen
* state.
*
* Since: 0.6
*/
stage_signals[UNFULLSCREEN] =
g_signal_new (I_("unfullscreen"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (ClutterStageClass, unfullscreen),
NULL, NULL,
_clutter_marshal_VOID__VOID,
G_TYPE_NONE, 0);
/**
* ClutterStage::activate:
* @stage: the stage which was activated
@@ -2146,28 +2266,6 @@ clutter_stage_class_init (ClutterStageClass *klass)
NULL, NULL, NULL,
G_TYPE_NONE, 0);
/**
* ClutterStage::paint-view:
* @stage: the stage that received the event
* @view: a #ClutterStageView
*
* The ::paint-view signal is emitted before a #ClutterStageView is being
* painted.
*
* The view is painted in the default handler. Hence, if you want to perform
* some action after the view is painted, like reading the contents of the
* framebuffer, use g_signal_connect_after() or pass %G_CONNECT_AFTER.
*/
stage_signals[PAINT_VIEW] =
g_signal_new (I_("paint-view"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (ClutterStageClass, paint_view),
NULL, NULL,
_clutter_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
CLUTTER_TYPE_STAGE_VIEW);
/**
* ClutterStage::presented: (skip)
* @stage: the stage that received the event
@@ -2185,6 +2283,7 @@ clutter_stage_class_init (ClutterStageClass *klass)
G_TYPE_NONE, 2,
G_TYPE_INT, G_TYPE_POINTER);
klass->fullscreen = clutter_stage_real_fullscreen;
klass->activate = clutter_stage_real_activate;
klass->deactivate = clutter_stage_real_deactivate;
klass->delete_event = clutter_stage_real_delete_event;
@@ -2235,6 +2334,8 @@ clutter_stage_init (ClutterStage *self)
priv->event_queue = g_queue_new ();
priv->is_fullscreen = FALSE;
priv->is_user_resizable = FALSE;
priv->is_cursor_visible = TRUE;
priv->use_fog = FALSE;
priv->throttle_motion_events = TRUE;
@@ -2630,6 +2731,136 @@ _clutter_stage_get_viewport (ClutterStage *stage,
*height = priv->viewport[3];
}
/**
* clutter_stage_set_fullscreen:
* @stage: a #ClutterStage
* @fullscreen: %TRUE to to set the stage fullscreen
*
* Asks to place the stage window in the fullscreen or unfullscreen
* states.
*
( Note that you shouldn't assume the window is definitely full screen
* afterward, because other entities (e.g. the user or window manager)
* could unfullscreen it again, and not all window managers honor
* requests to fullscreen windows.
*
* If you want to receive notification of the fullscreen state you
* should either use the #ClutterStage::fullscreen and
* #ClutterStage::unfullscreen signals, or use the notify signal
* for the #ClutterStage:fullscreen-set property
*
* Since: 1.0
*/
void
clutter_stage_set_fullscreen (ClutterStage *stage,
gboolean fullscreen)
{
ClutterStagePrivate *priv;
g_return_if_fail (CLUTTER_IS_STAGE (stage));
priv = stage->priv;
if (priv->is_fullscreen != fullscreen)
{
ClutterStageWindow *impl = CLUTTER_STAGE_WINDOW (priv->impl);
ClutterStageWindowInterface *iface;
iface = CLUTTER_STAGE_WINDOW_GET_IFACE (impl);
/* Only set if backend implements.
*
* Also see clutter_stage_event() for setting priv->is_fullscreen
* on state change event.
*/
if (iface->set_fullscreen)
iface->set_fullscreen (impl, fullscreen);
}
/* If the backend did fullscreen the stage window then we need to resize
* the stage and update its viewport so we queue a relayout. Note: if the
* fullscreen request is handled asynchronously we can't rely on this
* queue_relayout to update the viewport, but for example the X backend
* will recieve a ConfigureNotify after a successful resize which is how
* we ensure the viewport is updated on X.
*/
clutter_actor_queue_relayout (CLUTTER_ACTOR (stage));
}
/**
* clutter_stage_get_fullscreen:
* @stage: a #ClutterStage
*
* Retrieves whether the stage is full screen or not
*
* Return value: %TRUE if the stage is full screen
*
* Since: 1.0
*/
gboolean
clutter_stage_get_fullscreen (ClutterStage *stage)
{
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE);
return stage->priv->is_fullscreen;
}
/**
* clutter_stage_set_user_resizable:
* @stage: a #ClutterStage
* @resizable: whether the stage should be user resizable.
*
* Sets if the stage is resizable by user interaction (e.g. via
* window manager controls)
*
* Since: 0.4
*/
void
clutter_stage_set_user_resizable (ClutterStage *stage,
gboolean resizable)
{
ClutterStagePrivate *priv;
g_return_if_fail (CLUTTER_IS_STAGE (stage));
priv = stage->priv;
if (clutter_feature_available (CLUTTER_FEATURE_STAGE_USER_RESIZE)
&& priv->is_user_resizable != resizable)
{
ClutterStageWindow *impl = CLUTTER_STAGE_WINDOW (priv->impl);
ClutterStageWindowInterface *iface;
iface = CLUTTER_STAGE_WINDOW_GET_IFACE (impl);
if (iface->set_user_resizable)
{
priv->is_user_resizable = resizable;
iface->set_user_resizable (impl, resizable);
g_object_notify (G_OBJECT (stage), "user-resizable");
}
}
}
/**
* clutter_stage_get_user_resizable:
* @stage: a #ClutterStage
*
* Retrieves the value set with clutter_stage_set_user_resizable().
*
* Return value: %TRUE if the stage is resizable by the user.
*
* Since: 0.4
*/
gboolean
clutter_stage_get_user_resizable (ClutterStage *stage)
{
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE);
return stage->priv->is_user_resizable;
}
/**
* clutter_stage_show_cursor:
* @stage: a #ClutterStage
@@ -2841,9 +3072,13 @@ gboolean
clutter_stage_event (ClutterStage *stage,
ClutterEvent *event)
{
ClutterStagePrivate *priv;
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
priv = stage->priv;
if (event->type == CLUTTER_DELETE)
{
gboolean retval = FALSE;
@@ -2863,6 +3098,24 @@ clutter_stage_event (ClutterStage *stage,
if (clutter_actor_event (CLUTTER_ACTOR (stage), event, FALSE))
return TRUE;
if (event->stage_state.changed_mask & CLUTTER_STAGE_STATE_FULLSCREEN)
{
if (event->stage_state.new_state & CLUTTER_STAGE_STATE_FULLSCREEN)
{
priv->is_fullscreen = TRUE;
g_signal_emit (stage, stage_signals[FULLSCREEN], 0);
g_object_notify (G_OBJECT (stage), "fullscreen-set");
}
else
{
priv->is_fullscreen = FALSE;
g_signal_emit (stage, stage_signals[UNFULLSCREEN], 0);
g_object_notify (G_OBJECT (stage), "fullscreen-set");
}
}
if (event->stage_state.changed_mask & CLUTTER_STAGE_STATE_ACTIVATED)
{
if (event->stage_state.new_state & CLUTTER_STAGE_STATE_ACTIVATED)
@@ -3717,6 +3970,8 @@ clutter_stage_get_use_alpha (ClutterStage *stage)
* If the current size of @stage is smaller than the minimum size, the
* @stage will be resized to the new @width and @height
*
* This function has no effect if @stage is fullscreen
*
* Since: 1.2
*/
void
@@ -4403,6 +4658,20 @@ _clutter_stage_is_activated (ClutterStage *stage)
return (stage->priv->current_state & CLUTTER_STAGE_STATE_ACTIVATED) != 0;
}
/*< private >
* _clutter_stage_is_fullscreen:
* @stage: a #ClutterStage
*
* Checks whether the @stage state includes %CLUTTER_STAGE_STATE_FULLSCREEN.
*
* Return value: %TRUE if the @stage is fullscreen
*/
gboolean
_clutter_stage_is_fullscreen (ClutterStage *stage)
{
return (stage->priv->current_state & CLUTTER_STAGE_STATE_FULLSCREEN) != 0;
}
/*< private >
* _clutter_stage_update_state:
* @stage: a #ClutterStage

View File

@@ -30,7 +30,6 @@
#include <clutter/clutter-types.h>
#include <clutter/clutter-group.h>
#include <clutter/clutter-stage-view.h>
G_BEGIN_DECLS
@@ -62,6 +61,8 @@ struct _ClutterStage
};
/**
* ClutterStageClass:
* @fullscreen: handler for the #ClutterStage::fullscreen signal
* @unfullscreen: handler for the #ClutterStage::unfullscreen signal
* @activate: handler for the #ClutterStage::activate signal
* @deactivate: handler for the #ClutterStage::deactivate signal
* @delete_event: handler for the #ClutterStage::delete-event signal
@@ -78,18 +79,17 @@ struct _ClutterStageClass
/*< public >*/
/* signals */
void (* fullscreen) (ClutterStage *stage);
void (* unfullscreen) (ClutterStage *stage);
void (* activate) (ClutterStage *stage);
void (* deactivate) (ClutterStage *stage);
gboolean (* delete_event) (ClutterStage *stage,
ClutterEvent *event);
void (* paint_view) (ClutterStage *stage,
ClutterStageView *view);
/*< private >*/
/* padding for future expansion */
gpointer _padding_dummy[30];
gpointer _padding_dummy[31];
};
/**
@@ -168,6 +168,11 @@ CLUTTER_EXPORT
void clutter_stage_get_perspective (ClutterStage *stage,
ClutterPerspective *perspective);
CLUTTER_EXPORT
void clutter_stage_set_fullscreen (ClutterStage *stage,
gboolean fullscreen);
CLUTTER_EXPORT
gboolean clutter_stage_get_fullscreen (ClutterStage *stage);
CLUTTER_EXPORT
void clutter_stage_show_cursor (ClutterStage *stage);
CLUTTER_EXPORT
void clutter_stage_hide_cursor (ClutterStage *stage);
@@ -176,6 +181,11 @@ void clutter_stage_set_title (ClutterStage
const gchar *title);
CLUTTER_EXPORT
const gchar * clutter_stage_get_title (ClutterStage *stage);
CLUTTER_EXPORT
void clutter_stage_set_user_resizable (ClutterStage *stage,
gboolean resizable);
CLUTTER_EXPORT
gboolean clutter_stage_get_user_resizable (ClutterStage *stage);
CLUTTER_EXPORT
void clutter_stage_set_minimum_size (ClutterStage *stage,
@@ -264,10 +274,6 @@ gboolean clutter_stage_capture (ClutterStage *stage,
cairo_rectangle_int_t *rect,
ClutterCapture **captures,
int *n_captures);
CLUTTER_EXPORT
ClutterStageView * clutter_stage_get_view_at (ClutterStage *stage,
float x,
float y);
G_END_DECLS

View File

@@ -101,7 +101,6 @@
#include "clutter-snap-constraint.h"
#include "clutter-stage.h"
#include "clutter-stage-manager.h"
#include "clutter-stage-view.h"
#include "clutter-tap-action.h"
#include "clutter-test-utils.h"
#include "clutter-texture.h"

View File

@@ -45,7 +45,6 @@
#include "clutter-main.h"
#include "clutter-private.h"
#include "clutter-stage-private.h"
#include "clutter-stage-view-private.h"
#include "cogl/cogl-trace.h"
@@ -983,8 +982,6 @@ clutter_stage_cogl_redraw (ClutterStageWindow *stage_window)
clutter_stage_cogl_redraw_view (stage_window, view) || swap_event;
}
_clutter_stage_emit_after_paint (stage_cogl->wrapper);
_clutter_stage_window_finish_frame (stage_window);
if (swap_event)

View File

@@ -1225,7 +1225,7 @@ clutter_input_device_evdev_apply_kbd_a11y_settings (ClutterInputDeviceEvdev *dev
update_internal_xkb_state (device, 0, 0);
}
if (changed_flags & CLUTTER_A11Y_KEYBOARD_ENABLED)
if (changed_flags & (CLUTTER_A11Y_KEYBOARD_ENABLED | CLUTTER_A11Y_TOGGLE_KEYS_ENABLED))
{
device->toggle_slowkeys_timer = 0;
device->shift_count = 0;
@@ -1246,13 +1246,6 @@ clutter_input_device_evdev_apply_kbd_a11y_settings (ClutterInputDeviceEvdev *dev
device->a11y_flags = settings->controls;
}
void
clutter_evdev_a11y_maybe_notify_toggle_keys (ClutterInputDeviceEvdev *device)
{
if (device->a11y_flags & CLUTTER_A11Y_TOGGLE_KEYS_ENABLED)
clutter_input_device_evdev_bell_notify ();
}
static void
release_device_touch_slot (gpointer value)
{

View File

@@ -150,7 +150,6 @@ void clutter_input_device_evdev_release_touch_state (Clutte
void clutter_input_device_evdev_release_touch_slots (ClutterInputDeviceEvdev *device_evdev,
uint64_t time_us);
void clutter_evdev_a11y_maybe_notify_toggle_keys (ClutterInputDeviceEvdev *);
G_END_DECLS

View File

@@ -326,7 +326,6 @@ clutter_seat_evdev_notify_key (ClutterSeatEvdev *seat,
backend = clutter_get_default_backend ();
g_signal_emit_by_name (clutter_backend_get_keymap (backend), "state-changed");
clutter_seat_evdev_sync_leds (seat);
clutter_evdev_a11y_maybe_notify_toggle_keys (CLUTTER_INPUT_DEVICE_EVDEV (seat->core_keyboard));
}
if (state == 0 || /* key release */

View File

@@ -75,7 +75,6 @@ clutter_headers = [
'clutter-snap-constraint.h',
'clutter-stage.h',
'clutter-stage-manager.h',
'clutter-stage-view.h',
'clutter-tap-action.h',
'clutter-test-utils.h',
'clutter-texture.h',
@@ -165,7 +164,6 @@ clutter_sources = [
'clutter-snap-constraint.c',
'clutter-stage.c',
'clutter-stage-manager.c',
'clutter-stage-view.c',
'clutter-stage-window.c',
'clutter-tap-action.c',
'clutter-test-utils.c',
@@ -209,7 +207,7 @@ clutter_private_headers = [
'clutter-settings-private.h',
'clutter-stage-manager-private.h',
'clutter-stage-private.h',
'clutter-stage-view-private.h',
'clutter-stage-view.h',
'clutter-stage-window.h',
]
@@ -217,6 +215,7 @@ clutter_nonintrospected_sources = [
'clutter-easing.c',
'clutter-event-translator.c',
'clutter-id-pool.c',
'clutter-stage-view.c',
]
clutter_deprecated_headers = [
@@ -344,8 +343,14 @@ if have_native_backend
endif
if have_wayland
clutter_wayland_nonintrospected_sources = [
'wayland/clutter-wayland-surface.c',
]
clutter_backend_nonintrospected_sources += clutter_wayland_nonintrospected_sources
clutter_wayland_private_headers = [
'wayland/clutter-wayland-compositor.h',
'wayland/clutter-wayland-surface.h',
]
clutter_backend_private_headers += clutter_wayland_private_headers
endif

View File

@@ -0,0 +1,654 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2011 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*
* Authors:
* Robert Bragg <robert@linux.intel.com>
*/
/**
* SECTION:clutter-wayland-surface
* @Title: ClutterWaylandSurface
* @short_description: An actor which displays the content of a client surface
*
* #ClutterWaylandSurface is an actor for displaying the contents of a client
* surface. It is intended to support developers implementing Clutter based
* wayland compositors.
*/
#include "clutter-build-config.h"
#define CLUTTER_ENABLE_EXPERIMENTAL_API
#include "clutter-wayland-surface.h"
#include "clutter-actor-private.h"
#include "clutter-marshal.h"
#include "clutter-paint-volume-private.h"
#include "clutter-private.h"
#include "clutter-backend.h"
#include <cogl/cogl.h>
#include <cogl/cogl-wayland-server.h>
enum
{
PROP_SURFACE = 1,
PROP_SURFACE_WIDTH,
PROP_SURFACE_HEIGHT,
PROP_COGL_TEXTURE,
PROP_LAST
};
static GParamSpec *obj_props[PROP_LAST];
enum
{
QUEUE_DAMAGE_REDRAW,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0, };
struct _ClutterWaylandSurfacePrivate
{
struct wl_surface *surface;
CoglTexture2D *buffer;
int width, height;
CoglPipeline *pipeline;
};
G_DEFINE_TYPE_WITH_PRIVATE (ClutterWaylandSurface,
clutter_wayland_surface,
CLUTTER_TYPE_ACTOR)
static gboolean
clutter_wayland_surface_get_paint_volume (ClutterActor *self,
ClutterPaintVolume *volume)
{
return clutter_paint_volume_set_from_allocation (volume, self);
}
static void
clutter_wayland_surface_queue_damage_redraw (ClutterWaylandSurface *texture,
gint x,
gint y,
gint width,
gint height)
{
ClutterWaylandSurfacePrivate *priv = texture->priv;
ClutterActor *self = CLUTTER_ACTOR (texture);
ClutterActorBox allocation;
float scale_x;
float scale_y;
cairo_rectangle_int_t clip;
/* NB: clutter_actor_queue_redraw_with_clip expects a box in the actor's
* coordinate space so we need to convert from surface coordinates to
* actor coordinates...
*/
/* Calling clutter_actor_get_allocation_box() is enormously expensive
* if the actor has an out-of-date allocation, since it triggers
* a full redraw. clutter_actor_queue_redraw_with_clip() would redraw
* the whole stage anyways in that case, so just go ahead and do
* it here.
*/
if (!clutter_actor_has_allocation (self))
{
clutter_actor_queue_redraw (self);
return;
}
if (priv->width == 0 || priv->height == 0)
return;
clutter_actor_get_allocation_box (self, &allocation);
scale_x = (allocation.x2 - allocation.x1) / priv->width;
scale_y = (allocation.y2 - allocation.y1) / priv->height;
clip.x = x * scale_x;
clip.y = y * scale_y;
clip.width = width * scale_x;
clip.height = height * scale_y;
clutter_actor_queue_redraw_with_clip (self, &clip);
}
static void
free_pipeline (ClutterWaylandSurface *self)
{
ClutterWaylandSurfacePrivate *priv = self->priv;
if (priv->pipeline)
{
cogl_object_unref (priv->pipeline);
priv->pipeline = NULL;
}
}
static void
opacity_change_cb (ClutterWaylandSurface *self)
{
free_pipeline (self);
}
static void
clutter_wayland_surface_init (ClutterWaylandSurface *self)
{
ClutterWaylandSurfacePrivate *priv;
priv = clutter_wayland_surface_get_instance_private (self);
priv->surface = NULL;
priv->width = 0;
priv->height = 0;
self->priv = priv;
g_signal_connect (self, "notify::opacity", G_CALLBACK (opacity_change_cb), NULL);
}
static void
free_surface_buffers (ClutterWaylandSurface *self)
{
ClutterWaylandSurfacePrivate *priv = self->priv;
if (priv->buffer)
{
cogl_object_unref (priv->buffer);
priv->buffer = NULL;
free_pipeline (self);
}
}
static void
clutter_wayland_surface_dispose (GObject *object)
{
ClutterWaylandSurface *self = CLUTTER_WAYLAND_SURFACE (object);
ClutterWaylandSurfacePrivate *priv = self->priv;
free_pipeline (self);
free_surface_buffers (self);
priv->surface = NULL;
G_OBJECT_CLASS (clutter_wayland_surface_parent_class)->dispose (object);
}
static void
set_size (ClutterWaylandSurface *self,
int width,
int height)
{
ClutterWaylandSurfacePrivate *priv = self->priv;
if (priv->width != width)
{
priv->width = width;
g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_SURFACE_WIDTH]);
}
if (priv->height != height)
{
priv->height = height;
g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_SURFACE_HEIGHT]);
}
clutter_actor_set_size (CLUTTER_ACTOR (self), priv->width, priv->height);
}
/**
* clutter_wayland_surface_get_surface:
* @self: a #ClutterWaylandSurface
*
* Retrieves a point to the Wayland surface used by the actor.
*
* Return value: (transfer none): a wl_surface pointer, or %NULL
*
* Since: 1.10
*/
struct wl_surface *
clutter_wayland_surface_get_surface (ClutterWaylandSurface *self)
{
ClutterWaylandSurfacePrivate *priv = self->priv;
return priv->surface;
}
/**
* clutter_wayland_surface_set_surface:
* @self: a #ClutterWaylandSurface
* @surface: a Wayland wl_surface pointer
*
* Sets the Wayland surface to be used by the actor.
*
* Since: 1.10
*/
void
clutter_wayland_surface_set_surface (ClutterWaylandSurface *self,
struct wl_surface *surface)
{
ClutterWaylandSurfacePrivate *priv;
g_return_if_fail (CLUTTER_WAYLAND_IS_SURFACE (self));
priv = self->priv;
if (priv->surface == surface)
return;
if (priv->surface)
{
free_pipeline (self);
free_surface_buffers (self);
g_signal_emit (self, signals[QUEUE_DAMAGE_REDRAW],
0,
0, 0, priv->width, priv->height);
}
priv->surface = surface;
/* XXX: should we freeze/thaw notifications? */
g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_SURFACE]);
/* We have to wait until the next attach event to find out the surface
* geometry... */
set_size (self, 0, 0);
}
static void
clutter_wayland_surface_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
ClutterWaylandSurface *self = CLUTTER_WAYLAND_SURFACE (object);
switch (prop_id)
{
case PROP_SURFACE:
clutter_wayland_surface_set_surface (self, g_value_get_pointer (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
clutter_wayland_surface_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
ClutterWaylandSurface *self = CLUTTER_WAYLAND_SURFACE (object);
ClutterWaylandSurfacePrivate *priv = self->priv;
switch (prop_id)
{
case PROP_SURFACE:
g_value_set_pointer (value, priv->surface);
break;
case PROP_SURFACE_WIDTH:
g_value_set_uint (value, priv->width);
break;
case PROP_SURFACE_HEIGHT:
g_value_set_uint (value, priv->height);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
clutter_wayland_surface_paint (ClutterActor *self)
{
ClutterWaylandSurfacePrivate *priv;
CoglFramebuffer *framebuffer;
ClutterActorBox box;
g_return_if_fail (CLUTTER_WAYLAND_IS_SURFACE (self));
priv = CLUTTER_WAYLAND_SURFACE (self)->priv;
framebuffer = cogl_get_draw_framebuffer ();
if (G_UNLIKELY (priv->pipeline == NULL))
{
CoglContext *ctx =
clutter_backend_get_cogl_context (clutter_get_default_backend ());
guint8 paint_opacity = clutter_actor_get_paint_opacity (self);
priv->pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_color4ub (priv->pipeline,
paint_opacity,
paint_opacity,
paint_opacity,
paint_opacity);
cogl_pipeline_set_layer_texture (priv->pipeline, 0,
COGL_TEXTURE (priv->buffer));
}
clutter_actor_get_allocation_box (self, &box);
cogl_framebuffer_draw_rectangle (framebuffer,
priv->pipeline,
0, 0,
box.x2 - box.x1, box.y2 - box.y1);
}
static void
clutter_wayland_surface_get_preferred_width (ClutterActor *self,
gfloat for_height,
gfloat *min_width_p,
gfloat *natural_width_p)
{
ClutterWaylandSurfacePrivate *priv;
g_return_if_fail (CLUTTER_WAYLAND_IS_SURFACE (self));
priv = CLUTTER_WAYLAND_SURFACE (self)->priv;
if (min_width_p)
*min_width_p = 0;
if (natural_width_p)
*natural_width_p = priv->width;
}
static void
clutter_wayland_surface_get_preferred_height (ClutterActor *self,
gfloat for_width,
gfloat *min_height_p,
gfloat *natural_height_p)
{
ClutterWaylandSurfacePrivate *priv;
g_return_if_fail (CLUTTER_WAYLAND_IS_SURFACE (self));
priv = CLUTTER_WAYLAND_SURFACE (self)->priv;
if (min_height_p)
*min_height_p = 0;
if (natural_height_p)
*natural_height_p = priv->height;
}
static gboolean
clutter_wayland_surface_has_overlaps (ClutterActor *self)
{
/* Rectangles never need an offscreen redirect because there are
never any overlapping primitives */
return FALSE;
}
static void
clutter_wayland_surface_class_init (ClutterWaylandSurfaceClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
GParamSpec *pspec;
actor_class->get_paint_volume = clutter_wayland_surface_get_paint_volume;
actor_class->paint = clutter_wayland_surface_paint;
actor_class->get_preferred_width =
clutter_wayland_surface_get_preferred_width;
actor_class->get_preferred_height =
clutter_wayland_surface_get_preferred_height;
actor_class->has_overlaps = clutter_wayland_surface_has_overlaps;
object_class->dispose = clutter_wayland_surface_dispose;
object_class->set_property = clutter_wayland_surface_set_property;
object_class->get_property = clutter_wayland_surface_get_property;
pspec = g_param_spec_pointer ("surface",
P_("Surface"),
P_("The underlying wayland surface"),
CLUTTER_PARAM_READWRITE|
G_PARAM_CONSTRUCT_ONLY);
obj_props[PROP_SURFACE] = pspec;
g_object_class_install_property (object_class, PROP_SURFACE, pspec);
pspec = g_param_spec_uint ("surface-width",
P_("Surface width"),
P_("The width of the underlying wayland surface"),
0, G_MAXUINT,
0,
G_PARAM_READABLE);
obj_props[PROP_SURFACE_WIDTH] = pspec;
g_object_class_install_property (object_class, PROP_SURFACE_WIDTH, pspec);
pspec = g_param_spec_uint ("surface-height",
P_("Surface height"),
P_("The height of the underlying wayland surface"),
0, G_MAXUINT,
0,
G_PARAM_READABLE);
obj_props[PROP_SURFACE_HEIGHT] = pspec;
g_object_class_install_property (object_class, PROP_SURFACE_HEIGHT, pspec);
pspec = g_param_spec_boxed ("cogl-texture",
P_("Cogl Texture"),
P_("The underlying Cogl texture handle used to draw this actor"),
COGL_TYPE_HANDLE,
CLUTTER_PARAM_READWRITE);
obj_props[PROP_COGL_TEXTURE] = pspec;
g_object_class_install_property (object_class, PROP_COGL_TEXTURE, pspec);
/**
* ClutterWaylandSurface::queue-damage-redraw:
* @texture: the object which received the signal
* @x: The top left x position of the damage region
* @y: The top left y position of the damage region
* @width: The width of the damage region
* @height: The height of the damage region
*
* ::queue-damage-redraw is emitted to notify that some sub-region
* of the texture has been changed. This usually means a redraw
* needs to be queued for the actor.
*
* The default handler will queue a clipped redraw in response to
* the damage, using the assumption that the pixmap is being painted
* to a rectangle covering the transformed allocation of the actor.
* If you sub-class and change the paint method so this isn't true
* then you must also provide your own damage signal handler to
* queue a redraw that blocks this default behaviour.
*
* Since: 1.10
*/
signals[QUEUE_DAMAGE_REDRAW] =
g_signal_new (g_intern_static_string ("queue-damage-redraw"),
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (ClutterWaylandSurfaceClass, queue_damage_redraw),
NULL, NULL,
_clutter_marshal_VOID__INT_INT_INT_INT,
G_TYPE_NONE, 4,
G_TYPE_INT,
G_TYPE_INT,
G_TYPE_INT,
G_TYPE_INT);
klass->queue_damage_redraw = clutter_wayland_surface_queue_damage_redraw;
}
/**
* clutter_wayland_surface_new:
* @surface: the Wayland surface this actor should represent
*
* Creates a new #ClutterWaylandSurface for @surface
*
* Return value: A new #ClutterWaylandSurface representing @surface
*
* Since: 1.8
* Stability: unstable
*/
ClutterActor *
clutter_wayland_surface_new (struct wl_surface *surface)
{
ClutterActor *actor;
actor = g_object_new (CLUTTER_WAYLAND_TYPE_SURFACE,
"surface", surface,
NULL);
return actor;
}
/**
* clutter_wayland_surface_attach_buffer:
* @self: A #ClutterWaylandSurface actor
* @buffer: A compositor side resource representing a wl_buffer
* @error: A #GError
*
* This associates a client's buffer with the #ClutterWaylandSurface
* actor @self. This will automatically result in @self being re-drawn
* with the new buffer contents.
*
* Since: 1.8
* Stability: unstable
*/
gboolean
clutter_wayland_surface_attach_buffer (ClutterWaylandSurface *self,
struct wl_resource *buffer,
GError **error)
{
ClutterWaylandSurfacePrivate *priv;
ClutterBackend *backend = clutter_get_default_backend ();
CoglContext *context = clutter_backend_get_cogl_context (backend);
g_return_val_if_fail (CLUTTER_WAYLAND_IS_SURFACE (self), TRUE);
priv = self->priv;
free_surface_buffers (self);
priv->buffer =
cogl_wayland_texture_2d_new_from_buffer (context, buffer, error);
g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_COGL_TEXTURE]);
/* NB: We don't queue a redraw of the actor here because we don't
* know how much of the buffer has changed with respect to the
* previous buffer. We only ever queue a redraw in response to
* surface damage. */
if (!priv->buffer)
return FALSE;
set_size (self,
cogl_texture_get_width (COGL_TEXTURE (priv->buffer)),
cogl_texture_get_height (COGL_TEXTURE (priv->buffer)));
return TRUE;
}
/**
* clutter_wayland_surface_damage_buffer:
* @self: A #ClutterWaylandSurface actor
* @buffer: A wayland resource for a buffer
* @x: The x coordinate of the damaged rectangle
* @y: The y coordinate of the damaged rectangle
* @width: The width of the damaged rectangle
* @height: The height of the damaged rectangle
*
* This marks a region of the given @buffer has having been changed by
* the client. This will automatically result in the corresponding damaged
* region of the actor @self being redrawn.
*
* If multiple regions are changed then this should be called multiple
* times with different damage rectangles.
*
* Since: 1.8
* Stability: unstable
*/
void
clutter_wayland_surface_damage_buffer (ClutterWaylandSurface *self,
struct wl_resource *buffer,
gint32 x,
gint32 y,
gint32 width,
gint32 height)
{
ClutterWaylandSurfacePrivate *priv;
struct wl_shm_buffer *shm_buffer;
g_return_if_fail (CLUTTER_WAYLAND_IS_SURFACE (self));
priv = self->priv;
shm_buffer = wl_shm_buffer_get (buffer);
if (priv->buffer && shm_buffer)
{
CoglPixelFormat format;
switch (wl_shm_buffer_get_format (shm_buffer))
{
#if G_BYTE_ORDER == G_BIG_ENDIAN
case WL_SHM_FORMAT_ARGB8888:
format = COGL_PIXEL_FORMAT_ARGB_8888_PRE;
break;
case WL_SHM_FORMAT_XRGB8888:
format = COGL_PIXEL_FORMAT_ARGB_8888;
break;
#elif G_BYTE_ORDER == G_LITTLE_ENDIAN
case WL_SHM_FORMAT_ARGB8888:
format = COGL_PIXEL_FORMAT_BGRA_8888_PRE;
break;
case WL_SHM_FORMAT_XRGB8888:
format = COGL_PIXEL_FORMAT_BGRA_8888;
break;
#endif
default:
g_warn_if_reached ();
format = COGL_PIXEL_FORMAT_ARGB_8888;
}
cogl_texture_set_region (COGL_TEXTURE (priv->buffer),
x, y,
x, y,
width, height,
width, height,
format,
wl_shm_buffer_get_stride (shm_buffer),
wl_shm_buffer_get_data (shm_buffer));
}
g_signal_emit (self, signals[QUEUE_DAMAGE_REDRAW],
0,
x, y, width, height);
}
/**
* clutter_wayland_surface_get_cogl_texture:
* @self: a #ClutterWaylandSurface
*
* Retrieves the Cogl texture with the contents of the Wayland surface.
*
* Return value: (transfer none): a Cogl texture, or %NULL
*
* Since: 1.10
*/
CoglTexture *
clutter_wayland_surface_get_cogl_texture (ClutterWaylandSurface *self)
{
g_return_val_if_fail (CLUTTER_WAYLAND_IS_SURFACE (self), NULL);
return COGL_TEXTURE (self->priv->buffer);
}

View File

@@ -0,0 +1,117 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2011 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*
* Authors:
* Robert Bragg <robert@linux.intel.com>
*
*/
#ifndef __CLUTTER_WAYLAND_SURFACE_H__
#define __CLUTTER_WAYLAND_SURFACE_H__
#include <glib.h>
#include <glib-object.h>
#include <clutter/clutter.h>
#include <wayland-server.h>
G_BEGIN_DECLS
#define CLUTTER_WAYLAND_TYPE_SURFACE (clutter_wayland_surface_get_type ())
#define CLUTTER_WAYLAND_SURFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_WAYLAND_TYPE_SURFACE, ClutterWaylandSurface))
#define CLUTTER_WAYLAND_SURFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_WAYLAND_TYPE_SURFACE, ClutterWaylandSurfaceClass))
#define CLUTTER_WAYLAND_IS_SURFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_WAYLAND_TYPE_SURFACE))
#define CLUTTER_WAYLAND_IS_SURFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_WAYLAND_TYPE_SURFACE))
#define CLUTTER_WAYLAND_SURFACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_WAYLAND_TYPE_SURFACE, ClutterWaylandSurfaceClass))
typedef struct _ClutterWaylandSurface ClutterWaylandSurface;
typedef struct _ClutterWaylandSurfaceClass ClutterWaylandSurfaceClass;
typedef struct _ClutterWaylandSurfacePrivate ClutterWaylandSurfacePrivate;
/**
* ClutterWaylandSurface:
*
* The #ClutterWaylandSurface structure contains only private data
*
* Since: 1.10
* Stability: unstable
*/
struct _ClutterWaylandSurface
{
/*< private >*/
ClutterActor parent;
ClutterWaylandSurfacePrivate *priv;
};
/**
* ClutterWaylandSurfaceClass:
* @queue_damage_redraw: class handler of the #ClutterWaylandSurface::queue-damage-redraw signal
*
* The #ClutterWaylandSurfaceClass structure contains only private data
*
* Since: 1.10
* Stability: unstable
*/
struct _ClutterWaylandSurfaceClass
{
/*< private >*/
ClutterActorClass parent_class;
/*< public >*/
void (*queue_damage_redraw) (ClutterWaylandSurface *texture,
gint x,
gint y,
gint width,
gint height);
/*< private >*/
/* padding for future expansion */
gpointer _padding_dummy[8];
};
CLUTTER_EXPORT
GType clutter_wayland_surface_get_type (void) G_GNUC_CONST;
CLUTTER_EXPORT
ClutterActor *clutter_wayland_surface_new (struct wl_surface *surface);
CLUTTER_EXPORT
void clutter_wayland_surface_set_surface (ClutterWaylandSurface *self,
struct wl_surface *surface);
CLUTTER_EXPORT
struct wl_surface *clutter_wayland_surface_get_surface (ClutterWaylandSurface *self);
CLUTTER_EXPORT
gboolean clutter_wayland_surface_attach_buffer (ClutterWaylandSurface *self,
struct wl_resource *buffer,
GError **error);
CLUTTER_EXPORT
void clutter_wayland_surface_damage_buffer (ClutterWaylandSurface *self,
struct wl_resource *buffer,
gint32 x,
gint32 y,
gint32 width,
gint32 height);
CLUTTER_EXPORT
CoglTexture *clutter_wayland_surface_get_cogl_texture (ClutterWaylandSurface *self);
G_END_DECLS
#endif

View File

@@ -89,6 +89,7 @@ static const gchar *atom_names[] = {
"_NET_WM_PID",
"_NET_WM_PING",
"_NET_WM_STATE",
"_NET_WM_STATE_FULLSCREEN",
"_NET_WM_USER_TIME",
"WM_PROTOCOLS",
"WM_DELETE_WINDOW",
@@ -440,13 +441,14 @@ clutter_backend_x11_post_parse (ClutterBackend *backend,
backend_x11->atom_NET_WM_PID = atoms[0];
backend_x11->atom_NET_WM_PING = atoms[1];
backend_x11->atom_NET_WM_STATE = atoms[2];
backend_x11->atom_NET_WM_USER_TIME = atoms[3];
backend_x11->atom_WM_PROTOCOLS = atoms[4];
backend_x11->atom_WM_DELETE_WINDOW = atoms[5];
backend_x11->atom_XEMBED = atoms[6];
backend_x11->atom_XEMBED_INFO = atoms[7];
backend_x11->atom_NET_WM_NAME = atoms[8];
backend_x11->atom_UTF8_STRING = atoms[9];
backend_x11->atom_NET_WM_STATE_FULLSCREEN = atoms[3];
backend_x11->atom_NET_WM_USER_TIME = atoms[4];
backend_x11->atom_WM_PROTOCOLS = atoms[5];
backend_x11->atom_WM_DELETE_WINDOW = atoms[6];
backend_x11->atom_XEMBED = atoms[7];
backend_x11->atom_XEMBED_INFO = atoms[8];
backend_x11->atom_NET_WM_NAME = atoms[9];
backend_x11->atom_UTF8_STRING = atoms[10];
g_free (clutter_display_name);
@@ -561,7 +563,8 @@ clutter_backend_x11_dispose (GObject *gobject)
static ClutterFeatureFlags
clutter_backend_x11_get_features (ClutterBackend *backend)
{
ClutterFeatureFlags flags = CLUTTER_FEATURE_STAGE_CURSOR;
ClutterFeatureFlags flags = CLUTTER_FEATURE_STAGE_USER_RESIZE
| CLUTTER_FEATURE_STAGE_CURSOR;
flags |= CLUTTER_BACKEND_CLASS (clutter_backend_x11_parent_class)->get_features (backend);

View File

@@ -89,6 +89,7 @@ struct _ClutterBackendX11
Atom atom_NET_WM_PID;
Atom atom_NET_WM_PING;
Atom atom_NET_WM_STATE;
Atom atom_NET_WM_STATE_FULLSCREEN;
Atom atom_NET_WM_USER_TIME;
Atom atom_WM_PROTOCOLS;
Atom atom_WM_DELETE_WINDOW;

View File

@@ -87,6 +87,60 @@ G_DEFINE_TYPE_WITH_CODE (ClutterStageX11,
ButtonReleaseMask | \
PointerMotionMask
static void
send_wmspec_change_state (ClutterBackendX11 *backend_x11,
Window window,
Atom state,
gboolean add)
{
XClientMessageEvent xclient;
CLUTTER_NOTE (BACKEND, "%s NET_WM state", add ? "adding" : "removing");
memset (&xclient, 0, sizeof (xclient));
xclient.type = ClientMessage;
xclient.window = window;
xclient.message_type = backend_x11->atom_NET_WM_STATE;
xclient.format = 32;
xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
xclient.data.l[1] = state;
xclient.data.l[2] = 0;
xclient.data.l[3] = 0;
xclient.data.l[4] = 0;
XSendEvent (backend_x11->xdpy,
DefaultRootWindow (backend_x11->xdpy),
False,
SubstructureRedirectMask | SubstructureNotifyMask,
(XEvent *)&xclient);
}
static void
update_state (ClutterStageX11 *stage_x11,
ClutterBackendX11 *backend_x11,
Atom *state,
gboolean add)
{
if (add)
{
/* FIXME: This wont work if we support more states */
XChangeProperty (backend_x11->xdpy,
stage_x11->xwin,
backend_x11->atom_NET_WM_STATE, XA_ATOM, 32,
PropModeReplace,
(unsigned char *) state, 1);
}
else
{
/* FIXME: This wont work if we support more states */
XDeleteProperty (backend_x11->xdpy,
stage_x11->xwin,
backend_x11->atom_NET_WM_STATE);
}
}
static void
clutter_stage_x11_fix_window_size (ClutterStageX11 *stage_x11,
gint new_width,
@@ -99,6 +153,9 @@ clutter_stage_x11_fix_window_size (ClutterStageX11 *stage_x11,
{
guint min_width, min_height;
XSizeHints *size_hints;
gboolean resize;
resize = clutter_stage_get_user_resizable (stage_cogl->wrapper);
size_hints = XAllocSizeHints();
@@ -112,11 +169,27 @@ clutter_stage_x11_fix_window_size (ClutterStageX11 *stage_x11,
if (new_height <= 0)
new_height = min_height;
size_hints->min_width = new_width;
size_hints->min_height = new_height;
size_hints->max_width = new_width;
size_hints->max_height = new_height;
size_hints->flags = PMinSize | PMaxSize;
size_hints->flags = 0;
/* If we are going fullscreen then we don't want any
restrictions on the window size */
if (!stage_x11->fullscreening)
{
if (resize)
{
size_hints->min_width = min_width;
size_hints->min_height = min_height;
size_hints->flags = PMinSize;
}
else
{
size_hints->min_width = new_width;
size_hints->min_height = new_height;
size_hints->max_width = new_width;
size_hints->max_height = new_height;
size_hints->flags = PMinSize | PMaxSize;
}
}
XSetWMNormalHints (backend_x11->xdpy, stage_x11->xwin, size_hints);
@@ -143,8 +216,28 @@ clutter_stage_x11_get_geometry (ClutterStageWindow *stage_window,
cairo_rectangle_int_t *geometry)
{
ClutterStageX11 *stage_x11 = CLUTTER_STAGE_X11 (stage_window);
ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_x11);
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (stage_cogl->backend);
geometry->x = geometry->y = 0;
/* If we're fullscreen, return the size of the display.
*
* FIXME - this is utterly broken for anything that is not a single
* head set up; the window manager will give us the right size in a
* ConfigureNotify, but between the fullscreen signal emission on the
* stage and the following frame, the size returned by the stage will
* be wrong.
*/
if (_clutter_stage_is_fullscreen (stage_cogl->wrapper) &&
stage_x11->fullscreening)
{
geometry->width = DisplayWidth (backend_x11->xdpy, backend_x11->xscreen_num);
geometry->height = DisplayHeight (backend_x11->xdpy, backend_x11->xscreen_num);
return;
}
geometry->width = stage_x11->xwin_width;
geometry->height = stage_x11->xwin_height;
}
@@ -170,6 +263,10 @@ clutter_stage_x11_resize (ClutterStageWindow *stage_window,
return;
}
/* If we're going fullscreen, don't mess with the size */
if (stage_x11->fullscreening)
return;
if (width == 0 || height == 0)
{
/* Should not happen, if this turns up we need to debug it and
@@ -363,6 +460,117 @@ _clutter_stage_x11_update_foreign_event_mask (CoglOnscreen *onscreen,
&attrs);
}
static void
clutter_stage_x11_set_fullscreen (ClutterStageWindow *stage_window,
gboolean is_fullscreen)
{
ClutterStageX11 *stage_x11 = CLUTTER_STAGE_X11 (stage_window);
ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_x11);
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (stage_cogl->backend);
ClutterStage *stage = stage_cogl->wrapper;
gboolean was_fullscreen;
if (stage == NULL || CLUTTER_ACTOR_IN_DESTRUCTION (stage))
return;
was_fullscreen = _clutter_stage_is_fullscreen (stage);
is_fullscreen = !!is_fullscreen;
if (was_fullscreen == is_fullscreen)
return;
CLUTTER_NOTE (BACKEND, "%ssetting fullscreen", is_fullscreen ? "" : "un");
if (is_fullscreen)
{
#if 0
int width, height;
/* FIXME: this will do the wrong thing for dual-headed
displays. This will return the size of the combined display
but Metacity (at least) will fullscreen to only one of the
displays. This will cause the actor to report the wrong size
until the ConfigureNotify for the correct size is received */
width = DisplayWidth (backend_x11->xdpy, backend_x11->xscreen_num);
height = DisplayHeight (backend_x11->xdpy, backend_x11->xscreen_num);
#endif
/* Set the fullscreen hint so we can retain the old size of the window. */
stage_x11->fullscreening = TRUE;
if (stage_x11->xwin != None)
{
/* if the actor is not mapped we resize the stage window to match
* the size of the screen; this is useful for e.g. EGLX to avoid
* a resize when calling clutter_stage_fullscreen() before showing
* the stage
*/
if (!STAGE_X11_IS_MAPPED (stage_x11))
{
CLUTTER_NOTE (BACKEND, "Fullscreening unmapped stage");
update_state (stage_x11, backend_x11,
&backend_x11->atom_NET_WM_STATE_FULLSCREEN,
TRUE);
}
else
{
CLUTTER_NOTE (BACKEND, "Fullscreening mapped stage");
/* We need to fix the window size so that it will remove
the maximum and minimum window hints. Otherwise
metacity will honour the restrictions and not
fullscreen correctly. */
clutter_stage_x11_fix_window_size (stage_x11, -1, -1);
send_wmspec_change_state (backend_x11, stage_x11->xwin,
backend_x11->atom_NET_WM_STATE_FULLSCREEN,
TRUE);
}
}
else
stage_x11->fullscreen_on_realize = TRUE;
}
else
{
stage_x11->fullscreening = FALSE;
if (stage_x11->xwin != None)
{
if (!STAGE_X11_IS_MAPPED (stage_x11))
{
CLUTTER_NOTE (BACKEND, "Un-fullscreening unmapped stage");
update_state (stage_x11, backend_x11,
&backend_x11->atom_NET_WM_STATE_FULLSCREEN,
FALSE);
}
else
{
CLUTTER_NOTE (BACKEND, "Un-fullscreening mapped stage");
send_wmspec_change_state (backend_x11,
stage_x11->xwin,
backend_x11->atom_NET_WM_STATE_FULLSCREEN,
FALSE);
/* Fix the window size to restore the minimum/maximum
restriction */
clutter_stage_x11_fix_window_size (stage_x11,
stage_x11->xwin_width,
stage_x11->xwin_height);
}
}
else
stage_x11->fullscreen_on_realize = FALSE;
}
/* XXX: Note we rely on the ConfigureNotify mechanism as the common
* mechanism to handle notifications of new X window sizes from the
* X server so we don't actively change the stage viewport here or
* queue a relayout etc. */
}
void
_clutter_stage_x11_events_device_changed (ClutterStageX11 *stage_x11,
ClutterInputDevice *device,
@@ -514,6 +722,13 @@ clutter_stage_x11_realize (ClutterStageWindow *stage_window)
stage_x11->xwin_height);
clutter_stage_x11_set_wm_protocols (stage_x11);
if (stage_x11->fullscreen_on_realize)
{
stage_x11->fullscreen_on_realize = FALSE;
clutter_stage_x11_set_fullscreen (stage_window, TRUE);
}
CLUTTER_NOTE (BACKEND, "Successfully realized stage");
return TRUE;
@@ -540,6 +755,17 @@ clutter_stage_x11_set_title (ClutterStageWindow *stage_window,
set_wm_title (stage_x11);
}
static void
clutter_stage_x11_set_user_resizable (ClutterStageWindow *stage_window,
gboolean is_resizable)
{
ClutterStageX11 *stage_x11 = CLUTTER_STAGE_X11 (stage_window);
clutter_stage_x11_fix_window_size (stage_x11,
stage_x11->xwin_width,
stage_x11->xwin_height);
}
static inline void
update_wm_hints (ClutterStageX11 *stage_x11)
{
@@ -614,6 +840,11 @@ clutter_stage_x11_show (ClutterStageWindow *stage_window,
set_stage_x11_state (stage_x11, STAGE_X11_WITHDRAWN, 0);
update_wm_hints (stage_x11);
if (stage_x11->fullscreening)
clutter_stage_x11_set_fullscreen (stage_window, TRUE);
else
clutter_stage_x11_set_fullscreen (stage_window, FALSE);
}
g_assert (STAGE_X11_IS_MAPPED (stage_x11));
@@ -735,6 +966,7 @@ clutter_stage_x11_init (ClutterStageX11 *stage)
stage->wm_state = STAGE_X11_WITHDRAWN;
stage->is_foreign_xwin = FALSE;
stage->fullscreening = FALSE;
stage->is_cursor_visible = TRUE;
stage->accept_focus = TRUE;
@@ -747,7 +979,9 @@ clutter_stage_window_iface_init (ClutterStageWindowInterface *iface)
clutter_stage_window_parent_iface = g_type_interface_peek_parent (iface);
iface->set_title = clutter_stage_x11_set_title;
iface->set_fullscreen = clutter_stage_x11_set_fullscreen;
iface->set_cursor_visible = clutter_stage_x11_set_cursor_visible;
iface->set_user_resizable = clutter_stage_x11_set_user_resizable;
iface->set_accept_focus = clutter_stage_x11_set_accept_focus;
iface->show = clutter_stage_x11_show;
iface->hide = clutter_stage_x11_hide;
@@ -867,8 +1101,13 @@ clutter_stage_x11_translate_event (ClutterEventTranslator *translator,
xevent->xconfigure.width,
xevent->xconfigure.height);
if ((stage_x11->xwin_width != xevent->xconfigure.width) ||
(stage_x11->xwin_height != xevent->xconfigure.height))
/* When fullscreen, we'll keep the xwin_width/height
variables to track the old size of the window and we'll
assume all ConfigureNotifies constitute a size change */
if (_clutter_stage_is_fullscreen (stage))
size_changed = TRUE;
else if ((stage_x11->xwin_width != xevent->xconfigure.width) ||
(stage_x11->xwin_height != xevent->xconfigure.height))
{
size_changed = TRUE;
stage_x11->xwin_width = xevent->xconfigure.width;
@@ -958,6 +1197,57 @@ clutter_stage_x11_translate_event (ClutterEventTranslator *translator,
}
break;
case PropertyNotify:
if (xevent->xproperty.atom == backend_x11->atom_NET_WM_STATE &&
xevent->xproperty.window == stage_xwindow &&
!stage_x11->is_foreign_xwin)
{
Atom type;
gint format;
gulong n_items, bytes_after;
guchar *data = NULL;
gboolean fullscreen_set = FALSE;
clutter_x11_trap_x_errors ();
XGetWindowProperty (backend_x11->xdpy, stage_xwindow,
backend_x11->atom_NET_WM_STATE,
0, G_MAXLONG,
False, XA_ATOM,
&type, &format, &n_items,
&bytes_after, &data);
clutter_x11_untrap_x_errors ();
if (type != None && data != NULL)
{
gboolean is_fullscreen = FALSE;
Atom *atoms = (Atom *) data;
gulong i;
for (i = 0; i < n_items; i++)
{
if (atoms[i] == backend_x11->atom_NET_WM_STATE_FULLSCREEN)
fullscreen_set = TRUE;
}
is_fullscreen = _clutter_stage_is_fullscreen (stage_cogl->wrapper);
if (fullscreen_set != is_fullscreen)
{
if (fullscreen_set)
_clutter_stage_update_state (stage_cogl->wrapper,
0,
CLUTTER_STAGE_STATE_FULLSCREEN);
else
_clutter_stage_update_state (stage_cogl->wrapper,
CLUTTER_STAGE_STATE_FULLSCREEN,
0);
}
XFree (data);
}
}
break;
case FocusIn:
if (!_clutter_stage_is_activated (stage_cogl->wrapper))
{

View File

@@ -70,9 +70,11 @@ struct _ClutterStageX11
ClutterStageX11State wm_state;
guint is_foreign_xwin : 1;
guint fullscreening : 1;
guint is_cursor_visible : 1;
guint viewport_initialized : 1;
guint accept_focus : 1;
guint fullscreen_on_realize : 1;
};
struct _ClutterStageX11Class

View File

@@ -209,16 +209,14 @@ make_actor (GType shader_type)
}
static guint32
get_pixel (CoglFramebuffer *fb,
int x,
int y)
get_pixel (int x, int y)
{
guint8 data[4];
cogl_framebuffer_read_pixels (fb,
x, y, 1, 1,
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
data);
cogl_read_pixels (x, y, 1, 1,
COGL_READ_PIXELS_COLOR_BUFFER,
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
data);
return (((guint32) data[0] << 16) |
((guint32) data[1] << 8) |
@@ -226,21 +224,19 @@ get_pixel (CoglFramebuffer *fb,
}
static void
view_painted_cb (ClutterStage *stage,
ClutterStageView *view,
gpointer data)
paint_cb (ClutterStage *stage,
gpointer data)
{
CoglFramebuffer *fb = clutter_stage_view_get_framebuffer (view);
gboolean *was_painted = data;
/* old shader effect */
g_assert_cmpint (get_pixel (fb, 0, 25), ==, 0xff0000);
g_assert_cmpint (get_pixel (0, 25), ==, 0xff0000);
/* new shader effect */
g_assert_cmpint (get_pixel (fb, 100, 25), ==, 0x00ffff);
g_assert_cmpint (get_pixel (100, 25), ==, 0x00ffff);
/* another new shader effect */
g_assert_cmpint (get_pixel (fb, 200, 25), ==, 0xff00ff);
g_assert_cmpint (get_pixel (200, 25), ==, 0xff00ff);
/* new shader effect */
g_assert_cmpint (get_pixel (fb, 300, 25), ==, 0x00ffff);
g_assert_cmpint (get_pixel (300, 25), ==, 0x00ffff);
*was_painted = TRUE;
}
@@ -275,9 +271,9 @@ actor_shader_effect (void)
clutter_actor_show (stage);
was_painted = FALSE;
g_signal_connect_after (stage, "paint-view",
G_CALLBACK (view_painted_cb),
&was_painted);
g_signal_connect (stage, "after-paint",
G_CALLBACK (paint_cb),
&was_painted);
while (!was_painted)
g_main_context_iteration (NULL, FALSE);

View File

@@ -199,6 +199,7 @@ test_actors_main (int argc, char *argv[])
g_signal_connect (oh->stage, "destroy", G_CALLBACK (stop_and_quit), oh);
clutter_stage_set_title (CLUTTER_STAGE (oh->stage), "Actors");
clutter_stage_set_user_resizable (CLUTTER_STAGE (oh->stage), TRUE);
/* Create a timeline to manage animation */
oh->timeline = clutter_timeline_new (6000);

View File

@@ -181,6 +181,7 @@ test_bind_constraint_main (int argc, char *argv[])
stage = clutter_stage_new ();
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
clutter_stage_set_title (CLUTTER_STAGE (stage), "Constraints");
clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE);
clutter_actor_set_size (stage, 800, 600);
/* main rectangle */

View File

@@ -91,6 +91,7 @@ test_cairo_clock_main (int argc, char *argv[])
/* create a resizable stage */
stage = clutter_stage_new ();
clutter_stage_set_title (CLUTTER_STAGE (stage), "2D Clock");
clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE);
clutter_actor_set_background_color (stage, CLUTTER_COLOR_LightSkyBlue);
clutter_actor_set_size (stage, 300, 300);
clutter_actor_show (stage);

View File

@@ -181,6 +181,7 @@ test_content_main (int argc, char *argv[])
stage = clutter_stage_new ();
clutter_actor_set_name (stage, "Stage");
clutter_stage_set_title (CLUTTER_STAGE (stage), "Content");
clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE);
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
clutter_actor_show (stage);

View File

@@ -2,7 +2,7 @@
#include <clutter/clutter.h>
#include <string.h>
gboolean IsMotion = TRUE;
gboolean IsFullScreen = FALSE, IsMotion = TRUE;
int
test_events_main (int argc, char *argv[]);
@@ -114,6 +114,28 @@ stage_state_cb (ClutterStage *stage,
printf("[stage signal] %s\n", detail);
}
static gboolean
blue_button_cb (ClutterActor *actor,
ClutterEvent *event,
gpointer data)
{
ClutterActor *stage;
stage = clutter_actor_get_stage (actor);
if (IsFullScreen)
IsFullScreen = FALSE;
else
IsFullScreen = TRUE;
clutter_stage_set_fullscreen (CLUTTER_STAGE (stage), IsFullScreen);
g_print ("*** Fullscreen %s ***\n",
IsFullScreen ? "enabled" : "disabled");
return FALSE;
}
static gboolean
red_button_cb (ClutterActor *actor,
ClutterEvent *event,
@@ -407,6 +429,10 @@ test_events_main (int argc, char *argv[])
clutter_actor_set_name (stage, "Stage");
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
g_signal_connect (stage, "event", G_CALLBACK (input_cb), (char *) "stage");
g_signal_connect (stage, "fullscreen",
G_CALLBACK (stage_state_cb), (char *) "fullscreen");
g_signal_connect (stage, "unfullscreen",
G_CALLBACK (stage_state_cb), (char *) "unfullscreen");
g_signal_connect (stage, "activate",
G_CALLBACK (stage_state_cb), (char *) "activate");
g_signal_connect (stage, "deactivate",
@@ -442,6 +468,19 @@ test_events_main (int argc, char *argv[])
focus_box);
g_signal_connect (actor, "captured-event", G_CALLBACK (capture_cb), NULL);
actor = clutter_rectangle_new_with_color (CLUTTER_COLOR_Blue);
clutter_actor_set_name (actor, "Blue Box");
clutter_actor_set_size (actor, 100, 100);
clutter_actor_set_position (actor, 400, 100);
clutter_actor_set_reactive (actor, TRUE);
clutter_container_add (CLUTTER_CONTAINER(stage), actor, NULL);
g_signal_connect (actor, "event", G_CALLBACK (input_cb), (char *) "blue box");
g_signal_connect (actor, "key-focus-in", G_CALLBACK (key_focus_in_cb),
focus_box);
/* Fullscreen */
g_signal_connect (actor, "button-press-event",
G_CALLBACK (blue_button_cb), NULL);
/* non reactive */
actor = clutter_rectangle_new_with_color (CLUTTER_COLOR_Black);
clutter_actor_set_name (actor, "Black Box");

View File

@@ -218,6 +218,10 @@ test_grab_main (int argc, char *argv[])
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
g_signal_connect (stage, "event",
G_CALLBACK (debug_event_cb), (char *) "stage");
g_signal_connect (stage, "fullscreen",
G_CALLBACK (stage_state_cb), (char *) "fullscreen");
g_signal_connect (stage, "unfullscreen",
G_CALLBACK (stage_state_cb), (char *) "unfullscreen");
g_signal_connect (stage, "activate",
G_CALLBACK (stage_state_cb), (char *) "activate");
g_signal_connect (stage, "deactivate",

View File

@@ -189,6 +189,7 @@ test_image_main (int argc, char *argv[])
stage = clutter_stage_new ();
clutter_actor_set_name (stage, "Stage");
clutter_stage_set_title (CLUTTER_STAGE (stage), "Content");
clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE);
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
clutter_actor_show (stage);

View File

@@ -73,6 +73,7 @@ test_rotate_zoom_main (int argc, char *argv[])
stage = clutter_stage_new ();
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
clutter_stage_set_title (CLUTTER_STAGE (stage), "Rotate and Zoom actions");
clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE);
clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT);
clutter_actor_set_reactive (stage, FALSE);
clutter_actor_show (stage);

View File

@@ -8,6 +8,21 @@ test_stage_sizing_main (int argc, char *argv[]);
const char *
test_stage_sizing_describe (void);
static gboolean
fullscreen_clicked_cb (ClutterStage *stage)
{
clutter_stage_set_fullscreen (stage, !clutter_stage_get_fullscreen (stage));
return CLUTTER_EVENT_STOP;
}
static gboolean
resize_clicked_cb (ClutterStage *stage)
{
clutter_stage_set_user_resizable (stage,
!clutter_stage_get_user_resizable (stage));
return CLUTTER_EVENT_STOP;
}
static gboolean
shrink_clicked_cb (ClutterActor *stage)
{
@@ -26,6 +41,22 @@ expand_clicked_cb (ClutterActor *stage)
return CLUTTER_EVENT_STOP;
}
static void
on_fullscreen (ClutterStage *stage)
{
float width, height;
gboolean is_fullscreen;
is_fullscreen = clutter_stage_get_fullscreen (stage);
clutter_actor_get_size (CLUTTER_ACTOR (stage), &width, &height);
g_print ("Stage size [%s]: %d x %d\n",
is_fullscreen ? "fullscreen" : "not fullscreen",
(int) width,
(int) height);
}
G_MODULE_EXPORT int
test_stage_sizing_main (int argc, char *argv[])
{
@@ -38,12 +69,40 @@ test_stage_sizing_main (int argc, char *argv[])
stage = clutter_stage_new ();
clutter_stage_set_title (CLUTTER_STAGE (stage), "Stage Sizing");
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
g_signal_connect_after (stage, "notify::fullscreen-set", G_CALLBACK (on_fullscreen), NULL);
box = clutter_actor_new ();
clutter_actor_set_layout_manager (box, clutter_box_layout_new ());
clutter_actor_add_constraint (box, clutter_align_constraint_new (stage, CLUTTER_ALIGN_BOTH, 0.5));
clutter_actor_add_child (stage, box);
rect = clutter_actor_new ();
clutter_actor_set_layout_manager (rect,
clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
CLUTTER_BIN_ALIGNMENT_CENTER));
clutter_actor_set_background_color (rect, CLUTTER_COLOR_LightScarletRed);
clutter_actor_set_reactive (rect, TRUE);
g_signal_connect_swapped (rect, "button-press-event",
G_CALLBACK (fullscreen_clicked_cb),
stage);
label = clutter_text_new_with_text ("Sans 16", "Toggle fullscreen");
clutter_actor_set_margin (label, &margin);
clutter_actor_add_child (rect, label);
clutter_actor_add_child (box, rect);
rect = clutter_actor_new ();
clutter_actor_set_layout_manager (rect,
clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
CLUTTER_BIN_ALIGNMENT_CENTER));
clutter_actor_set_background_color (rect, CLUTTER_COLOR_Chameleon);
clutter_actor_set_reactive (rect, TRUE);
g_signal_connect_swapped (rect, "button-press-event",
G_CALLBACK (resize_clicked_cb), stage);
label = clutter_text_new_with_text ("Sans 16", "Toggle resizable");
clutter_actor_set_margin (label, &margin);
clutter_actor_add_child (rect, label);
clutter_actor_add_child (box, rect);
rect = clutter_actor_new ();
clutter_actor_set_layout_manager (rect,
clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,

View File

@@ -28,6 +28,7 @@ test_state_script_main (int argc, char *argv[])
stage = clutter_stage_new ();
clutter_stage_set_title (CLUTTER_STAGE (stage), "State Script");
clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE);
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
clutter_actor_show (stage);

View File

@@ -179,6 +179,7 @@ test_table_layout_main (int argc, char *argv[])
stage = clutter_stage_new ();
clutter_stage_set_title (CLUTTER_STAGE (stage), "Table Layout");
clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE);
clutter_actor_set_size (stage, 640, 480);
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);

View File

@@ -146,6 +146,7 @@ test_touch_events_main (int argc, char *argv[])
stage = clutter_stage_new ();
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
clutter_stage_set_title (CLUTTER_STAGE (stage), "Touch events");
clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE);
clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT);
clutter_actor_set_reactive (stage, TRUE);
clutter_actor_show (stage);

View File

@@ -94,7 +94,7 @@ cogl_pango_font_map_new (void)
PangoContext *
cogl_pango_font_map_create_context (CoglPangoFontMap *fm)
{
g_return_val_if_fail (COGL_PANGO_IS_FONT_MAP (fm), NULL);
_COGL_RETURN_VAL_IF_FAIL (COGL_PANGO_IS_FONT_MAP (fm), NULL);
#if PANGO_VERSION_CHECK (1, 22, 0)
/* We can just directly use the pango context from the Cairo font
@@ -138,7 +138,7 @@ void
cogl_pango_font_map_set_resolution (CoglPangoFontMap *font_map,
double dpi)
{
g_return_if_fail (COGL_PANGO_IS_FONT_MAP (font_map));
_COGL_RETURN_IF_FAIL (COGL_PANGO_IS_FONT_MAP (font_map));
pango_cairo_font_map_set_resolution (PANGO_CAIRO_FONT_MAP (font_map), dpi);
}

View File

@@ -217,7 +217,7 @@ cogl_pango_glyph_cache_add_to_global_atlas (CoglPangoGlyphCache *cache,
CoglPangoGlyphCacheValue *value)
{
CoglAtlasTexture *texture;
GError *ignore_error = NULL;
CoglError *ignore_error = NULL;
if (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_SHARED_ATLAS))
return FALSE;
@@ -232,7 +232,7 @@ cogl_pango_glyph_cache_add_to_global_atlas (CoglPangoGlyphCache *cache,
value->draw_height);
if (!cogl_texture_allocate (COGL_TEXTURE (texture), &ignore_error))
{
g_error_free (ignore_error);
cogl_error_free (ignore_error);
return FALSE;
}

View File

@@ -153,7 +153,7 @@ cogl_pango_renderer_draw_glyph (CoglPangoRenderer *priv,
{
CoglPangoRendererSliceCbData data;
g_return_if_fail (priv->display_list != NULL);
_COGL_RETURN_IF_FAIL (priv->display_list != NULL);
data.display_list = priv->display_list;
data.x1 = x1;
@@ -577,7 +577,7 @@ cogl_pango_renderer_set_dirty_glyph (PangoFont *font,
/* Glyphs that don't take up any space will end up without a
texture. These should never become dirty so they shouldn't end up
here */
g_return_if_fail (value->texture != NULL);
_COGL_RETURN_IF_FAIL (value->texture != NULL);
if (_cogl_texture_get_format (value->texture) == COGL_PIXEL_FORMAT_A_8)
{
@@ -705,7 +705,7 @@ cogl_pango_ensure_glyph_cache_for_layout (PangoLayout *layout)
context = pango_layout_get_context (layout);
priv = cogl_pango_get_renderer_from_context (context);
g_return_if_fail (PANGO_IS_LAYOUT (layout));
_COGL_RETURN_IF_FAIL (PANGO_IS_LAYOUT (layout));
if ((iter = pango_layout_get_iter (layout)) == NULL)
return;
@@ -759,7 +759,7 @@ cogl_pango_renderer_draw_box (PangoRenderer *renderer,
{
CoglPangoRenderer *priv = COGL_PANGO_RENDERER (renderer);
g_return_if_fail (priv->display_list != NULL);
_COGL_RETURN_IF_FAIL (priv->display_list != NULL);
_cogl_pango_display_list_add_rectangle (priv->display_list,
x,
@@ -803,7 +803,7 @@ cogl_pango_renderer_draw_rectangle (PangoRenderer *renderer,
CoglPangoRenderer *priv = COGL_PANGO_RENDERER (renderer);
float x1, x2, y1, y2;
g_return_if_fail (priv->display_list != NULL);
_COGL_RETURN_IF_FAIL (priv->display_list != NULL);
cogl_pango_renderer_set_color_for_part (renderer, part);
@@ -830,7 +830,7 @@ cogl_pango_renderer_draw_trapezoid (PangoRenderer *renderer,
{
CoglPangoRenderer *priv = COGL_PANGO_RENDERER (renderer);
g_return_if_fail (priv->display_list != NULL);
_COGL_RETURN_IF_FAIL (priv->display_list != NULL);
cogl_pango_renderer_set_color_for_part (renderer, part);

View File

@@ -9,7 +9,7 @@ G_BEGIN_DECLS
/*** END file-header ***/
/*** BEGIN file-production ***/
/* enumerations from "@basename@" */
/* enumerations from "@filename@" */
/*** END file-production ***/
/*** BEGIN file-tail ***/

View File

@@ -149,7 +149,7 @@ void
cogl2_path_set_fill_rule (CoglPath *path,
CoglPathFillRule fill_rule)
{
g_return_if_fail (cogl_is_path (path));
_COGL_RETURN_IF_FAIL (cogl_is_path (path));
if (path->data->fill_rule != fill_rule)
{
@@ -162,7 +162,7 @@ cogl2_path_set_fill_rule (CoglPath *path,
CoglPathFillRule
cogl2_path_get_fill_rule (CoglPath *path)
{
g_return_val_if_fail (cogl_is_path (path), COGL_PATH_FILL_RULE_NON_ZERO);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_path (path), COGL_PATH_FILL_RULE_NON_ZERO);
return path->data->fill_rule;
}
@@ -225,9 +225,9 @@ _cogl_path_stroke_nodes (CoglPath *path,
int path_num = 0;
CoglPathNode *node;
g_return_if_fail (cogl_is_path (path));
g_return_if_fail (cogl_is_framebuffer (framebuffer));
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_path (path));
_COGL_RETURN_IF_FAIL (cogl_is_framebuffer (framebuffer));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
data = path->data;
@@ -392,7 +392,7 @@ _cogl_path_fill_nodes (CoglPath *path,
void
cogl2_path_fill (CoglPath *path)
{
g_return_if_fail (cogl_is_path (path));
_COGL_RETURN_IF_FAIL (cogl_is_path (path));
_cogl_path_fill_nodes (path,
cogl_get_draw_framebuffer (),
@@ -407,7 +407,7 @@ cogl2_path_fill (CoglPath *path)
void
cogl2_path_stroke (CoglPath *path)
{
g_return_if_fail (cogl_is_path (path));
_COGL_RETURN_IF_FAIL (cogl_is_path (path));
if (path->data->path_nodes->len == 0)
return;
@@ -424,7 +424,7 @@ cogl2_path_move_to (CoglPath *path,
{
CoglPathData *data;
g_return_if_fail (cogl_is_path (path));
_COGL_RETURN_IF_FAIL (cogl_is_path (path));
_cogl_path_add_node (path, TRUE, x, y);
@@ -443,7 +443,7 @@ cogl2_path_rel_move_to (CoglPath *path,
{
CoglPathData *data;
g_return_if_fail (cogl_is_path (path));
_COGL_RETURN_IF_FAIL (cogl_is_path (path));
data = path->data;
@@ -459,7 +459,7 @@ cogl2_path_line_to (CoglPath *path,
{
CoglPathData *data;
g_return_if_fail (cogl_is_path (path));
_COGL_RETURN_IF_FAIL (cogl_is_path (path));
_cogl_path_add_node (path, FALSE, x, y);
@@ -476,7 +476,7 @@ cogl2_path_rel_line_to (CoglPath *path,
{
CoglPathData *data;
g_return_if_fail (cogl_is_path (path));
_COGL_RETURN_IF_FAIL (cogl_is_path (path));
data = path->data;
@@ -488,7 +488,7 @@ cogl2_path_rel_line_to (CoglPath *path,
void
cogl2_path_close (CoglPath *path)
{
g_return_if_fail (cogl_is_path (path));
_COGL_RETURN_IF_FAIL (cogl_is_path (path));
_cogl_path_add_node (path, FALSE, path->data->path_start.x,
path->data->path_start.y);
@@ -514,7 +514,7 @@ cogl2_path_polyline (CoglPath *path,
{
int c = 0;
g_return_if_fail (cogl_is_path (path));
_COGL_RETURN_IF_FAIL (cogl_is_path (path));
cogl2_path_move_to (path, coords[0], coords[1]);
@@ -639,7 +639,7 @@ cogl2_path_arc (CoglPath *path,
{
float angle_step = 10;
g_return_if_fail (cogl_is_path (path));
_COGL_RETURN_IF_FAIL (cogl_is_path (path));
/* it is documented that a move to is needed to create a freestanding
* arc
@@ -683,7 +683,7 @@ cogl2_path_ellipse (CoglPath *path,
{
float angle_step = 10;
g_return_if_fail (cogl_is_path (path));
_COGL_RETURN_IF_FAIL (cogl_is_path (path));
/* FIXME: if shows to be slow might be optimized
* by mirroring just a quarter of it */
@@ -709,7 +709,7 @@ cogl2_path_round_rectangle (CoglPath *path,
float inner_width = x_2 - x_1 - radius * 2;
float inner_height = y_2 - y_1 - radius * 2;
g_return_if_fail (cogl_is_path (path));
_COGL_RETURN_IF_FAIL (cogl_is_path (path));
cogl2_path_move_to (path, x_1, y_1 + radius);
_cogl_path_rel_arc (path,
@@ -860,7 +860,7 @@ cogl2_path_curve_to (CoglPath *path,
{
CoglBezCubic cubic;
g_return_if_fail (cogl_is_path (path));
_COGL_RETURN_IF_FAIL (cogl_is_path (path));
/* Prepare cubic curve */
cubic.p1 = path->data->path_pen;
@@ -890,7 +890,7 @@ cogl2_path_rel_curve_to (CoglPath *path,
{
CoglPathData *data;
g_return_if_fail (cogl_is_path (path));
_COGL_RETURN_IF_FAIL (cogl_is_path (path));
data = path->data;
@@ -932,7 +932,7 @@ cogl_path_copy (CoglPath *old_path)
{
CoglPath *new_path;
g_return_val_if_fail (cogl_is_path (old_path), NULL);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_path (old_path), NULL);
new_path = g_slice_new (CoglPath);
new_path->data = old_path->data;
@@ -1053,7 +1053,7 @@ cogl_rel_curve2_to (CoglPath *path,
{
CoglPathData *data;
g_return_if_fail (cogl_is_path (path));
_COGL_RETURN_IF_FAIL (cogl_is_path (path));
data = path->data;
@@ -1579,9 +1579,9 @@ cogl_framebuffer_fill_path (CoglFramebuffer *framebuffer,
CoglPipeline *pipeline,
CoglPath *path)
{
g_return_if_fail (cogl_is_framebuffer (framebuffer));
g_return_if_fail (cogl_is_pipeline (pipeline));
g_return_if_fail (cogl_is_path (path));
_COGL_RETURN_IF_FAIL (cogl_is_framebuffer (framebuffer));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_path (path));
_cogl_path_fill_nodes (path, framebuffer, pipeline, 0 /* flags */);
}
@@ -1591,9 +1591,9 @@ cogl_framebuffer_stroke_path (CoglFramebuffer *framebuffer,
CoglPipeline *pipeline,
CoglPath *path)
{
g_return_if_fail (cogl_is_framebuffer (framebuffer));
g_return_if_fail (cogl_is_pipeline (pipeline));
g_return_if_fail (cogl_is_path (path));
_COGL_RETURN_IF_FAIL (cogl_is_framebuffer (framebuffer));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_path (path));
_cogl_path_stroke_nodes (path, framebuffer, pipeline);
}

View File

@@ -47,6 +47,7 @@
#include "cogl-atlas.h"
#include "cogl1-context.h"
#include "cogl-sub-texture.h"
#include "cogl-error-private.h"
#include "cogl-gtype-private.h"
#include "driver/gl/cogl-pipeline-opengl-private.h"
#include "driver/gl/cogl-texture-gl-private.h"
@@ -452,7 +453,7 @@ _cogl_atlas_texture_set_region_with_border (CoglAtlasTexture *atlas_tex,
int dst_width,
int dst_height,
CoglBitmap *bmp,
GError **error)
CoglError **error)
{
CoglAtlas *atlas = atlas_tex->atlas;
@@ -523,7 +524,7 @@ _cogl_atlas_texture_convert_bitmap_for_upload (CoglAtlasTexture *atlas_tex,
CoglBitmap *bmp,
CoglPixelFormat internal_format,
gboolean can_convert_in_place,
GError **error)
CoglError **error)
{
CoglBitmap *upload_bmp;
CoglBitmap *override_bmp;
@@ -573,7 +574,7 @@ _cogl_atlas_texture_set_region (CoglTexture *tex,
int dst_height,
int level,
CoglBitmap *bmp,
GError **error)
CoglError **error)
{
CoglAtlasTexture *atlas_tex = COGL_ATLAS_TEXTURE (tex);
@@ -693,7 +694,7 @@ cogl_atlas_texture_new_with_size (CoglContext *ctx,
/* We can't atlas zero-sized textures because it breaks the atlas
* data structure */
g_return_val_if_fail (width > 0 && height > 0, NULL);
_COGL_RETURN_VAL_IF_FAIL (width > 0 && height > 0, NULL);
loader = _cogl_texture_create_loader ();
loader->src_type = COGL_TEXTURE_SOURCE_TYPE_SIZED;
@@ -710,7 +711,7 @@ allocate_space (CoglAtlasTexture *atlas_tex,
int width,
int height,
CoglPixelFormat internal_format,
GError **error)
CoglError **error)
{
CoglTexture *tex = COGL_TEXTURE (atlas_tex);
CoglContext *ctx = tex->context;
@@ -722,10 +723,10 @@ allocate_space (CoglAtlasTexture *atlas_tex,
{
COGL_NOTE (ATLAS, "Texture can not be added because the "
"format is unsupported");
g_set_error_literal (error,
COGL_TEXTURE_ERROR,
COGL_TEXTURE_ERROR_FORMAT,
"Texture format unsuitable for atlasing");
_cogl_set_error (error,
COGL_TEXTURE_ERROR,
COGL_TEXTURE_ERROR_FORMAT,
"Texture format unsuitable for atlasing");
return FALSE;
}
@@ -733,11 +734,11 @@ allocate_space (CoglAtlasTexture *atlas_tex,
and we shouldn't use the atlas */
if (!cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN))
{
g_set_error_literal (error,
COGL_SYSTEM_ERROR,
COGL_SYSTEM_ERROR_UNSUPPORTED,
"Atlasing disabled because migrations "
"would be too slow");
_cogl_set_error (error,
COGL_SYSTEM_ERROR,
COGL_SYSTEM_ERROR_UNSUPPORTED,
"Atlasing disabled because migrations "
"would be too slow");
return FALSE;
}
@@ -776,10 +777,10 @@ allocate_space (CoglAtlasTexture *atlas_tex,
/* Ok, this means we really can't add it to the atlas */
cogl_object_unref (atlas);
g_set_error_literal (error,
COGL_SYSTEM_ERROR,
COGL_SYSTEM_ERROR_NO_MEMORY,
"Not enough memory to atlas texture");
_cogl_set_error (error,
COGL_SYSTEM_ERROR,
COGL_SYSTEM_ERROR_NO_MEMORY,
"Not enough memory to atlas texture");
return FALSE;
}
}
@@ -794,7 +795,7 @@ allocate_space (CoglAtlasTexture *atlas_tex,
static gboolean
allocate_with_size (CoglAtlasTexture *atlas_tex,
CoglTextureLoader *loader,
GError **error)
CoglError **error)
{
CoglTexture *tex = COGL_TEXTURE (atlas_tex);
CoglPixelFormat internal_format =
@@ -819,7 +820,7 @@ allocate_with_size (CoglAtlasTexture *atlas_tex,
static gboolean
allocate_from_bitmap (CoglAtlasTexture *atlas_tex,
CoglTextureLoader *loader,
GError **error)
CoglError **error)
{
CoglTexture *tex = COGL_TEXTURE (atlas_tex);
CoglBitmap *bmp = loader->src.bitmap.bitmap;
@@ -830,7 +831,7 @@ allocate_from_bitmap (CoglAtlasTexture *atlas_tex,
CoglPixelFormat internal_format;
CoglBitmap *upload_bmp;
g_return_val_if_fail (atlas_tex->atlas == NULL, FALSE);
_COGL_RETURN_VAL_IF_FAIL (atlas_tex->atlas == NULL, FALSE);
internal_format = _cogl_texture_determine_internal_format (tex, bmp_format);
@@ -879,12 +880,12 @@ allocate_from_bitmap (CoglAtlasTexture *atlas_tex,
static gboolean
_cogl_atlas_texture_allocate (CoglTexture *tex,
GError **error)
CoglError **error)
{
CoglAtlasTexture *atlas_tex = COGL_ATLAS_TEXTURE (tex);
CoglTextureLoader *loader = tex->loader;
g_return_val_if_fail (loader, FALSE);
_COGL_RETURN_VAL_IF_FAIL (loader, FALSE);
switch (loader->src_type)
{
@@ -905,7 +906,7 @@ _cogl_atlas_texture_new_from_bitmap (CoglBitmap *bmp,
{
CoglTextureLoader *loader;
g_return_val_if_fail (cogl_is_bitmap (bmp), NULL);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_bitmap (bmp), NULL);
loader = _cogl_texture_create_loader ();
loader->src_type = COGL_TEXTURE_SOURCE_TYPE_BITMAP;
@@ -932,13 +933,13 @@ cogl_atlas_texture_new_from_data (CoglContext *ctx,
CoglPixelFormat format,
int rowstride,
const uint8_t *data,
GError **error)
CoglError **error)
{
CoglBitmap *bmp;
CoglAtlasTexture *atlas_tex;
g_return_val_if_fail (format != COGL_PIXEL_FORMAT_ANY, NULL);
g_return_val_if_fail (data != NULL, NULL);
_COGL_RETURN_VAL_IF_FAIL (format != COGL_PIXEL_FORMAT_ANY, NULL);
_COGL_RETURN_VAL_IF_FAIL (data != NULL, NULL);
/* Rowstride from width if not given */
if (rowstride == 0)
@@ -968,12 +969,12 @@ cogl_atlas_texture_new_from_data (CoglContext *ctx,
CoglAtlasTexture *
cogl_atlas_texture_new_from_file (CoglContext *ctx,
const char *filename,
GError **error)
CoglError **error)
{
CoglBitmap *bmp;
CoglAtlasTexture *atlas_tex = NULL;
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
_COGL_RETURN_VAL_IF_FAIL (error == NULL || *error == NULL, NULL);
bmp = cogl_bitmap_new_from_file (filename, error);
if (bmp == NULL)

View File

@@ -117,7 +117,7 @@ cogl_atlas_texture_new_with_size (CoglContext *ctx,
* cogl_atlas_texture_new_from_file:
* @ctx: A #CoglContext
* @filename: the file to load
* @error: A #GError to catch exceptional errors or %NULL
* @error: A #CoglError to catch exceptional errors or %NULL
*
* Creates a #CoglAtlasTexture from an image file. A #CoglAtlasTexture
* represents a sub-region within one of Cogl's shared texture
@@ -149,7 +149,7 @@ cogl_atlas_texture_new_with_size (CoglContext *ctx,
CoglAtlasTexture *
cogl_atlas_texture_new_from_file (CoglContext *ctx,
const char *filename,
GError **error);
CoglError **error);
/**
* cogl_atlas_texture_new_from_data:
@@ -161,7 +161,7 @@ cogl_atlas_texture_new_from_file (CoglContext *ctx,
* row in @data. A value of 0 will make Cogl automatically
* calculate @rowstride from @width and @format.
* @data: pointer to the memory region where the source buffer resides
* @error: A #GError to catch exceptional errors or %NULL
* @error: A #CoglError to catch exceptional errors or %NULL
*
* Creates a new #CoglAtlasTexture texture based on data residing in
* memory. A #CoglAtlasTexture represents a sub-region within one of
@@ -198,7 +198,7 @@ cogl_atlas_texture_new_from_data (CoglContext *ctx,
CoglPixelFormat format,
int rowstride,
const uint8_t *data,
GError **error);
CoglError **error);
/**
* cogl_atlas_texture_new_from_bitmap:

View File

@@ -283,7 +283,7 @@ _cogl_atlas_create_texture (CoglAtlas *atlas,
int height)
{
CoglTexture2D *tex;
GError *ignore_error = NULL;
CoglError *ignore_error = NULL;
_COGL_GET_CONTEXT (ctx, NULL);
@@ -309,7 +309,7 @@ _cogl_atlas_create_texture (CoglAtlas *atlas,
if (!cogl_texture_allocate (COGL_TEXTURE (tex), &ignore_error))
{
g_error_free (ignore_error);
cogl_error_free (ignore_error);
cogl_object_unref (tex);
tex = NULL;
}
@@ -327,7 +327,7 @@ _cogl_atlas_create_texture (CoglAtlas *atlas,
if (!cogl_texture_allocate (COGL_TEXTURE (tex), &ignore_error))
{
g_error_free (ignore_error);
cogl_error_free (ignore_error);
cogl_object_unref (tex);
tex = NULL;
}
@@ -560,7 +560,7 @@ create_migration_texture (CoglContext *ctx,
CoglPixelFormat internal_format)
{
CoglTexture *tex;
GError *skip_error = NULL;
CoglError *skip_error = NULL;
/* First try creating a fast-path non-sliced texture */
tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx, width, height));
@@ -573,7 +573,7 @@ create_migration_texture (CoglContext *ctx,
* lazily when uploading data. */
if (!cogl_texture_allocate (tex, &skip_error))
{
g_error_free (skip_error);
cogl_error_free (skip_error);
cogl_object_unref (tex);
tex = NULL;
}
@@ -605,7 +605,7 @@ _cogl_atlas_copy_rectangle (CoglAtlas *atlas,
{
CoglTexture *tex;
CoglBlitData blit_data;
GError *ignore_error = NULL;
CoglError *ignore_error = NULL;
_COGL_GET_CONTEXT (ctx, NULL);
@@ -613,7 +613,7 @@ _cogl_atlas_copy_rectangle (CoglAtlas *atlas,
tex = create_migration_texture (ctx, width, height, internal_format);
if (!cogl_texture_allocate (tex, &ignore_error))
{
g_error_free (ignore_error);
cogl_error_free (ignore_error);
cogl_object_unref (tex);
return NULL;
}

View File

@@ -71,7 +71,7 @@ cogl_attribute_buffer_new (CoglContext *context,
buffer = cogl_attribute_buffer_new_with_size (context, bytes);
/* Note: to keep the common cases simple this API doesn't throw
* GErrors, so developers can assume this function never returns
* CoglErrors, so developers can assume this function never returns
* NULL and we will simply abort on error.
*
* Developers wanting to catch errors can use

View File

@@ -309,7 +309,7 @@ _cogl_attribute_new_const (CoglContext *context,
/* FIXME: Up until GL[ES] 3 only square matrices were supported
* and we don't currently expose non-square matrices in Cogl.
*/
g_return_val_if_fail (n_columns == n_components, NULL);
_COGL_RETURN_VAL_IF_FAIL (n_columns == n_components, NULL);
_cogl_boxed_value_set_matrix (&attribute->d.constant.boxed,
n_columns,
1,
@@ -469,7 +469,7 @@ cogl_attribute_new_const_4x4fv (CoglContext *context,
gboolean
cogl_attribute_get_normalized (CoglAttribute *attribute)
{
g_return_val_if_fail (cogl_is_attribute (attribute), FALSE);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_attribute (attribute), FALSE);
return attribute->normalized;
}
@@ -490,7 +490,7 @@ void
cogl_attribute_set_normalized (CoglAttribute *attribute,
gboolean normalized)
{
g_return_if_fail (cogl_is_attribute (attribute));
_COGL_RETURN_IF_FAIL (cogl_is_attribute (attribute));
if (G_UNLIKELY (attribute->immutable_ref))
warn_about_midscene_changes ();
@@ -501,8 +501,8 @@ cogl_attribute_set_normalized (CoglAttribute *attribute,
CoglAttributeBuffer *
cogl_attribute_get_buffer (CoglAttribute *attribute)
{
g_return_val_if_fail (cogl_is_attribute (attribute), NULL);
g_return_val_if_fail (attribute->is_buffered, NULL);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_attribute (attribute), NULL);
_COGL_RETURN_VAL_IF_FAIL (attribute->is_buffered, NULL);
return attribute->d.buffered.attribute_buffer;
}
@@ -511,8 +511,8 @@ void
cogl_attribute_set_buffer (CoglAttribute *attribute,
CoglAttributeBuffer *attribute_buffer)
{
g_return_if_fail (cogl_is_attribute (attribute));
g_return_if_fail (attribute->is_buffered);
_COGL_RETURN_IF_FAIL (cogl_is_attribute (attribute));
_COGL_RETURN_IF_FAIL (attribute->is_buffered);
if (G_UNLIKELY (attribute->immutable_ref))
warn_about_midscene_changes ();
@@ -528,7 +528,7 @@ _cogl_attribute_immutable_ref (CoglAttribute *attribute)
{
CoglBuffer *buffer = COGL_BUFFER (attribute->d.buffered.attribute_buffer);
g_return_val_if_fail (cogl_is_attribute (attribute), NULL);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_attribute (attribute), NULL);
attribute->immutable_ref++;
_cogl_buffer_immutable_ref (buffer);
@@ -540,8 +540,8 @@ _cogl_attribute_immutable_unref (CoglAttribute *attribute)
{
CoglBuffer *buffer = COGL_BUFFER (attribute->d.buffered.attribute_buffer);
g_return_if_fail (cogl_is_attribute (attribute));
g_return_if_fail (attribute->immutable_ref > 0);
_COGL_RETURN_IF_FAIL (cogl_is_attribute (attribute));
_COGL_RETURN_IF_FAIL (attribute->immutable_ref > 0);
attribute->immutable_ref--;
_cogl_buffer_immutable_unref (buffer);

View File

@@ -361,7 +361,7 @@ _cogl_bitmap_needs_short_temp_buffer (CoglPixelFormat format)
gboolean
_cogl_bitmap_convert_into_bitmap (CoglBitmap *src_bmp,
CoglBitmap *dst_bmp,
GError **error)
CoglError **error)
{
uint8_t *src_data;
uint8_t *dst_data;
@@ -384,8 +384,8 @@ _cogl_bitmap_convert_into_bitmap (CoglBitmap *src_bmp,
width = cogl_bitmap_get_width (src_bmp);
height = cogl_bitmap_get_height (src_bmp);
g_return_val_if_fail (width == cogl_bitmap_get_width (dst_bmp), FALSE);
g_return_val_if_fail (height == cogl_bitmap_get_height (dst_bmp), FALSE);
_COGL_RETURN_VAL_IF_FAIL (width == cogl_bitmap_get_width (dst_bmp), FALSE);
_COGL_RETURN_VAL_IF_FAIL (height == cogl_bitmap_get_height (dst_bmp), FALSE);
need_premult
= ((src_format & COGL_PREMULT_BIT) != (dst_format & COGL_PREMULT_BIT) &&
@@ -488,7 +488,7 @@ _cogl_bitmap_convert_into_bitmap (CoglBitmap *src_bmp,
CoglBitmap *
_cogl_bitmap_convert (CoglBitmap *src_bmp,
CoglPixelFormat dst_format,
GError **error)
CoglError **error)
{
CoglBitmap *dst_bmp;
int width, height;
@@ -547,13 +547,13 @@ CoglBitmap *
_cogl_bitmap_convert_for_upload (CoglBitmap *src_bmp,
CoglPixelFormat internal_format,
gboolean can_convert_in_place,
GError **error)
CoglError **error)
{
CoglContext *ctx = _cogl_bitmap_get_context (src_bmp);
CoglPixelFormat src_format = cogl_bitmap_get_format (src_bmp);
CoglBitmap *dst_bmp;
g_return_val_if_fail (internal_format != COGL_PIXEL_FORMAT_ANY, NULL);
_COGL_RETURN_VAL_IF_FAIL (internal_format != COGL_PIXEL_FORMAT_ANY, NULL);
/* OpenGL supports specifying a different format for the internal
format when uploading texture data. We should use this to convert
@@ -616,7 +616,7 @@ _cogl_bitmap_convert_for_upload (CoglBitmap *src_bmp,
gboolean
_cogl_bitmap_unpremult (CoglBitmap *bmp,
GError **error)
CoglError **error)
{
uint8_t *p, *data;
uint16_t *tmp_row;
@@ -684,7 +684,7 @@ _cogl_bitmap_unpremult (CoglBitmap *bmp,
gboolean
_cogl_bitmap_premult (CoglBitmap *bmp,
GError **error)
CoglError **error)
{
uint8_t *p, *data;
uint16_t *tmp_row;

View File

@@ -34,6 +34,7 @@
#include "cogl-bitmap-private.h"
#include "cogl-context-private.h"
#include "cogl-private.h"
#include "cogl-error-private.h"
#include <string.h>
@@ -44,7 +45,7 @@ _cogl_bitmap_get_size_from_file (const char *filename,
int *width,
int *height)
{
g_return_val_if_fail (filename != NULL, FALSE);
_COGL_RETURN_VAL_IF_FAIL (filename != NULL, FALSE);
if (gdk_pixbuf_get_file_info (filename, width, height) != NULL)
return TRUE;
@@ -55,7 +56,7 @@ _cogl_bitmap_get_size_from_file (const char *filename,
CoglBitmap *
_cogl_bitmap_from_file (CoglContext *ctx,
const char *filename,
GError **error)
CoglError **error)
{
static CoglUserDataKey pixbuf_key;
GdkPixbuf *pixbuf;
@@ -74,7 +75,7 @@ _cogl_bitmap_from_file (CoglContext *ctx,
pixbuf = gdk_pixbuf_new_from_file (filename, &glib_error);
if (pixbuf == NULL)
{
g_propagate_error (error, glib_error);
_cogl_propagate_gerror (error, glib_error);
return FALSE;
}

View File

@@ -70,7 +70,7 @@ struct _CoglBitmap
* @width: width of the bitmap in pixels
* @height: height of the bitmap in pixels
* @format: the format of the pixels the array will store
* @error: A #GError for catching exceptional errors or %NULL
* @error: A #CoglError for catching exceptional errors or %NULL
*
* This is equivalent to cogl_bitmap_new_with_size() except that it
* allocated the buffer using g_malloc() instead of creating a
@@ -87,7 +87,7 @@ _cogl_bitmap_new_with_malloc_buffer (CoglContext *context,
unsigned int width,
unsigned int height,
CoglPixelFormat format,
GError **error);
CoglError **error);
/* The idea of this function is that it will create a bitmap that
shares the actual data with another bitmap. This is needed for the
@@ -103,53 +103,53 @@ _cogl_bitmap_new_shared (CoglBitmap *shared_bmp,
CoglBitmap *
_cogl_bitmap_convert (CoglBitmap *bmp,
CoglPixelFormat dst_format,
GError **error);
CoglPixelFormat dst_format,
CoglError **error);
CoglBitmap *
_cogl_bitmap_convert_for_upload (CoglBitmap *src_bmp,
CoglPixelFormat internal_format,
gboolean can_convert_in_place,
GError **error);
CoglError **error);
gboolean
_cogl_bitmap_convert_into_bitmap (CoglBitmap *src_bmp,
CoglBitmap *dst_bmp,
GError **error);
CoglError **error);
CoglBitmap *
_cogl_bitmap_from_file (CoglContext *ctx,
const char *filename,
GError **error);
CoglError **error);
gboolean
_cogl_bitmap_unpremult (CoglBitmap *dst_bmp,
GError **error);
CoglError **error);
gboolean
_cogl_bitmap_premult (CoglBitmap *dst_bmp,
GError **error);
CoglError **error);
gboolean
_cogl_bitmap_convert_premult_status (CoglBitmap *bmp,
CoglPixelFormat dst_format,
GError **error);
CoglError **error);
gboolean
_cogl_bitmap_copy_subregion (CoglBitmap *src,
CoglBitmap *dst,
int src_x,
int src_y,
int dst_x,
int dst_y,
int width,
int height,
GError **error);
CoglBitmap *dst,
int src_x,
int src_y,
int dst_x,
int dst_y,
int width,
int height,
CoglError **error);
/* Creates a deep copy of the source bitmap */
CoglBitmap *
_cogl_bitmap_copy (CoglBitmap *src_bmp,
GError **error);
CoglError **error);
gboolean
_cogl_bitmap_get_size_from_file (const char *filename,
@@ -172,7 +172,7 @@ uint8_t *
_cogl_bitmap_map (CoglBitmap *bitmap,
CoglBufferAccess access,
CoglBufferMapHint hints,
GError **error);
CoglError **error);
void
_cogl_bitmap_unmap (CoglBitmap *bitmap);
@@ -190,7 +190,7 @@ uint8_t *
_cogl_bitmap_gl_bind (CoglBitmap *bitmap,
CoglBufferAccess access,
CoglBufferMapHint hints,
GError **error);
CoglError **error);
void
_cogl_bitmap_gl_unbind (CoglBitmap *bitmap);

View File

@@ -37,6 +37,7 @@
#include "cogl-buffer-private.h"
#include "cogl-pixel-buffer.h"
#include "cogl-context-private.h"
#include "cogl-error-private.h"
#include "cogl-gtype-private.h"
#include "driver/gl/cogl-buffer-gl-private.h"
@@ -65,7 +66,7 @@ _cogl_bitmap_free (CoglBitmap *bmp)
gboolean
_cogl_bitmap_convert_premult_status (CoglBitmap *bmp,
CoglPixelFormat dst_format,
GError **error)
CoglError **error)
{
/* Do we need to unpremultiply? */
if ((bmp->format & COGL_PREMULT_BIT) > 0 &&
@@ -85,7 +86,7 @@ _cogl_bitmap_convert_premult_status (CoglBitmap *bmp,
CoglBitmap *
_cogl_bitmap_copy (CoglBitmap *src_bmp,
GError **error)
CoglError **error)
{
CoglBitmap *dst_bmp;
CoglPixelFormat src_format = cogl_bitmap_get_format (src_bmp);
@@ -123,7 +124,7 @@ _cogl_bitmap_copy_subregion (CoglBitmap *src,
int dst_y,
int width,
int height,
GError **error)
CoglError **error)
{
uint8_t *srcdata;
uint8_t *dstdata;
@@ -132,9 +133,9 @@ _cogl_bitmap_copy_subregion (CoglBitmap *src,
gboolean succeeded = FALSE;
/* Intended only for fast copies when format is equal! */
g_return_val_if_fail ((src->format & ~COGL_PREMULT_BIT) ==
(dst->format & ~COGL_PREMULT_BIT),
FALSE);
_COGL_RETURN_VAL_IF_FAIL ((src->format & ~COGL_PREMULT_BIT) ==
(dst->format & ~COGL_PREMULT_BIT),
FALSE);
bpp = _cogl_pixel_format_get_bytes_per_pixel (src->format);
@@ -208,7 +209,7 @@ _cogl_bitmap_new_with_malloc_buffer (CoglContext *context,
unsigned int width,
unsigned int height,
CoglPixelFormat format,
GError **error)
CoglError **error)
{
static CoglUserDataKey bitmap_free_key;
int bpp = _cogl_pixel_format_get_bytes_per_pixel (format);
@@ -218,9 +219,10 @@ _cogl_bitmap_new_with_malloc_buffer (CoglContext *context,
if (!data)
{
g_set_error_literal (error, COGL_SYSTEM_ERROR,
COGL_SYSTEM_ERROR_NO_MEMORY,
"Failed to allocate memory for bitmap");
_cogl_set_error (error,
COGL_SYSTEM_ERROR,
COGL_SYSTEM_ERROR_NO_MEMORY,
"Failed to allocate memory for bitmap");
return NULL;
}
@@ -259,12 +261,12 @@ _cogl_bitmap_new_shared (CoglBitmap *shared_bmp,
CoglBitmap *
cogl_bitmap_new_from_file (const char *filename,
GError **error)
CoglError **error)
{
_COGL_GET_CONTEXT (ctx, NULL);
g_return_val_if_fail (filename != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
_COGL_RETURN_VAL_IF_FAIL (filename != NULL, NULL);
_COGL_RETURN_VAL_IF_FAIL (error == NULL || *error == NULL, NULL);
return _cogl_bitmap_from_file (ctx, filename, error);
}
@@ -279,7 +281,7 @@ cogl_bitmap_new_from_buffer (CoglBuffer *buffer,
{
CoglBitmap *bmp;
g_return_val_if_fail (cogl_is_buffer (buffer), NULL);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_buffer (buffer), NULL);
bmp = cogl_bitmap_new_for_data (buffer->context,
width, height,
@@ -304,7 +306,7 @@ cogl_bitmap_new_with_size (CoglContext *context,
unsigned int rowstride;
/* creating a buffer to store "any" format does not make sense */
g_return_val_if_fail (format != COGL_PIXEL_FORMAT_ANY, NULL);
_COGL_RETURN_VAL_IF_FAIL (format != COGL_PIXEL_FORMAT_ANY, NULL);
/* for now we fallback to cogl_pixel_buffer_new, later, we could ask
* libdrm a tiled buffer for instance */
@@ -315,7 +317,7 @@ cogl_bitmap_new_with_size (CoglContext *context,
height * rowstride,
NULL); /* data */
g_return_val_if_fail (pixel_buffer != NULL, NULL);
_COGL_RETURN_VAL_IF_FAIL (pixel_buffer != NULL, NULL);
bitmap = cogl_bitmap_new_from_buffer (COGL_BUFFER (pixel_buffer),
format,
@@ -378,7 +380,7 @@ uint8_t *
_cogl_bitmap_map (CoglBitmap *bitmap,
CoglBufferAccess access,
CoglBufferMapHint hints,
GError **error)
CoglError **error)
{
/* Divert to another bitmap if this data is shared */
if (bitmap->shared_bmp)
@@ -435,10 +437,10 @@ uint8_t *
_cogl_bitmap_gl_bind (CoglBitmap *bitmap,
CoglBufferAccess access,
CoglBufferMapHint hints,
GError **error)
CoglError **error)
{
uint8_t *ptr;
GError *internal_error = NULL;
CoglError *internal_error = NULL;
g_return_val_if_fail (access & (COGL_BUFFER_ACCESS_READ |
COGL_BUFFER_ACCESS_WRITE),
@@ -448,7 +450,7 @@ _cogl_bitmap_gl_bind (CoglBitmap *bitmap,
if (bitmap->shared_bmp)
return _cogl_bitmap_gl_bind (bitmap->shared_bmp, access, hints, error);
g_return_val_if_fail (!bitmap->bound, NULL);
_COGL_RETURN_VAL_IF_FAIL (!bitmap->bound, NULL);
/* If the bitmap wasn't created from a buffer then the
implementation of bind is the same as map */
@@ -480,7 +482,7 @@ _cogl_bitmap_gl_bind (CoglBitmap *bitmap,
* if an exception was thrown */
if (internal_error)
{
g_propagate_error (error, internal_error);
_cogl_propagate_error (error, internal_error);
return NULL;
}

View File

@@ -70,7 +70,7 @@ GType cogl_bitmap_get_gtype (void);
/**
* cogl_bitmap_new_from_file:
* @filename: the file to load.
* @error: a #GError or %NULL.
* @error: a #CoglError or %NULL.
*
* Loads an image file from disk. This function can be safely called from
* within a thread.
@@ -82,7 +82,7 @@ GType cogl_bitmap_get_gtype (void);
*/
CoglBitmap *
cogl_bitmap_new_from_file (const char *filename,
GError **error);
CoglError **error);
/**
* cogl_bitmap_new_from_buffer: (skip)
@@ -269,7 +269,7 @@ cogl_is_bitmap (void *object);
/**
* COGL_BITMAP_ERROR:
*
* #GError domain for bitmap errors.
* #CoglError domain for bitmap errors.
*
* Since: 1.4
*/

View File

@@ -41,6 +41,7 @@
#include "cogl-context-private.h"
#include "cogl-debug.h"
#include "cogl-blend-string.h"
#include "cogl-error-private.h"
typedef enum _ParserState
{
@@ -165,7 +166,7 @@ _cogl_blend_string_split_rgba_statement (CoglBlendStringStatement *statement,
static gboolean
validate_tex_combine_statements (CoglBlendStringStatement *statements,
int n_statements,
GError **error)
CoglError **error)
{
int i, j;
const char *error_string;
@@ -194,8 +195,11 @@ validate_tex_combine_statements (CoglBlendStringStatement *statements,
return TRUE;
error:
g_set_error (error, COGL_BLEND_STRING_ERROR, detail,
"Invalid texture combine string: %s", error_string);
_cogl_set_error (error,
COGL_BLEND_STRING_ERROR,
detail,
"Invalid texture combine string: %s",
error_string);
if (COGL_DEBUG_ENABLED (COGL_DEBUG_BLEND_STRINGS))
{
@@ -208,7 +212,7 @@ error:
static gboolean
validate_blend_statements (CoglBlendStringStatement *statements,
int n_statements,
GError **error)
CoglError **error)
{
int i, j;
const char *error_string;
@@ -261,8 +265,11 @@ validate_blend_statements (CoglBlendStringStatement *statements,
return TRUE;
error:
g_set_error (error, COGL_BLEND_STRING_ERROR, detail,
"Invalid blend string: %s", error_string);
_cogl_set_error (error,
COGL_BLEND_STRING_ERROR,
detail,
"Invalid blend string: %s",
error_string);
return FALSE;
}
@@ -270,7 +277,7 @@ static gboolean
validate_statements_for_context (CoglBlendStringStatement *statements,
int n_statements,
CoglBlendStringContext context,
GError **error)
CoglError **error)
{
const char *error_string;
@@ -296,12 +303,13 @@ validate_statements_for_context (CoglBlendStringStatement *statements,
return validate_tex_combine_statements (statements, n_statements, error);
error:
g_set_error (error, COGL_BLEND_STRING_ERROR,
COGL_BLEND_STRING_ERROR_INVALID_ERROR,
"Invalid %s string: %s",
context == COGL_BLEND_STRING_CONTEXT_BLENDING ?
"blend" : "texture combine",
error_string);
_cogl_set_error (error,
COGL_BLEND_STRING_ERROR,
COGL_BLEND_STRING_ERROR_INVALID_ERROR,
"Invalid %s string: %s",
context == COGL_BLEND_STRING_CONTEXT_BLENDING ?
"blend" : "texture combine",
error_string);
if (COGL_DEBUG_ENABLED (COGL_DEBUG_BLEND_STRINGS))
{
@@ -456,7 +464,7 @@ parse_argument (const char *string, /* original user string */
int current_arg,
CoglBlendStringArgument *arg, /* OUT */
CoglBlendStringContext context,
GError **error)
CoglError **error)
{
const char *p = *ret_p;
const char *mark = NULL;
@@ -725,13 +733,13 @@ parse_argument (const char *string, /* original user string */
error:
{
int offset = p - string;
g_set_error (error,
COGL_BLEND_STRING_ERROR,
COGL_BLEND_STRING_ERROR_ARGUMENT_PARSE_ERROR,
"Syntax error for argument %d at offset %d: %s",
current_arg,
offset,
error_string);
_cogl_set_error (error,
COGL_BLEND_STRING_ERROR,
COGL_BLEND_STRING_ERROR_ARGUMENT_PARSE_ERROR,
"Syntax error for argument %d at offset %d: %s",
current_arg,
offset,
error_string);
if (COGL_DEBUG_ENABLED (COGL_DEBUG_BLEND_STRINGS))
{
@@ -746,7 +754,7 @@ int
_cogl_blend_string_compile (const char *string,
CoglBlendStringContext context,
CoglBlendStringStatement *statements,
GError **error)
CoglError **error)
{
const char *p = string;
const char *mark = NULL;
@@ -906,12 +914,12 @@ finished:
error:
{
int offset = p - string;
g_set_error (error,
COGL_BLEND_STRING_ERROR,
COGL_BLEND_STRING_ERROR_PARSE_ERROR,
"Syntax error at offset %d: %s",
offset,
error_string);
_cogl_set_error (error,
COGL_BLEND_STRING_ERROR,
COGL_BLEND_STRING_ERROR_PARSE_ERROR,
"Syntax error at offset %d: %s",
offset,
error_string);
if (COGL_DEBUG_ENABLED (COGL_DEBUG_BLEND_STRINGS))
{
@@ -963,7 +971,7 @@ _cogl_blend_string_test (void)
};
int i;
GError *error = NULL;
CoglError *error = NULL;
for (i = 0; strings[i].string; i++)
{
CoglBlendStringStatement statements[2];
@@ -976,7 +984,7 @@ _cogl_blend_string_test (void)
g_print ("Failed to parse string:\n%s\n%s\n",
strings[i].string,
error->message);
g_error_free (error);
cogl_error_free (error);
error = NULL;
continue;
}

View File

@@ -133,7 +133,7 @@ gboolean
_cogl_blend_string_compile (const char *string,
CoglBlendStringContext context,
CoglBlendStringStatement *statements,
GError **error);
CoglError **error);
void
_cogl_blend_string_split_rgba_statement (CoglBlendStringStatement *statement,

View File

@@ -52,7 +52,7 @@ _cogl_blit_texture_render_begin (CoglBlitData *data)
CoglFramebuffer *fb;
CoglPipeline *pipeline;
unsigned int dst_width, dst_height;
GError *ignore_error = NULL;
CoglError *ignore_error = NULL;
offscreen = _cogl_offscreen_new_with_texture_full
(data->dst_tex, COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL, 0 /* level */);
@@ -60,7 +60,7 @@ _cogl_blit_texture_render_begin (CoglBlitData *data)
fb = COGL_FRAMEBUFFER (offscreen);
if (!cogl_framebuffer_allocate (fb, &ignore_error))
{
g_error_free (ignore_error);
cogl_error_free (ignore_error);
cogl_object_unref (fb);
return FALSE;
}
@@ -150,7 +150,7 @@ _cogl_blit_framebuffer_begin (CoglBlitData *data)
CoglContext *ctx = data->src_tex->context;
CoglOffscreen *dst_offscreen = NULL, *src_offscreen = NULL;
CoglFramebuffer *dst_fb, *src_fb;
GError *ignore_error = NULL;
CoglError *ignore_error = NULL;
/* We can only blit between FBOs if both textures are the same
format and the blit framebuffer extension is supported */
@@ -165,7 +165,7 @@ _cogl_blit_framebuffer_begin (CoglBlitData *data)
dst_fb = COGL_FRAMEBUFFER (dst_offscreen);
if (!cogl_framebuffer_allocate (dst_fb, &ignore_error))
{
g_error_free (ignore_error);
cogl_error_free (ignore_error);
goto error;
}
@@ -177,7 +177,7 @@ _cogl_blit_framebuffer_begin (CoglBlitData *data)
src_fb = COGL_FRAMEBUFFER (src_offscreen);
if (!cogl_framebuffer_allocate (src_fb, &ignore_error))
{
g_error_free (ignore_error);
cogl_error_free (ignore_error);
goto error;
}
@@ -224,7 +224,7 @@ _cogl_blit_copy_tex_sub_image_begin (CoglBlitData *data)
{
CoglOffscreen *offscreen;
CoglFramebuffer *fb;
GError *ignore_error = NULL;
CoglError *ignore_error = NULL;
/* This will only work if the target texture is a CoglTexture2D */
if (!cogl_is_texture_2d (data->dst_tex))
@@ -236,7 +236,7 @@ _cogl_blit_copy_tex_sub_image_begin (CoglBlitData *data)
fb = COGL_FRAMEBUFFER (offscreen);
if (!cogl_framebuffer_allocate (fb, &ignore_error))
{
g_error_free (ignore_error);
cogl_error_free (ignore_error);
cogl_object_unref (fb);
return FALSE;
}
@@ -292,7 +292,7 @@ _cogl_blit_get_tex_data_blit (CoglBlitData *data,
int width,
int height)
{
GError *ignore = NULL;
CoglError *ignore = NULL;
int rowstride = data->src_width * data->bpp;
int offset = rowstride * src_y + src_x * data->bpp;
@@ -409,7 +409,7 @@ _cogl_blit_begin (CoglBlitData *data,
_cogl_blit_modes[i].name);
/* The last blit mode can't fail so this should never happen */
g_return_if_fail (i < G_N_ELEMENTS (_cogl_blit_modes));
_COGL_RETURN_IF_FAIL (i < G_N_ELEMENTS (_cogl_blit_modes));
}
data->blit_mode = _cogl_blit_default_mode;

View File

@@ -53,7 +53,7 @@ struct _CoglBufferVtable
size_t size,
CoglBufferAccess access,
CoglBufferMapHint hints,
GError **error);
CoglError **error);
void (* unmap) (CoglBuffer *buffer);
@@ -61,7 +61,7 @@ struct _CoglBufferVtable
unsigned int offset,
const void *data,
unsigned int size,
GError **error);
CoglError **error);
};
typedef enum _CoglBufferFlags
@@ -153,13 +153,13 @@ _cogl_buffer_set_data (CoglBuffer *buffer,
size_t offset,
const void *data,
size_t size,
GError **error);
CoglError **error);
void *
_cogl_buffer_map (CoglBuffer *buffer,
CoglBufferAccess access,
CoglBufferMapHint hints,
GError **error);
CoglError **error);
/* This is a wrapper around cogl_buffer_map_range for internal use
when we want to map the buffer for write only to replace the entire

View File

@@ -88,7 +88,7 @@ malloc_map_range (CoglBuffer *buffer,
size_t size,
CoglBufferAccess access,
CoglBufferMapHint hints,
GError **error)
CoglError **error)
{
buffer->flags |= COGL_BUFFER_FLAG_MAPPED;
return buffer->data + offset;
@@ -105,7 +105,7 @@ malloc_set_data (CoglBuffer *buffer,
unsigned int offset,
const void *data,
unsigned int size,
GError **error)
CoglError **error)
{
memcpy (buffer->data + offset, data, size);
return TRUE;
@@ -167,8 +167,8 @@ _cogl_buffer_initialize (CoglBuffer *buffer,
void
_cogl_buffer_fini (CoglBuffer *buffer)
{
g_return_if_fail (!(buffer->flags & COGL_BUFFER_FLAG_MAPPED));
g_return_if_fail (buffer->immutable_ref == 0);
_COGL_RETURN_IF_FAIL (!(buffer->flags & COGL_BUFFER_FLAG_MAPPED));
_COGL_RETURN_IF_FAIL (buffer->immutable_ref == 0);
if (buffer->flags & COGL_BUFFER_FLAG_BUFFER_OBJECT)
buffer->context->driver_vtable->buffer_destroy (buffer);
@@ -223,9 +223,9 @@ void *
_cogl_buffer_map (CoglBuffer *buffer,
CoglBufferAccess access,
CoglBufferMapHint hints,
GError **error)
CoglError **error)
{
g_return_val_if_fail (cogl_is_buffer (buffer), NULL);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_buffer (buffer), NULL);
return cogl_buffer_map_range (buffer, 0, buffer->size, access, hints, error);
}
@@ -235,11 +235,12 @@ cogl_buffer_map (CoglBuffer *buffer,
CoglBufferAccess access,
CoglBufferMapHint hints)
{
GError *ignore_error = NULL;
CoglError *ignore_error = NULL;
void *ptr =
cogl_buffer_map_range (buffer, 0, buffer->size, access, hints,
&ignore_error);
g_clear_error (&ignore_error);
if (!ptr)
cogl_error_free (ignore_error);
return ptr;
}
@@ -249,10 +250,10 @@ cogl_buffer_map_range (CoglBuffer *buffer,
size_t size,
CoglBufferAccess access,
CoglBufferMapHint hints,
GError **error)
CoglError **error)
{
g_return_val_if_fail (cogl_is_buffer (buffer), NULL);
g_return_val_if_fail (!(buffer->flags & COGL_BUFFER_FLAG_MAPPED), NULL);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_buffer (buffer), NULL);
_COGL_RETURN_VAL_IF_FAIL (!(buffer->flags & COGL_BUFFER_FLAG_MAPPED), NULL);
if (G_UNLIKELY (buffer->immutable_ref))
warn_about_midscene_changes ();
@@ -292,9 +293,9 @@ _cogl_buffer_map_range_for_fill_or_fallback (CoglBuffer *buffer,
{
CoglContext *ctx = buffer->context;
void *ret;
GError *ignore_error = NULL;
CoglError *ignore_error = NULL;
g_return_val_if_fail (!ctx->buffer_map_fallback_in_use, NULL);
_COGL_RETURN_VAL_IF_FAIL (!ctx->buffer_map_fallback_in_use, NULL);
ctx->buffer_map_fallback_in_use = TRUE;
@@ -308,7 +309,7 @@ _cogl_buffer_map_range_for_fill_or_fallback (CoglBuffer *buffer,
if (ret)
return ret;
g_error_free (ignore_error);
cogl_error_free (ignore_error);
/* If the map fails then we'll use a temporary buffer to fill
the data and then upload it using cogl_buffer_set_data when
@@ -327,7 +328,7 @@ _cogl_buffer_unmap_for_fill_or_fallback (CoglBuffer *buffer)
{
CoglContext *ctx = buffer->context;
g_return_if_fail (ctx->buffer_map_fallback_in_use);
_COGL_RETURN_IF_FAIL (ctx->buffer_map_fallback_in_use);
ctx->buffer_map_fallback_in_use = FALSE;
@@ -363,10 +364,10 @@ _cogl_buffer_set_data (CoglBuffer *buffer,
size_t offset,
const void *data,
size_t size,
GError **error)
CoglError **error)
{
g_return_val_if_fail (cogl_is_buffer (buffer), FALSE);
g_return_val_if_fail ((offset + size) <= buffer->size, FALSE);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_buffer (buffer), FALSE);
_COGL_RETURN_VAL_IF_FAIL ((offset + size) <= buffer->size, FALSE);
if (G_UNLIKELY (buffer->immutable_ref))
warn_about_midscene_changes ();
@@ -380,17 +381,18 @@ cogl_buffer_set_data (CoglBuffer *buffer,
const void *data,
size_t size)
{
GError *ignore_error = NULL;
CoglError *ignore_error = NULL;
gboolean status =
_cogl_buffer_set_data (buffer, offset, data, size, &ignore_error);
g_clear_error (&ignore_error);
if (!status)
cogl_error_free (ignore_error);
return status;
}
CoglBuffer *
_cogl_buffer_immutable_ref (CoglBuffer *buffer)
{
g_return_val_if_fail (cogl_is_buffer (buffer), NULL);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_buffer (buffer), NULL);
buffer->immutable_ref++;
return buffer;
@@ -399,8 +401,8 @@ _cogl_buffer_immutable_ref (CoglBuffer *buffer)
void
_cogl_buffer_immutable_unref (CoglBuffer *buffer)
{
g_return_if_fail (cogl_is_buffer (buffer));
g_return_if_fail (buffer->immutable_ref > 0);
_COGL_RETURN_IF_FAIL (cogl_is_buffer (buffer));
_COGL_RETURN_IF_FAIL (buffer->immutable_ref > 0);
buffer->immutable_ref--;
}

View File

@@ -40,6 +40,7 @@
#define __COGL_BUFFER_H__
#include <cogl/cogl-types.h>
#include <cogl/cogl-error.h>
G_BEGIN_DECLS
@@ -257,7 +258,7 @@ cogl_buffer_map (CoglBuffer *buffer,
* @access: how the mapped buffer will be used by the application
* @hints: A mask of #CoglBufferMapHint<!-- -->s that tell Cogl how
* the data will be modified once mapped.
* @error: A #GError for catching exceptional errors
* @error: A #CoglError for catching exceptional errors
*
* Maps a sub-region of the buffer into the application's address space
* for direct access.
@@ -287,7 +288,7 @@ cogl_buffer_map_range (CoglBuffer *buffer,
size_t size,
CoglBufferAccess access,
CoglBufferMapHint hints,
GError **error);
CoglError **error);
/**
* cogl_buffer_unmap:

View File

@@ -350,7 +350,7 @@ _cogl_clip_stack_pop (CoglClipStack *stack)
{
CoglClipStack *new_top;
g_return_val_if_fail (stack != NULL, NULL);
_COGL_RETURN_VAL_IF_FAIL (stack != NULL, NULL);
/* To pop we are moving the top of the stack to the old top's parent
node. The stack always needs to have a reference to the top entry

View File

@@ -68,7 +68,7 @@ cogl_color_init_from_4ub (CoglColor *color,
uint8_t blue,
uint8_t alpha)
{
g_return_if_fail (color != NULL);
_COGL_RETURN_IF_FAIL (color != NULL);
color->red = red;
color->green = green;
@@ -94,7 +94,7 @@ cogl_color_init_from_4f (CoglColor *color,
float blue,
float alpha)
{
g_return_if_fail (color != NULL);
_COGL_RETURN_IF_FAIL (color != NULL);
color->red = (red * 255);
color->green = (green * 255);
@@ -117,7 +117,7 @@ void
cogl_color_init_from_4fv (CoglColor *color,
const float *color_array)
{
g_return_if_fail (color != NULL);
_COGL_RETURN_IF_FAIL (color != NULL);
color->red = (color_array[0] * 255);
color->green = (color_array[1] * 255);
@@ -305,8 +305,8 @@ cogl_color_equal (const void *v1, const void *v2)
{
const uint32_t *c1 = v1, *c2 = v2;
g_return_val_if_fail (v1 != NULL, FALSE);
g_return_val_if_fail (v2 != NULL, FALSE);
_COGL_RETURN_VAL_IF_FAIL (v1 != NULL, FALSE);
_COGL_RETURN_VAL_IF_FAIL (v2 != NULL, FALSE);
/* XXX: We don't compare the padding */
return *c1 == *c2 ? TRUE : FALSE;

View File

@@ -363,7 +363,7 @@ _cogl_context_get_winsys (CoglContext *context);
* return FALSE and set @error */
gboolean
_cogl_context_update_features (CoglContext *context,
GError **error);
CoglError **error);
/* Obtains the context and returns retval if NULL */
#define _COGL_GET_CONTEXT(ctxvar, retval) \

View File

@@ -47,6 +47,7 @@
#include "cogl1-context.h"
#include "cogl-gpu-info-private.h"
#include "cogl-config-private.h"
#include "cogl-error-private.h"
#include "cogl-gtype-private.h"
#include "driver/gl/cogl-pipeline-opengl-private.h"
#include "driver/gl/cogl-util-gl-private.h"
@@ -122,7 +123,7 @@ _cogl_context_get_winsys (CoglContext *context)
*/
CoglContext *
cogl_context_new (CoglDisplay *display,
GError **error)
CoglError **error)
{
CoglContext *context;
uint8_t white_pixel[] = { 0xff, 0xff, 0xff, 0xff };
@@ -527,7 +528,7 @@ _cogl_context_free (CoglContext *context)
CoglContext *
_cogl_context_get_default (void)
{
GError *error = NULL;
CoglError *error = NULL;
/* Create if doesn't exist yet */
if (_cogl_context == NULL)
{
@@ -536,7 +537,7 @@ _cogl_context_get_default (void)
{
g_warning ("Failed to create default context: %s",
error->message);
g_error_free (error);
cogl_error_free (error);
}
}
@@ -557,7 +558,7 @@ cogl_context_get_renderer (CoglContext *context)
gboolean
_cogl_context_update_features (CoglContext *context,
GError **error)
CoglError **error)
{
return context->driver_vtable->update_features (context, error);
}

View File

@@ -104,7 +104,7 @@ GType cogl_context_get_gtype (void);
/**
* cogl_context_new: (constructor)
* @display: (allow-none): A #CoglDisplay pointer
* @error: A GError return location.
* @error: A CoglError return location.
*
* Creates a new #CoglContext which acts as an application sandbox
* for any state objects that are allocated.
@@ -115,7 +115,7 @@ GType cogl_context_get_gtype (void);
*/
CoglContext *
cogl_context_new (CoglDisplay *display,
GError **error);
CoglError **error);
/**
* cogl_context_get_display:

View File

@@ -46,4 +46,3 @@
#mesondefine COGL_HAS_X11_SUPPORT
#mesondefine COGL_HAS_XLIB
#mesondefine COGL_HAS_XLIB_SUPPORT
#mesondefine COGL_HAS_LIBDRM

View File

@@ -52,14 +52,14 @@ void
cogl_depth_state_set_test_enabled (CoglDepthState *state,
gboolean enabled)
{
g_return_if_fail (state->magic == COGL_DEPTH_STATE_MAGIC);
_COGL_RETURN_IF_FAIL (state->magic == COGL_DEPTH_STATE_MAGIC);
state->test_enabled = enabled;
}
gboolean
cogl_depth_state_get_test_enabled (CoglDepthState *state)
{
g_return_val_if_fail (state->magic == COGL_DEPTH_STATE_MAGIC, FALSE);
_COGL_RETURN_VAL_IF_FAIL (state->magic == COGL_DEPTH_STATE_MAGIC, FALSE);
return state->test_enabled;
}
@@ -67,14 +67,14 @@ void
cogl_depth_state_set_write_enabled (CoglDepthState *state,
gboolean enabled)
{
g_return_if_fail (state->magic == COGL_DEPTH_STATE_MAGIC);
_COGL_RETURN_IF_FAIL (state->magic == COGL_DEPTH_STATE_MAGIC);
state->write_enabled = enabled;
}
gboolean
cogl_depth_state_get_write_enabled (CoglDepthState *state)
{
g_return_val_if_fail (state->magic == COGL_DEPTH_STATE_MAGIC, FALSE);
_COGL_RETURN_VAL_IF_FAIL (state->magic == COGL_DEPTH_STATE_MAGIC, FALSE);
return state->write_enabled;
}
@@ -82,14 +82,14 @@ void
cogl_depth_state_set_test_function (CoglDepthState *state,
CoglDepthTestFunction function)
{
g_return_if_fail (state->magic == COGL_DEPTH_STATE_MAGIC);
_COGL_RETURN_IF_FAIL (state->magic == COGL_DEPTH_STATE_MAGIC);
state->test_function = function;
}
CoglDepthTestFunction
cogl_depth_state_get_test_function (CoglDepthState *state)
{
g_return_val_if_fail (state->magic == COGL_DEPTH_STATE_MAGIC, FALSE);
_COGL_RETURN_VAL_IF_FAIL (state->magic == COGL_DEPTH_STATE_MAGIC, FALSE);
return state->test_function;
}
@@ -98,7 +98,7 @@ cogl_depth_state_set_range (CoglDepthState *state,
float near,
float far)
{
g_return_if_fail (state->magic == COGL_DEPTH_STATE_MAGIC);
_COGL_RETURN_IF_FAIL (state->magic == COGL_DEPTH_STATE_MAGIC);
state->range_near = near;
state->range_far = far;
}
@@ -108,7 +108,7 @@ cogl_depth_state_get_range (CoglDepthState *state,
float *near_out,
float *far_out)
{
g_return_if_fail (state->magic == COGL_DEPTH_STATE_MAGIC);
_COGL_RETURN_IF_FAIL (state->magic == COGL_DEPTH_STATE_MAGIC);
*near_out = state->range_near;
*far_out = state->range_far;
}

View File

@@ -87,7 +87,7 @@ cogl_display_new (CoglRenderer *renderer,
CoglOnscreenTemplate *onscreen_template)
{
CoglDisplay *display = g_slice_new0 (CoglDisplay);
GError *error = NULL;
CoglError *error = NULL;
_cogl_init ();
@@ -119,7 +119,7 @@ void
cogl_display_set_onscreen_template (CoglDisplay *display,
CoglOnscreenTemplate *onscreen_template)
{
g_return_if_fail (display->setup == FALSE);
_COGL_RETURN_IF_FAIL (display->setup == FALSE);
if (onscreen_template)
cogl_object_ref (onscreen_template);
@@ -137,7 +137,7 @@ cogl_display_set_onscreen_template (CoglDisplay *display,
gboolean
cogl_display_setup (CoglDisplay *display,
GError **error)
CoglError **error)
{
const CoglWinsysVtable *winsys;
@@ -158,7 +158,7 @@ void
cogl_wayland_display_set_compositor_display (CoglDisplay *display,
struct wl_display *wayland_display)
{
g_return_if_fail (display->setup == FALSE);
_COGL_RETURN_IF_FAIL (display->setup == FALSE);
display->wayland_compositor_display = wayland_display;
}

View File

@@ -158,7 +158,7 @@ cogl_display_set_onscreen_template (CoglDisplay *display,
/**
* cogl_display_setup:
* @display: a #CoglDisplay
* @error: return location for a #GError
* @error: return location for a #CoglError
*
* Explicitly sets up the given @display object. Use of this api is
* optional since Cogl will internally setup the display if not done
@@ -188,7 +188,7 @@ cogl_display_set_onscreen_template (CoglDisplay *display,
*/
gboolean
cogl_display_setup (CoglDisplay *display,
GError **error);
CoglError **error);
/**
* cogl_is_display:

View File

@@ -58,11 +58,11 @@ struct _CoglDriverVtable
gboolean
(* update_features) (CoglContext *context,
GError **error);
CoglError **error);
gboolean
(* offscreen_allocate) (CoglOffscreen *offscreen,
GError **error);
CoglError **error);
void
(* offscreen_free) (CoglOffscreen *offscreen);
@@ -118,7 +118,7 @@ struct _CoglDriverVtable
int y,
CoglReadPixelsFlags source,
CoglBitmap *bitmap,
GError **error);
CoglError **error);
/* Destroys any driver specific resources associated with the given
* 2D texture. */
@@ -146,7 +146,7 @@ struct _CoglDriverVtable
* to the configured size and format of the texture */
gboolean
(* texture_2d_allocate) (CoglTexture *tex,
GError **error);
CoglError **error);
/* Initialize the specified region of storage of the given texture
* with the contents of the specified framebuffer region
@@ -190,7 +190,7 @@ struct _CoglDriverVtable
int dst_x,
int dst_y,
int level,
GError **error);
CoglError **error);
gboolean
(* texture_2d_is_get_data_supported) (CoglTexture2D *tex_2d);
@@ -239,7 +239,7 @@ struct _CoglDriverVtable
size_t size,
CoglBufferAccess access,
CoglBufferMapHint hints,
GError **error);
CoglError **error);
/* Unmaps a buffer */
void
@@ -252,7 +252,7 @@ struct _CoglDriverVtable
unsigned int offset,
const void *data,
unsigned int size,
GError **error);
CoglError **error);
};
#define COGL_DRIVER_ERROR (_cogl_driver_error_quark ())

View File

@@ -0,0 +1,57 @@
/*
* Cogl
*
* A Low Level GPU Graphics and Utilities API
*
* Copyright (C) 2012 Intel Corporation.
*
* 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:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* 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.
*/
#ifndef __COGL_ERROR_PRIVATE_H__
#define __COGL_ERROR_PRIVATE_H__
#include "cogl-error.h"
void
_cogl_set_error (CoglError **error,
uint32_t domain,
int code,
const char *format,
...) G_GNUC_PRINTF (4, 5);
void
_cogl_set_error_literal (CoglError **error,
uint32_t domain,
int code,
const char *message);
void
_cogl_propagate_error (CoglError **dest,
CoglError *src);
void
_cogl_propagate_gerror (CoglError **dest,
GError *src);
#define _cogl_clear_error(X) g_clear_error ((GError **)X)
#endif /* __COGL_ERROR_PRIVATE_H__ */

126
cogl/cogl/cogl-error.c Normal file
View File

@@ -0,0 +1,126 @@
/*
* Cogl
*
* A Low Level GPU Graphics and Utilities API
*
* Copyright (C) 2011 Intel Corporation.
*
* 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:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* 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.
*
* Authors:
* Robert Bragg <robert@linux.intel.com>
*/
#include "cogl-config.h"
#include "cogl-types.h"
#include "cogl-util.h"
#include "cogl-error-private.h"
#include <glib.h>
void
cogl_error_free (CoglError *error)
{
g_error_free ((GError *)error);
}
CoglError *
cogl_error_copy (CoglError *error)
{
return (CoglError *)g_error_copy ((GError *)error);
}
gboolean
cogl_error_matches (CoglError *error,
uint32_t domain,
int code)
{
return g_error_matches ((GError *)error, domain, code);
}
#define ERROR_OVERWRITTEN_WARNING \
"CoglError set over the top of a previous CoglError or " \
"uninitialized memory.\nThis indicates a bug in someone's " \
"code. You must ensure an error is NULL before it's set.\n" \
"The overwriting error message was: %s"
void
_cogl_set_error (CoglError **error,
uint32_t domain,
int code,
const char *format,
...)
{
GError *new;
va_list args;
va_start (args, format);
if (error == NULL)
{
g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format, args);
va_end (args);
return;
}
new = g_error_new_valist (domain, code, format, args);
va_end (args);
if (*error == NULL)
*error = (CoglError *)new;
else
g_warning (ERROR_OVERWRITTEN_WARNING, new->message);
}
void
_cogl_set_error_literal (CoglError **error,
uint32_t domain,
int code,
const char *message)
{
_cogl_set_error (error, domain, code, "%s", message);
}
void
_cogl_propagate_error (CoglError **dest,
CoglError *src)
{
_COGL_RETURN_IF_FAIL (src != NULL);
if (dest == NULL)
{
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, "%s", src->message);
cogl_error_free (src);
}
else if (*dest)
g_warning (ERROR_OVERWRITTEN_WARNING, src->message);
else
*dest = src;
}
void
_cogl_propagate_gerror (CoglError **dest,
GError *src)
{
_cogl_propagate_error (dest, (CoglError *) src);
}

169
cogl/cogl/cogl-error.h Normal file
View File

@@ -0,0 +1,169 @@
/*
* Cogl
*
* A Low Level GPU Graphics and Utilities API
*
* Copyright (C) 2012 Intel Corporation.
*
* 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:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* 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.
*/
#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION)
#error "Only <cogl/cogl.h> can be included directly."
#endif
#ifndef __COGL_ERROR_H__
#define __COGL_ERROR_H__
#include "cogl-types.h"
G_BEGIN_DECLS
/**
* SECTION:cogl-error
* @short_description: A way for Cogl to throw exceptions
*
* As a general rule Cogl shields non-recoverable errors from
* developers, such as most heap allocation failures (unless for
* exceptionally large resources which we might reasonably expect to
* fail) and this reduces the burden on developers.
*
* There are some Cogl apis though that can fail for exceptional
* reasons that can also potentially be recovered from at runtime
* and for these apis we use a standard convention for reporting
* runtime recoverable errors.
*
* As an example if we look at the cogl_context_new() api which
* takes an error argument:
* |[
* CoglContext *
* cogl_context_new (CoglDisplay *display, CoglError **error);
* ]|
*
* A caller interested in catching any runtime error when creating a
* new #CoglContext would pass the address of a #CoglError pointer
* that has first been initialized to %NULL as follows:
*
* |[
* CoglError *error = NULL;
* CoglContext *context;
*
* context = cogl_context_new (NULL, &error);
* ]|
*
* The return status should usually be enough to determine if there
* was an error set (in this example we can check if context == %NULL)
* but if it's not possible to tell from the function's return status
* you can instead look directly at the error pointer which you
* initialized to %NULL. In this example we now check the error,
* report any error to the user, free the error and then simply
* abort without attempting to recover.
*
* |[
* if (context == NULL)
* {
* fprintf (stderr, "Failed to create a Cogl context: %s\n",
* error->message);
* cogl_error_free (error);
* abort ();
* }
* ]|
*
* All Cogl APIs that accept an error argument can also be passed a
* %NULL pointer. In this case if an exceptional error condition is hit
* then Cogl will simply log the error message and abort the
* application. This can be compared to language execeptions where the
* developer has not attempted to catch the exception. This means the
* above example is essentially redundant because it's what Cogl would
* have done automatically and so, similarly, if your application has
* no way to recover from a particular error you might just as well
* pass a %NULL #CoglError pointer to save a bit of typing.
*
* <note>If you are used to using the GLib API you will probably
* recognize that #CoglError is just like a #GError. In fact if Cogl
* has been built with --enable-glib then it is safe to cast a
* #CoglError to a #GError.</note>
*
* <note>An important detail to be aware of if you are used to using
* GLib's GError API is that Cogl deviates from the GLib GError
* conventions in one noteable way which is that a %NULL error pointer
* does not mean you want to ignore the details of an error, it means
* you are not trying to catch any exceptional errors the function might
* throw which will result in the program aborting with a log message
* if an error is thrown.</note>
*/
#define CoglError GError
/**
* cogl_error_free:
* @error: A #CoglError thrown by the Cogl api
*
* Frees a #CoglError and associated resources.
*/
void
cogl_error_free (CoglError *error);
/**
* cogl_error_copy:
* @error: A #CoglError thrown by the Cogl api
*
* Makes a copy of @error which can later be freed using
* cogl_error_free().
*
* Return value: A newly allocated #CoglError initialized to match the
* contents of @error.
*/
CoglError *
cogl_error_copy (CoglError *error);
/**
* cogl_error_matches:
* @error: A #CoglError thrown by the Cogl api or %NULL
* @domain: The error domain
* @code: The error code
*
* Returns %TRUE if error matches @domain and @code, %FALSE otherwise.
* In particular, when error is %NULL, FALSE will be returned.
*
* Return value: whether the @error corresponds to the given @domain
* and @code.
*/
gboolean
cogl_error_matches (CoglError *error,
uint32_t domain,
int code);
/**
* COGL_GLIB_ERROR:
* @COGL_ERROR: A #CoglError thrown by the Cogl api or %NULL
*
* Simply casts a #CoglError to a #CoglError
*
* If Cogl is built with GLib support then it can safely be assumed
* that a CoglError is a GError and can be used directly with the
* GError api.
*/
#define COGL_GLIB_ERROR(COGL_ERROR) ((CoglError *)COGL_ERROR)
G_END_DECLS
#endif /* __COGL_ERROR_H__ */

View File

@@ -164,8 +164,8 @@ cogl_euler_equal (const void *v1, const void *v2)
const CoglEuler *a = v1;
const CoglEuler *b = v2;
g_return_val_if_fail (v1 != NULL, FALSE);
g_return_val_if_fail (v2 != NULL, FALSE);
_COGL_RETURN_VAL_IF_FAIL (v1 != NULL, FALSE);
_COGL_RETURN_VAL_IF_FAIL (v2 != NULL, FALSE);
if (v1 == v2)
return TRUE;

View File

@@ -497,7 +497,7 @@ _cogl_framebuffer_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
int y,
CoglReadPixelsFlags source,
CoglBitmap *bitmap,
GError **error);
CoglError **error);
/*
* _cogl_framebuffer_get_stencil_bits:

View File

@@ -50,6 +50,7 @@
#include "cogl1-context.h"
#include "cogl-private.h"
#include "cogl-primitives-private.h"
#include "cogl-error-private.h"
#include "cogl-gtype-private.h"
#include "driver/gl/cogl-texture-gl-private.h"
#include "winsys/cogl-winsys-private.h"
@@ -444,11 +445,11 @@ ensure_size_initialized (CoglFramebuffer *framebuffer)
{
/* Currently we assume the size is always initialized for
* onscreen framebuffers. */
g_return_if_fail (cogl_is_offscreen (framebuffer));
_COGL_RETURN_IF_FAIL (cogl_is_offscreen (framebuffer));
/* We also assume the size would have been initialized if the
* framebuffer were allocated. */
g_return_if_fail (!framebuffer->allocated);
_COGL_RETURN_IF_FAIL (!framebuffer->allocated);
cogl_framebuffer_allocate (framebuffer, NULL);
}
@@ -492,7 +493,7 @@ cogl_framebuffer_set_viewport (CoglFramebuffer *framebuffer,
{
CoglContext *context = framebuffer->context;
g_return_if_fail (width > 0 && height > 0);
_COGL_RETURN_IF_FAIL (width > 0 && height > 0);
if (framebuffer->viewport_x == x &&
framebuffer->viewport_y == y &&
@@ -617,7 +618,7 @@ _cogl_offscreen_new_with_texture_full (CoglTexture *texture,
CoglFramebuffer *fb;
CoglOffscreen *ret;
g_return_val_if_fail (cogl_is_texture (texture), NULL);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_texture (texture), NULL);
offscreen = g_new0 (CoglOffscreen, 1);
offscreen->texture = cogl_object_ref (texture);
@@ -649,12 +650,12 @@ CoglOffscreen *
cogl_offscreen_new_to_texture (CoglTexture *texture)
{
CoglOffscreen *ret = _cogl_offscreen_new_with_texture_full (texture, 0, 0);
GError *error = NULL;
CoglError *error = NULL;
if (!cogl_framebuffer_allocate (COGL_FRAMEBUFFER (ret), &error))
{
cogl_object_unref (ret);
g_error_free (error);
cogl_error_free (error);
ret = NULL;
}
@@ -695,7 +696,7 @@ _cogl_offscreen_free (CoglOffscreen *offscreen)
gboolean
cogl_framebuffer_allocate (CoglFramebuffer *framebuffer,
GError **error)
CoglError **error)
{
CoglOnscreen *onscreen = COGL_ONSCREEN (framebuffer);
const CoglWinsysVtable *winsys = _cogl_framebuffer_get_winsys (framebuffer);
@@ -708,10 +709,10 @@ cogl_framebuffer_allocate (CoglFramebuffer *framebuffer,
{
if (framebuffer->config.depth_texture_enabled)
{
g_set_error_literal (error, COGL_FRAMEBUFFER_ERROR,
COGL_FRAMEBUFFER_ERROR_ALLOCATE,
"Can't allocate onscreen framebuffer with a "
"texture based depth buffer");
_cogl_set_error (error, COGL_FRAMEBUFFER_ERROR,
COGL_FRAMEBUFFER_ERROR_ALLOCATE,
"Can't allocate onscreen framebuffer with a "
"texture based depth buffer");
return FALSE;
}
@@ -731,9 +732,9 @@ cogl_framebuffer_allocate (CoglFramebuffer *framebuffer,
if (!cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN))
{
g_set_error_literal (error, COGL_SYSTEM_ERROR,
COGL_SYSTEM_ERROR_UNSUPPORTED,
"Offscreen framebuffers not supported by system");
_cogl_set_error (error, COGL_SYSTEM_ERROR,
COGL_SYSTEM_ERROR_UNSUPPORTED,
"Offscreen framebuffers not supported by system");
return FALSE;
}
@@ -744,9 +745,10 @@ cogl_framebuffer_allocate (CoglFramebuffer *framebuffer,
* determine whether a texture needs slicing... */
if (cogl_texture_is_sliced (offscreen->texture))
{
g_set_error (error, COGL_SYSTEM_ERROR, COGL_SYSTEM_ERROR_UNSUPPORTED,
"Can't create offscreen framebuffer from "
"sliced texture");
_cogl_set_error (error, COGL_SYSTEM_ERROR,
COGL_SYSTEM_ERROR_UNSUPPORTED,
"Can't create offscreen framebuffer from "
"sliced texture");
return FALSE;
}
@@ -1067,7 +1069,7 @@ void
cogl_framebuffer_set_depth_texture_enabled (CoglFramebuffer *framebuffer,
gboolean enabled)
{
g_return_if_fail (!framebuffer->allocated);
_COGL_RETURN_IF_FAIL (!framebuffer->allocated);
framebuffer->config.depth_texture_enabled = enabled;
}
@@ -1085,7 +1087,7 @@ cogl_framebuffer_get_depth_texture (CoglFramebuffer *framebuffer)
if (!cogl_framebuffer_allocate (framebuffer, NULL))
return NULL;
g_return_val_if_fail (cogl_is_offscreen (framebuffer), NULL);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_offscreen (framebuffer), NULL);
return COGL_OFFSCREEN(framebuffer)->depth_texture;
}
@@ -1102,7 +1104,7 @@ void
cogl_framebuffer_set_samples_per_pixel (CoglFramebuffer *framebuffer,
int samples_per_pixel)
{
g_return_if_fail (!framebuffer->allocated);
_COGL_RETURN_IF_FAIL (!framebuffer->allocated);
framebuffer->config.samples_per_pixel = samples_per_pixel;
}
@@ -1156,7 +1158,7 @@ cogl_framebuffer_resolve_samples_region (CoglFramebuffer *framebuffer,
CoglContext *
cogl_framebuffer_get_context (CoglFramebuffer *framebuffer)
{
g_return_val_if_fail (framebuffer != NULL, NULL);
_COGL_RETURN_VAL_IF_FAIL (framebuffer != NULL, NULL);
return framebuffer->context;
}
@@ -1210,7 +1212,7 @@ _cogl_framebuffer_try_fast_read_pixel (CoglFramebuffer *framebuffer,
y < framebuffer->clear_clip_y1)
{
uint8_t *pixel;
GError *ignore_error = NULL;
CoglError *ignore_error = NULL;
/* we currently only care about cases where the premultiplied or
* unpremultipled colors are equivalent... */
@@ -1223,7 +1225,7 @@ _cogl_framebuffer_try_fast_read_pixel (CoglFramebuffer *framebuffer,
&ignore_error);
if (pixel == NULL)
{
g_error_free (ignore_error);
cogl_error_free (ignore_error);
return FALSE;
}
@@ -1246,14 +1248,14 @@ _cogl_framebuffer_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
int y,
CoglReadPixelsFlags source,
CoglBitmap *bitmap,
GError **error)
CoglError **error)
{
CoglContext *ctx;
int width;
int height;
g_return_val_if_fail (source & COGL_READ_PIXELS_COLOR_BUFFER, FALSE);
g_return_val_if_fail (cogl_is_framebuffer (framebuffer), FALSE);
_COGL_RETURN_VAL_IF_FAIL (source & COGL_READ_PIXELS_COLOR_BUFFER, FALSE);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_framebuffer (framebuffer), FALSE);
if (!cogl_framebuffer_allocate (framebuffer, error))
return FALSE;
@@ -1297,12 +1299,13 @@ cogl_framebuffer_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
CoglReadPixelsFlags source,
CoglBitmap *bitmap)
{
GError *ignore_error = NULL;
CoglError *ignore_error = NULL;
gboolean status =
_cogl_framebuffer_read_pixels_into_bitmap (framebuffer,
x, y, source, bitmap,
&ignore_error);
g_clear_error (&ignore_error);
if (!status)
cogl_error_free (ignore_error);
return status;
}
@@ -1352,16 +1355,16 @@ _cogl_blit_framebuffer (CoglFramebuffer *src,
{
CoglContext *ctx = src->context;
g_return_if_fail (_cogl_has_private_feature
(ctx, COGL_PRIVATE_FEATURE_OFFSCREEN_BLIT));
_COGL_RETURN_IF_FAIL (_cogl_has_private_feature
(ctx, COGL_PRIVATE_FEATURE_OFFSCREEN_BLIT));
/* We can only support blitting between offscreen buffers because
otherwise we would need to mirror the image and GLES2.0 doesn't
support this */
g_return_if_fail (cogl_is_offscreen (src));
g_return_if_fail (cogl_is_offscreen (dest));
_COGL_RETURN_IF_FAIL (cogl_is_offscreen (src));
_COGL_RETURN_IF_FAIL (cogl_is_offscreen (dest));
/* The buffers must be the same format */
g_return_if_fail (src->internal_format == dest->internal_format);
_COGL_RETURN_IF_FAIL (src->internal_format == dest->internal_format);
/* Make sure the current framebuffers are bound. We explicitly avoid
flushing the clip state so we can bind our own empty state */
@@ -1396,7 +1399,7 @@ cogl_framebuffer_discard_buffers (CoglFramebuffer *framebuffer,
{
CoglContext *ctx = framebuffer->context;
g_return_if_fail (buffers & COGL_BUFFER_BIT_COLOR);
_COGL_RETURN_IF_FAIL (buffers & COGL_BUFFER_BIT_COLOR);
ctx->driver_vtable->framebuffer_discard_buffers (framebuffer, buffers);
}

View File

@@ -106,7 +106,7 @@ GType cogl_framebuffer_get_gtype (void);
/**
* cogl_framebuffer_allocate:
* @framebuffer: A #CoglFramebuffer
* @error: A pointer to a #GError for returning exceptions.
* @error: A pointer to a #CoglError for returning exceptions.
*
* Explicitly allocates a configured #CoglFramebuffer allowing developers to
* check and handle any errors that might arise from an unsupported
@@ -125,7 +125,7 @@ GType cogl_framebuffer_get_gtype (void);
*/
gboolean
cogl_framebuffer_allocate (CoglFramebuffer *framebuffer,
GError **error);
CoglError **error);
/**
* cogl_framebuffer_get_width:

View File

@@ -48,6 +48,7 @@
#include "cogl-swap-chain-private.h"
#include "cogl-texture-2d-gl.h"
#include "cogl-texture-2d-private.h"
#include "cogl-error-private.h"
#include "cogl-gtype-private.h"
#include "driver/gl/cogl-framebuffer-gl-private.h"
#include "driver/gl/cogl-pipeline-opengl-private.h"
@@ -158,10 +159,10 @@ replace_token (char *string,
/* NOTE: this assumes token and replacement are the same length */
while ((token_pos = memmem (last_pos,
end - last_pos,
token,
token_length)))
while ((token_pos = _cogl_util_memmem (last_pos,
end - last_pos,
token,
token_length)))
{
/* Make sure this isn't in the middle of some longer token */
if ((token_pos <= string ||
@@ -907,10 +908,10 @@ gl_get_shader_source_wrapper (GLuint shader,
/* Strip out the wrapper snippet we added when the source was
* specified */
wrapper_start = memmem (source,
copy_length,
wrapper_marker,
sizeof (wrapper_marker) - 1);
wrapper_start = _cogl_util_memmem (source,
copy_length,
wrapper_marker,
sizeof (wrapper_marker) - 1);
if (wrapper_start)
{
length = wrapper_start - source;
@@ -1565,16 +1566,16 @@ free_texture_object_data (CoglGLES2TextureObjectData *data)
}
CoglGLES2Context *
cogl_gles2_context_new (CoglContext *ctx, GError **error)
cogl_gles2_context_new (CoglContext *ctx, CoglError **error)
{
CoglGLES2Context *gles2_ctx;
const CoglWinsysVtable *winsys;
if (!cogl_has_feature (ctx, COGL_FEATURE_ID_GLES2_CONTEXT))
{
g_set_error_literal (error, COGL_GLES2_CONTEXT_ERROR,
COGL_GLES2_CONTEXT_ERROR_UNSUPPORTED,
"Backend doesn't support creating GLES2 contexts");
_cogl_set_error (error, COGL_GLES2_CONTEXT_ERROR,
COGL_GLES2_CONTEXT_ERROR_UNSUPPORTED,
"Backend doesn't support creating GLES2 contexts");
return NULL;
}
@@ -1692,11 +1693,11 @@ cogl_gles2_context_get_vtable (CoglGLES2Context *gles2_ctx)
static CoglGLES2Offscreen *
_cogl_gles2_offscreen_allocate (CoglOffscreen *offscreen,
CoglGLES2Context *gles2_context,
GError **error)
CoglError **error)
{
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (offscreen);
const CoglWinsysVtable *winsys;
GError *internal_error = NULL;
CoglError *internal_error = NULL;
CoglGLES2Offscreen *gles2_offscreen;
int level_width;
int level_height;
@@ -1721,10 +1722,10 @@ _cogl_gles2_offscreen_allocate (CoglOffscreen *offscreen,
{
winsys->restore_context (framebuffer->context);
g_error_free (internal_error);
g_set_error_literal (error, COGL_FRAMEBUFFER_ERROR,
COGL_FRAMEBUFFER_ERROR_ALLOCATE,
"Failed to bind gles2 context to create framebuffer");
cogl_error_free (internal_error);
_cogl_set_error (error, COGL_FRAMEBUFFER_ERROR,
COGL_FRAMEBUFFER_ERROR_ALLOCATE,
"Failed to bind gles2 context to create framebuffer");
return NULL;
}
@@ -1750,9 +1751,9 @@ _cogl_gles2_offscreen_allocate (CoglOffscreen *offscreen,
g_slice_free (CoglGLES2Offscreen, gles2_offscreen);
g_set_error_literal (error, COGL_FRAMEBUFFER_ERROR,
COGL_FRAMEBUFFER_ERROR_ALLOCATE,
"Failed to create an OpenGL framebuffer object");
_cogl_set_error (error, COGL_FRAMEBUFFER_ERROR,
COGL_FRAMEBUFFER_ERROR_ALLOCATE,
"Failed to create an OpenGL framebuffer object");
return NULL;
}
@@ -1780,12 +1781,12 @@ cogl_push_gles2_context (CoglContext *ctx,
CoglGLES2Context *gles2_ctx,
CoglFramebuffer *read_buffer,
CoglFramebuffer *write_buffer,
GError **error)
CoglError **error)
{
const CoglWinsysVtable *winsys = ctx->display->renderer->winsys_vtable;
GError *internal_error = NULL;
CoglError *internal_error = NULL;
g_return_val_if_fail (gles2_ctx != NULL, FALSE);
_COGL_RETURN_VAL_IF_FAIL (gles2_ctx != NULL, FALSE);
/* The read/write buffers are properties of the gles2 context and we
* don't currently track the read/write buffers as part of the stack
@@ -1862,10 +1863,10 @@ cogl_push_gles2_context (CoglContext *ctx,
{
winsys->restore_context (ctx);
g_error_free (internal_error);
g_set_error_literal (error, COGL_GLES2_CONTEXT_ERROR,
COGL_GLES2_CONTEXT_ERROR_DRIVER,
"Driver failed to make GLES2 context current");
cogl_error_free (internal_error);
_cogl_set_error (error, COGL_GLES2_CONTEXT_ERROR,
COGL_GLES2_CONTEXT_ERROR_DRIVER,
"Driver failed to make GLES2 context current");
return FALSE;
}
@@ -1922,7 +1923,7 @@ cogl_pop_gles2_context (CoglContext *ctx)
CoglGLES2Context *gles2_ctx;
const CoglWinsysVtable *winsys = ctx->display->renderer->winsys_vtable;
g_return_if_fail (ctx->gles2_context_stack.length > 0);
_COGL_RETURN_IF_FAIL (ctx->gles2_context_stack.length > 0);
g_queue_pop_tail (&ctx->gles2_context_stack);

View File

@@ -189,7 +189,7 @@ typedef enum /*< prefix=COGL_GLES2_CONTEXT_ERROR >*/
/**
* cogl_gles2_context_new:
* @ctx: A #CoglContext
* @error: A pointer to a #GError for returning exceptions
* @error: A pointer to a #CoglError for returning exceptions
*
* Allocates a new OpenGLES 2.0 context that can be used to render to
* #CoglOffscreen framebuffers (Rendering to #CoglOnscreen
@@ -216,7 +216,7 @@ typedef enum /*< prefix=COGL_GLES2_CONTEXT_ERROR >*/
* Stability: unstable
*/
CoglGLES2Context *
cogl_gles2_context_new (CoglContext *ctx, GError **error);
cogl_gles2_context_new (CoglContext *ctx, CoglError **error);
/**
* cogl_gles2_context_get_vtable:
@@ -248,7 +248,7 @@ cogl_gles2_context_get_vtable (CoglGLES2Context *gles2_ctx);
* @write_buffer: A #CoglFramebuffer to access for drawing operations
* such as glDrawArrays. (must be a #CoglOffscreen
* framebuffer currently)
* @error: A pointer to a #GError for returning exceptions
* @error: A pointer to a #CoglError for returning exceptions
*
* Pushes the given @gles2_ctx onto a stack associated with @ctx so
* that the OpenGLES 2.0 api can be used instead of the Cogl
@@ -272,7 +272,7 @@ cogl_push_gles2_context (CoglContext *ctx,
CoglGLES2Context *gles2_ctx,
CoglFramebuffer *read_buffer,
CoglFramebuffer *write_buffer,
GError **error);
CoglError **error);
/**
* cogl_pop_gles2_context:

View File

@@ -91,7 +91,7 @@ cogl_indices_new (CoglContext *context,
CoglIndexBuffer *index_buffer = cogl_index_buffer_new (context, buffer_bytes);
CoglBuffer *buffer = COGL_BUFFER (index_buffer);
CoglIndices *indices;
GError *ignore_error = NULL;
CoglError *ignore_error = NULL;
_cogl_buffer_set_data (buffer,
0,
@@ -100,7 +100,7 @@ cogl_indices_new (CoglContext *context,
&ignore_error);
if (ignore_error)
{
g_error_free (ignore_error);
cogl_error_free (ignore_error);
cogl_object_unref (index_buffer);
return NULL;
}
@@ -120,15 +120,15 @@ cogl_indices_get_buffer (CoglIndices *indices)
CoglIndicesType
cogl_indices_get_type (CoglIndices *indices)
{
g_return_val_if_fail (cogl_is_indices (indices),
COGL_INDICES_TYPE_UNSIGNED_BYTE);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_indices (indices),
COGL_INDICES_TYPE_UNSIGNED_BYTE);
return indices->type;
}
size_t
cogl_indices_get_offset (CoglIndices *indices)
{
g_return_val_if_fail (cogl_is_indices (indices), 0);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_indices (indices), 0);
return indices->offset;
}
@@ -149,7 +149,7 @@ void
cogl_indices_set_offset (CoglIndices *indices,
size_t offset)
{
g_return_if_fail (cogl_is_indices (indices));
_COGL_RETURN_IF_FAIL (cogl_is_indices (indices));
if (G_UNLIKELY (indices->immutable_ref))
warn_about_midscene_changes ();
@@ -167,7 +167,7 @@ _cogl_indices_free (CoglIndices *indices)
CoglIndices *
_cogl_indices_immutable_ref (CoglIndices *indices)
{
g_return_val_if_fail (cogl_is_indices (indices), NULL);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_indices (indices), NULL);
indices->immutable_ref++;
_cogl_buffer_immutable_ref (COGL_BUFFER (indices->buffer));
@@ -177,8 +177,8 @@ _cogl_indices_immutable_ref (CoglIndices *indices)
void
_cogl_indices_immutable_unref (CoglIndices *indices)
{
g_return_if_fail (cogl_is_indices (indices));
g_return_if_fail (indices->immutable_ref > 0);
_COGL_RETURN_IF_FAIL (cogl_is_indices (indices));
_COGL_RETURN_IF_FAIL (indices->immutable_ref > 0);
indices->immutable_ref--;
_cogl_buffer_immutable_unref (COGL_BUFFER (indices->buffer));

View File

@@ -1786,7 +1786,7 @@ _cogl_journal_try_read_pixel (CoglJournal *journal,
float poly[16];
CoglFramebuffer *framebuffer = journal->framebuffer;
uint8_t *pixel;
GError *ignore_error;
CoglError *ignore_error;
entry_to_screen_polygon (framebuffer, entry, vertices, poly);
@@ -1831,7 +1831,7 @@ _cogl_journal_try_read_pixel (CoglJournal *journal,
&ignore_error);
if (pixel == NULL)
{
g_error_free (ignore_error);
cogl_error_free (ignore_error);
return FALSE;
}

View File

@@ -396,10 +396,10 @@ cogl_matrix_stack_pop (CoglMatrixStack *stack)
CoglMatrixEntry *old_top;
CoglMatrixEntry *new_top;
g_return_if_fail (stack != NULL);
_COGL_RETURN_IF_FAIL (stack != NULL);
old_top = stack->last_entry;
g_return_if_fail (old_top != NULL);
_COGL_RETURN_IF_FAIL (old_top != NULL);
/* To pop we are moving the top of the stack to the old top's parent
* node. The stack always needs to have a reference to the top entry

View File

@@ -376,7 +376,7 @@ _cogl_matrix_prefix_print (const char *prefix, const CoglMatrix *matrix)
{
if (!(matrix->flags & MAT_DIRTY_TYPE))
{
g_return_if_fail (matrix->type < COGL_MATRIX_N_TYPES);
_COGL_RETURN_IF_FAIL (matrix->type < COGL_MATRIX_N_TYPES);
g_print ("%sMatrix type: %s, flags: %x\n",
prefix, types[matrix->type], (int)matrix->flags);
}
@@ -1942,8 +1942,8 @@ cogl_matrix_equal (const void *v1, const void *v2)
const CoglMatrix *a = v1;
const CoglMatrix *b = v2;
g_return_val_if_fail (v1 != NULL, FALSE);
g_return_val_if_fail (v2 != NULL, FALSE);
_COGL_RETURN_VAL_IF_FAIL (v1 != NULL, FALSE);
_COGL_RETURN_VAL_IF_FAIL (v2 != NULL, FALSE);
/* We want to avoid having a fuzzy _equal() function (e.g. that uses
* an arbitrary epsilon value) since this function noteably conforms
@@ -2167,7 +2167,7 @@ cogl_matrix_transform_points (const CoglMatrix *matrix,
int n_points)
{
/* The results of transforming always have three components... */
g_return_if_fail (stride_out >= sizeof (Point3f));
_COGL_RETURN_IF_FAIL (stride_out >= sizeof (Point3f));
if (n_components == 2)
_cogl_matrix_transform_points_f2 (matrix,
@@ -2176,7 +2176,7 @@ cogl_matrix_transform_points (const CoglMatrix *matrix,
n_points);
else
{
g_return_if_fail (n_components == 3);
_COGL_RETURN_IF_FAIL (n_components == 3);
_cogl_matrix_transform_points_f3 (matrix,
stride_in, points_in,
@@ -2206,7 +2206,7 @@ cogl_matrix_project_points (const CoglMatrix *matrix,
n_points);
else
{
g_return_if_fail (n_components == 4);
_COGL_RETURN_IF_FAIL (n_components == 4);
_cogl_matrix_project_points_f4 (matrix,
stride_in, points_in,

View File

@@ -36,6 +36,7 @@
#include <cogl/cogl-texture.h>
#include <cogl/cogl-meta-texture.h>
#include <cogl/cogl-error-private.h>
#include <cogl/cogl-frame-info-private.h>
#include <cogl/cogl-renderer-private.h>
#if defined (COGL_HAS_EGL_SUPPORT)

View File

@@ -84,7 +84,7 @@ _cogl_pipeline_node_unparent_real (CoglNode *node)
if (parent == NULL)
return;
g_return_if_fail (!_cogl_list_empty (&parent->children));
_COGL_RETURN_IF_FAIL (!_cogl_list_empty (&parent->children));
_cogl_list_remove (&node->link);

View File

@@ -46,7 +46,7 @@ cogl_object_ref (void *object)
{
CoglObject *obj = object;
g_return_val_if_fail (object != NULL, NULL);
_COGL_RETURN_VAL_IF_FAIL (object != NULL, NULL);
obj->ref_count++;
return object;
@@ -63,8 +63,8 @@ _cogl_object_default_unref (void *object)
{
CoglObject *obj = object;
g_return_if_fail (object != NULL);
g_return_if_fail (obj->ref_count > 0);
_COGL_RETURN_IF_FAIL (object != NULL);
_COGL_RETURN_IF_FAIL (obj->ref_count > 0);
if (--obj->ref_count < 1)
{
@@ -109,7 +109,7 @@ cogl_object_unref (void *obj)
{
void (* unref_func) (void *);
g_return_if_fail (obj != NULL);
_COGL_RETURN_IF_FAIL (obj != NULL);
unref_func = ((CoglObject *) obj)->klass->virt_unref;
unref_func (obj);

View File

@@ -90,7 +90,7 @@ GType cogl_offscreen_get_gtype (void);
* message. If you need to be able to catch such exceptions at runtime
* then you can explicitly allocate your framebuffer when you have
* finished configuring it by calling cogl_framebuffer_allocate() and
* passing in a #GError argument to catch any exceptions.
* passing in a #CoglError argument to catch any exceptions.
*
* Return value: (transfer full): a newly instantiated #CoglOffscreen
* framebuffer.

View File

@@ -165,7 +165,7 @@ _cogl_onscreen_free (CoglOnscreen *onscreen)
framebuffer->context->window_buffer = NULL;
winsys->onscreen_deinit (onscreen);
g_return_if_fail (onscreen->winsys == NULL);
_COGL_RETURN_IF_FAIL (onscreen->winsys == NULL);
/* Chain up to parent */
_cogl_framebuffer_free (framebuffer);
@@ -304,7 +304,7 @@ cogl_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen,
const CoglWinsysVtable *winsys;
CoglFrameInfo *info;
g_return_if_fail (framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN);
_COGL_RETURN_IF_FAIL (framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN);
info = _cogl_frame_info_new ();
info->frame_counter = onscreen->frame_counter;
@@ -354,7 +354,7 @@ cogl_onscreen_swap_region (CoglOnscreen *onscreen,
const CoglWinsysVtable *winsys;
CoglFrameInfo *info;
g_return_if_fail (framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN);
_COGL_RETURN_IF_FAIL (framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN);
info = _cogl_frame_info_new ();
info->frame_counter = onscreen->frame_counter;
@@ -367,7 +367,7 @@ cogl_onscreen_swap_region (CoglOnscreen *onscreen,
/* This should only be called if the winsys advertises
COGL_WINSYS_FEATURE_SWAP_REGION */
g_return_if_fail (winsys->onscreen_swap_region != NULL);
_COGL_RETURN_IF_FAIL (winsys->onscreen_swap_region != NULL);
winsys->onscreen_swap_region (COGL_ONSCREEN (framebuffer),
rectangles,
@@ -402,7 +402,7 @@ cogl_onscreen_get_buffer_age (CoglOnscreen *onscreen)
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
const CoglWinsysVtable *winsys;
g_return_val_if_fail (framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN, 0);
_COGL_RETURN_VAL_IF_FAIL (framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN, 0);
winsys = _cogl_framebuffer_get_winsys (framebuffer);
@@ -421,7 +421,7 @@ cogl_x11_onscreen_set_foreign_window_xid (CoglOnscreen *onscreen,
{
/* We don't wan't applications to get away with being lazy here and not
* passing an update callback... */
g_return_if_fail (update);
_COGL_RETURN_IF_FAIL (update);
onscreen->foreign_xid = xid;
onscreen->foreign_update_mask_callback = update;
@@ -440,7 +440,7 @@ cogl_x11_onscreen_get_window_xid (CoglOnscreen *onscreen)
const CoglWinsysVtable *winsys = _cogl_framebuffer_get_winsys (framebuffer);
/* This should only be called for x11 onscreens */
g_return_val_if_fail (winsys->onscreen_x11_get_window_xid != NULL, 0);
_COGL_RETURN_VAL_IF_FAIL (winsys->onscreen_x11_get_window_xid != NULL, 0);
return winsys->onscreen_x11_get_window_xid (onscreen);
}
@@ -480,7 +480,7 @@ void
cogl_onscreen_remove_frame_callback (CoglOnscreen *onscreen,
CoglFrameClosure *closure)
{
g_return_if_fail (closure);
_COGL_RETURN_IF_FAIL (closure);
_cogl_closure_disconnect (closure);
}
@@ -552,7 +552,7 @@ cogl_onscreen_remove_swap_buffers_callback (CoglOnscreen *onscreen,
CoglFrameClosure *closure = g_hash_table_lookup (ctx->swap_callback_closures,
GINT_TO_POINTER (id));
g_return_if_fail (closure);
_COGL_RETURN_IF_FAIL (closure);
cogl_onscreen_remove_frame_callback (onscreen, closure);
}
@@ -692,7 +692,7 @@ void
cogl_onscreen_remove_dirty_callback (CoglOnscreen *onscreen,
CoglOnscreenDirtyClosure *closure)
{
g_return_if_fail (closure);
_COGL_RETURN_IF_FAIL (closure);
_cogl_closure_disconnect (closure);
}

View File

@@ -41,6 +41,7 @@
#include "cogl-snippet-private.h"
#include "cogl-texture-private.h"
#include "cogl-pipeline-layer-state-private.h"
#include "cogl-error-private.h"
#include "string.h"
#if 0
@@ -292,7 +293,7 @@ public_to_internal_wrap_mode (CoglPipelineWrapMode mode)
static CoglPipelineWrapMode
internal_to_public_wrap_mode (CoglSamplerCacheWrapMode internal_mode)
{
g_return_val_if_fail (internal_mode !=
_COGL_RETURN_VAL_IF_FAIL (internal_mode !=
COGL_SAMPLER_CACHE_WRAP_MODE_CLAMP_TO_BORDER,
COGL_PIPELINE_WRAP_MODE_AUTOMATIC);
return (CoglPipelineWrapMode)internal_mode;
@@ -312,7 +313,7 @@ cogl_pipeline_set_layer_wrap_mode_s (CoglPipeline *pipeline,
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
/* Note: this will ensure that the layer exists, creating one if it
* doesn't already.
@@ -354,7 +355,7 @@ cogl_pipeline_set_layer_wrap_mode_t (CoglPipeline *pipeline,
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
/* Note: this will ensure that the layer exists, creating one if it
* doesn't already.
@@ -408,7 +409,7 @@ cogl_pipeline_set_layer_wrap_mode_p (CoglPipeline *pipeline,
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
/* Note: this will ensure that the layer exists, creating one if it
* doesn't already.
@@ -450,7 +451,7 @@ cogl_pipeline_set_layer_wrap_mode (CoglPipeline *pipeline,
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
/* Note: this will ensure that the layer exists, creating one if it
* doesn't already.
@@ -486,7 +487,7 @@ _cogl_pipeline_layer_get_wrap_mode_s (CoglPipelineLayer *layer)
CoglPipelineLayer *authority;
const CoglSamplerCacheEntry *sampler_state;
g_return_val_if_fail (_cogl_is_pipeline_layer (layer), FALSE);
_COGL_RETURN_VAL_IF_FAIL (_cogl_is_pipeline_layer (layer), FALSE);
/* Now find the ancestor of the layer that is the authority for the
* state we want to change */
@@ -501,7 +502,7 @@ cogl_pipeline_get_layer_wrap_mode_s (CoglPipeline *pipeline, int layer_index)
{
CoglPipelineLayer *layer;
g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE);
/* Note: this will ensure that the layer exists, creating one if it
* doesn't already.
@@ -523,7 +524,7 @@ _cogl_pipeline_layer_get_wrap_mode_t (CoglPipelineLayer *layer)
CoglPipelineLayer *authority;
const CoglSamplerCacheEntry *sampler_state;
g_return_val_if_fail (_cogl_is_pipeline_layer (layer), FALSE);
_COGL_RETURN_VAL_IF_FAIL (_cogl_is_pipeline_layer (layer), FALSE);
/* Now find the ancestor of the layer that is the authority for the
* state we want to change */
@@ -538,7 +539,7 @@ cogl_pipeline_get_layer_wrap_mode_t (CoglPipeline *pipeline, int layer_index)
{
CoglPipelineLayer *layer;
g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE);
/* Note: this will ensure that the layer exists, creating one if it
* doesn't already.
@@ -569,7 +570,7 @@ cogl_pipeline_get_layer_wrap_mode_p (CoglPipeline *pipeline, int layer_index)
{
CoglPipelineLayer *layer;
g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE);
/* Note: this will ensure that the layer exists, creating one if it
* doesn't already.
@@ -601,7 +602,7 @@ gboolean
cogl_pipeline_set_layer_point_sprite_coords_enabled (CoglPipeline *pipeline,
int layer_index,
gboolean enable,
GError **error)
CoglError **error)
{
CoglPipelineLayerState change =
COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS;
@@ -611,7 +612,7 @@ cogl_pipeline_set_layer_point_sprite_coords_enabled (CoglPipeline *pipeline,
_COGL_GET_CONTEXT (ctx, FALSE);
g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE);
/* Don't allow point sprite coordinates to be enabled if the driver
doesn't support it */
@@ -619,11 +620,11 @@ cogl_pipeline_set_layer_point_sprite_coords_enabled (CoglPipeline *pipeline,
{
if (error)
{
g_set_error_literal (error,
COGL_SYSTEM_ERROR,
COGL_SYSTEM_ERROR_UNSUPPORTED,
"Point sprite texture coordinates are enabled for "
"a layer but the GL driver does not support it.");
_cogl_set_error (error,
COGL_SYSTEM_ERROR,
COGL_SYSTEM_ERROR_UNSUPPORTED,
"Point sprite texture coordinates are enabled for "
"a layer but the GL driver does not support it.");
}
else
{
@@ -705,7 +706,7 @@ cogl_pipeline_get_layer_point_sprite_coords_enabled (CoglPipeline *pipeline,
CoglPipelineLayer *layer;
CoglPipelineLayer *authority;
g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE);
/* Note: this will ensure that the layer exists, creating one if it
* doesn't already.
@@ -798,9 +799,9 @@ cogl_pipeline_add_layer_snippet (CoglPipeline *pipeline,
int layer_index,
CoglSnippet *snippet)
{
g_return_if_fail (cogl_is_pipeline (pipeline));
g_return_if_fail (cogl_is_snippet (snippet));
g_return_if_fail (snippet->hook >= COGL_SNIPPET_FIRST_LAYER_HOOK);
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_snippet (snippet));
_COGL_RETURN_IF_FAIL (snippet->hook >= COGL_SNIPPET_FIRST_LAYER_HOOK);
if (snippet->hook < COGL_SNIPPET_FIRST_LAYER_FRAGMENT_HOOK)
_cogl_pipeline_layer_add_vertex_snippet (pipeline,
@@ -1028,7 +1029,7 @@ gboolean
cogl_pipeline_set_layer_combine (CoglPipeline *pipeline,
int layer_index,
const char *combine_description,
GError **error)
CoglError **error)
{
CoglPipelineLayerState state = COGL_PIPELINE_LAYER_STATE_COMBINE;
CoglPipelineLayer *authority;
@@ -1039,7 +1040,7 @@ cogl_pipeline_set_layer_combine (CoglPipeline *pipeline,
CoglBlendStringStatement *a;
int count;
g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE);
/* Note: this will ensure that the layer exists, creating one if it
* doesn't already.
@@ -1139,7 +1140,7 @@ cogl_pipeline_set_layer_combine_constant (CoglPipeline *pipeline,
CoglPipelineLayer *new;
float color_as_floats[4];
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
/* Note: this will ensure that the layer exists, creating one if it
* doesn't already.
@@ -1222,7 +1223,7 @@ _cogl_pipeline_get_layer_combine_constant (CoglPipeline *pipeline,
CoglPipelineLayer *layer;
CoglPipelineLayer *authority;
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
/* Note: this will ensure that the layer exists, creating one if it
* doesn't already.
@@ -1249,7 +1250,7 @@ _cogl_pipeline_get_layer_matrix (CoglPipeline *pipeline, int layer_index)
CoglPipelineLayer *layer;
CoglPipelineLayer *authority;
g_return_val_if_fail (cogl_is_pipeline (pipeline), NULL);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), NULL);
layer = _cogl_pipeline_get_layer (pipeline, layer_index);
@@ -1267,7 +1268,7 @@ cogl_pipeline_set_layer_matrix (CoglPipeline *pipeline,
CoglPipelineLayer *authority;
CoglPipelineLayer *new;
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
/* Note: this will ensure that the layer exists, creating one if it
* doesn't already.
@@ -1329,7 +1330,7 @@ cogl_pipeline_set_layer_matrix (CoglPipeline *pipeline,
CoglTexture *
_cogl_pipeline_layer_get_texture (CoglPipelineLayer *layer)
{
g_return_val_if_fail (_cogl_is_pipeline_layer (layer), NULL);
_COGL_RETURN_VAL_IF_FAIL (_cogl_is_pipeline_layer (layer), NULL);
return _cogl_pipeline_layer_get_texture_real (layer);
}
@@ -1373,7 +1374,7 @@ _cogl_pipeline_get_layer_filters (CoglPipeline *pipeline,
CoglPipelineLayer *layer;
CoglPipelineLayer *authority;
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
layer = _cogl_pipeline_get_layer (pipeline, layer_index);
@@ -1414,7 +1415,7 @@ _cogl_pipeline_layer_get_min_filter (CoglPipelineLayer *layer)
{
CoglPipelineLayer *authority;
g_return_val_if_fail (_cogl_is_pipeline_layer (layer), 0);
_COGL_RETURN_VAL_IF_FAIL (_cogl_is_pipeline_layer (layer), 0);
authority =
_cogl_pipeline_layer_get_authority (layer,
@@ -1428,7 +1429,7 @@ _cogl_pipeline_layer_get_mag_filter (CoglPipelineLayer *layer)
{
CoglPipelineLayer *authority;
g_return_val_if_fail (_cogl_is_pipeline_layer (layer), 0);
_COGL_RETURN_VAL_IF_FAIL (_cogl_is_pipeline_layer (layer), 0);
authority =
_cogl_pipeline_layer_get_authority (layer,
@@ -1450,10 +1451,10 @@ cogl_pipeline_set_layer_filters (CoglPipeline *pipeline,
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
g_return_if_fail (mag_filter == COGL_PIPELINE_FILTER_NEAREST ||
mag_filter == COGL_PIPELINE_FILTER_LINEAR);
_COGL_RETURN_IF_FAIL (mag_filter == COGL_PIPELINE_FILTER_NEAREST ||
mag_filter == COGL_PIPELINE_FILTER_LINEAR);
/* Note: this will ensure that the layer exists, creating one if it
* doesn't already.

View File

@@ -209,7 +209,7 @@ cogl_pipeline_remove_layer (CoglPipeline *pipeline,
* @layer_index: Specifies the layer you want define a combine function for
* @blend_string: A <link linkend="cogl-Blend-Strings">Cogl blend string</link>
* describing the desired texture combine function.
* @error: A #GError that may report parse errors or lack of GPU/driver
* @error: A #CoglError that may report parse errors or lack of GPU/driver
* support. May be %NULL, in which case a warning will be printed out if an
* error is encountered.
*
@@ -301,7 +301,7 @@ gboolean
cogl_pipeline_set_layer_combine (CoglPipeline *pipeline,
int layer_index,
const char *blend_string,
GError **error);
CoglError **error);
/**
* cogl_pipeline_set_layer_combine_constant:
@@ -423,7 +423,7 @@ cogl_pipeline_get_layer_mag_filter (CoglPipeline *pipeline,
* @pipeline: A #CoglPipeline object
* @layer_index: the layer number to change.
* @enable: whether to enable point sprite coord generation.
* @error: A return location for a #GError, or NULL to ignore errors.
* @error: A return location for a CoglError, or NULL to ignore errors.
*
* When rendering points, if @enable is %TRUE then the texture
* coordinates for this layer will be replaced with coordinates that
@@ -444,7 +444,7 @@ gboolean
cogl_pipeline_set_layer_point_sprite_coords_enabled (CoglPipeline *pipeline,
int layer_index,
gboolean enable,
GError **error);
CoglError **error);
/**
* cogl_pipeline_get_layer_point_sprite_coords_enabled:

View File

@@ -173,7 +173,7 @@ _cogl_pipeline_layer_copy_differences (CoglPipelineLayer *dest,
while (differences)
{
int index = ffs (differences) - 1;
int index = _cogl_util_ffs (differences) - 1;
differences &= ~(1 << index);
@@ -351,7 +351,7 @@ _cogl_pipeline_layer_pre_change_notify (CoglPipeline *required_owner,
goto init_layer_state;
/* We only allow a NULL required_owner for new layers */
g_return_val_if_fail (required_owner != NULL, layer);
_COGL_RETURN_VAL_IF_FAIL (required_owner != NULL, layer);
/* Chain up:
* A modification of a layer is indirectly also a modification of

View File

@@ -40,6 +40,7 @@
#include "cogl-depth-state-private.h"
#include "cogl-pipeline-state-private.h"
#include "cogl-snippet-private.h"
#include "cogl-error-private.h"
#include <test-fixtures/test-unit.h>
@@ -54,7 +55,7 @@ _cogl_pipeline_get_user_program (CoglPipeline *pipeline)
{
CoglPipeline *authority;
g_return_val_if_fail (cogl_is_pipeline (pipeline), NULL);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), NULL);
authority =
_cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_USER_SHADER);
@@ -374,7 +375,7 @@ cogl_pipeline_get_color (CoglPipeline *pipeline,
{
CoglPipeline *authority;
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
authority =
_cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_COLOR);
@@ -400,7 +401,7 @@ cogl_pipeline_set_color (CoglPipeline *pipeline,
CoglPipelineState state = COGL_PIPELINE_STATE_COLOR;
CoglPipeline *authority;
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
authority = _cogl_pipeline_get_authority (pipeline, state);
@@ -451,7 +452,7 @@ _cogl_pipeline_get_blend_enabled (CoglPipeline *pipeline)
{
CoglPipeline *authority;
g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE);
authority =
_cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_BLEND_ENABLE);
@@ -472,9 +473,9 @@ _cogl_pipeline_set_blend_enabled (CoglPipeline *pipeline,
CoglPipelineState state = COGL_PIPELINE_STATE_BLEND_ENABLE;
CoglPipeline *authority;
g_return_if_fail (cogl_is_pipeline (pipeline));
g_return_if_fail (enable > 1 &&
"don't pass TRUE or FALSE to _set_blend_enabled!");
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (enable > 1 &&
"don't pass TRUE or FALSE to _set_blend_enabled!");
authority = _cogl_pipeline_get_authority (pipeline, state);
@@ -502,7 +503,7 @@ cogl_pipeline_get_ambient (CoglPipeline *pipeline,
{
CoglPipeline *authority;
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
authority =
_cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LIGHTING);
@@ -519,7 +520,7 @@ cogl_pipeline_set_ambient (CoglPipeline *pipeline,
CoglPipeline *authority;
CoglPipelineLightingState *lighting_state;
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
authority = _cogl_pipeline_get_authority (pipeline, state);
@@ -552,7 +553,7 @@ cogl_pipeline_get_diffuse (CoglPipeline *pipeline,
{
CoglPipeline *authority;
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
authority =
_cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LIGHTING);
@@ -569,7 +570,7 @@ cogl_pipeline_set_diffuse (CoglPipeline *pipeline,
CoglPipeline *authority;
CoglPipelineLightingState *lighting_state;
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
authority = _cogl_pipeline_get_authority (pipeline, state);
@@ -611,7 +612,7 @@ cogl_pipeline_get_specular (CoglPipeline *pipeline,
{
CoglPipeline *authority;
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
authority =
_cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LIGHTING);
@@ -627,7 +628,7 @@ cogl_pipeline_set_specular (CoglPipeline *pipeline, const CoglColor *specular)
CoglPipelineState state = COGL_PIPELINE_STATE_LIGHTING;
CoglPipelineLightingState *lighting_state;
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
authority = _cogl_pipeline_get_authority (pipeline, state);
@@ -659,7 +660,7 @@ cogl_pipeline_get_shininess (CoglPipeline *pipeline)
{
CoglPipeline *authority;
g_return_val_if_fail (cogl_is_pipeline (pipeline), 0);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), 0);
authority =
_cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LIGHTING);
@@ -675,7 +676,7 @@ cogl_pipeline_set_shininess (CoglPipeline *pipeline,
CoglPipelineState state = COGL_PIPELINE_STATE_LIGHTING;
CoglPipelineLightingState *lighting_state;
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
if (shininess < 0.0)
{
@@ -711,7 +712,7 @@ cogl_pipeline_get_emission (CoglPipeline *pipeline,
{
CoglPipeline *authority;
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
authority =
_cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LIGHTING);
@@ -727,7 +728,7 @@ cogl_pipeline_set_emission (CoglPipeline *pipeline, const CoglColor *emission)
CoglPipelineState state = COGL_PIPELINE_STATE_LIGHTING;
CoglPipelineLightingState *lighting_state;
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
authority = _cogl_pipeline_get_authority (pipeline, state);
@@ -762,7 +763,7 @@ _cogl_pipeline_set_alpha_test_function (CoglPipeline *pipeline,
CoglPipeline *authority;
CoglPipelineAlphaFuncState *alpha_state;
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
authority = _cogl_pipeline_get_authority (pipeline, state);
@@ -792,7 +793,7 @@ _cogl_pipeline_set_alpha_test_function_reference (CoglPipeline *pipeline,
CoglPipeline *authority;
CoglPipelineAlphaFuncState *alpha_state;
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
authority = _cogl_pipeline_get_authority (pipeline, state);
@@ -829,7 +830,7 @@ cogl_pipeline_get_alpha_test_function (CoglPipeline *pipeline)
{
CoglPipeline *authority;
g_return_val_if_fail (cogl_is_pipeline (pipeline), 0);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), 0);
authority =
_cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_ALPHA_FUNC);
@@ -842,7 +843,7 @@ cogl_pipeline_get_alpha_test_reference (CoglPipeline *pipeline)
{
CoglPipeline *authority;
g_return_val_if_fail (cogl_is_pipeline (pipeline), 0.0f);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), 0.0f);
authority =
_cogl_pipeline_get_authority (pipeline,
@@ -945,7 +946,7 @@ setup_blend_state (CoglBlendStringStatement *statement,
gboolean
cogl_pipeline_set_blend (CoglPipeline *pipeline,
const char *blend_description,
GError **error)
CoglError **error)
{
CoglPipelineState state = COGL_PIPELINE_STATE_BLEND;
CoglPipeline *authority;
@@ -957,7 +958,7 @@ cogl_pipeline_set_blend (CoglPipeline *pipeline,
_COGL_GET_CONTEXT (ctx, FALSE);
g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE);
count =
_cogl_blend_string_compile (blend_description,
@@ -1030,7 +1031,7 @@ cogl_pipeline_set_blend_constant (CoglPipeline *pipeline,
{
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
if (!_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_BLEND_CONSTANT))
return;
@@ -1070,7 +1071,7 @@ cogl_pipeline_get_user_program (CoglPipeline *pipeline)
{
CoglPipeline *authority;
g_return_val_if_fail (cogl_is_pipeline (pipeline), COGL_INVALID_HANDLE);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), COGL_INVALID_HANDLE);
authority =
_cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_USER_SHADER);
@@ -1091,7 +1092,7 @@ cogl_pipeline_set_user_program (CoglPipeline *pipeline,
CoglPipelineState state = COGL_PIPELINE_STATE_USER_SHADER;
CoglPipeline *authority;
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
authority = _cogl_pipeline_get_authority (pipeline, state);
@@ -1143,7 +1144,7 @@ cogl_pipeline_set_user_program (CoglPipeline *pipeline,
gboolean
cogl_pipeline_set_depth_state (CoglPipeline *pipeline,
const CoglDepthState *depth_state,
GError **error)
CoglError **error)
{
CoglPipelineState state = COGL_PIPELINE_STATE_DEPTH;
CoglPipeline *authority;
@@ -1151,8 +1152,8 @@ cogl_pipeline_set_depth_state (CoglPipeline *pipeline,
_COGL_GET_CONTEXT (ctx, FALSE);
g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE);
g_return_val_if_fail (depth_state->magic == COGL_DEPTH_STATE_MAGIC, FALSE);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE);
_COGL_RETURN_VAL_IF_FAIL (depth_state->magic == COGL_DEPTH_STATE_MAGIC, FALSE);
authority = _cogl_pipeline_get_authority (pipeline, state);
@@ -1185,7 +1186,7 @@ cogl_pipeline_get_depth_state (CoglPipeline *pipeline,
{
CoglPipeline *authority;
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
authority =
_cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_DEPTH);
@@ -1200,7 +1201,7 @@ _cogl_pipeline_set_fog_state (CoglPipeline *pipeline,
CoglPipeline *authority;
CoglPipelineFogState *current_fog_state;
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
authority = _cogl_pipeline_get_authority (pipeline, state);
@@ -1235,7 +1236,7 @@ cogl_pipeline_set_cull_face_mode (CoglPipeline *pipeline,
CoglPipeline *authority;
CoglPipelineCullFaceState *cull_face_state;
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
authority = _cogl_pipeline_get_authority (pipeline, state);
@@ -1265,7 +1266,7 @@ cogl_pipeline_set_front_face_winding (CoglPipeline *pipeline,
CoglPipeline *authority;
CoglPipelineCullFaceState *cull_face_state;
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
authority = _cogl_pipeline_get_authority (pipeline, state);
@@ -1293,8 +1294,8 @@ cogl_pipeline_get_cull_face_mode (CoglPipeline *pipeline)
CoglPipelineState state = COGL_PIPELINE_STATE_CULL_FACE;
CoglPipeline *authority;
g_return_val_if_fail (cogl_is_pipeline (pipeline),
COGL_PIPELINE_CULL_FACE_MODE_NONE);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline),
COGL_PIPELINE_CULL_FACE_MODE_NONE);
authority = _cogl_pipeline_get_authority (pipeline, state);
@@ -1307,8 +1308,8 @@ cogl_pipeline_get_front_face_winding (CoglPipeline *pipeline)
CoglPipelineState state = COGL_PIPELINE_STATE_CULL_FACE;
CoglPipeline *authority;
g_return_val_if_fail (cogl_is_pipeline (pipeline),
COGL_PIPELINE_CULL_FACE_MODE_NONE);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline),
COGL_PIPELINE_CULL_FACE_MODE_NONE);
authority = _cogl_pipeline_get_authority (pipeline, state);
@@ -1320,7 +1321,7 @@ cogl_pipeline_get_point_size (CoglPipeline *pipeline)
{
CoglPipeline *authority;
g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE);
authority =
_cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_POINT_SIZE);
@@ -1335,7 +1336,7 @@ _cogl_pipeline_set_non_zero_point_size (CoglPipeline *pipeline,
CoglPipelineState state = COGL_PIPELINE_STATE_NON_ZERO_POINT_SIZE;
CoglPipeline *authority;
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
authority = _cogl_pipeline_get_authority (pipeline, state);
@@ -1359,7 +1360,7 @@ cogl_pipeline_set_point_size (CoglPipeline *pipeline,
CoglPipelineState state = COGL_PIPELINE_STATE_POINT_SIZE;
CoglPipeline *authority;
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
authority = _cogl_pipeline_get_authority (pipeline, state);
@@ -1388,13 +1389,13 @@ cogl_pipeline_set_point_size (CoglPipeline *pipeline,
gboolean
cogl_pipeline_set_per_vertex_point_size (CoglPipeline *pipeline,
gboolean enable,
GError **error)
CoglError **error)
{
CoglPipelineState state = COGL_PIPELINE_STATE_PER_VERTEX_POINT_SIZE;
CoglPipeline *authority;
_COGL_GET_CONTEXT (ctx, FALSE);
g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE);
authority = _cogl_pipeline_get_authority (pipeline, state);
@@ -1405,10 +1406,10 @@ cogl_pipeline_set_per_vertex_point_size (CoglPipeline *pipeline,
if (enable && !cogl_has_feature (ctx, COGL_FEATURE_ID_PER_VERTEX_POINT_SIZE))
{
g_set_error_literal (error,
COGL_SYSTEM_ERROR,
COGL_SYSTEM_ERROR_UNSUPPORTED,
"Per-vertex point size is not supported");
_cogl_set_error (error,
COGL_SYSTEM_ERROR,
COGL_SYSTEM_ERROR_UNSUPPORTED,
"Per-vertex point size is not supported");
return FALSE;
}
@@ -1433,7 +1434,7 @@ cogl_pipeline_get_per_vertex_point_size (CoglPipeline *pipeline)
{
CoglPipeline *authority;
g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE);
authority =
_cogl_pipeline_get_authority (pipeline,

View File

@@ -390,7 +390,7 @@ cogl_pipeline_get_alpha_test_reference (CoglPipeline *pipeline);
* @pipeline: A #CoglPipeline object
* @blend_string: A <link linkend="cogl-Blend-Strings">Cogl blend string</link>
* describing the desired blend function.
* @error: return location for a #GError that may report lack of driver
* @error: return location for a #CoglError that may report lack of driver
* support if you give separate blend string statements for the alpha
* channel and RGB channels since some drivers, or backends such as
* GLES 1.1, don't support this feature. May be %NULL, in which case a
@@ -470,7 +470,7 @@ cogl_pipeline_get_alpha_test_reference (CoglPipeline *pipeline);
gboolean
cogl_pipeline_set_blend (CoglPipeline *pipeline,
const char *blend_string,
GError **error);
CoglError **error);
/**
* cogl_pipeline_set_blend_constant:
@@ -531,7 +531,7 @@ cogl_pipeline_get_point_size (CoglPipeline *pipeline);
* cogl_pipeline_set_per_vertex_point_size:
* @pipeline: a #CoglPipeline pointer
* @enable: whether to enable per-vertex point size
* @error: a location to store a #GError if the change failed
* @error: a location to store a #CoglError if the change failed
*
* Sets whether to use a per-vertex point size or to use the value set
* by cogl_pipeline_set_point_size(). If per-vertex point size is
@@ -547,7 +547,7 @@ cogl_pipeline_get_point_size (CoglPipeline *pipeline);
* Note that enabling this will only work if the
* %COGL_FEATURE_ID_PER_VERTEX_POINT_SIZE feature is available. If
* this is not available then the function will return %FALSE and set
* a #GError.
* a #CoglError.
*
* Since: 2.0
* Stability: Unstable
@@ -556,7 +556,7 @@ cogl_pipeline_get_point_size (CoglPipeline *pipeline);
gboolean
cogl_pipeline_set_per_vertex_point_size (CoglPipeline *pipeline,
gboolean enable,
GError **error);
CoglError **error);
/**
* cogl_pipeline_get_per_vertex_point_size:
@@ -637,7 +637,7 @@ cogl_pipeline_set_user_program (CoglPipeline *pipeline,
* cogl_pipeline_set_depth_state: (skip)
* @pipeline: A #CoglPipeline object
* @state: A #CoglDepthState struct
* @error: A #GError to report failures to setup the given @state.
* @error: A #CoglError to report failures to setup the given @state.
*
* This commits all the depth state configured in @state struct to the
* given @pipeline. The configuration values are copied into the
@@ -656,7 +656,7 @@ cogl_pipeline_set_user_program (CoglPipeline *pipeline,
gboolean
cogl_pipeline_set_depth_state (CoglPipeline *pipeline,
const CoglDepthState *state,
GError **error);
CoglError **error);
/**
* cogl_pipeline_get_depth_state: (skip)

View File

@@ -276,7 +276,7 @@ _cogl_pipeline_promote_weak_ancestors (CoglPipeline *strong)
{
CoglNode *n;
g_return_if_fail (!strong->is_weak);
_COGL_RETURN_IF_FAIL (!strong->is_weak);
/* If the parent of strong is weak, then we want to promote it by
taking a reference on strong's grandparent. We don't need to take
@@ -298,7 +298,7 @@ _cogl_pipeline_revert_weak_ancestors (CoglPipeline *strong)
{
CoglNode *n;
g_return_if_fail (!strong->is_weak);
_COGL_RETURN_IF_FAIL (!strong->is_weak);
/* This reverts the effect of calling
_cogl_pipeline_promote_weak_ancestors */
@@ -474,7 +474,7 @@ _cogl_pipeline_free (CoglPipeline *pipeline)
gboolean
_cogl_pipeline_get_real_blend_enabled (CoglPipeline *pipeline)
{
g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE);
return pipeline->real_blend_enable;
}
@@ -579,7 +579,7 @@ _cogl_pipeline_foreach_layer_internal (CoglPipeline *pipeline,
for (i = 0, cont = TRUE; i < n_layers && cont == TRUE; i++)
{
g_return_if_fail (authority->layers_cache_dirty == FALSE);
_COGL_RETURN_IF_FAIL (authority->layers_cache_dirty == FALSE);
cont = callback (authority->layers_cache[i], user_data);
}
}
@@ -1077,7 +1077,7 @@ _cogl_pipeline_init_multi_property_sparse_state (CoglPipeline *pipeline,
{
CoglPipeline *authority;
g_return_if_fail (change & COGL_PIPELINE_STATE_ALL_SPARSE);
_COGL_RETURN_IF_FAIL (change & COGL_PIPELINE_STATE_ALL_SPARSE);
if (!(change & COGL_PIPELINE_STATE_MULTI_PROPERTY))
return;
@@ -1420,7 +1420,7 @@ _cogl_pipeline_add_layer_difference (CoglPipeline *pipeline,
CoglPipelineLayer *layer,
gboolean inc_n_layers)
{
g_return_if_fail (layer->owner == NULL);
_COGL_RETURN_IF_FAIL (layer->owner == NULL);
layer->owner = pipeline;
cogl_object_ref (layer);
@@ -1816,7 +1816,7 @@ _cogl_pipeline_prune_empty_layer_difference (CoglPipeline *layers_authority,
CoglPipelineLayerInfo layer_info;
CoglPipeline *old_layers_authority;
g_return_if_fail (link != NULL);
_COGL_RETURN_IF_FAIL (link != NULL);
/* If the layer's parent doesn't have an owner then we can simply
* take ownership ourselves and drop our reference on the empty
@@ -2401,7 +2401,7 @@ _cogl_pipeline_get_fog_enabled (CoglPipeline *pipeline)
{
CoglPipeline *authority;
g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE);
authority =
_cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_FOG);
@@ -2411,7 +2411,7 @@ _cogl_pipeline_get_fog_enabled (CoglPipeline *pipeline)
unsigned long
_cogl_pipeline_get_age (CoglPipeline *pipeline)
{
g_return_val_if_fail (cogl_is_pipeline (pipeline), 0);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), 0);
return pipeline->age;
}
@@ -2423,7 +2423,7 @@ cogl_pipeline_remove_layer (CoglPipeline *pipeline, int layer_index)
CoglPipelineLayerInfo layer_info;
int i;
g_return_if_fail (cogl_is_pipeline (pipeline));
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
authority =
_cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LAYERS);
@@ -2486,7 +2486,7 @@ prepend_layer_to_list_cb (CoglPipelineLayer *layer,
const GList *
_cogl_pipeline_get_layers (CoglPipeline *pipeline)
{
g_return_val_if_fail (cogl_is_pipeline (pipeline), NULL);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), NULL);
if (!pipeline->deprecated_get_layers_list_dirty)
g_list_free (pipeline->deprecated_get_layers_list);
@@ -2509,7 +2509,7 @@ cogl_pipeline_get_n_layers (CoglPipeline *pipeline)
{
CoglPipeline *authority;
g_return_val_if_fail (cogl_is_pipeline (pipeline), 0);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), 0);
authority =
_cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LAYERS);

View File

@@ -77,7 +77,7 @@ static CoglPixelBuffer *
_cogl_pixel_buffer_new (CoglContext *context,
size_t size,
const void *data,
GError **error)
CoglError **error)
{
CoglPixelBuffer *pixel_buffer = g_slice_new0 (CoglPixelBuffer);
CoglBuffer *buffer = COGL_BUFFER (pixel_buffer);
@@ -113,11 +113,11 @@ cogl_pixel_buffer_new (CoglContext *context,
size_t size,
const void *data)
{
GError *ignore_error = NULL;
CoglError *ignore_error = NULL;
CoglPixelBuffer *buffer =
_cogl_pixel_buffer_new (context, size, data, &ignore_error);
g_clear_error (&ignore_error);
if (!buffer)
cogl_error_free (ignore_error);
return buffer;
}

View File

@@ -29,7 +29,6 @@
*/
#include "cogl-config.h"
#include "cogl-defines.h"
#include <string.h>
#include <math.h>
@@ -309,66 +308,3 @@ cogl_pixel_format_to_string (CoglPixelFormat format)
g_assert_not_reached ();
}
#ifdef COGL_HAS_LIBDRM
typedef struct _PixelFormatMap {
uint32_t drm_format;
CoglPixelFormat cogl_format;
CoglTextureComponents cogl_components;
} PixelFormatMap;
static const PixelFormatMap pixel_format_map[] = {
/* DRM formats are defined as little-endian, not machine endian. */
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
{ DRM_FORMAT_RGB565, COGL_PIXEL_FORMAT_RGB_565, COGL_TEXTURE_COMPONENTS_RGB },
{ DRM_FORMAT_ABGR8888, COGL_PIXEL_FORMAT_RGBA_8888_PRE, COGL_TEXTURE_COMPONENTS_RGBA },
{ DRM_FORMAT_XBGR8888, COGL_PIXEL_FORMAT_RGBA_8888_PRE, COGL_TEXTURE_COMPONENTS_RGB },
{ DRM_FORMAT_ARGB8888, COGL_PIXEL_FORMAT_BGRA_8888_PRE, COGL_TEXTURE_COMPONENTS_RGBA },
{ DRM_FORMAT_XRGB8888, COGL_PIXEL_FORMAT_BGRA_8888_PRE, COGL_TEXTURE_COMPONENTS_RGB },
{ DRM_FORMAT_BGRA8888, COGL_PIXEL_FORMAT_ARGB_8888_PRE, COGL_TEXTURE_COMPONENTS_RGBA },
{ DRM_FORMAT_BGRX8888, COGL_PIXEL_FORMAT_ARGB_8888_PRE, COGL_TEXTURE_COMPONENTS_RGB },
{ DRM_FORMAT_RGBA8888, COGL_PIXEL_FORMAT_ABGR_8888_PRE, COGL_TEXTURE_COMPONENTS_RGBA },
{ DRM_FORMAT_RGBX8888, COGL_PIXEL_FORMAT_ABGR_8888_PRE, COGL_TEXTURE_COMPONENTS_RGB },
#elif G_BYTE_ORDER == G_BIG_ENDIAN
/* DRM_FORMAT_RGB565 cannot be expressed. */
{ DRM_FORMAT_ABGR8888, COGL_PIXEL_FORMAT_ABGR_8888_PRE, COGL_TEXTURE_COMPONENTS_RGBA },
{ DRM_FORMAT_XBGR8888, COGL_PIXEL_FORMAT_ABGR_8888_PRE, COGL_TEXTURE_COMPONENTS_RGB },
{ DRM_FORMAT_ARGB8888, COGL_PIXEL_FORMAT_ARGB_8888_PRE, COGL_TEXTURE_COMPONENTS_RGBA },
{ DRM_FORMAT_XRGB8888, COGL_PIXEL_FORMAT_ARGB_8888_PRE, COGL_TEXTURE_COMPONENTS_RGB },
{ DRM_FORMAT_BGRA8888, COGL_PIXEL_FORMAT_BGRA_8888_PRE, COGL_TEXTURE_COMPONENTS_RGBA },
{ DRM_FORMAT_BGRX8888, COGL_PIXEL_FORMAT_BGRA_8888_PRE, COGL_TEXTURE_COMPONENTS_RGB },
{ DRM_FORMAT_RGBA8888, COGL_PIXEL_FORMAT_RGBA_8888_PRE, COGL_TEXTURE_COMPONENTS_RGBA },
{ DRM_FORMAT_RGBX8888, COGL_PIXEL_FORMAT_RGBA_8888_PRE, COGL_TEXTURE_COMPONENTS_RGB },
#else
#error "unexpected G_BYTE_ORDER"
#endif
};
gboolean
cogl_pixel_format_from_drm_format (uint32_t drm_format,
CoglPixelFormat *out_format,
CoglTextureComponents *out_components)
{
const size_t n = G_N_ELEMENTS (pixel_format_map);
size_t i;
for (i = 0; i < n; i++)
{
if (pixel_format_map[i].drm_format == drm_format)
break;
}
if (i == n)
return FALSE;
if (out_format)
*out_format = pixel_format_map[i].cogl_format;
if (out_components)
*out_components = pixel_format_map[i].cogl_components;
return TRUE;
}
#endif

View File

@@ -38,12 +38,7 @@
#include <stdint.h>
#include <stddef.h>
#ifdef COGL_HAS_LIBDRM
#include <drm_fourcc.h>
#endif
#include <cogl/cogl-defines.h>
#include <cogl/cogl-texture-components.h>
#include <glib.h>
#include <glib-object.h>
@@ -63,9 +58,6 @@ G_BEGIN_DECLS
*
* Other examples of factors that can influence the layout in memory are the
* system's endianness.
*
* This file also contains methods to map Linux DRM 4CC codes to
* CoglPixelFormats.
*/
#define COGL_A_BIT (1 << 4)
@@ -303,34 +295,6 @@ _cogl_pixel_format_is_endian_dependant (CoglPixelFormat format);
const char *
cogl_pixel_format_to_string (CoglPixelFormat format);
#ifdef COGL_HAS_LIBDRM
/* added in libdrm 2.4.95 */
#ifndef DRM_FORMAT_INVALID
#define DRM_FORMAT_INVALID 0
#endif
/**
* cogl_pixel_format_from_drm_format:
* @drm_format: The DRM 4CC code (as specified in drm_fourcc.h)
* @out_format: (out) (optional): The corresponding #CoglPixelFormat (if successful)
* @out_components: (out) (optional): The corresponding #CoglTextureComponents,
* if sucessful.
*
* Does an internal lookup to find a #CoglPixelFormat that matches the given
* DRM 4CC code. If no such format could be found, this function will return
* %FALSE and the output parameters will stay untouched.
*
* Returns: %TRUE if a #CoglPixelFormat corresponding to the 4CC code exists,
* %FALSE otherwise.
*/
gboolean
cogl_pixel_format_from_drm_format (uint32_t drm_format,
CoglPixelFormat *out_format,
CoglTextureComponents *out_components);
#endif /* COGL_HAS_LIBDRM */
G_END_DECLS
#endif /* __COGL_PIXEL_FORMAT_H__ */

View File

@@ -53,10 +53,10 @@ cogl_poll_renderer_get_info (CoglRenderer *renderer,
{
GList *l, *next;
g_return_val_if_fail (cogl_is_renderer (renderer), 0);
g_return_val_if_fail (poll_fds != NULL, 0);
g_return_val_if_fail (n_poll_fds != NULL, 0);
g_return_val_if_fail (timeout != NULL, 0);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_renderer (renderer), 0);
_COGL_RETURN_VAL_IF_FAIL (poll_fds != NULL, 0);
_COGL_RETURN_VAL_IF_FAIL (n_poll_fds != NULL, 0);
_COGL_RETURN_VAL_IF_FAIL (timeout != NULL, 0);
*timeout = -1;
@@ -95,7 +95,7 @@ cogl_poll_renderer_dispatch (CoglRenderer *renderer,
{
GList *l, *next;
g_return_if_fail (cogl_is_renderer (renderer));
_COGL_RETURN_IF_FAIL (cogl_is_renderer (renderer));
_cogl_closure_list_invoke_no_args (&renderer->idle_closures);

View File

@@ -48,7 +48,7 @@ cogl_primitive_texture_set_auto_mipmap (CoglPrimitiveTexture *primitive_texture,
{
CoglTexture *texture;
g_return_if_fail (cogl_is_primitive_texture (primitive_texture));
_COGL_RETURN_IF_FAIL (cogl_is_primitive_texture (primitive_texture));
texture = COGL_TEXTURE (primitive_texture);

View File

@@ -74,7 +74,7 @@ cogl_primitive_new_with_attributes (CoglVerticesMode mode,
CoglAttribute *attribute = attributes[i];
cogl_object_ref (attribute);
g_return_val_if_fail (cogl_is_attribute (attribute), NULL);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_attribute (attribute), NULL);
primitive->attributes[i] = attribute;
}
@@ -414,7 +414,7 @@ cogl_primitive_set_attributes (CoglPrimitive *primitive,
{
int i;
g_return_if_fail (cogl_is_primitive (primitive));
_COGL_RETURN_IF_FAIL (cogl_is_primitive (primitive));
if (G_UNLIKELY (primitive->immutable_ref))
{
@@ -427,7 +427,7 @@ cogl_primitive_set_attributes (CoglPrimitive *primitive,
* attribute thats actually in the new list too. */
for (i = 0; i < n_attributes; i++)
{
g_return_if_fail (cogl_is_attribute (attributes[i]));
_COGL_RETURN_IF_FAIL (cogl_is_attribute (attributes[i]));
cogl_object_ref (attributes[i]);
}
@@ -463,7 +463,7 @@ cogl_primitive_set_attributes (CoglPrimitive *primitive,
int
cogl_primitive_get_first_vertex (CoglPrimitive *primitive)
{
g_return_val_if_fail (cogl_is_primitive (primitive), 0);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_primitive (primitive), 0);
return primitive->first_vertex;
}
@@ -472,7 +472,7 @@ void
cogl_primitive_set_first_vertex (CoglPrimitive *primitive,
int first_vertex)
{
g_return_if_fail (cogl_is_primitive (primitive));
_COGL_RETURN_IF_FAIL (cogl_is_primitive (primitive));
if (G_UNLIKELY (primitive->immutable_ref))
{
@@ -486,7 +486,7 @@ cogl_primitive_set_first_vertex (CoglPrimitive *primitive,
int
cogl_primitive_get_n_vertices (CoglPrimitive *primitive)
{
g_return_val_if_fail (cogl_is_primitive (primitive), 0);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_primitive (primitive), 0);
return primitive->n_vertices;
}
@@ -495,7 +495,7 @@ void
cogl_primitive_set_n_vertices (CoglPrimitive *primitive,
int n_vertices)
{
g_return_if_fail (cogl_is_primitive (primitive));
_COGL_RETURN_IF_FAIL (cogl_is_primitive (primitive));
primitive->n_vertices = n_vertices;
}
@@ -503,7 +503,7 @@ cogl_primitive_set_n_vertices (CoglPrimitive *primitive,
CoglVerticesMode
cogl_primitive_get_mode (CoglPrimitive *primitive)
{
g_return_val_if_fail (cogl_is_primitive (primitive), 0);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_primitive (primitive), 0);
return primitive->mode;
}
@@ -512,7 +512,7 @@ void
cogl_primitive_set_mode (CoglPrimitive *primitive,
CoglVerticesMode mode)
{
g_return_if_fail (cogl_is_primitive (primitive));
_COGL_RETURN_IF_FAIL (cogl_is_primitive (primitive));
if (G_UNLIKELY (primitive->immutable_ref))
{
@@ -528,7 +528,7 @@ cogl_primitive_set_indices (CoglPrimitive *primitive,
CoglIndices *indices,
int n_indices)
{
g_return_if_fail (cogl_is_primitive (primitive));
_COGL_RETURN_IF_FAIL (cogl_is_primitive (primitive));
if (G_UNLIKELY (primitive->immutable_ref))
{
@@ -571,7 +571,7 @@ _cogl_primitive_immutable_ref (CoglPrimitive *primitive)
{
int i;
g_return_val_if_fail (cogl_is_primitive (primitive), NULL);
_COGL_RETURN_VAL_IF_FAIL (cogl_is_primitive (primitive), NULL);
primitive->immutable_ref++;
@@ -586,8 +586,8 @@ _cogl_primitive_immutable_unref (CoglPrimitive *primitive)
{
int i;
g_return_if_fail (cogl_is_primitive (primitive));
g_return_if_fail (primitive->immutable_ref > 0);
_COGL_RETURN_IF_FAIL (cogl_is_primitive (primitive));
_COGL_RETURN_IF_FAIL (primitive->immutable_ref > 0);
primitive->immutable_ref--;

View File

@@ -330,8 +330,8 @@ cogl_quaternion_equal (const void *v1, const void *v2)
const CoglQuaternion *a = v1;
const CoglQuaternion *b = v2;
g_return_val_if_fail (v1 != NULL, FALSE);
g_return_val_if_fail (v2 != NULL, FALSE);
_COGL_RETURN_VAL_IF_FAIL (v1 != NULL, FALSE);
_COGL_RETURN_VAL_IF_FAIL (v2 != NULL, FALSE);
if (v1 == v2)
return TRUE;
@@ -447,7 +447,7 @@ cogl_quaternion_multiply (CoglQuaternion *result,
float y = a->y;
float z = a->z;
g_return_if_fail (b != result);
_COGL_RETURN_IF_FAIL (b != result);
result->w = w * b->w - x * b->x - y * b->y - z * b->z;
@@ -504,7 +504,7 @@ cogl_quaternion_slerp (CoglQuaternion *result,
float fa;
float fb;
g_return_if_fail (t >=0 && t <= 1.0f);
_COGL_RETURN_IF_FAIL (t >=0 && t <= 1.0f);
if (t == 0)
{
@@ -591,7 +591,7 @@ cogl_quaternion_nlerp (CoglQuaternion *result,
float fa;
float fb;
g_return_if_fail (t >=0 && t <= 1.0f);
_COGL_RETURN_IF_FAIL (t >=0 && t <= 1.0f);
if (t == 0)
{

Some files were not shown because too many files have changed in this diff Show More