cogl: Port Node/Pipeline/PipelineLayer away from CoglObject

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
This commit is contained in:
Bilal Elmoussaoui 2023-09-19 11:16:43 +02:00 committed by Marge Bot
parent 80ce052a47
commit 9b9e12edb2
87 changed files with 649 additions and 532 deletions

View File

@ -117,7 +117,7 @@ clutter_blur_effect_create_pipeline (ClutterOffscreenEffect *effect,
cogl_pipeline_set_layer_texture (blur_effect->pipeline, 0, texture); cogl_pipeline_set_layer_texture (blur_effect->pipeline, 0, texture);
return cogl_object_ref (blur_effect->pipeline); return g_object_ref (blur_effect->pipeline);
} }
static gboolean static gboolean
@ -147,7 +147,7 @@ clutter_blur_effect_dispose (GObject *gobject)
{ {
ClutterBlurEffect *self = CLUTTER_BLUR_EFFECT (gobject); ClutterBlurEffect *self = CLUTTER_BLUR_EFFECT (gobject);
cogl_clear_object (&self->pipeline); g_clear_object (&self->pipeline);
G_OBJECT_CLASS (clutter_blur_effect_parent_class)->dispose (gobject); G_OBJECT_CLASS (clutter_blur_effect_parent_class)->dispose (gobject);
} }

View File

@ -326,7 +326,7 @@ apply_blur_pass (BlurPass *pass)
static void static void
clear_blur_pass (BlurPass *pass) clear_blur_pass (BlurPass *pass)
{ {
cogl_clear_object (&pass->pipeline); g_clear_object (&pass->pipeline);
g_clear_object (&pass->texture); g_clear_object (&pass->texture);
g_clear_object (&pass->framebuffer); g_clear_object (&pass->framebuffer);
} }

View File

@ -130,7 +130,7 @@ clutter_brightness_contrast_effect_create_pipeline (ClutterOffscreenEffect *effe
cogl_pipeline_set_layer_texture (self->pipeline, 0, texture); cogl_pipeline_set_layer_texture (self->pipeline, 0, texture);
return cogl_object_ref (self->pipeline); return g_object_ref (self->pipeline);
} }
static gboolean static gboolean
@ -155,7 +155,7 @@ clutter_brightness_contrast_effect_dispose (GObject *gobject)
{ {
ClutterBrightnessContrastEffect *self = CLUTTER_BRIGHTNESS_CONTRAST_EFFECT (gobject); ClutterBrightnessContrastEffect *self = CLUTTER_BRIGHTNESS_CONTRAST_EFFECT (gobject);
cogl_clear_object (&self->pipeline); g_clear_object (&self->pipeline);
G_OBJECT_CLASS (clutter_brightness_contrast_effect_parent_class)->dispose (gobject); G_OBJECT_CLASS (clutter_brightness_contrast_effect_parent_class)->dispose (gobject);
} }

View File

@ -105,7 +105,7 @@ clutter_colorize_effect_create_pipeline (ClutterOffscreenEffect *effect,
cogl_pipeline_set_layer_texture (colorize_effect->pipeline, 0, texture); cogl_pipeline_set_layer_texture (colorize_effect->pipeline, 0, texture);
return cogl_object_ref (colorize_effect->pipeline); return g_object_ref (colorize_effect->pipeline);
} }
static void static void
@ -113,7 +113,7 @@ clutter_colorize_effect_dispose (GObject *gobject)
{ {
ClutterColorizeEffect *self = CLUTTER_COLORIZE_EFFECT (gobject); ClutterColorizeEffect *self = CLUTTER_COLORIZE_EFFECT (gobject);
cogl_clear_object (&self->pipeline); g_clear_object (&self->pipeline);
G_OBJECT_CLASS (clutter_colorize_effect_parent_class)->dispose (gobject); G_OBJECT_CLASS (clutter_colorize_effect_parent_class)->dispose (gobject);
} }

View File

@ -313,7 +313,7 @@ clutter_deform_effect_paint_target (ClutterOffscreenEffect *effect,
clutter_paint_node_add_primitive (back_node, priv->primitive); clutter_paint_node_add_primitive (back_node, priv->primitive);
clutter_paint_node_unref (back_node); clutter_paint_node_unref (back_node);
cogl_object_unref (back_pipeline); g_object_unref (back_pipeline);
} }
if (G_UNLIKELY (priv->lines_primitive != NULL)) if (G_UNLIKELY (priv->lines_primitive != NULL))
@ -487,7 +487,7 @@ clutter_deform_effect_free_back_pipeline (ClutterDeformEffect *self)
{ {
ClutterDeformEffectPrivate *priv = self->priv; ClutterDeformEffectPrivate *priv = self->priv;
cogl_clear_object (&priv->back_pipeline); g_clear_object (&priv->back_pipeline);
} }
static void static void
@ -522,7 +522,7 @@ clutter_deform_effect_set_property (GObject *gobject,
break; break;
case PROP_BACK_MATERIAL: case PROP_BACK_MATERIAL:
clutter_deform_effect_set_back_material (self, g_value_get_pointer (value)); clutter_deform_effect_set_back_material (self, g_value_get_object (value));
break; break;
default: default:
@ -550,7 +550,7 @@ clutter_deform_effect_get_property (GObject *gobject,
break; break;
case PROP_BACK_MATERIAL: case PROP_BACK_MATERIAL:
g_value_set_pointer (value, priv->back_pipeline); g_value_set_object (value, priv->back_pipeline);
break; break;
default: default:
@ -601,7 +601,8 @@ clutter_deform_effect_class_init (ClutterDeformEffectClass *klass)
* By default, no material will be used * By default, no material will be used
*/ */
obj_props[PROP_BACK_MATERIAL] = obj_props[PROP_BACK_MATERIAL] =
g_param_spec_pointer ("back-material", NULL, NULL, g_param_spec_object ("back-material", NULL, NULL,
COGL_TYPE_PIPELINE,
CLUTTER_PARAM_READWRITE); CLUTTER_PARAM_READWRITE);
gobject_class->finalize = clutter_deform_effect_finalize; gobject_class->finalize = clutter_deform_effect_finalize;
@ -644,7 +645,7 @@ clutter_deform_effect_set_back_material (ClutterDeformEffect *effect,
ClutterDeformEffectPrivate *priv; ClutterDeformEffectPrivate *priv;
g_return_if_fail (CLUTTER_IS_DEFORM_EFFECT (effect)); g_return_if_fail (CLUTTER_IS_DEFORM_EFFECT (effect));
g_return_if_fail (pipeline == NULL || cogl_is_pipeline (pipeline)); g_return_if_fail (pipeline == NULL || COGL_IS_PIPELINE (pipeline));
priv = effect->priv; priv = effect->priv;
@ -652,7 +653,7 @@ clutter_deform_effect_set_back_material (ClutterDeformEffect *effect,
priv->back_pipeline = pipeline; priv->back_pipeline = pipeline;
if (priv->back_pipeline != NULL) if (priv->back_pipeline != NULL)
cogl_object_ref (priv->back_pipeline); g_object_ref (priv->back_pipeline);
clutter_deform_effect_invalidate (effect); clutter_deform_effect_invalidate (effect);
} }

View File

@ -116,7 +116,7 @@ clutter_desaturate_effect_create_pipeline (ClutterOffscreenEffect *effect,
cogl_pipeline_set_layer_texture (desaturate_effect->pipeline, 0, texture); cogl_pipeline_set_layer_texture (desaturate_effect->pipeline, 0, texture);
return cogl_object_ref (desaturate_effect->pipeline); return g_object_ref (desaturate_effect->pipeline);
} }
static void static void
@ -124,7 +124,7 @@ clutter_desaturate_effect_dispose (GObject *gobject)
{ {
ClutterDesaturateEffect *self = CLUTTER_DESATURATE_EFFECT (gobject); ClutterDesaturateEffect *self = CLUTTER_DESATURATE_EFFECT (gobject);
cogl_clear_object (&self->pipeline); g_clear_object (&self->pipeline);
G_OBJECT_CLASS (clutter_desaturate_effect_parent_class)->dispose (gobject); G_OBJECT_CLASS (clutter_desaturate_effect_parent_class)->dispose (gobject);
} }

View File

@ -101,13 +101,13 @@
* // Clear the previous state // * // Clear the previous state //
* if (self->rect_1) * if (self->rect_1)
* { * {
* cogl_object_unref (self->rect_1); * g_object_unref (self->rect_1);
* self->rect_1 = NULL; * self->rect_1 = NULL;
* } * }
* *
* if (self->rect_2) * if (self->rect_2)
* { * {
* cogl_object_unref (self->rect_2); * g_object_unref (self->rect_2);
* self->rect_2 = NULL; * self->rect_2 = NULL;
* } * }
* *

View File

@ -274,7 +274,7 @@ update_fbo (ClutterEffect *effect,
error->message); error->message);
g_object_unref (offscreen); g_object_unref (offscreen);
cogl_clear_object (&priv->pipeline); g_clear_object (&priv->pipeline);
priv->target_width = 0; priv->target_width = 0;
priv->target_height = 0; priv->target_height = 0;
@ -284,7 +284,7 @@ update_fbo (ClutterEffect *effect,
priv->offscreen = offscreen; priv->offscreen = offscreen;
cogl_clear_object (&priv->pipeline); g_clear_object (&priv->pipeline);
priv->pipeline = offscreen_class->create_pipeline (self, priv->texture); priv->pipeline = offscreen_class->create_pipeline (self, priv->texture);
return TRUE; return TRUE;
@ -577,7 +577,7 @@ clutter_offscreen_effect_finalize (GObject *gobject)
g_clear_object (&priv->offscreen); g_clear_object (&priv->offscreen);
g_clear_object (&priv->texture); g_clear_object (&priv->texture);
g_clear_pointer (&priv->pipeline, cogl_object_unref); g_clear_object (&priv->pipeline);
G_OBJECT_CLASS (clutter_offscreen_effect_parent_class)->finalize (gobject); G_OBJECT_CLASS (clutter_offscreen_effect_parent_class)->finalize (gobject);
} }

View File

@ -384,7 +384,7 @@ clutter_pipeline_node_finalize (ClutterPaintNode *node)
ClutterPipelineNode *pnode = CLUTTER_PIPELINE_NODE (node); ClutterPipelineNode *pnode = CLUTTER_PIPELINE_NODE (node);
if (pnode->pipeline != NULL) if (pnode->pipeline != NULL)
cogl_object_unref (pnode->pipeline); g_object_unref (pnode->pipeline);
CLUTTER_PAINT_NODE_CLASS (clutter_pipeline_node_parent_class)->finalize (node); CLUTTER_PAINT_NODE_CLASS (clutter_pipeline_node_parent_class)->finalize (node);
} }
@ -554,7 +554,7 @@ clutter_pipeline_node_init (ClutterPipelineNode *self)
* paint its contents. * paint its contents.
* *
* This function will acquire a reference on the passed @pipeline, * This function will acquire a reference on the passed @pipeline,
* so it is safe to call cogl_object_unref() when it returns. * so it is safe to call g_object_unref() when it returns.
* *
* Return value: (transfer full): the newly created #ClutterPaintNode. * Return value: (transfer full): the newly created #ClutterPaintNode.
* Use clutter_paint_node_unref() when done. * Use clutter_paint_node_unref() when done.
@ -564,12 +564,12 @@ clutter_pipeline_node_new (CoglPipeline *pipeline)
{ {
ClutterPipelineNode *res; ClutterPipelineNode *res;
g_return_val_if_fail (pipeline == NULL || cogl_is_pipeline (pipeline), NULL); g_return_val_if_fail (pipeline == NULL || COGL_IS_PIPELINE (pipeline), NULL);
res = _clutter_paint_node_create (CLUTTER_TYPE_PIPELINE_NODE); res = _clutter_paint_node_create (CLUTTER_TYPE_PIPELINE_NODE);
if (pipeline != NULL) if (pipeline != NULL)
res->pipeline = cogl_object_ref (pipeline); res->pipeline = g_object_ref (pipeline);
return (ClutterPaintNode *) res; return (ClutterPaintNode *) res;
} }
@ -1427,7 +1427,7 @@ clutter_layer_node_finalize (ClutterPaintNode *node)
ClutterLayerNode *lnode = CLUTTER_LAYER_NODE (node); ClutterLayerNode *lnode = CLUTTER_LAYER_NODE (node);
if (lnode->pipeline != NULL) if (lnode->pipeline != NULL)
cogl_object_unref (lnode->pipeline); g_object_unref (lnode->pipeline);
g_clear_object (&lnode->offscreen); g_clear_object (&lnode->offscreen);
@ -1494,7 +1494,7 @@ clutter_layer_node_new_to_framebuffer (CoglFramebuffer *framebuffer,
ClutterLayerNode *res; ClutterLayerNode *res;
g_return_val_if_fail (COGL_IS_FRAMEBUFFER (framebuffer), NULL); g_return_val_if_fail (COGL_IS_FRAMEBUFFER (framebuffer), NULL);
g_return_val_if_fail (cogl_is_pipeline (pipeline), NULL); g_return_val_if_fail (COGL_IS_PIPELINE (pipeline), NULL);
res = _clutter_paint_node_create (CLUTTER_TYPE_LAYER_NODE); res = _clutter_paint_node_create (CLUTTER_TYPE_LAYER_NODE);

View File

@ -208,7 +208,7 @@ clutter_stage_view_invalidate_offscreen_blit_pipeline (ClutterStageView *view)
ClutterStageViewPrivate *priv = ClutterStageViewPrivate *priv =
clutter_stage_view_get_instance_private (view); clutter_stage_view_get_instance_private (view);
g_clear_pointer (&priv->offscreen_pipeline, cogl_object_unref); g_clear_object (&priv->offscreen_pipeline);
} }
void void
@ -1485,7 +1485,7 @@ clutter_stage_view_dispose (GObject *object)
clutter_damage_history_free); clutter_damage_history_free);
g_clear_object (&priv->offscreen); g_clear_object (&priv->offscreen);
g_clear_pointer (&priv->offscreen_pipeline, cogl_object_unref); g_clear_object (&priv->offscreen_pipeline);
g_clear_pointer (&priv->redraw_clip, cairo_region_destroy); g_clear_pointer (&priv->redraw_clip, cairo_region_destroy);
g_clear_pointer (&priv->accumulated_redraw_clip, cairo_region_destroy); g_clear_pointer (&priv->accumulated_redraw_clip, cairo_region_destroy);
g_clear_pointer (&priv->frame_clock, clutter_frame_clock_destroy); g_clear_pointer (&priv->frame_clock, clutter_frame_clock_destroy);

View File

@ -1964,7 +1964,7 @@ paint_selection_rectangle (ClutterText *self,
cogl_pango_show_layout (fb, layout, priv->text_x, 0, &cogl_color); cogl_pango_show_layout (fb, layout, priv->text_x, 0, &cogl_color);
cogl_framebuffer_pop_clip (fb); cogl_framebuffer_pop_clip (fb);
cogl_object_unref (color_pipeline); g_object_unref (color_pipeline);
} }
/* Draws the selected text, its background, and the cursor */ /* Draws the selected text, its background, and the cursor */
@ -2007,7 +2007,7 @@ selection_paint (ClutterText *self,
priv->cursor_rect.origin.x + priv->cursor_rect.size.width, priv->cursor_rect.origin.x + priv->cursor_rect.size.width,
priv->cursor_rect.origin.y + priv->cursor_rect.size.height); priv->cursor_rect.origin.y + priv->cursor_rect.size.height);
g_clear_pointer (&color_pipeline, cogl_object_unref); g_clear_object (&color_pipeline);
} }
else else
{ {

View File

@ -469,7 +469,7 @@ _cogl_pango_display_list_node_free (CoglPangoDisplayListNode *node)
cogl_object_unref (node->d.trapezoid.primitive); cogl_object_unref (node->d.trapezoid.primitive);
if (node->pipeline) if (node->pipeline)
cogl_object_unref (node->pipeline); g_object_unref (node->pipeline);
g_free (node); g_free (node);
} }

View File

@ -41,6 +41,8 @@
typedef struct _CoglPangoPipelineCacheEntry CoglPangoPipelineCacheEntry; typedef struct _CoglPangoPipelineCacheEntry CoglPangoPipelineCacheEntry;
static GQuark pipeline_destroy_notify_key = 0;
struct _CoglPangoPipelineCacheEntry struct _CoglPangoPipelineCacheEntry
{ {
/* This will take a reference or it can be NULL to represent the /* This will take a reference or it can be NULL to represent the
@ -55,7 +57,7 @@ static void
_cogl_pango_pipeline_cache_key_destroy (void *data) _cogl_pango_pipeline_cache_key_destroy (void *data)
{ {
if (data) if (data)
cogl_object_unref (data); g_object_unref (data);
} }
static void static void
@ -173,13 +175,13 @@ _cogl_pango_pipeline_cache_get (CoglPangoPipelineCache *cache,
{ {
CoglPangoPipelineCacheEntry *entry; CoglPangoPipelineCacheEntry *entry;
PipelineDestroyNotifyData *destroy_data; PipelineDestroyNotifyData *destroy_data;
static CoglUserDataKey pipeline_destroy_notify_key; pipeline_destroy_notify_key = g_quark_from_static_string ("-cogl-pango-pipeline-cache-key");
/* Look for an existing entry */ /* Look for an existing entry */
entry = g_hash_table_lookup (cache->hash_table, texture); entry = g_hash_table_lookup (cache->hash_table, texture);
if (entry) if (entry)
return cogl_object_ref (entry->pipeline); return g_object_ref (entry->pipeline);
/* No existing pipeline was found so let's create another */ /* No existing pipeline was found so let's create another */
entry = g_new0 (CoglPangoPipelineCacheEntry, 1); entry = g_new0 (CoglPangoPipelineCacheEntry, 1);
@ -210,8 +212,8 @@ _cogl_pango_pipeline_cache_get (CoglPangoPipelineCache *cache,
destroy_data = g_new0 (PipelineDestroyNotifyData, 1); destroy_data = g_new0 (PipelineDestroyNotifyData, 1);
destroy_data->cache = cache; destroy_data->cache = cache;
destroy_data->texture = texture; destroy_data->texture = texture;
cogl_object_set_user_data (COGL_OBJECT (entry->pipeline), g_object_set_qdata_full (G_OBJECT (entry->pipeline),
&pipeline_destroy_notify_key, pipeline_destroy_notify_key,
destroy_data, destroy_data,
pipeline_destroy_notify_cb); pipeline_destroy_notify_cb);
@ -228,9 +230,9 @@ void
_cogl_pango_pipeline_cache_free (CoglPangoPipelineCache *cache) _cogl_pango_pipeline_cache_free (CoglPangoPipelineCache *cache)
{ {
if (cache->base_texture_rgba_pipeline) if (cache->base_texture_rgba_pipeline)
cogl_object_unref (cache->base_texture_rgba_pipeline); g_object_unref (cache->base_texture_rgba_pipeline);
if (cache->base_texture_alpha_pipeline) if (cache->base_texture_alpha_pipeline)
cogl_object_unref (cache->base_texture_alpha_pipeline); g_object_unref (cache->base_texture_alpha_pipeline);
g_hash_table_destroy (cache->hash_table); g_hash_table_destroy (cache->hash_table);

View File

@ -642,7 +642,7 @@ _cogl_flush_attributes_state (CoglFramebuffer *framebuffer,
n_attributes); n_attributes);
if (copy) if (copy)
cogl_object_unref (copy); g_object_unref (copy);
} }
int int

View File

@ -81,10 +81,10 @@ cogl_context_dispose (GObject *object)
g_object_unref (context->default_gl_texture_2d_tex); g_object_unref (context->default_gl_texture_2d_tex);
if (context->opaque_color_pipeline) if (context->opaque_color_pipeline)
cogl_object_unref (context->opaque_color_pipeline); g_object_unref (context->opaque_color_pipeline);
if (context->blit_texture_pipeline) if (context->blit_texture_pipeline)
cogl_object_unref (context->blit_texture_pipeline); g_object_unref (context->blit_texture_pipeline);
if (context->swap_callback_closures) if (context->swap_callback_closures)
g_hash_table_destroy (context->swap_callback_closures); g_hash_table_destroy (context->swap_callback_closures);
@ -100,14 +100,14 @@ cogl_context_dispose (GObject *object)
g_object_unref (context->rectangle_short_indices); g_object_unref (context->rectangle_short_indices);
if (context->default_pipeline) if (context->default_pipeline)
cogl_object_unref (context->default_pipeline); g_object_unref (context->default_pipeline);
if (context->dummy_layer_dependant) if (context->dummy_layer_dependant)
cogl_object_unref (context->dummy_layer_dependant); g_object_unref (context->dummy_layer_dependant);
if (context->default_layer_n) if (context->default_layer_n)
cogl_object_unref (context->default_layer_n); g_object_unref (context->default_layer_n);
if (context->default_layer_0) if (context->default_layer_0)
cogl_object_unref (context->default_layer_0); g_object_unref (context->default_layer_0);
if (context->current_clip_stack_valid) if (context->current_clip_stack_valid)
_cogl_clip_stack_unref (context->current_clip_stack); _cogl_clip_stack_unref (context->current_clip_stack);
@ -402,7 +402,7 @@ cogl_context_new (CoglDisplay *display,
_cogl_list_init (&context->fences); _cogl_list_init (&context->fences);
context->named_pipelines = context->named_pipelines =
g_hash_table_new_full (NULL, NULL, NULL, cogl_object_unref); g_hash_table_new_full (NULL, NULL, NULL, g_object_unref);
return context; return context;
} }

View File

@ -77,7 +77,7 @@ enum
static guint signals[N_SIGNALS]; static guint signals[N_SIGNALS];
#ifdef COGL_ENABLE_DEBUG #ifdef COGL_ENABLE_DEBUG
static CoglUserDataKey wire_pipeline_key; static GQuark wire_pipeline_key = 0;
#endif #endif
typedef struct _CoglFramebufferPrivate typedef struct _CoglFramebufferPrivate
@ -869,7 +869,7 @@ _cogl_framebuffer_add_dependency (CoglFramebuffer *framebuffer,
} }
/* TODO: generalize the primed-array type structure we e.g. use for /* TODO: generalize the primed-array type structure we e.g. use for
* cogl_object_set_user_data or for pipeline children as a way to * g_object_set_qdata_full or for pipeline children as a way to
* avoid quite a lot of mid-scene micro allocations here... */ * avoid quite a lot of mid-scene micro allocations here... */
priv->deps = priv->deps =
g_list_prepend (priv->deps, g_object_ref (dependency)); g_list_prepend (priv->deps, g_object_ref (dependency));
@ -2288,7 +2288,7 @@ pipeline_destroyed_cb (CoglPipeline *weak_pipeline, void *user_data)
/* XXX: I think we probably need to provide a custom unref function for /* XXX: I think we probably need to provide a custom unref function for
* CoglPipeline because it's possible that we will reach this callback * CoglPipeline because it's possible that we will reach this callback
* because original_pipeline is being freed which means cogl_object_unref * because original_pipeline is being freed which means g_object_unref
* will have already freed any associated user data. * will have already freed any associated user data.
* *
* Setting more user data here will *probably* succeed but that may allocate * Setting more user data here will *probably* succeed but that may allocate
@ -2298,10 +2298,10 @@ pipeline_destroyed_cb (CoglPipeline *weak_pipeline, void *user_data)
* that a custom unref function could be written that can destroy weak * that a custom unref function could be written that can destroy weak
* pipeline children before removing user data. * pipeline children before removing user data.
*/ */
cogl_object_set_user_data (COGL_OBJECT (original_pipeline), g_object_set_qdata_full (G_OBJECT (original_pipeline),
&wire_pipeline_key, NULL, NULL); wire_pipeline_key, NULL, NULL);
cogl_object_unref (weak_pipeline); g_object_unref (weak_pipeline);
} }
static void static void
@ -2319,7 +2319,7 @@ draw_wireframe (CoglContext *ctx,
CoglIndices *wire_indices; CoglIndices *wire_indices;
CoglPipeline *wire_pipeline; CoglPipeline *wire_pipeline;
int n_indices; int n_indices;
wire_pipeline_key = g_quark_from_static_string ("framebuffer-wire-pipeline-key");
wire_indices = get_wire_line_indices (ctx, wire_indices = get_wire_line_indices (ctx,
mode, mode,
first_vertex, first_vertex,
@ -2327,8 +2327,8 @@ draw_wireframe (CoglContext *ctx,
indices, indices,
&n_indices); &n_indices);
wire_pipeline = cogl_object_get_user_data (COGL_OBJECT (pipeline), wire_pipeline = g_object_get_qdata (G_OBJECT (pipeline),
&wire_pipeline_key); wire_pipeline_key);
if (!wire_pipeline) if (!wire_pipeline)
{ {
@ -2337,8 +2337,8 @@ draw_wireframe (CoglContext *ctx,
wire_pipeline = wire_pipeline =
_cogl_pipeline_weak_copy (pipeline, pipeline_destroyed_cb, NULL); _cogl_pipeline_weak_copy (pipeline, pipeline_destroyed_cb, NULL);
cogl_object_set_user_data (COGL_OBJECT (pipeline), g_object_set_qdata_full (G_OBJECT (pipeline),
&wire_pipeline_key, wire_pipeline, wire_pipeline_key, wire_pipeline,
NULL); NULL);
/* If we have glsl then the pipeline may have an associated /* If we have glsl then the pipeline may have an associated

View File

@ -1618,7 +1618,7 @@ _cogl_journal_log_quad (CoglJournal *journal,
cogl_framebuffer_get_viewport4fv (framebuffer, entry->viewport); cogl_framebuffer_get_viewport4fv (framebuffer, entry->viewport);
if (G_UNLIKELY (final_pipeline != pipeline)) if (G_UNLIKELY (final_pipeline != pipeline))
cogl_object_unref (final_pipeline); g_object_unref (final_pipeline);
modelview_stack = modelview_stack =
_cogl_framebuffer_get_modelview_stack (framebuffer); _cogl_framebuffer_get_modelview_stack (framebuffer);

View File

@ -33,9 +33,9 @@
#pragma once #pragma once
#include "cogl/cogl-object-private.h"
#include "cogl/cogl-list.h" #include "cogl/cogl-list.h"
typedef struct _CoglNodeClass CoglNodeClass;
typedef struct _CoglNode CoglNode; typedef struct _CoglNode CoglNode;
/* Pipelines and layers represent their state in a tree structure where /* Pipelines and layers represent their state in a tree structure where
@ -44,9 +44,7 @@ typedef struct _CoglNode CoglNode;
* type to track the tree hierarchy so we can share code... */ * type to track the tree hierarchy so we can share code... */
struct _CoglNode struct _CoglNode
{ {
/* the parent in terms of class hierarchy, so anything inheriting GObject parent_instance;
* from CoglNode also inherits from CoglObject. */
CoglObject _parent;
/* The parent pipeline/layer */ /* The parent pipeline/layer */
CoglNode *parent; CoglNode *parent;
@ -62,10 +60,23 @@ struct _CoglNode
gboolean has_parent_reference; gboolean has_parent_reference;
}; };
#define COGL_NODE(X) ((CoglNode *)(X)) struct _CoglNodeClass
{
GObjectClass parent_class;
};
void #define COGL_TYPE_NODE (cogl_node_get_type ())
_cogl_pipeline_node_init (CoglNode *node); #define COGL_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), COGL_TYPE_NODE, CoglNode))
#define COGL_NODE_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), COGL_TYPE_NODE, CoglNode const))
#define COGL_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), COGL_TYPE_NODE, CoglNodeClass))
#define COGL_IS_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), COGL_TYPE_NODE))
#define COGL_IS_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), COGL_TYPE_NODE))
#define COGL_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), COGL_TYPE_NODE, CoglNodeClass))
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglNode, g_object_unref)
COGL_EXPORT
GType cogl_node_get_type (void) G_GNUC_CONST;
void void
_cogl_pipeline_node_set_parent_real (CoglNode *node, _cogl_pipeline_node_set_parent_real (CoglNode *node,

View File

@ -36,8 +36,15 @@
#include "cogl/cogl-util.h" #include "cogl/cogl-util.h"
#include "cogl/cogl-node-private.h" #include "cogl/cogl-node-private.h"
void G_DEFINE_ABSTRACT_TYPE (CoglNode, cogl_node, G_TYPE_OBJECT)
_cogl_pipeline_node_init (CoglNode *node)
static void
cogl_node_class_init (CoglNodeClass *klass)
{
}
static void
cogl_node_init (CoglNode *node)
{ {
node->parent = NULL; node->parent = NULL;
_cogl_list_init (&node->children); _cogl_list_init (&node->children);
@ -57,7 +64,7 @@ _cogl_pipeline_node_set_parent_real (CoglNode *node,
* consistent link to all weak nodes. Once the node is linked to its * consistent link to all weak nodes. Once the node is linked to its
* parent then we remove the reference at the end if * parent then we remove the reference at the end if
* take_strong_reference == FALSE. */ * take_strong_reference == FALSE. */
cogl_object_ref (parent); g_object_ref (parent);
if (node->parent) if (node->parent)
_cogl_pipeline_node_unparent_real (node); _cogl_pipeline_node_unparent_real (node);
@ -72,7 +79,7 @@ _cogl_pipeline_node_set_parent_real (CoglNode *node,
* out that the new parent was only being kept alive by the old * out that the new parent was only being kept alive by the old
* parent then it will be disposed of here. */ * parent then it will be disposed of here. */
if (!take_strong_reference) if (!take_strong_reference)
cogl_object_unref (parent); g_object_unref (parent);
} }
void void
@ -88,7 +95,7 @@ _cogl_pipeline_node_unparent_real (CoglNode *node)
_cogl_list_remove (&node->link); _cogl_list_remove (&node->link);
if (node->has_parent_reference) if (node->has_parent_reference)
cogl_object_unref (parent); g_object_unref (parent);
node->parent = NULL; node->parent = NULL;
} }

View File

@ -34,6 +34,7 @@
#include "cogl-config.h" #include "cogl-config.h"
#include "cogl/cogl-context-private.h" #include "cogl/cogl-context-private.h"
#include "cogl/cogl-debug.h"
#include "cogl/cogl-pipeline-private.h" #include "cogl/cogl-pipeline-private.h"
#include "cogl/cogl-pipeline-layer-private.h" #include "cogl/cogl-pipeline-layer-private.h"
#include "cogl/cogl-node-private.h" #include "cogl/cogl-node-private.h"
@ -61,7 +62,7 @@ dump_layer_cb (CoglNode *node, void *user_data)
if (state->parent_id >= 0) if (state->parent_id >= 0)
g_string_append_printf (state->graph, "%*slayer%p -> layer%p;\n", g_string_append_printf (state->graph, "%*slayer%p -> layer%p;\n",
state->indent, "", state->indent, "",
layer->_parent.parent, layer->parent_instance.parent,
layer); layer);
g_string_append_printf (state->graph, g_string_append_printf (state->graph,
@ -71,7 +72,7 @@ dump_layer_cb (CoglNode *node, void *user_data)
state->indent, "", state->indent, "",
layer, layer,
layer, layer,
COGL_OBJECT (layer)->ref_count); G_OBJECT (layer)->ref_count);
changes_label = g_string_new (""); changes_label = g_string_new ("");
g_string_append_printf (changes_label, g_string_append_printf (changes_label,
@ -161,9 +162,9 @@ dump_pipeline_cb (CoglNode *node, void *user_data)
state->indent, "", state->indent, "",
pipeline_id, pipeline_id,
pipeline, pipeline,
COGL_OBJECT (pipeline)->ref_count, G_OBJECT (pipeline)->ref_count,
pipeline->has_static_breadcrumb ?
#ifdef COGL_DEBUG_ENABLED #ifdef COGL_DEBUG_ENABLED
pipeline->has_static_breadcrumb ?
pipeline->static_breadcrumb : "NULL" pipeline->static_breadcrumb : "NULL"
#else #else
"NULL" "NULL"

View File

@ -64,7 +64,7 @@ value_destroy_cb (void *value)
{ {
CoglPipelineHashTableEntry *entry = value; CoglPipelineHashTableEntry *entry = value;
cogl_object_unref (entry->parent.pipeline); g_object_unref (entry->parent.pipeline);
g_free (entry); g_free (entry);
} }

View File

@ -43,8 +43,21 @@
#include <glib.h> #include <glib.h>
#define COGL_TYPE_PIPELINE_LAYER (cogl_pipeline_layer_get_type ())
#define COGL_PIPELINE_LAYER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), COGL_TYPE_PIPELINE_LAYER, CoglPipelineLayer))
#define COGL_PIPELINE_LAYER_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), COGL_TYPE_PIPELINE_LAYER, CoglPipelineLayer const))
#define COGL_PIPELINE_LAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), COGL_TYPE_PIPELINE_LAYER, CoglPipelineLayerClass))
#define COGL_IS_PIPELINE_LAYER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), COGL_TYPE_PIPELINE_LAYER))
#define COGL_IS_PIPELINE_LAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), COGL_TYPE_PIPELINE_LAYER))
#define COGL_PIPELINE_LAYER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), COGL_TYPE_PIPELINE_LAYER, CoglPipelineLayerClass))
typedef struct _CoglPipelineLayerClass CoglPipelineLayerClass;
typedef struct _CoglPipelineLayer CoglPipelineLayer; typedef struct _CoglPipelineLayer CoglPipelineLayer;
#define COGL_PIPELINE_LAYER(OBJECT) ((CoglPipelineLayer *)OBJECT)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglPipelineLayer, g_object_unref)
COGL_EXPORT
GType cogl_pipeline_layer_get_type (void) G_GNUC_CONST;
/* XXX: should I rename these as /* XXX: should I rename these as
* COGL_PIPELINE_LAYER_STATE_INDEX_XYZ... ? * COGL_PIPELINE_LAYER_STATE_INDEX_XYZ... ?
@ -206,7 +219,7 @@ struct _CoglPipelineLayer
* the state relating to a given pipeline or layer may actually be * the state relating to a given pipeline or layer may actually be
* owned by one if is ancestors in the tree. We have a common data * owned by one if is ancestors in the tree. We have a common data
* type to track the tree hierarchy so we can share code... */ * type to track the tree hierarchy so we can share code... */
CoglNode _parent; CoglNode parent_instance;
/* Some layers have a pipeline owner, which is to say that the layer /* Some layers have a pipeline owner, which is to say that the layer
* is referenced in that pipelines->layer_differences list. A layer * is referenced in that pipelines->layer_differences list. A layer
@ -250,6 +263,12 @@ struct _CoglPipelineLayer
}; };
struct _CoglPipelineLayerClass
{
CoglNodeClass parent_class;
};
typedef gboolean typedef gboolean
(*CoglPipelineLayerStateComparator) (CoglPipelineLayer *authority0, (*CoglPipelineLayerStateComparator) (CoglPipelineLayer *authority0,
CoglPipelineLayer *authority1); CoglPipelineLayer *authority1);
@ -330,12 +349,6 @@ _cogl_pipeline_layer_get_texture (CoglPipelineLayer *layer);
CoglTexture * CoglTexture *
_cogl_pipeline_layer_get_texture_real (CoglPipelineLayer *layer); _cogl_pipeline_layer_get_texture_real (CoglPipelineLayer *layer);
CoglPipelineFilter
_cogl_pipeline_layer_get_min_filter (CoglPipelineLayer *layer);
CoglPipelineFilter
_cogl_pipeline_layer_get_mag_filter (CoglPipelineLayer *layer);
CoglPipelineWrapMode CoglPipelineWrapMode
_cogl_pipeline_layer_get_wrap_mode_s (CoglPipelineLayer *layer); _cogl_pipeline_layer_get_wrap_mode_s (CoglPipelineLayer *layer);

View File

@ -311,7 +311,7 @@ cogl_pipeline_set_layer_wrap_mode_s (CoglPipeline *pipeline,
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
g_return_if_fail (cogl_is_pipeline (pipeline)); g_return_if_fail (COGL_IS_PIPELINE (pipeline));
/* Note: this will ensure that the layer exists, creating one if it /* Note: this will ensure that the layer exists, creating one if it
* doesn't already. * doesn't already.
@ -351,7 +351,7 @@ cogl_pipeline_set_layer_wrap_mode_t (CoglPipeline *pipeline,
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
g_return_if_fail (cogl_is_pipeline (pipeline)); g_return_if_fail (COGL_IS_PIPELINE (pipeline));
/* Note: this will ensure that the layer exists, creating one if it /* Note: this will ensure that the layer exists, creating one if it
* doesn't already. * doesn't already.
@ -391,7 +391,7 @@ cogl_pipeline_set_layer_wrap_mode (CoglPipeline *pipeline,
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
g_return_if_fail (cogl_is_pipeline (pipeline)); g_return_if_fail (COGL_IS_PIPELINE (pipeline));
/* Note: this will ensure that the layer exists, creating one if it /* Note: this will ensure that the layer exists, creating one if it
* doesn't already. * doesn't already.
@ -424,7 +424,7 @@ _cogl_pipeline_layer_get_wrap_mode_s (CoglPipelineLayer *layer)
CoglPipelineLayer *authority; CoglPipelineLayer *authority;
const CoglSamplerCacheEntry *sampler_state; const CoglSamplerCacheEntry *sampler_state;
g_return_val_if_fail (_cogl_is_pipeline_layer (layer), FALSE); g_return_val_if_fail (COGL_IS_PIPELINE_LAYER (layer), FALSE);
/* Now find the ancestor of the layer that is the authority for the /* Now find the ancestor of the layer that is the authority for the
* state we want to change */ * state we want to change */
@ -439,7 +439,7 @@ cogl_pipeline_get_layer_wrap_mode_s (CoglPipeline *pipeline, int layer_index)
{ {
CoglPipelineLayer *layer; CoglPipelineLayer *layer;
g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); g_return_val_if_fail (COGL_IS_PIPELINE (pipeline), FALSE);
/* Note: this will ensure that the layer exists, creating one if it /* Note: this will ensure that the layer exists, creating one if it
* doesn't already. * doesn't already.
@ -461,7 +461,7 @@ _cogl_pipeline_layer_get_wrap_mode_t (CoglPipelineLayer *layer)
CoglPipelineLayer *authority; CoglPipelineLayer *authority;
const CoglSamplerCacheEntry *sampler_state; const CoglSamplerCacheEntry *sampler_state;
g_return_val_if_fail (_cogl_is_pipeline_layer (layer), FALSE); g_return_val_if_fail (COGL_IS_PIPELINE_LAYER (layer), FALSE);
/* Now find the ancestor of the layer that is the authority for the /* Now find the ancestor of the layer that is the authority for the
* state we want to change */ * state we want to change */
@ -476,7 +476,7 @@ cogl_pipeline_get_layer_wrap_mode_t (CoglPipeline *pipeline, int layer_index)
{ {
CoglPipelineLayer *layer; CoglPipelineLayer *layer;
g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); g_return_val_if_fail (COGL_IS_PIPELINE (pipeline), FALSE);
/* Note: this will ensure that the layer exists, creating one if it /* Note: this will ensure that the layer exists, creating one if it
* doesn't already. * doesn't already.
@ -517,7 +517,7 @@ cogl_pipeline_set_layer_point_sprite_coords_enabled (CoglPipeline *pipeline,
_COGL_GET_CONTEXT (ctx, FALSE); _COGL_GET_CONTEXT (ctx, FALSE);
g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); g_return_val_if_fail (COGL_IS_PIPELINE (pipeline), FALSE);
/* Note: this will ensure that the layer exists, creating one if it /* Note: this will ensure that the layer exists, creating one if it
* doesn't already. * doesn't already.
@ -587,7 +587,7 @@ cogl_pipeline_get_layer_point_sprite_coords_enabled (CoglPipeline *pipeline,
CoglPipelineLayer *layer; CoglPipelineLayer *layer;
CoglPipelineLayer *authority; CoglPipelineLayer *authority;
g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); g_return_val_if_fail (COGL_IS_PIPELINE (pipeline), FALSE);
/* Note: this will ensure that the layer exists, creating one if it /* Note: this will ensure that the layer exists, creating one if it
* doesn't already. * doesn't already.
@ -680,7 +680,7 @@ cogl_pipeline_add_layer_snippet (CoglPipeline *pipeline,
int layer_index, int layer_index,
CoglSnippet *snippet) CoglSnippet *snippet)
{ {
g_return_if_fail (cogl_is_pipeline (pipeline)); g_return_if_fail (COGL_IS_PIPELINE (pipeline));
g_return_if_fail (COGL_IS_SNIPPET (snippet)); g_return_if_fail (COGL_IS_SNIPPET (snippet));
g_return_if_fail (snippet->hook >= COGL_SNIPPET_FIRST_LAYER_HOOK); g_return_if_fail (snippet->hook >= COGL_SNIPPET_FIRST_LAYER_HOOK);
@ -921,7 +921,7 @@ cogl_pipeline_set_layer_combine (CoglPipeline *pipeline,
CoglBlendStringStatement *a; CoglBlendStringStatement *a;
int count; int count;
g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); g_return_val_if_fail (COGL_IS_PIPELINE (pipeline), FALSE);
/* Note: this will ensure that the layer exists, creating one if it /* Note: this will ensure that the layer exists, creating one if it
* doesn't already. * doesn't already.
@ -1021,7 +1021,7 @@ cogl_pipeline_set_layer_combine_constant (CoglPipeline *pipeline,
CoglPipelineLayer *new; CoglPipelineLayer *new;
float color_as_floats[4]; float color_as_floats[4];
g_return_if_fail (cogl_is_pipeline (pipeline)); g_return_if_fail (COGL_IS_PIPELINE (pipeline));
/* Note: this will ensure that the layer exists, creating one if it /* Note: this will ensure that the layer exists, creating one if it
* doesn't already. * doesn't already.
@ -1104,7 +1104,7 @@ _cogl_pipeline_get_layer_combine_constant (CoglPipeline *pipeline,
CoglPipelineLayer *layer; CoglPipelineLayer *layer;
CoglPipelineLayer *authority; CoglPipelineLayer *authority;
g_return_if_fail (cogl_is_pipeline (pipeline)); g_return_if_fail (COGL_IS_PIPELINE (pipeline));
/* Note: this will ensure that the layer exists, creating one if it /* Note: this will ensure that the layer exists, creating one if it
* doesn't already. * doesn't already.
@ -1131,7 +1131,7 @@ _cogl_pipeline_get_layer_matrix (CoglPipeline *pipeline, int layer_index)
CoglPipelineLayer *layer; CoglPipelineLayer *layer;
CoglPipelineLayer *authority; CoglPipelineLayer *authority;
g_return_val_if_fail (cogl_is_pipeline (pipeline), NULL); g_return_val_if_fail (COGL_IS_PIPELINE (pipeline), NULL);
layer = _cogl_pipeline_get_layer (pipeline, layer_index); layer = _cogl_pipeline_get_layer (pipeline, layer_index);
@ -1149,7 +1149,7 @@ cogl_pipeline_set_layer_matrix (CoglPipeline *pipeline,
CoglPipelineLayer *authority; CoglPipelineLayer *authority;
CoglPipelineLayer *new; CoglPipelineLayer *new;
g_return_if_fail (cogl_is_pipeline (pipeline)); g_return_if_fail (COGL_IS_PIPELINE (pipeline));
/* Note: this will ensure that the layer exists, creating one if it /* Note: this will ensure that the layer exists, creating one if it
* doesn't already. * doesn't already.
@ -1211,7 +1211,7 @@ cogl_pipeline_set_layer_matrix (CoglPipeline *pipeline,
CoglTexture * CoglTexture *
_cogl_pipeline_layer_get_texture (CoglPipelineLayer *layer) _cogl_pipeline_layer_get_texture (CoglPipelineLayer *layer)
{ {
g_return_val_if_fail (_cogl_is_pipeline_layer (layer), NULL); g_return_val_if_fail (COGL_IS_PIPELINE_LAYER (layer), NULL);
return _cogl_pipeline_layer_get_texture_real (layer); return _cogl_pipeline_layer_get_texture_real (layer);
} }
@ -1254,7 +1254,7 @@ cogl_pipeline_get_layer_filters (CoglPipeline *pipeline,
{ {
CoglPipelineLayer *layer; CoglPipelineLayer *layer;
g_return_if_fail (cogl_is_pipeline (pipeline)); g_return_if_fail (COGL_IS_PIPELINE (pipeline));
layer = _cogl_pipeline_get_layer (pipeline, layer_index); layer = _cogl_pipeline_get_layer (pipeline, layer_index);
return _cogl_pipeline_layer_get_filters (layer, min_filter, mag_filter); return _cogl_pipeline_layer_get_filters (layer, min_filter, mag_filter);
@ -1273,7 +1273,7 @@ cogl_pipeline_set_layer_filters (CoglPipeline *pipeline,
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
g_return_if_fail (cogl_is_pipeline (pipeline)); g_return_if_fail (COGL_IS_PIPELINE (pipeline));
g_return_if_fail (mag_filter == COGL_PIPELINE_FILTER_NEAREST || g_return_if_fail (mag_filter == COGL_PIPELINE_FILTER_NEAREST ||
mag_filter == COGL_PIPELINE_FILTER_LINEAR); mag_filter == COGL_PIPELINE_FILTER_LINEAR);

View File

@ -47,15 +47,43 @@
#include <string.h> #include <string.h>
G_DEFINE_FINAL_TYPE (CoglPipelineLayer, cogl_pipeline_layer, COGL_TYPE_NODE)
static void static void
_cogl_pipeline_layer_free (CoglPipelineLayer *layer); cogl_pipeline_layer_dispose (GObject *object)
{
CoglPipelineLayer *layer = COGL_PIPELINE_LAYER (object);
/* This type was made deprecated before the cogl_is_pipeline_layer _cogl_pipeline_node_unparent_real (COGL_NODE (layer));
function was ever exposed in the public headers so there's no need
to make the cogl_is_pipeline_layer function public. We use INTERNAL
so that the cogl_is_* function won't get defined */
COGL_OBJECT_INTERNAL_DEFINE (PipelineLayer, pipeline_layer);
if (layer->differences & COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA &&
layer->texture != NULL)
g_object_unref (layer->texture);
if (layer->differences & COGL_PIPELINE_LAYER_STATE_VERTEX_SNIPPETS)
_cogl_pipeline_snippet_list_free (&layer->big_state->vertex_snippets);
if (layer->differences & COGL_PIPELINE_LAYER_STATE_FRAGMENT_SNIPPETS)
_cogl_pipeline_snippet_list_free (&layer->big_state->fragment_snippets);
if (layer->differences & COGL_PIPELINE_LAYER_STATE_NEEDS_BIG_STATE)
g_free (layer->big_state);
G_OBJECT_CLASS (cogl_pipeline_layer_parent_class)->dispose (object);
}
static void
cogl_pipeline_layer_class_init (CoglPipelineLayerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = cogl_pipeline_layer_dispose;
}
static void
cogl_pipeline_layer_init (CoglPipelineLayer *layer)
{
}
CoglPipelineLayer * CoglPipelineLayer *
_cogl_pipeline_layer_get_authority (CoglPipelineLayer *layer, _cogl_pipeline_layer_get_authority (CoglPipelineLayer *layer,
@ -372,7 +400,7 @@ _cogl_pipeline_layer_pre_change_notify (CoglPipeline *required_owner,
if (layer->owner == required_owner) if (layer->owner == required_owner)
_cogl_pipeline_remove_layer_difference (required_owner, layer, FALSE); _cogl_pipeline_remove_layer_difference (required_owner, layer, FALSE);
_cogl_pipeline_add_layer_difference (required_owner, new, FALSE); _cogl_pipeline_add_layer_difference (required_owner, new, FALSE);
cogl_object_unref (new); g_object_unref (new);
layer = new; layer = new;
goto init_layer_state; goto init_layer_state;
} }
@ -449,9 +477,7 @@ _cogl_pipeline_layer_set_parent (CoglPipelineLayer *layer,
CoglPipelineLayer * CoglPipelineLayer *
_cogl_pipeline_layer_copy (CoglPipelineLayer *src) _cogl_pipeline_layer_copy (CoglPipelineLayer *src)
{ {
CoglPipelineLayer *layer = g_new0 (CoglPipelineLayer, 1); CoglPipelineLayer *layer = g_object_new (COGL_TYPE_PIPELINE_LAYER, NULL);
_cogl_pipeline_node_init (COGL_NODE (layer));
layer->owner = NULL; layer->owner = NULL;
layer->index = src->index; layer->index = src->index;
@ -460,7 +486,7 @@ _cogl_pipeline_layer_copy (CoglPipelineLayer *src)
_cogl_pipeline_layer_set_parent (layer, src); _cogl_pipeline_layer_set_parent (layer, src);
return _cogl_pipeline_layer_object_new (layer); return layer;
} }
/* XXX: This is duplicated logic; the same as for /* XXX: This is duplicated logic; the same as for
@ -688,39 +714,16 @@ _cogl_pipeline_layer_equal (CoglPipelineLayer *layer0,
return TRUE; return TRUE;
} }
static void
_cogl_pipeline_layer_free (CoglPipelineLayer *layer)
{
_cogl_pipeline_node_unparent_real (COGL_NODE (layer));
if (layer->differences & COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA &&
layer->texture != NULL)
g_object_unref (layer->texture);
if (layer->differences & COGL_PIPELINE_LAYER_STATE_VERTEX_SNIPPETS)
_cogl_pipeline_snippet_list_free (&layer->big_state->vertex_snippets);
if (layer->differences & COGL_PIPELINE_LAYER_STATE_FRAGMENT_SNIPPETS)
_cogl_pipeline_snippet_list_free (&layer->big_state->fragment_snippets);
if (layer->differences & COGL_PIPELINE_LAYER_STATE_NEEDS_BIG_STATE)
g_free (layer->big_state);
g_free (layer);
}
void void
_cogl_pipeline_init_default_layers (void) _cogl_pipeline_init_default_layers (void)
{ {
CoglPipelineLayer *layer = g_new0 (CoglPipelineLayer, 1); CoglPipelineLayer *layer = g_object_new (COGL_TYPE_PIPELINE_LAYER, NULL);
CoglPipelineLayerBigState *big_state = CoglPipelineLayerBigState *big_state =
g_new0 (CoglPipelineLayerBigState, 1); g_new0 (CoglPipelineLayerBigState, 1);
CoglPipelineLayer *new; CoglPipelineLayer *new;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
_cogl_pipeline_node_init (COGL_NODE (layer));
layer->index = 0; layer->index = 0;
layer->differences = COGL_PIPELINE_LAYER_STATE_ALL_SPARSE; layer->differences = COGL_PIPELINE_LAYER_STATE_ALL_SPARSE;
@ -762,7 +765,7 @@ _cogl_pipeline_init_default_layers (void)
graphene_matrix_init_identity (&big_state->matrix); graphene_matrix_init_identity (&big_state->matrix);
ctx->default_layer_0 = _cogl_pipeline_layer_object_new (layer); ctx->default_layer_0 = layer;
/* TODO: we should make default_layer_n comprise of two /* TODO: we should make default_layer_n comprise of two
* descendants of default_layer_0: * descendants of default_layer_0:

View File

@ -33,10 +33,10 @@
#pragma once #pragma once
#include "cogl/cogl-debug.h"
#include "cogl/cogl-node-private.h" #include "cogl/cogl-node-private.h"
#include "cogl/cogl-pipeline-layer-private.h" #include "cogl/cogl-pipeline-layer-private.h"
#include "cogl/cogl-pipeline.h" #include "cogl/cogl-pipeline.h"
#include "cogl/cogl-object-private.h"
#include "cogl/cogl-profile.h" #include "cogl/cogl-profile.h"
#include "cogl/cogl-list.h" #include "cogl/cogl-list.h"
#include "cogl/cogl-boxed-value.h" #include "cogl/cogl-boxed-value.h"
@ -269,7 +269,7 @@ struct _CoglPipeline
* the state relating to a given pipeline or layer may actually be * the state relating to a given pipeline or layer may actually be
* owned by one if is ancestors in the tree. We have a common data * owned by one if is ancestors in the tree. We have a common data
* type to track the tree hierarchy so we can share code... */ * type to track the tree hierarchy so we can share code... */
CoglNode _parent; CoglNode parent_instance;
/* When weak pipelines are destroyed the user is notified via this /* When weak pipelines are destroyed the user is notified via this
* callback */ * callback */
@ -373,6 +373,11 @@ struct _CoglPipeline
#endif #endif
}; };
struct _CoglPipelineClass
{
CoglNodeClass parent_class;
};
typedef struct _CoglPipelineFragend typedef struct _CoglPipelineFragend
{ {
void (*start) (CoglPipeline *pipeline, void (*start) (CoglPipeline *pipeline,
@ -488,9 +493,6 @@ _cogl_pipeline_get_layer_with_flags (CoglPipeline *pipeline,
#define _cogl_pipeline_get_layer(p, l) \ #define _cogl_pipeline_get_layer(p, l) \
_cogl_pipeline_get_layer_with_flags (p, l, 0) _cogl_pipeline_get_layer_with_flags (p, l, 0)
gboolean
_cogl_is_pipeline_layer (void *object);
void void
_cogl_pipeline_prune_empty_layer_difference (CoglPipeline *layers_authority, _cogl_pipeline_prune_empty_layer_difference (CoglPipeline *layers_authority,
CoglPipelineLayer *layer); CoglPipelineLayer *layer);
@ -623,7 +625,7 @@ _cogl_get_n_args_for_combine_func (CoglPipelineCombineFunc func);
* This is the recommended coding pattern for validating an input * This is the recommended coding pattern for validating an input
* pipeline and caching a derived result: * pipeline and caching a derived result:
* |[ * |[
* static CoglUserDataKey _cogl_my_cache_key; * static GQuark _cogl_my_cache_key = 0;
* *
* typedef struct { * typedef struct {
* CoglPipeline *validated_source; * CoglPipeline *validated_source;
@ -639,21 +641,23 @@ _cogl_get_n_args_for_combine_func (CoglPipelineCombineFunc func);
* invalidate_cache_cb (CoglPipeline *destroyed, void *user_data) * invalidate_cache_cb (CoglPipeline *destroyed, void *user_data)
* { * {
* MyValidatedMaterialCache *cache = user_data; * MyValidatedMaterialCache *cache = user_data;
* cogl_object_unref (cache->validated_source); * g_object_unref (cache->validated_source);
* cache->validated_source = NULL; * cache->validated_source = NULL;
* } * }
* *
* static CoglPipeline * * static CoglPipeline *
* get_validated_pipeline (CoglPipeline *source) * get_validated_pipeline (CoglPipeline *source)
* { * {
* _cogl_my_cache_key = g_quark_from_static_string ("my-cache-key");
* MyValidatedMaterialCache *cache = * MyValidatedMaterialCache *cache =
* cogl_object_get_user_data (COGL_OBJECT (source), * g_object_get_qdata (G_OBJECT (source),
* &_cogl_my_cache_key); * _cogl_my_cache_key);
* if (G_UNLIKELY (cache == NULL)) * if (G_UNLIKELY (cache == NULL))
* { * {
* cache = g_new0 (MyValidatedMaterialCache, 1); * cache = g_new0 (MyValidatedMaterialCache, 1);
* cogl_object_set_user_data (COGL_OBJECT (source), *
* &_cogl_my_cache_key, * g_object_set_qdata_full (G_OBJECT (source),
* _cogl_my_cache_key,
* cache, destroy_cache_cb); * cache, destroy_cache_cb);
* cache->validated_source = source; * cache->validated_source = source;
* } * }

View File

@ -320,7 +320,7 @@ cogl_pipeline_get_color (CoglPipeline *pipeline,
{ {
CoglPipeline *authority; CoglPipeline *authority;
g_return_if_fail (cogl_is_pipeline (pipeline)); g_return_if_fail (COGL_IS_PIPELINE (pipeline));
authority = authority =
_cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_COLOR); _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_COLOR);
@ -346,7 +346,7 @@ cogl_pipeline_set_color (CoglPipeline *pipeline,
CoglPipelineState state = COGL_PIPELINE_STATE_COLOR; CoglPipelineState state = COGL_PIPELINE_STATE_COLOR;
CoglPipeline *authority; CoglPipeline *authority;
g_return_if_fail (cogl_is_pipeline (pipeline)); g_return_if_fail (COGL_IS_PIPELINE (pipeline));
authority = _cogl_pipeline_get_authority (pipeline, state); authority = _cogl_pipeline_get_authority (pipeline, state);
@ -400,7 +400,7 @@ _cogl_pipeline_set_alpha_test_function (CoglPipeline *pipeline,
CoglPipeline *authority; CoglPipeline *authority;
CoglPipelineAlphaFuncState *alpha_state; CoglPipelineAlphaFuncState *alpha_state;
g_return_if_fail (cogl_is_pipeline (pipeline)); g_return_if_fail (COGL_IS_PIPELINE (pipeline));
authority = _cogl_pipeline_get_authority (pipeline, state); authority = _cogl_pipeline_get_authority (pipeline, state);
@ -430,7 +430,7 @@ _cogl_pipeline_set_alpha_test_function_reference (CoglPipeline *pipeline,
CoglPipeline *authority; CoglPipeline *authority;
CoglPipelineAlphaFuncState *alpha_state; CoglPipelineAlphaFuncState *alpha_state;
g_return_if_fail (cogl_is_pipeline (pipeline)); g_return_if_fail (COGL_IS_PIPELINE (pipeline));
authority = _cogl_pipeline_get_authority (pipeline, state); authority = _cogl_pipeline_get_authority (pipeline, state);
@ -467,7 +467,7 @@ cogl_pipeline_get_alpha_test_function (CoglPipeline *pipeline)
{ {
CoglPipeline *authority; CoglPipeline *authority;
g_return_val_if_fail (cogl_is_pipeline (pipeline), 0); g_return_val_if_fail (COGL_IS_PIPELINE (pipeline), 0);
authority = authority =
_cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_ALPHA_FUNC); _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_ALPHA_FUNC);
@ -480,7 +480,7 @@ cogl_pipeline_get_alpha_test_reference (CoglPipeline *pipeline)
{ {
CoglPipeline *authority; CoglPipeline *authority;
g_return_val_if_fail (cogl_is_pipeline (pipeline), 0.0f); g_return_val_if_fail (COGL_IS_PIPELINE (pipeline), 0.0f);
authority = authority =
_cogl_pipeline_get_authority (pipeline, _cogl_pipeline_get_authority (pipeline,
@ -593,7 +593,7 @@ cogl_pipeline_set_blend (CoglPipeline *pipeline,
_COGL_GET_CONTEXT (ctx, FALSE); _COGL_GET_CONTEXT (ctx, FALSE);
g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); g_return_val_if_fail (COGL_IS_PIPELINE (pipeline), FALSE);
count = count =
_cogl_blend_string_compile (blend_description, _cogl_blend_string_compile (blend_description,
@ -670,7 +670,7 @@ cogl_pipeline_set_blend_constant (CoglPipeline *pipeline,
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
g_return_if_fail (cogl_is_pipeline (pipeline)); g_return_if_fail (COGL_IS_PIPELINE (pipeline));
authority = _cogl_pipeline_get_authority (pipeline, state); authority = _cogl_pipeline_get_authority (pipeline, state);
@ -699,7 +699,7 @@ cogl_pipeline_get_user_program (CoglPipeline *pipeline)
{ {
CoglPipeline *authority; CoglPipeline *authority;
g_return_val_if_fail (cogl_is_pipeline (pipeline), NULL); g_return_val_if_fail (COGL_IS_PIPELINE (pipeline), NULL);
authority = authority =
_cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_USER_SHADER); _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_USER_SHADER);
@ -720,7 +720,7 @@ cogl_pipeline_set_user_program (CoglPipeline *pipeline,
CoglPipelineState state = COGL_PIPELINE_STATE_USER_SHADER; CoglPipelineState state = COGL_PIPELINE_STATE_USER_SHADER;
CoglPipeline *authority; CoglPipeline *authority;
g_return_if_fail (cogl_is_pipeline (pipeline)); g_return_if_fail (COGL_IS_PIPELINE (pipeline));
authority = _cogl_pipeline_get_authority (pipeline, state); authority = _cogl_pipeline_get_authority (pipeline, state);
@ -777,7 +777,7 @@ cogl_pipeline_set_depth_state (CoglPipeline *pipeline,
_COGL_GET_CONTEXT (ctx, FALSE); _COGL_GET_CONTEXT (ctx, FALSE);
g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); g_return_val_if_fail (COGL_IS_PIPELINE (pipeline), FALSE);
g_return_val_if_fail (depth_state->magic == COGL_DEPTH_STATE_MAGIC, FALSE); g_return_val_if_fail (depth_state->magic == COGL_DEPTH_STATE_MAGIC, FALSE);
authority = _cogl_pipeline_get_authority (pipeline, state); authority = _cogl_pipeline_get_authority (pipeline, state);
@ -811,7 +811,7 @@ cogl_pipeline_get_depth_state (CoglPipeline *pipeline,
{ {
CoglPipeline *authority; CoglPipeline *authority;
g_return_if_fail (cogl_is_pipeline (pipeline)); g_return_if_fail (COGL_IS_PIPELINE (pipeline));
authority = authority =
_cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_DEPTH); _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_DEPTH);
@ -826,7 +826,7 @@ cogl_pipeline_set_cull_face_mode (CoglPipeline *pipeline,
CoglPipeline *authority; CoglPipeline *authority;
CoglPipelineCullFaceState *cull_face_state; CoglPipelineCullFaceState *cull_face_state;
g_return_if_fail (cogl_is_pipeline (pipeline)); g_return_if_fail (COGL_IS_PIPELINE (pipeline));
authority = _cogl_pipeline_get_authority (pipeline, state); authority = _cogl_pipeline_get_authority (pipeline, state);
@ -856,7 +856,7 @@ cogl_pipeline_set_front_face_winding (CoglPipeline *pipeline,
CoglPipeline *authority; CoglPipeline *authority;
CoglPipelineCullFaceState *cull_face_state; CoglPipelineCullFaceState *cull_face_state;
g_return_if_fail (cogl_is_pipeline (pipeline)); g_return_if_fail (COGL_IS_PIPELINE (pipeline));
authority = _cogl_pipeline_get_authority (pipeline, state); authority = _cogl_pipeline_get_authority (pipeline, state);
@ -884,7 +884,7 @@ cogl_pipeline_get_cull_face_mode (CoglPipeline *pipeline)
CoglPipelineState state = COGL_PIPELINE_STATE_CULL_FACE; CoglPipelineState state = COGL_PIPELINE_STATE_CULL_FACE;
CoglPipeline *authority; CoglPipeline *authority;
g_return_val_if_fail (cogl_is_pipeline (pipeline), g_return_val_if_fail (COGL_IS_PIPELINE (pipeline),
COGL_PIPELINE_CULL_FACE_MODE_NONE); COGL_PIPELINE_CULL_FACE_MODE_NONE);
authority = _cogl_pipeline_get_authority (pipeline, state); authority = _cogl_pipeline_get_authority (pipeline, state);
@ -898,7 +898,7 @@ cogl_pipeline_get_front_face_winding (CoglPipeline *pipeline)
CoglPipelineState state = COGL_PIPELINE_STATE_CULL_FACE; CoglPipelineState state = COGL_PIPELINE_STATE_CULL_FACE;
CoglPipeline *authority; CoglPipeline *authority;
g_return_val_if_fail (cogl_is_pipeline (pipeline), g_return_val_if_fail (COGL_IS_PIPELINE (pipeline),
COGL_WINDING_CLOCKWISE); COGL_WINDING_CLOCKWISE);
authority = _cogl_pipeline_get_authority (pipeline, state); authority = _cogl_pipeline_get_authority (pipeline, state);
@ -911,7 +911,7 @@ cogl_pipeline_get_point_size (CoglPipeline *pipeline)
{ {
CoglPipeline *authority; CoglPipeline *authority;
g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); g_return_val_if_fail (COGL_IS_PIPELINE (pipeline), FALSE);
authority = authority =
_cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_POINT_SIZE); _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_POINT_SIZE);
@ -926,7 +926,7 @@ _cogl_pipeline_set_non_zero_point_size (CoglPipeline *pipeline,
CoglPipelineState state = COGL_PIPELINE_STATE_NON_ZERO_POINT_SIZE; CoglPipelineState state = COGL_PIPELINE_STATE_NON_ZERO_POINT_SIZE;
CoglPipeline *authority; CoglPipeline *authority;
g_return_if_fail (cogl_is_pipeline (pipeline)); g_return_if_fail (COGL_IS_PIPELINE (pipeline));
authority = _cogl_pipeline_get_authority (pipeline, state); authority = _cogl_pipeline_get_authority (pipeline, state);
@ -950,7 +950,7 @@ cogl_pipeline_set_point_size (CoglPipeline *pipeline,
CoglPipelineState state = COGL_PIPELINE_STATE_POINT_SIZE; CoglPipelineState state = COGL_PIPELINE_STATE_POINT_SIZE;
CoglPipeline *authority; CoglPipeline *authority;
g_return_if_fail (cogl_is_pipeline (pipeline)); g_return_if_fail (COGL_IS_PIPELINE (pipeline));
authority = _cogl_pipeline_get_authority (pipeline, state); authority = _cogl_pipeline_get_authority (pipeline, state);
@ -985,7 +985,7 @@ cogl_pipeline_set_per_vertex_point_size (CoglPipeline *pipeline,
CoglPipeline *authority; CoglPipeline *authority;
_COGL_GET_CONTEXT (ctx, FALSE); _COGL_GET_CONTEXT (ctx, FALSE);
g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); g_return_val_if_fail (COGL_IS_PIPELINE (pipeline), FALSE);
authority = _cogl_pipeline_get_authority (pipeline, state); authority = _cogl_pipeline_get_authority (pipeline, state);
@ -1014,7 +1014,7 @@ cogl_pipeline_get_per_vertex_point_size (CoglPipeline *pipeline)
{ {
CoglPipeline *authority; CoglPipeline *authority;
g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); g_return_val_if_fail (COGL_IS_PIPELINE (pipeline), FALSE);
authority = authority =
_cogl_pipeline_get_authority (pipeline, _cogl_pipeline_get_authority (pipeline,
@ -1033,7 +1033,7 @@ _cogl_pipeline_override_uniform (CoglPipeline *pipeline,
_COGL_GET_CONTEXT (ctx, NULL); _COGL_GET_CONTEXT (ctx, NULL);
g_return_val_if_fail (cogl_is_pipeline (pipeline), NULL); g_return_val_if_fail (COGL_IS_PIPELINE (pipeline), NULL);
g_return_val_if_fail (location >= 0, NULL); g_return_val_if_fail (location >= 0, NULL);
g_return_val_if_fail (location < ctx->n_uniform_names, NULL); g_return_val_if_fail (location < ctx->n_uniform_names, NULL);
@ -1204,7 +1204,7 @@ void
cogl_pipeline_add_snippet (CoglPipeline *pipeline, cogl_pipeline_add_snippet (CoglPipeline *pipeline,
CoglSnippet *snippet) CoglSnippet *snippet)
{ {
g_return_if_fail (cogl_is_pipeline (pipeline)); g_return_if_fail (COGL_IS_PIPELINE (pipeline));
g_return_if_fail (COGL_IS_SNIPPET (snippet)); g_return_if_fail (COGL_IS_SNIPPET (snippet));
g_return_if_fail (snippet->hook < COGL_SNIPPET_FIRST_LAYER_HOOK); g_return_if_fail (snippet->hook < COGL_SNIPPET_FIRST_LAYER_HOOK);

View File

@ -35,8 +35,6 @@
#include "cogl/cogl-debug.h" #include "cogl/cogl-debug.h"
#include "cogl/cogl-context-private.h" #include "cogl/cogl-context-private.h"
#include "cogl/cogl-object.h"
#include "cogl/cogl-pipeline-private.h" #include "cogl/cogl-pipeline-private.h"
#include "cogl/cogl-pipeline-state-private.h" #include "cogl/cogl-pipeline-state-private.h"
#include "cogl/cogl-pipeline-layer-state-private.h" #include "cogl/cogl-pipeline-layer-state-private.h"
@ -48,13 +46,11 @@
#include "cogl/cogl-profile.h" #include "cogl/cogl-profile.h"
#include "cogl/cogl-depth-state-private.h" #include "cogl/cogl-depth-state-private.h"
#include "cogl/cogl1-context.h" #include "cogl/cogl1-context.h"
#include "cogl/cogl-gtype-private.h"
#include <glib.h> #include <glib.h>
#include <glib/gprintf.h> #include <glib/gprintf.h>
#include <string.h> #include <string.h>
static void _cogl_pipeline_free (CoglPipeline *tex);
static void recursively_free_layer_caches (CoglPipeline *pipeline); static void recursively_free_layer_caches (CoglPipeline *pipeline);
static gboolean _cogl_pipeline_is_weak (CoglPipeline *pipeline); static gboolean _cogl_pipeline_is_weak (CoglPipeline *pipeline);
@ -66,8 +62,113 @@ const CoglPipelineProgend *_cogl_pipeline_progend;
#include "cogl/driver/gl/cogl-pipeline-vertend-glsl-private.h" #include "cogl/driver/gl/cogl-pipeline-vertend-glsl-private.h"
#include "cogl/driver/gl/cogl-pipeline-progend-glsl-private.h" #include "cogl/driver/gl/cogl-pipeline-progend-glsl-private.h"
COGL_OBJECT_DEFINE (Pipeline, pipeline); G_DEFINE_FINAL_TYPE (CoglPipeline, cogl_pipeline, COGL_TYPE_NODE)
COGL_GTYPE_DEFINE_CLASS (Pipeline, pipeline);
static void
_cogl_pipeline_revert_weak_ancestors (CoglPipeline *strong)
{
CoglNode *n;
g_return_if_fail (!strong->is_weak);
/* This reverts the effect of calling
_cogl_pipeline_promote_weak_ancestors */
if (COGL_NODE (strong)->parent == NULL)
return;
for (n = COGL_NODE (strong)->parent;
/* We can assume that all weak pipelines have a parent */
COGL_PIPELINE (n)->is_weak;
n = n->parent)
/* 'n' is weak so we unref its parent */
g_object_unref (n->parent);
}
static gboolean
destroy_weak_children_cb (CoglNode *node,
void *user_data)
{
CoglPipeline *pipeline = COGL_PIPELINE (node);
if (_cogl_pipeline_is_weak (pipeline))
{
_cogl_pipeline_node_foreach_child (COGL_NODE (pipeline),
destroy_weak_children_cb,
NULL);
pipeline->destroy_callback (pipeline, pipeline->destroy_data);
_cogl_pipeline_node_unparent_real (COGL_NODE (pipeline));
}
return TRUE;
}
static void
cogl_pipeline_dispose (GObject *object)
{
CoglPipeline *pipeline = COGL_PIPELINE (object);
if (!pipeline->is_weak)
_cogl_pipeline_revert_weak_ancestors (pipeline);
/* Weak pipelines don't take a reference on their parent */
_cogl_pipeline_node_foreach_child (COGL_NODE (pipeline),
destroy_weak_children_cb,
NULL);
g_assert (_cogl_list_empty (&COGL_NODE (pipeline)->children));
_cogl_pipeline_node_unparent_real (COGL_NODE (pipeline));
if (pipeline->differences & COGL_PIPELINE_STATE_USER_SHADER &&
pipeline->big_state->user_program)
g_object_unref (pipeline->big_state->user_program);
if (pipeline->differences & COGL_PIPELINE_STATE_UNIFORMS)
{
CoglPipelineUniformsState *uniforms_state
= &pipeline->big_state->uniforms_state;
int n_overrides = _cogl_bitmask_popcount (&uniforms_state->override_mask);
int i;
for (i = 0; i < n_overrides; i++)
_cogl_boxed_value_destroy (uniforms_state->override_values + i);
g_free (uniforms_state->override_values);
_cogl_bitmask_destroy (&uniforms_state->override_mask);
_cogl_bitmask_destroy (&uniforms_state->changed_mask);
}
if (pipeline->differences & COGL_PIPELINE_STATE_LAYERS)
g_list_free_full (pipeline->layer_differences, g_object_unref);
if (pipeline->differences & COGL_PIPELINE_STATE_VERTEX_SNIPPETS)
_cogl_pipeline_snippet_list_free (&pipeline->big_state->vertex_snippets);
if (pipeline->differences & COGL_PIPELINE_STATE_FRAGMENT_SNIPPETS)
_cogl_pipeline_snippet_list_free (&pipeline->big_state->fragment_snippets);
if (pipeline->differences & COGL_PIPELINE_STATE_NEEDS_BIG_STATE)
g_free (pipeline->big_state);
recursively_free_layer_caches (pipeline);
G_OBJECT_CLASS (cogl_pipeline_parent_class)->dispose (object);
}
static void
cogl_pipeline_class_init (CoglPipelineClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = cogl_pipeline_dispose;
}
static void
cogl_pipeline_init (CoglPipeline *pipeline)
{
}
/* /*
* This initializes the first pipeline owned by the Cogl context. All * This initializes the first pipeline owned by the Cogl context. All
@ -80,7 +181,7 @@ void
_cogl_pipeline_init_default_pipeline (void) _cogl_pipeline_init_default_pipeline (void)
{ {
/* Create new - blank - pipeline */ /* Create new - blank - pipeline */
CoglPipeline *pipeline = g_new0 (CoglPipeline, 1); CoglPipeline *pipeline = g_object_new (COGL_TYPE_PIPELINE, NULL);
/* XXX: NB: It's important that we zero this to avoid polluting /* XXX: NB: It's important that we zero this to avoid polluting
* pipeline hash values with un-initialized data */ * pipeline hash values with un-initialized data */
CoglPipelineBigState *big_state = g_new0 (CoglPipelineBigState, 1); CoglPipelineBigState *big_state = g_new0 (CoglPipelineBigState, 1);
@ -96,8 +197,6 @@ _cogl_pipeline_init_default_pipeline (void)
_cogl_pipeline_progend = &_cogl_pipeline_glsl_progend; _cogl_pipeline_progend = &_cogl_pipeline_glsl_progend;
_cogl_pipeline_vertend = &_cogl_pipeline_glsl_vertend; _cogl_pipeline_vertend = &_cogl_pipeline_glsl_vertend;
_cogl_pipeline_node_init (COGL_NODE (pipeline));
pipeline->is_weak = FALSE; pipeline->is_weak = FALSE;
pipeline->journal_ref_count = 0; pipeline->journal_ref_count = 0;
pipeline->differences = COGL_PIPELINE_STATE_ALL_SPARSE; pipeline->differences = COGL_PIPELINE_STATE_ALL_SPARSE;
@ -109,9 +208,10 @@ _cogl_pipeline_init_default_pipeline (void)
pipeline->big_state = big_state; pipeline->big_state = big_state;
pipeline->has_big_state = TRUE; pipeline->has_big_state = TRUE;
#ifdef COGL_DEBUG_ENABLED
pipeline->static_breadcrumb = "default pipeline"; pipeline->static_breadcrumb = "default pipeline";
pipeline->has_static_breadcrumb = TRUE; pipeline->has_static_breadcrumb = TRUE;
#endif
pipeline->age = 0; pipeline->age = 0;
@ -145,7 +245,7 @@ _cogl_pipeline_init_default_pipeline (void)
_cogl_bitmask_init (&uniforms_state->changed_mask); _cogl_bitmask_init (&uniforms_state->changed_mask);
uniforms_state->override_values = NULL; uniforms_state->override_values = NULL;
ctx->default_pipeline = _cogl_pipeline_object_new (pipeline); ctx->default_pipeline = pipeline;
} }
@ -215,28 +315,7 @@ _cogl_pipeline_promote_weak_ancestors (CoglPipeline *strong)
COGL_PIPELINE (n)->is_weak; COGL_PIPELINE (n)->is_weak;
n = n->parent) n = n->parent)
/* 'n' is weak so we take a reference on its parent */ /* 'n' is weak so we take a reference on its parent */
cogl_object_ref (n->parent); g_object_ref (n->parent);
}
static void
_cogl_pipeline_revert_weak_ancestors (CoglPipeline *strong)
{
CoglNode *n;
g_return_if_fail (!strong->is_weak);
/* This reverts the effect of calling
_cogl_pipeline_promote_weak_ancestors */
if (COGL_NODE (strong)->parent == NULL)
return;
for (n = COGL_NODE (strong)->parent;
/* We can assume that all weak pipelines have a parent */
COGL_PIPELINE (n)->is_weak;
n = n->parent)
/* 'n' is weak so we unref its parent */
cogl_object_unref (n->parent);
} }
/* XXX: Always have an eye out for opportunities to lower the cost of /* XXX: Always have an eye out for opportunities to lower the cost of
@ -244,9 +323,7 @@ _cogl_pipeline_revert_weak_ancestors (CoglPipeline *strong)
static CoglPipeline * static CoglPipeline *
_cogl_pipeline_copy (CoglPipeline *src, gboolean is_weak) _cogl_pipeline_copy (CoglPipeline *src, gboolean is_weak)
{ {
CoglPipeline *pipeline = g_new0 (CoglPipeline, 1); CoglPipeline *pipeline = g_object_new (COGL_TYPE_PIPELINE, NULL);
_cogl_pipeline_node_init (COGL_NODE (pipeline));
pipeline->is_weak = is_weak; pipeline->is_weak = is_weak;
@ -271,7 +348,9 @@ _cogl_pipeline_copy (CoglPipeline *src, gboolean is_weak)
pipeline->layers_cache_dirty = TRUE; pipeline->layers_cache_dirty = TRUE;
#ifdef COGL_DEBUG_ENABLED
pipeline->has_static_breadcrumb = FALSE; pipeline->has_static_breadcrumb = FALSE;
#endif
pipeline->age = 0; pipeline->age = 0;
@ -283,7 +362,7 @@ _cogl_pipeline_copy (CoglPipeline *src, gboolean is_weak)
if (!is_weak) if (!is_weak)
_cogl_pipeline_promote_weak_ancestors (pipeline); _cogl_pipeline_promote_weak_ancestors (pipeline);
return _cogl_pipeline_object_new (pipeline); return pipeline;
} }
CoglPipeline * CoglPipeline *
@ -320,80 +399,10 @@ cogl_pipeline_new (CoglContext *context)
return new; return new;
} }
static gboolean
destroy_weak_children_cb (CoglNode *node,
void *user_data)
{
CoglPipeline *pipeline = COGL_PIPELINE (node);
if (_cogl_pipeline_is_weak (pipeline))
{
_cogl_pipeline_node_foreach_child (COGL_NODE (pipeline),
destroy_weak_children_cb,
NULL);
pipeline->destroy_callback (pipeline, pipeline->destroy_data);
_cogl_pipeline_node_unparent_real (COGL_NODE (pipeline));
}
return TRUE;
}
static void
_cogl_pipeline_free (CoglPipeline *pipeline)
{
if (!pipeline->is_weak)
_cogl_pipeline_revert_weak_ancestors (pipeline);
/* Weak pipelines don't take a reference on their parent */
_cogl_pipeline_node_foreach_child (COGL_NODE (pipeline),
destroy_weak_children_cb,
NULL);
g_assert (_cogl_list_empty (&COGL_NODE (pipeline)->children));
_cogl_pipeline_node_unparent_real (COGL_NODE (pipeline));
if (pipeline->differences & COGL_PIPELINE_STATE_USER_SHADER &&
pipeline->big_state->user_program)
g_object_unref (pipeline->big_state->user_program);
if (pipeline->differences & COGL_PIPELINE_STATE_UNIFORMS)
{
CoglPipelineUniformsState *uniforms_state
= &pipeline->big_state->uniforms_state;
int n_overrides = _cogl_bitmask_popcount (&uniforms_state->override_mask);
int i;
for (i = 0; i < n_overrides; i++)
_cogl_boxed_value_destroy (uniforms_state->override_values + i);
g_free (uniforms_state->override_values);
_cogl_bitmask_destroy (&uniforms_state->override_mask);
_cogl_bitmask_destroy (&uniforms_state->changed_mask);
}
if (pipeline->differences & COGL_PIPELINE_STATE_LAYERS)
g_list_free_full (pipeline->layer_differences, cogl_object_unref);
if (pipeline->differences & COGL_PIPELINE_STATE_VERTEX_SNIPPETS)
_cogl_pipeline_snippet_list_free (&pipeline->big_state->vertex_snippets);
if (pipeline->differences & COGL_PIPELINE_STATE_FRAGMENT_SNIPPETS)
_cogl_pipeline_snippet_list_free (&pipeline->big_state->fragment_snippets);
if (pipeline->differences & COGL_PIPELINE_STATE_NEEDS_BIG_STATE)
g_free (pipeline->big_state);
recursively_free_layer_caches (pipeline);
g_free (pipeline);
}
gboolean gboolean
_cogl_pipeline_get_real_blend_enabled (CoglPipeline *pipeline) _cogl_pipeline_get_real_blend_enabled (CoglPipeline *pipeline)
{ {
g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); g_return_val_if_fail (COGL_IS_PIPELINE (pipeline), FALSE);
return pipeline->real_blend_enable; return pipeline->real_blend_enable;
} }
@ -805,7 +814,7 @@ _cogl_pipeline_copy_differences (CoglPipeline *dest,
if (dest->differences & COGL_PIPELINE_STATE_LAYERS && if (dest->differences & COGL_PIPELINE_STATE_LAYERS &&
dest->layer_differences) dest->layer_differences)
g_list_free_full (dest->layer_differences, cogl_object_unref); g_list_free_full (dest->layer_differences, g_object_unref);
for (l = src->layer_differences; l; l = l->next) for (l = src->layer_differences; l; l = l->next)
{ {
@ -815,7 +824,7 @@ _cogl_pipeline_copy_differences (CoglPipeline *dest,
* originals instead. */ * originals instead. */
CoglPipelineLayer *copy = _cogl_pipeline_layer_copy (l->data); CoglPipelineLayer *copy = _cogl_pipeline_layer_copy (l->data);
_cogl_pipeline_add_layer_difference (dest, copy, FALSE); _cogl_pipeline_add_layer_difference (dest, copy, FALSE);
cogl_object_unref (copy); g_object_unref (copy);
} }
/* Note: we initialize n_layers after adding the layer differences /* Note: we initialize n_layers after adding the layer differences
@ -1198,7 +1207,7 @@ _cogl_pipeline_pre_change_notify (CoglPipeline *pipeline,
/* The children will keep the new authority alive so drop the /* The children will keep the new authority alive so drop the
* reference we got when copying... */ * reference we got when copying... */
cogl_object_unref (new_authority); g_object_unref (new_authority);
} }
/* At this point we know we have a pipeline with no strong /* At this point we know we have a pipeline with no strong
@ -1259,7 +1268,7 @@ _cogl_pipeline_add_layer_difference (CoglPipeline *pipeline,
g_return_if_fail (layer->owner == NULL); g_return_if_fail (layer->owner == NULL);
layer->owner = pipeline; layer->owner = pipeline;
cogl_object_ref (layer); g_object_ref (layer);
/* - Flush journal primitives referencing the current state. /* - Flush journal primitives referencing the current state.
* - Make sure the pipeline has no dependants so it may be modified. * - Make sure the pipeline has no dependants so it may be modified.
@ -1320,7 +1329,7 @@ _cogl_pipeline_remove_layer_difference (CoglPipeline *pipeline,
if (layer->owner == pipeline) if (layer->owner == pipeline)
{ {
layer->owner = NULL; layer->owner = NULL;
cogl_object_unref (layer); g_object_unref (layer);
pipeline->layer_differences = pipeline->layer_differences =
g_list_remove (pipeline->layer_differences, layer); g_list_remove (pipeline->layer_differences, layer);
@ -1636,7 +1645,7 @@ _cogl_pipeline_get_layer_with_flags (CoglPipeline *pipeline,
_cogl_pipeline_add_layer_difference (pipeline, layer, TRUE); _cogl_pipeline_add_layer_difference (pipeline, layer, TRUE);
cogl_object_unref (layer); g_object_unref (layer);
return layer; return layer;
} }
@ -1662,10 +1671,10 @@ _cogl_pipeline_prune_empty_layer_difference (CoglPipeline *layers_authority,
if (layer_parent->index == layer->index && layer_parent->owner == NULL && if (layer_parent->index == layer->index && layer_parent->owner == NULL &&
_cogl_pipeline_layer_get_parent (layer_parent) != NULL) _cogl_pipeline_layer_get_parent (layer_parent) != NULL)
{ {
cogl_object_ref (layer_parent); g_object_ref (layer_parent);
layer_parent->owner = layers_authority; layer_parent->owner = layers_authority;
link->data = layer_parent; link->data = layer_parent;
cogl_object_unref (layer); g_object_unref (layer);
recursively_free_layer_caches (layers_authority); recursively_free_layer_caches (layers_authority);
return; return;
} }
@ -2224,7 +2233,7 @@ _cogl_pipeline_update_authority (CoglPipeline *pipeline,
unsigned long unsigned long
_cogl_pipeline_get_age (CoglPipeline *pipeline) _cogl_pipeline_get_age (CoglPipeline *pipeline)
{ {
g_return_val_if_fail (cogl_is_pipeline (pipeline), 0); g_return_val_if_fail (COGL_IS_PIPELINE (pipeline), 0);
return pipeline->age; return pipeline->age;
} }
@ -2236,7 +2245,7 @@ cogl_pipeline_remove_layer (CoglPipeline *pipeline, int layer_index)
CoglPipelineLayerInfo layer_info; CoglPipelineLayerInfo layer_info;
int i; int i;
g_return_if_fail (cogl_is_pipeline (pipeline)); g_return_if_fail (COGL_IS_PIPELINE (pipeline));
authority = authority =
_cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LAYERS); _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LAYERS);
@ -2286,7 +2295,7 @@ cogl_pipeline_get_n_layers (CoglPipeline *pipeline)
{ {
CoglPipeline *authority; CoglPipeline *authority;
g_return_val_if_fail (cogl_is_pipeline (pipeline), 0); g_return_val_if_fail (COGL_IS_PIPELINE (pipeline), 0);
authority = authority =
_cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LAYERS); _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LAYERS);
@ -2309,14 +2318,14 @@ CoglPipeline *
_cogl_pipeline_journal_ref (CoglPipeline *pipeline) _cogl_pipeline_journal_ref (CoglPipeline *pipeline)
{ {
pipeline->journal_ref_count++; pipeline->journal_ref_count++;
return cogl_object_ref (pipeline); return g_object_ref (pipeline);
} }
void void
_cogl_pipeline_journal_unref (CoglPipeline *pipeline) _cogl_pipeline_journal_unref (CoglPipeline *pipeline)
{ {
pipeline->journal_ref_count--; pipeline->journal_ref_count--;
cogl_object_unref (pipeline); g_object_unref (pipeline);
} }
#ifdef COGL_DEBUG_ENABLED #ifdef COGL_DEBUG_ENABLED

View File

@ -48,9 +48,9 @@ typedef struct _CoglPipeline CoglPipeline;
G_BEGIN_DECLS G_BEGIN_DECLS
/** /**
* SECTION:cogl-pipeline * CoglPipeline:
* @short_description: Functions for creating and manipulating the GPU *
* pipeline * Functions for creating and manipulating the GPU pipeline
* *
* Cogl allows creating and manipulating objects representing the full * Cogl allows creating and manipulating objects representing the full
* configuration of the GPU pipeline. In simplified terms the GPU * configuration of the GPU pipeline. In simplified terms the GPU
@ -60,16 +60,21 @@ G_BEGIN_DECLS
* performs fragment processing including depth testing and texture * performs fragment processing including depth testing and texture
* mapping. Finally it blends the result with the framebuffer. * mapping. Finally it blends the result with the framebuffer.
*/ */
#define COGL_TYPE_PIPELINE (cogl_pipeline_get_type ())
#define COGL_PIPELINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), COGL_TYPE_PIPELINE, CoglPipeline))
#define COGL_PIPELINE_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), COGL_TYPE_PIPELINE, CoglPipeline const))
#define COGL_PIPELINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), COGL_TYPE_PIPELINE, CoglPipelineClass))
#define COGL_IS_PIPELINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), COGL_TYPE_PIPELINE))
#define COGL_IS_PIPELINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), COGL_TYPE_PIPELINE))
#define COGL_PIPELINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), COGL_TYPE_PIPELINE, CoglPipelineClass))
#define COGL_PIPELINE(OBJECT) ((CoglPipeline *)OBJECT) typedef struct _CoglPipelineClass CoglPipelineClass;
typedef struct _CoglPipeline CoglPipeline;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglPipeline, g_object_unref)
/**
* cogl_pipeline_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
COGL_EXPORT COGL_EXPORT
GType cogl_pipeline_get_gtype (void); GType cogl_pipeline_get_type (void) G_GNUC_CONST;
/** /**
* cogl_pipeline_new: (constructor) * cogl_pipeline_new: (constructor)
@ -101,18 +106,6 @@ cogl_pipeline_new (CoglContext *context);
COGL_EXPORT CoglPipeline * COGL_EXPORT CoglPipeline *
cogl_pipeline_copy (CoglPipeline *source); cogl_pipeline_copy (CoglPipeline *source);
/**
* cogl_is_pipeline:
* @object: A #CoglObject
*
* Gets whether the given @object references an existing pipeline object.
*
* Return value: %TRUE if the @object references a #CoglPipeline,
* %FALSE otherwise
*/
COGL_EXPORT gboolean
cogl_is_pipeline (void *object);
/** /**
* CoglPipelineLayerCallback: * CoglPipelineLayerCallback:
* @pipeline: The #CoglPipeline whose layers are being iterated * @pipeline: The #CoglPipeline whose layers are being iterated

View File

@ -280,7 +280,7 @@ _cogl_texture_quad_multiple_primitives (CoglFramebuffer *framebuffer,
&state); &state);
if (validate_first_layer_state.override_pipeline) if (validate_first_layer_state.override_pipeline)
cogl_object_unref (validate_first_layer_state.override_pipeline); g_object_unref (validate_first_layer_state.override_pipeline);
} }
typedef struct _ValidateTexCoordsState typedef struct _ValidateTexCoordsState
@ -364,7 +364,7 @@ validate_tex_coords_cb (CoglPipeline *pipeline,
} }
if (state->override_pipeline) if (state->override_pipeline)
cogl_object_unref (state->override_pipeline); g_object_unref (state->override_pipeline);
state->needs_multiple_primitives = TRUE; state->needs_multiple_primitives = TRUE;
return FALSE; return FALSE;
} }
@ -467,7 +467,7 @@ _cogl_multitexture_quad_single_primitive (CoglFramebuffer *framebuffer,
n_layers * 4); n_layers * 4);
if (state.override_pipeline) if (state.override_pipeline)
cogl_object_unref (state.override_pipeline); g_object_unref (state.override_pipeline);
return TRUE; return TRUE;
} }
@ -703,7 +703,7 @@ _cogl_framebuffer_draw_multitextured_rectangles (
} }
if (pipeline != original_pipeline) if (pipeline != original_pipeline)
cogl_object_unref (pipeline); g_object_unref (pipeline);
} }
void void

View File

@ -231,7 +231,7 @@ _cogl_gl_flush_attributes_state (CoglFramebuffer *framebuffer,
* memcmp (&overrides->options, &options, * memcmp (&overrides->options, &options,
* sizeof (options) != 0) * sizeof (options) != 0)
* { * {
* cogl_object_unref (overrides->weak_pipeline); * g_object_unref (overrides->weak_pipeline);
* g_free (overrides); * g_free (overrides);
* overrides = NULL; * overrides = NULL;
* } * }
@ -300,5 +300,5 @@ _cogl_gl_flush_attributes_state (CoglFramebuffer *framebuffer,
apply_attribute_enable_updates (ctx, pipeline); apply_attribute_enable_updates (ctx, pipeline);
if (copy) if (copy)
cogl_object_unref (copy); g_object_unref (copy);
} }

View File

@ -101,7 +101,7 @@ typedef struct
CoglPipelineCacheEntry *cache_entry; CoglPipelineCacheEntry *cache_entry;
} CoglPipelineFragendShaderState; } CoglPipelineFragendShaderState;
static CoglUserDataKey shader_state_key; static GQuark shader_state_key = 0;
static void static void
ensure_layer_generated (CoglPipeline *pipeline, ensure_layer_generated (CoglPipeline *pipeline,
@ -120,23 +120,41 @@ shader_state_new (int n_layers,
return shader_state; return shader_state;
} }
typedef struct
{
CoglPipelineFragendShaderState *shader_state;
CoglPipeline *instance;
} CoglPipelineFragendShaderStateCache;
static GQuark
get_cache_key (void)
{
if (G_UNLIKELY (shader_state_key == 0))
shader_state_key = g_quark_from_static_string ("shader-state-key");
return shader_state_key;
}
static CoglPipelineFragendShaderState * static CoglPipelineFragendShaderState *
get_shader_state (CoglPipeline *pipeline) get_shader_state (CoglPipeline *pipeline)
{ {
return cogl_object_get_user_data (COGL_OBJECT (pipeline), &shader_state_key); CoglPipelineFragendShaderStateCache *cache;
cache = g_object_get_qdata (G_OBJECT (pipeline), get_cache_key ());
if (cache)
return cache->shader_state;
return NULL;
} }
static void static void
destroy_shader_state (void *user_data, destroy_shader_state (void *user_data)
void *instance)
{ {
CoglPipelineFragendShaderState *shader_state = user_data; CoglPipelineFragendShaderStateCache *cache = user_data;
CoglPipelineFragendShaderState *shader_state = cache->shader_state;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
if (shader_state->cache_entry && if (shader_state->cache_entry &&
shader_state->cache_entry->pipeline != instance) shader_state->cache_entry->pipeline != cache->instance)
shader_state->cache_entry->usage_count--; shader_state->cache_entry->usage_count--;
if (--shader_state->ref_count == 0) if (--shader_state->ref_count == 0)
@ -147,6 +165,7 @@ destroy_shader_state (void *user_data,
g_free (shader_state->unit_state); g_free (shader_state->unit_state);
g_free (shader_state); g_free (shader_state);
g_free (cache);
} }
} }
@ -163,18 +182,21 @@ set_shader_state (CoglPipeline *pipeline, CoglPipelineFragendShaderState *shader
shader_state->cache_entry->pipeline != pipeline) shader_state->cache_entry->pipeline != pipeline)
shader_state->cache_entry->usage_count++; shader_state->cache_entry->usage_count++;
} }
CoglPipelineFragendShaderStateCache *cache = g_new0 (CoglPipelineFragendShaderStateCache, 1);
cache->instance = pipeline;
cache->shader_state = shader_state;
_cogl_object_set_user_data (COGL_OBJECT (pipeline), g_object_set_qdata_full (G_OBJECT (pipeline),
&shader_state_key, get_cache_key (),
shader_state, cache,
destroy_shader_state); destroy_shader_state);
} }
static void static void
dirty_shader_state (CoglPipeline *pipeline) dirty_shader_state (CoglPipeline *pipeline)
{ {
cogl_object_set_user_data (COGL_OBJECT (pipeline), g_object_set_qdata_full (G_OBJECT (pipeline),
&shader_state_key, get_cache_key (),
NULL, NULL,
NULL); NULL);
} }

View File

@ -84,7 +84,7 @@ static void
texture_unit_free (CoglTextureUnit *unit) texture_unit_free (CoglTextureUnit *unit)
{ {
if (unit->layer) if (unit->layer)
cogl_object_unref (unit->layer); g_object_unref (unit->layer);
g_object_unref (unit->matrix_stack); g_object_unref (unit->matrix_stack);
} }
@ -563,9 +563,9 @@ flush_layers_common_gl_state_cb (CoglPipelineLayer *layer, void *user_data)
GE( ctx, glBindSampler (unit_index, sampler_state->sampler_object) ); GE( ctx, glBindSampler (unit_index, sampler_state->sampler_object) );
} }
cogl_object_ref (layer); g_object_ref (layer);
if (unit->layer != NULL) if (unit->layer != NULL)
cogl_object_unref (unit->layer); g_object_unref (unit->layer);
unit->layer = layer; unit->layer = layer;
unit->layer_changes_since_flush = 0; unit->layer_changes_since_flush = 0;
@ -1088,9 +1088,9 @@ _cogl_pipeline_flush_gl_state (CoglContext *ctx,
* XXX: The issue should largely go away when we switch to using * XXX: The issue should largely go away when we switch to using
* weak pipelines for overrides. * weak pipelines for overrides.
*/ */
cogl_object_ref (pipeline); g_object_ref (pipeline);
if (ctx->current_pipeline != NULL) if (ctx->current_pipeline != NULL)
cogl_object_unref (ctx->current_pipeline); g_object_unref (ctx->current_pipeline);
ctx->current_pipeline = pipeline; ctx->current_pipeline = pipeline;
ctx->current_pipeline_changes_since_flush = 0; ctx->current_pipeline_changes_since_flush = 0;
ctx->current_pipeline_with_color_attrib = with_color_attrib; ctx->current_pipeline_with_color_attrib = with_color_attrib;

View File

@ -140,12 +140,31 @@ typedef struct
CoglPipelineCacheEntry *cache_entry; CoglPipelineCacheEntry *cache_entry;
} CoglPipelineProgramState; } CoglPipelineProgramState;
static CoglUserDataKey program_state_key; static GQuark program_state_key = 0;
typedef struct
{
CoglPipelineProgramState *program_state;
CoglPipeline *instance;
} CoglPipelineProgramStateCache;
static GQuark
get_cache_key (void)
{
if (G_UNLIKELY (program_state_key == 0))
program_state_key = g_quark_from_static_string ("program-state-progend-key");
return program_state_key;
}
static CoglPipelineProgramState * static CoglPipelineProgramState *
get_program_state (CoglPipeline *pipeline) get_program_state (CoglPipeline *pipeline)
{ {
return cogl_object_get_user_data (COGL_OBJECT (pipeline), &program_state_key); CoglPipelineProgramStateCache *cache;
cache = g_object_get_qdata (G_OBJECT (pipeline), get_cache_key ());
if (cache)
return cache->program_state;
return NULL;
} }
#define UNIFORM_LOCATION_UNKNOWN -2 #define UNIFORM_LOCATION_UNKNOWN -2
@ -246,10 +265,10 @@ program_state_new (int n_layers,
} }
static void static void
destroy_program_state (void *user_data, destroy_program_state (void *user_data)
void *instance)
{ {
CoglPipelineProgramState *program_state = user_data; CoglPipelineProgramStateCache *cache = user_data;
CoglPipelineProgramState *program_state = cache->program_state;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
@ -257,11 +276,11 @@ destroy_program_state (void *user_data,
it so that if same address gets used again for a new pipeline it so that if same address gets used again for a new pipeline
then we won't think it's the same pipeline and avoid updating the then we won't think it's the same pipeline and avoid updating the
uniforms */ uniforms */
if (program_state->last_used_for_pipeline == instance) if (program_state->last_used_for_pipeline == cache->instance)
program_state->last_used_for_pipeline = NULL; program_state->last_used_for_pipeline = NULL;
if (program_state->cache_entry && if (program_state->cache_entry &&
program_state->cache_entry->pipeline != instance) program_state->cache_entry->pipeline != cache->instance)
program_state->cache_entry->usage_count--; program_state->cache_entry->usage_count--;
if (--program_state->ref_count == 0) if (--program_state->ref_count == 0)
@ -280,6 +299,7 @@ destroy_program_state (void *user_data,
g_array_free (program_state->uniform_locations, TRUE); g_array_free (program_state->uniform_locations, TRUE);
g_free (program_state); g_free (program_state);
g_free (cache);
} }
} }
@ -298,17 +318,21 @@ set_program_state (CoglPipeline *pipeline,
program_state->cache_entry->usage_count++; program_state->cache_entry->usage_count++;
} }
_cogl_object_set_user_data (COGL_OBJECT (pipeline), CoglPipelineProgramStateCache *cache = g_new0 (CoglPipelineProgramStateCache, 1);
&program_state_key, cache->instance = pipeline;
program_state, cache->program_state = program_state;
g_object_set_qdata_full (G_OBJECT (pipeline),
get_cache_key (),
cache,
destroy_program_state); destroy_program_state);
} }
static void static void
dirty_program_state (CoglPipeline *pipeline) dirty_program_state (CoglPipeline *pipeline)
{ {
cogl_object_set_user_data (COGL_OBJECT (pipeline), g_object_set_qdata_full (G_OBJECT (pipeline),
&program_state_key, get_cache_key (),
NULL, NULL,
NULL); NULL);
} }
@ -660,7 +684,7 @@ _cogl_shader_compile_real (CoglShader *shader,
if (shader->compilation_pipeline) if (shader->compilation_pipeline)
{ {
cogl_object_unref (shader->compilation_pipeline); g_object_unref (shader->compilation_pipeline);
shader->compilation_pipeline = NULL; shader->compilation_pipeline = NULL;
} }
} }
@ -690,7 +714,7 @@ _cogl_shader_compile_real (CoglShader *shader,
NULL); NULL);
GE (ctx, glCompileShader (shader->gl_handle)); GE (ctx, glCompileShader (shader->gl_handle));
shader->compilation_pipeline = cogl_object_ref (pipeline); shader->compilation_pipeline = g_object_ref (pipeline);
GE (ctx, glGetShaderiv (shader->gl_handle, GL_COMPILE_STATUS, &status)); GE (ctx, glGetShaderiv (shader->gl_handle, GL_COMPILE_STATUS, &status));
if (!status) if (!status)

View File

@ -59,7 +59,7 @@ struct _CoglPipelineVertendShaderState
CoglPipelineCacheEntry *cache_entry; CoglPipelineCacheEntry *cache_entry;
}; };
static CoglUserDataKey shader_state_key; static GQuark shader_state_key = 0;
static CoglPipelineVertendShaderState * static CoglPipelineVertendShaderState *
shader_state_new (CoglPipelineCacheEntry *cache_entry) shader_state_new (CoglPipelineCacheEntry *cache_entry)
@ -73,10 +73,29 @@ shader_state_new (CoglPipelineCacheEntry *cache_entry)
return shader_state; return shader_state;
} }
typedef struct
{
CoglPipelineVertendShaderState *shader_state;
CoglPipeline *instance;
} CoglPipelineVertendShaderStateCache;
static GQuark
get_cache_key (void)
{
if (G_UNLIKELY (shader_state_key == 0))
shader_state_key = g_quark_from_static_string ("shader-vertend-state-key");
return shader_state_key;
}
static CoglPipelineVertendShaderState * static CoglPipelineVertendShaderState *
get_shader_state (CoglPipeline *pipeline) get_shader_state (CoglPipeline *pipeline)
{ {
return cogl_object_get_user_data (COGL_OBJECT (pipeline), &shader_state_key); CoglPipelineVertendShaderStateCache * cache;
cache = g_object_get_qdata (G_OBJECT (pipeline), get_cache_key ());
if (cache)
return cache->shader_state;
return NULL;
} }
CoglPipelineVertendShaderState * CoglPipelineVertendShaderState *
@ -86,15 +105,15 @@ cogl_pipeline_vertend_glsl_get_shader_state (CoglPipeline *pipeline)
} }
static void static void
destroy_shader_state (void *user_data, destroy_shader_state (void *user_data)
void *instance)
{ {
CoglPipelineVertendShaderState *shader_state = user_data; CoglPipelineVertendShaderStateCache *cache = user_data;
CoglPipelineVertendShaderState *shader_state = cache->shader_state;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
if (shader_state->cache_entry && if (shader_state->cache_entry &&
shader_state->cache_entry->pipeline != instance) shader_state->cache_entry->pipeline != cache->instance)
shader_state->cache_entry->usage_count--; shader_state->cache_entry->usage_count--;
if (--shader_state->ref_count == 0) if (--shader_state->ref_count == 0)
@ -103,6 +122,7 @@ destroy_shader_state (void *user_data,
GE( ctx, glDeleteShader (shader_state->gl_shader) ); GE( ctx, glDeleteShader (shader_state->gl_shader) );
g_free (shader_state); g_free (shader_state);
g_free (cache);
} }
} }
@ -121,17 +141,20 @@ set_shader_state (CoglPipeline *pipeline,
shader_state->cache_entry->usage_count++; shader_state->cache_entry->usage_count++;
} }
_cogl_object_set_user_data (COGL_OBJECT (pipeline), CoglPipelineVertendShaderStateCache *cache = g_new0 (CoglPipelineVertendShaderStateCache, 1);
&shader_state_key, cache->instance = pipeline;
shader_state, cache->shader_state = shader_state;
g_object_set_qdata_full (G_OBJECT (pipeline),
get_cache_key (),
cache,
destroy_shader_state); destroy_shader_state);
} }
static void static void
dirty_shader_state (CoglPipeline *pipeline) dirty_shader_state (CoglPipeline *pipeline)
{ {
cogl_object_set_user_data (COGL_OBJECT (pipeline), g_object_set_qdata_full (G_OBJECT (pipeline),
&shader_state_key, get_cache_key (),
NULL, NULL,
NULL); NULL);
} }

View File

@ -353,7 +353,7 @@ draw_cursor_sprite_via_offscreen (MetaScreenCastStreamSrc *src,
cogl_framebuffer_clear (fb, COGL_BUFFER_BIT_COLOR, &clear_color); cogl_framebuffer_clear (fb, COGL_BUFFER_BIT_COLOR, &clear_color);
cogl_framebuffer_draw_rectangle (fb, pipeline, cogl_framebuffer_draw_rectangle (fb, pipeline,
-1, 1, 1, -1); -1, 1, 1, -1);
cogl_object_unref (pipeline); g_object_unref (pipeline);
cogl_framebuffer_read_pixels (fb, cogl_framebuffer_read_pixels (fb,
0, 0, 0, 0,

View File

@ -255,7 +255,7 @@ maybe_blit_cursor_sprite (MetaScreenCastWindowStreamSrc *window_src,
x, y, x, y,
x + width, y + height); x + width, y + height);
cogl_object_unref (pipeline); g_object_unref (pipeline);
} }
static gboolean static gboolean

View File

@ -87,7 +87,7 @@ static void
meta_overlay_free (MetaOverlay *overlay) meta_overlay_free (MetaOverlay *overlay)
{ {
if (overlay->pipeline) if (overlay->pipeline)
cogl_object_unref (overlay->pipeline); g_object_unref (overlay->pipeline);
g_free (overlay); g_free (overlay);
} }

View File

@ -197,7 +197,7 @@ meta_stage_x11_nested_unrealize (ClutterStageWindow *stage_window)
{ {
MetaStageX11Nested *stage_nested = META_STAGE_X11_NESTED (stage_window); MetaStageX11Nested *stage_nested = META_STAGE_X11_NESTED (stage_window);
g_clear_pointer (&stage_nested->pipeline, cogl_object_unref); g_clear_object (&stage_nested->pipeline);
clutter_stage_window_parent_iface->unrealize (stage_window); clutter_stage_window_parent_iface->unrealize (stage_window);
} }

View File

@ -410,7 +410,7 @@ setup_pipeline (MetaBackgroundContent *self,
pipeline_flags |= PIPELINE_ROUNDED_CLIP | PIPELINE_BLEND; pipeline_flags |= PIPELINE_ROUNDED_CLIP | PIPELINE_BLEND;
if (pipeline_flags != self->pipeline_flags) if (pipeline_flags != self->pipeline_flags)
g_clear_pointer (&self->pipeline, cogl_object_unref); g_clear_object (&self->pipeline);
if (self->pipeline == NULL) if (self->pipeline == NULL)
{ {
@ -830,7 +830,7 @@ meta_background_content_dispose (GObject *object)
set_unobscured_region (self, NULL); set_unobscured_region (self, NULL);
meta_background_content_set_background (self, NULL); meta_background_content_set_background (self, NULL);
g_clear_pointer (&self->pipeline, cogl_object_unref); g_clear_object (&self->pipeline);
G_OBJECT_CLASS (meta_background_content_parent_class)->dispose (object); G_OBJECT_CLASS (meta_background_content_parent_class)->dispose (object);
} }

View File

@ -694,7 +694,7 @@ ensure_wallpaper_texture (MetaBackground *self,
cogl_pipeline_set_layer_texture (pipeline, 0, texture); cogl_pipeline_set_layer_texture (pipeline, 0, texture);
cogl_framebuffer_draw_textured_rectangle (fbo, pipeline, 0, 0, width, height, cogl_framebuffer_draw_textured_rectangle (fbo, pipeline, 0, 0, width, height,
0., 0., 1., 1.); 0., 0., 1., 1.);
cogl_object_unref (pipeline); g_object_unref (pipeline);
if (texture_has_alpha (texture)) if (texture_has_alpha (texture))
{ {
@ -703,7 +703,7 @@ ensure_wallpaper_texture (MetaBackground *self,
pipeline = create_pipeline (PIPELINE_OVER_REVERSE); pipeline = create_pipeline (PIPELINE_OVER_REVERSE);
cogl_pipeline_set_layer_texture (pipeline, 0, self->color_texture); cogl_pipeline_set_layer_texture (pipeline, 0, self->color_texture);
cogl_framebuffer_draw_rectangle (fbo, pipeline, 0, 0, width, height); cogl_framebuffer_draw_rectangle (fbo, pipeline, 0, 0, width, height);
cogl_object_unref (pipeline); g_object_unref (pipeline);
} }
g_object_unref (fbo); g_object_unref (fbo);
@ -873,7 +873,7 @@ meta_background_get_texture (MetaBackground *self,
texture2, &monitor_area, texture2, &monitor_area,
monitor_scale); monitor_scale);
cogl_object_unref (pipeline); g_object_unref (pipeline);
} }
else else
{ {
@ -905,7 +905,7 @@ meta_background_get_texture (MetaBackground *self,
texture1, &monitor_area, texture1, &monitor_area,
monitor_scale); monitor_scale);
cogl_object_unref (pipeline); g_object_unref (pipeline);
} }
if (bare_region_visible) if (bare_region_visible)
@ -918,7 +918,7 @@ meta_background_get_texture (MetaBackground *self,
pipeline, pipeline,
0, 0, 0, 0,
monitor_area.width, monitor_area.height); monitor_area.width, monitor_area.height);
cogl_object_unref (pipeline); g_object_unref (pipeline);
} }
monitor->dirty = FALSE; monitor->dirty = FALSE;

View File

@ -168,7 +168,7 @@ meta_shadow_unref (MetaShadow *shadow)
meta_window_shape_unref (shadow->key.shape); meta_window_shape_unref (shadow->key.shape);
g_object_unref (shadow->texture); g_object_unref (shadow->texture);
cogl_object_unref (shadow->pipeline); g_object_unref (shadow->pipeline);
g_free (shadow); g_free (shadow);
} }

View File

@ -226,14 +226,14 @@ meta_shaped_texture_set_clip_region (MetaShapedTexture *stex,
static void static void
meta_shaped_texture_reset_pipelines (MetaShapedTexture *stex) meta_shaped_texture_reset_pipelines (MetaShapedTexture *stex)
{ {
g_clear_pointer (&stex->base_pipeline, cogl_object_unref); g_clear_object (&stex->base_pipeline);
g_clear_pointer (&stex->combined_pipeline, cogl_object_unref); g_clear_object (&stex->combined_pipeline);
g_clear_pointer (&stex->unmasked_pipeline, cogl_object_unref); g_clear_object (&stex->unmasked_pipeline);
g_clear_pointer (&stex->unmasked_tower_pipeline, cogl_object_unref); g_clear_object (&stex->unmasked_tower_pipeline);
g_clear_pointer (&stex->masked_pipeline, cogl_object_unref); g_clear_object (&stex->masked_pipeline);
g_clear_pointer (&stex->masked_tower_pipeline, cogl_object_unref); g_clear_object (&stex->masked_tower_pipeline);
g_clear_pointer (&stex->unblended_pipeline, cogl_object_unref); g_clear_object (&stex->unblended_pipeline);
g_clear_pointer (&stex->unblended_tower_pipeline, cogl_object_unref); g_clear_object (&stex->unblended_tower_pipeline);
} }
static void static void

View File

@ -68,7 +68,7 @@ meta_texture_mipmap_free (MetaTextureMipmap *mipmap)
{ {
g_return_if_fail (mipmap != NULL); g_return_if_fail (mipmap != NULL);
cogl_clear_object (&mipmap->pipeline); g_clear_object (&mipmap->pipeline);
g_clear_object (&mipmap->base_texture); g_clear_object (&mipmap->base_texture);
g_clear_object (&mipmap->mipmap_texture); g_clear_object (&mipmap->mipmap_texture);
g_clear_object (&mipmap->fb); g_clear_object (&mipmap->fb);

View File

@ -65,7 +65,7 @@ foo_actor_paint (ClutterActor *actor,
allocation.y1, allocation.y1,
allocation.x2, allocation.x2,
allocation.y2); allocation.y2);
cogl_object_unref (pipeline); g_object_unref (pipeline);
} }
static gboolean static gboolean

View File

@ -171,7 +171,7 @@ key_group_paint (ClutterActor *actor,
clutter_actor_paint (child, paint_context); clutter_actor_paint (child, paint_context);
} }
cogl_object_unref (pipeline); g_object_unref (pipeline);
} }
static void static void

View File

@ -222,8 +222,8 @@ test_cogl_multitexture_main (int argc, char *argv[])
clutter_test_main (); clutter_test_main ();
cogl_object_unref (state->pipeline1); g_object_unref (state->pipeline1);
cogl_object_unref (state->pipeline0); g_object_unref (state->pipeline0);
g_object_unref (state->alpha_tex); g_object_unref (state->alpha_tex);
g_object_unref (state->redhand_tex); g_object_unref (state->redhand_tex);
g_object_unref (state->light_tex0); g_object_unref (state->light_tex0);

View File

@ -53,7 +53,7 @@ test_coglbox_paint (ClutterActor *self,
pipeline = cogl_pipeline_new (ctx); pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_color4ub (pipeline, 0x66, 0x66, 0xdd, 0xff); cogl_pipeline_set_color4ub (pipeline, 0x66, 0x66, 0xdd, 0xff);
cogl_framebuffer_draw_rectangle (framebuffer, pipeline, 0, 0, 400, 400); cogl_framebuffer_draw_rectangle (framebuffer, pipeline, 0, 0, 400, 400);
cogl_object_unref (pipeline); g_object_unref (pipeline);
pipeline = cogl_pipeline_new (ctx); pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_layer_texture (pipeline, 0, coglbox->texhand_id); cogl_pipeline_set_layer_texture (pipeline, 0, coglbox->texhand_id);
@ -62,7 +62,7 @@ test_coglbox_paint (ClutterActor *self,
400, 400, 400, 400,
0, 0, 0, 0,
6, 6); 6, 6);
cogl_object_unref (pipeline); g_object_unref (pipeline);
pipeline = cogl_pipeline_new (ctx); pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_color4ub (pipeline, 0xff, 0, 0, 0xff); cogl_pipeline_set_color4ub (pipeline, 0xff, 0, 0, 0xff);
@ -72,7 +72,7 @@ test_coglbox_paint (ClutterActor *self,
cogl_pipeline_set_color4ub (pipeline, 0, 0xff, 0, 0xff); cogl_pipeline_set_color4ub (pipeline, 0, 0xff, 0, 0xff);
cogl_framebuffer_draw_rectangle (coglbox->framebuffer, pipeline, cogl_framebuffer_draw_rectangle (coglbox->framebuffer, pipeline,
80, 80, 80 + 100, 80 + 100); 80, 80, 80 + 100, 80 + 100);
cogl_object_unref (pipeline); g_object_unref (pipeline);
pipeline = cogl_pipeline_new (ctx); pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_color4ub (pipeline, 0x88, 0x88, 0x88, 0x88); cogl_pipeline_set_color4ub (pipeline, 0x88, 0x88, 0x88, 0x88);
@ -84,7 +84,7 @@ test_coglbox_paint (ClutterActor *self,
texcoords[1], texcoords[1],
texcoords[2], texcoords[2],
texcoords[3]); texcoords[3]);
cogl_object_unref (pipeline); g_object_unref (pipeline);
} }
static void static void

View File

@ -272,7 +272,7 @@ test_cogl_point_sprites_main (int argc, char *argv[])
clutter_test_main (); clutter_test_main ();
cogl_object_unref (data.pipeline); g_object_unref (data.pipeline);
g_timer_destroy (data.last_spark_time); g_timer_destroy (data.last_spark_time);
for (i = 0; i < N_FIREWORKS; i++) for (i = 0; i < N_FIREWORKS; i++)

View File

@ -211,7 +211,7 @@ test_coglbox_paint (ClutterActor *self,
cogl_framebuffer_pop_matrix (framebuffer); cogl_framebuffer_pop_matrix (framebuffer);
cogl_object_unref (pipeline); g_object_unref (pipeline);
} }
static void static void

View File

@ -73,7 +73,7 @@ test_coglbox_paint (ClutterActor *self,
pipeline = cogl_pipeline_new (ctx); pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_color4ub (pipeline, 0x66, 0x66, 0xdd, 0xff); cogl_pipeline_set_color4ub (pipeline, 0x66, 0x66, 0xdd, 0xff);
cogl_framebuffer_draw_rectangle (framebuffer, pipeline, 0, 0, 400, 400); cogl_framebuffer_draw_rectangle (framebuffer, pipeline, 0, 0, 400, 400);
cogl_object_unref (pipeline); g_object_unref (pipeline);
cogl_framebuffer_translate (framebuffer, 100, 100, 0); cogl_framebuffer_translate (framebuffer, 100, 100, 0);
@ -83,7 +83,7 @@ test_coglbox_paint (ClutterActor *self,
0, 0, 200, 213, 0, 0, 200, 213,
texcoords[0], texcoords[1], texcoords[0], texcoords[1],
texcoords[2], texcoords[3]); texcoords[2], texcoords[3]);
cogl_object_unref (pipeline); g_object_unref (pipeline);
cogl_framebuffer_pop_matrix (framebuffer); cogl_framebuffer_pop_matrix (framebuffer);
} }

View File

@ -47,7 +47,7 @@ test_alpha_test (void)
-1, -1, -1, -1,
1, 1); 1, 1);
cogl_object_unref (pipeline); g_object_unref (pipeline);
g_object_unref (tex); g_object_unref (tex);
/* The left side of the framebuffer should use the first pixel from /* The left side of the framebuffer should use the first pixel from

View File

@ -78,8 +78,8 @@ test_alpha_textures (void)
g_object_unref (tex1); g_object_unref (tex1);
g_object_unref (tex2); g_object_unref (tex2);
cogl_object_unref (pipeline1); g_object_unref (pipeline1);
cogl_object_unref (pipeline2); g_object_unref (pipeline2);
/* Unmodified texture */ /* Unmodified texture */
test_utils_check_pixel (test_fb, test_utils_check_pixel (test_fb,

View File

@ -158,10 +158,10 @@ paint_test_backface_culling (TestState *state,
cogl_framebuffer_pop_matrix (framebuffer); cogl_framebuffer_pop_matrix (framebuffer);
cogl_object_unref (pipeline); g_object_unref (pipeline);
} }
cogl_object_unref (base_pipeline); g_object_unref (base_pipeline);
} }
static void static void
@ -248,7 +248,7 @@ paint (TestState *state)
0, TEXTURE_RENDER_SIZE * 8, 0, TEXTURE_RENDER_SIZE * 8,
state->width, state->width,
state->height + TEXTURE_RENDER_SIZE * 8); state->height + TEXTURE_RENDER_SIZE * 8);
cogl_object_unref (pipeline); g_object_unref (pipeline);
validate_result (test_fb, 0); validate_result (test_fb, 0);
validate_result (test_fb, 8); validate_result (test_fb, 8);

View File

@ -68,7 +68,7 @@ test_blend_paint (TestState *state,
y * QUAD_WIDTH, y * QUAD_WIDTH,
x * QUAD_WIDTH + QUAD_WIDTH, x * QUAD_WIDTH + QUAD_WIDTH,
y * QUAD_WIDTH + QUAD_WIDTH); y * QUAD_WIDTH + QUAD_WIDTH);
cogl_object_unref (pipeline); g_object_unref (pipeline);
/* /*
* Now blend a rectangle over our well defined destination: * Now blend a rectangle over our well defined destination:
@ -100,7 +100,7 @@ test_blend_paint (TestState *state,
y * QUAD_WIDTH, y * QUAD_WIDTH,
x * QUAD_WIDTH + QUAD_WIDTH, x * QUAD_WIDTH + QUAD_WIDTH,
y * QUAD_WIDTH + QUAD_WIDTH); y * QUAD_WIDTH + QUAD_WIDTH);
cogl_object_unref (pipeline); g_object_unref (pipeline);
/* See what we got... */ /* See what we got... */
@ -216,7 +216,7 @@ test_tex_combine (TestState *state,
x * QUAD_WIDTH + QUAD_WIDTH, x * QUAD_WIDTH + QUAD_WIDTH,
y * QUAD_WIDTH + QUAD_WIDTH); y * QUAD_WIDTH + QUAD_WIDTH);
cogl_object_unref (pipeline); g_object_unref (pipeline);
g_object_unref (tex0); g_object_unref (tex0);
g_object_unref (tex1); g_object_unref (tex1);

View File

@ -83,7 +83,7 @@ test_copy_replace_texture (void)
/* Unref everything but the last pipeline */ /* Unref everything but the last pipeline */
for (pipeline_num = 0; pipeline_num < N_PIPELINES - 1; pipeline_num++) for (pipeline_num = 0; pipeline_num < N_PIPELINES - 1; pipeline_num++)
cogl_object_unref (pipelines[pipeline_num]); g_object_unref (pipelines[pipeline_num]);
if (alive_texture_mask && cogl_test_verbose ()) if (alive_texture_mask && cogl_test_verbose ())
{ {
@ -110,7 +110,7 @@ test_copy_replace_texture (void)
LAST_PIPELINE_MASK); LAST_PIPELINE_MASK);
/* Clean up the last pipeline */ /* Clean up the last pipeline */
cogl_object_unref (pipelines[N_PIPELINES - 1]); g_object_unref (pipelines[N_PIPELINES - 1]);
/* That should get rid of the last of the textures */ /* That should get rid of the last of the textures */
g_assert_cmpint (alive_texture_mask, ==, 0); g_assert_cmpint (alive_texture_mask, ==, 0);

View File

@ -254,8 +254,8 @@ test_short_verts (TestState *state, int offset_x, int offset_y)
g_object_unref (attributes[0]); g_object_unref (attributes[0]);
cogl_object_unref (pipeline2); g_object_unref (pipeline2);
cogl_object_unref (pipeline); g_object_unref (pipeline);
g_object_unref (buffer); g_object_unref (buffer);
test_utils_check_pixel (test_fb, offset_x + 5, offset_y + 5, 0xff0000ff); test_utils_check_pixel (test_fb, offset_x + 5, offset_y + 5, 0xff0000ff);
@ -293,7 +293,7 @@ test_custom_attributes (void)
paint (&state); paint (&state);
cogl_object_unref (state.pipeline); g_object_unref (state.pipeline);
g_object_unref (snippet); g_object_unref (snippet);
if (cogl_test_verbose ()) if (cogl_test_verbose ())

View File

@ -58,7 +58,7 @@ draw_rectangle (TestState *state,
pipeline = cogl_pipeline_new (test_ctx); pipeline = cogl_pipeline_new (test_ctx);
if (!cogl_pipeline_set_depth_state (pipeline, &depth_state, NULL)) if (!cogl_pipeline_set_depth_state (pipeline, &depth_state, NULL))
{ {
cogl_object_unref (pipeline); g_object_unref (pipeline);
return FALSE; return FALSE;
} }
@ -95,10 +95,10 @@ draw_rectangle (TestState *state,
y * QUAD_WIDTH + QUAD_WIDTH); y * QUAD_WIDTH + QUAD_WIDTH);
cogl_framebuffer_pop_matrix (test_fb); cogl_framebuffer_pop_matrix (test_fb);
cogl_object_unref (legacy_pipeline); g_object_unref (legacy_pipeline);
} }
cogl_object_unref (pipeline); g_object_unref (pipeline);
return TRUE; return TRUE;
} }

View File

@ -30,7 +30,7 @@ test_journal_unref_flush (void)
cogl_framebuffer_draw_rectangle (COGL_FRAMEBUFFER (offscreen), cogl_framebuffer_draw_rectangle (COGL_FRAMEBUFFER (offscreen),
pipeline, pipeline,
-1, -1, 1, 1); -1, -1, 1, 1);
cogl_object_unref (pipeline); g_object_unref (pipeline);
g_object_unref (offscreen); g_object_unref (offscreen);
g_assert_null (offscreen); g_assert_null (offscreen);

View File

@ -86,7 +86,7 @@ paint (TestState *state)
50, 0, 100, 50); 50, 0, 100, 50);
cogl_pipeline_set_user_program (pipeline, NULL); cogl_pipeline_set_user_program (pipeline, NULL);
cogl_object_unref (pipeline); g_object_unref (pipeline);
} }
static void static void

View File

@ -68,21 +68,21 @@ test_layer_remove (void)
* together properly */ * together properly */
pipeline0 = create_two_layer_pipeline (); pipeline0 = create_two_layer_pipeline ();
test_color (pipeline0, 0xffff00ff, pos++); test_color (pipeline0, 0xffff00ff, pos++);
cogl_object_unref (pipeline0); g_object_unref (pipeline0);
/** TEST 2 **/ /** TEST 2 **/
/* Check that we can remove the second layer */ /* Check that we can remove the second layer */
pipeline0 = create_two_layer_pipeline (); pipeline0 = create_two_layer_pipeline ();
cogl_pipeline_remove_layer (pipeline0, 1); cogl_pipeline_remove_layer (pipeline0, 1);
test_color (pipeline0, 0xff0000ff, pos++); test_color (pipeline0, 0xff0000ff, pos++);
cogl_object_unref (pipeline0); g_object_unref (pipeline0);
/** TEST 3 **/ /** TEST 3 **/
/* Check that we can remove the first layer */ /* Check that we can remove the first layer */
pipeline0 = create_two_layer_pipeline (); pipeline0 = create_two_layer_pipeline ();
cogl_pipeline_remove_layer (pipeline0, 0); cogl_pipeline_remove_layer (pipeline0, 0);
test_color (pipeline0, 0x00ff00ff, pos++); test_color (pipeline0, 0x00ff00ff, pos++);
cogl_object_unref (pipeline0); g_object_unref (pipeline0);
/** TEST 4 **/ /** TEST 4 **/
/* Check that we can make a copy and remove a layer from the /* Check that we can make a copy and remove a layer from the
@ -92,8 +92,8 @@ test_layer_remove (void)
cogl_pipeline_remove_layer (pipeline0, 1); cogl_pipeline_remove_layer (pipeline0, 1);
test_color (pipeline0, 0xff0000ff, pos++); test_color (pipeline0, 0xff0000ff, pos++);
test_color (pipeline1, 0xffff00ff, pos++); test_color (pipeline1, 0xffff00ff, pos++);
cogl_object_unref (pipeline0); g_object_unref (pipeline0);
cogl_object_unref (pipeline1); g_object_unref (pipeline1);
/** TEST 5 **/ /** TEST 5 **/
/* Check that we can make a copy and remove the second layer from the /* Check that we can make a copy and remove the second layer from the
@ -103,8 +103,8 @@ test_layer_remove (void)
cogl_pipeline_remove_layer (pipeline1, 1); cogl_pipeline_remove_layer (pipeline1, 1);
test_color (pipeline0, 0xffff00ff, pos++); test_color (pipeline0, 0xffff00ff, pos++);
test_color (pipeline1, 0xff0000ff, pos++); test_color (pipeline1, 0xff0000ff, pos++);
cogl_object_unref (pipeline0); g_object_unref (pipeline0);
cogl_object_unref (pipeline1); g_object_unref (pipeline1);
/** TEST 6 **/ /** TEST 6 **/
/* Check that we can make a copy and remove the first layer from the /* Check that we can make a copy and remove the first layer from the
@ -114,8 +114,8 @@ test_layer_remove (void)
cogl_pipeline_remove_layer (pipeline1, 0); cogl_pipeline_remove_layer (pipeline1, 0);
test_color (pipeline0, 0xffff00ff, pos++); test_color (pipeline0, 0xffff00ff, pos++);
test_color (pipeline1, 0x00ff00ff, pos++); test_color (pipeline1, 0x00ff00ff, pos++);
cogl_object_unref (pipeline0); g_object_unref (pipeline0);
cogl_object_unref (pipeline1); g_object_unref (pipeline1);
/** TEST 7 **/ /** TEST 7 **/
/* Check that we can modify a layer in a child pipeline */ /* Check that we can modify a layer in a child pipeline */
@ -125,8 +125,8 @@ test_layer_remove (void)
cogl_pipeline_set_layer_combine_constant (pipeline1, 0, &color); cogl_pipeline_set_layer_combine_constant (pipeline1, 0, &color);
test_color (pipeline0, 0xffff00ff, pos++); test_color (pipeline0, 0xffff00ff, pos++);
test_color (pipeline1, 0x00ffffff, pos++); test_color (pipeline1, 0x00ffffff, pos++);
cogl_object_unref (pipeline0); g_object_unref (pipeline0);
cogl_object_unref (pipeline1); g_object_unref (pipeline1);
/** TEST 8 **/ /** TEST 8 **/
/* Check that we can modify a layer in a child pipeline but then remove it */ /* Check that we can modify a layer in a child pipeline but then remove it */
@ -137,8 +137,8 @@ test_layer_remove (void)
cogl_pipeline_remove_layer (pipeline1, 0); cogl_pipeline_remove_layer (pipeline1, 0);
test_color (pipeline0, 0xffff00ff, pos++); test_color (pipeline0, 0xffff00ff, pos++);
test_color (pipeline1, 0x00ff00ff, pos++); test_color (pipeline1, 0x00ff00ff, pos++);
cogl_object_unref (pipeline0); g_object_unref (pipeline0);
cogl_object_unref (pipeline1); g_object_unref (pipeline1);
if (cogl_test_verbose ()) if (cogl_test_verbose ())
g_print ("OK\n"); g_print ("OK\n");

View File

@ -121,7 +121,7 @@ test_map_buffer_range (void)
g_object_unref (pos_attribute); g_object_unref (pos_attribute);
g_object_unref (tex_coord_attribute); g_object_unref (tex_coord_attribute);
cogl_object_unref (pipeline); g_object_unref (pipeline);
g_object_unref (tex); g_object_unref (tex);
if (cogl_test_verbose ()) if (cogl_test_verbose ())

View File

@ -151,7 +151,7 @@ on_paint (ClutterActor *actor,
cogl_rectangle_with_multitexture_coords (0, 0, QUAD_WIDTH, QUAD_WIDTH, cogl_rectangle_with_multitexture_coords (0, 0, QUAD_WIDTH, QUAD_WIDTH,
tex_coords, 8); tex_coords, 8);
cogl_object_unref (pipeline); g_object_unref (pipeline);
g_object_unref (tex0); g_object_unref (tex0);
g_object_unref (tex1); g_object_unref (tex1);

View File

@ -137,7 +137,7 @@ paint (void)
(x + 1) / 2.0f, (x + 1) / 2.0f,
(y + 1) / 2.0f); (y + 1) / 2.0f);
cogl_object_unref (pipeline); g_object_unref (pipeline);
g_object_unref (texture); g_object_unref (texture);
} }

View File

@ -5,9 +5,9 @@
#include "test-conform-common.h" #include "test-conform-common.h"
CoglUserDataKey private_key0; static GQuark private_key0 = 0;
CoglUserDataKey private_key1; static GQuark private_key1 = 0;
CoglUserDataKey private_key2; static GQuark private_key2 = 0;
static int user_data0; static int user_data0;
static int user_data1; static int user_data1;
@ -49,32 +49,36 @@ test_object (TestUtilsGTestFixture *fixture,
cogl_pipeline_new (); cogl_pipeline_new ();
pipeline = cogl_pipeline_path (); pipeline = cogl_pipeline_path ();
cogl_object_set_user_data (COGL_OBJECT (pipeline), private_key0 = g_quark_from_static_string ("test-object-private_key0");
&private_key0, private_key1 = g_quark_from_static_string ("test-object-private_key1");
private_key2 = g_quark_from_static_string ("test-object-private_key2");
g_object_set_qdata_full (G_OBJECT (pipeline),
private_key0,
&user_data0, &user_data0,
destroy0_cb); destroy0_cb);
cogl_object_set_user_data (COGL_OBJECT (pipeline), g_object_set_qdata_full (G_OBJECT (pipeline),
&private_key1, private_key1,
&user_data1, &user_data1,
destroy1_cb); destroy1_cb);
cogl_object_set_user_data (COGL_OBJECT (pipeline), g_object_set_qdata_full (G_OBJECT (pipeline),
&private_key2, private_key2,
&user_data2, &user_data2,
destroy2_cb); destroy2_cb);
cogl_object_set_user_data (COGL_OBJECT (pipeline), g_object_set_qdata_full (G_OBJECT (pipeline),
&private_key1, private_key1,
NULL, NULL,
destroy1_cb); destroy1_cb);
cogl_object_set_user_data (COGL_OBJECT (pipeline), g_object_set_qdata_full (G_OBJECT (pipeline),
&private_key1, private_key1,
&user_data1, &user_data1,
destroy1_cb); destroy1_cb);
cogl_object_unref (pipeline); g_object_unref (pipeline);
g_assert_cmpint (destroy0_count, ==, 1); g_assert_cmpint (destroy0_count, ==, 1);
g_assert_cmpint (destroy1_count, ==, 2); g_assert_cmpint (destroy1_count, ==, 2);

View File

@ -350,7 +350,7 @@ test_offscreen_texture_formats_paint_rgb10 (void)
cogl_framebuffer_draw_rectangle (COGL_FRAMEBUFFER (offscreen_dst), cogl_framebuffer_draw_rectangle (COGL_FRAMEBUFFER (offscreen_dst),
pipeline, pipeline,
-1.0, -1.0, 1.0, 1.0); -1.0, -1.0, 1.0, 1.0);
cogl_object_unref (pipeline); g_object_unref (pipeline);
cogl_framebuffer_read_pixels (COGL_FRAMEBUFFER (offscreen_dst), cogl_framebuffer_read_pixels (COGL_FRAMEBUFFER (offscreen_dst),
0, 0, 2, 2, formats[j], 0, 0, 2, 2, formats[j],
@ -476,7 +476,7 @@ test_offscreen_texture_formats_paint_rgb8 (void)
cogl_framebuffer_draw_rectangle (COGL_FRAMEBUFFER (offscreen_dst), cogl_framebuffer_draw_rectangle (COGL_FRAMEBUFFER (offscreen_dst),
pipeline, pipeline,
-1.0, -1.0, 1.0, 1.0); -1.0, -1.0, 1.0, 1.0);
cogl_object_unref (pipeline); g_object_unref (pipeline);
cogl_framebuffer_read_pixels (COGL_FRAMEBUFFER (offscreen_dst), cogl_framebuffer_read_pixels (COGL_FRAMEBUFFER (offscreen_dst),
0, 0, 2, 2, formats[j], 0, 0, 2, 2, formats[j],

View File

@ -98,8 +98,8 @@ test_paint (TestState *state)
cogl_pipeline_set_layer_texture (texture_pipeline, 0, tex); cogl_pipeline_set_layer_texture (texture_pipeline, 0, tex);
cogl_framebuffer_draw_rectangle (test_fb, texture_pipeline, -1, 1, 1, -1); cogl_framebuffer_draw_rectangle (test_fb, texture_pipeline, -1, 1, 1, -1);
cogl_object_unref (opaque_pipeline); g_object_unref (opaque_pipeline);
cogl_object_unref (texture_pipeline); g_object_unref (texture_pipeline);
g_object_unref (tex); g_object_unref (tex);
cogl_framebuffer_pop_matrix (test_fb); cogl_framebuffer_pop_matrix (test_fb);
@ -184,7 +184,7 @@ test_flush (TestState *state)
g_object_unref (offscreen); g_object_unref (offscreen);
} }
cogl_object_unref (pipeline); g_object_unref (pipeline);
} }
static void static void

View File

@ -76,13 +76,13 @@ test_pipeline_cache_unrefs_texture (void)
} }
cogl_framebuffer_draw_rectangle (test_fb, simple_pipeline, 0, 0, 10, 10); cogl_framebuffer_draw_rectangle (test_fb, simple_pipeline, 0, 0, 10, 10);
cogl_framebuffer_finish (test_fb); cogl_framebuffer_finish (test_fb);
cogl_object_unref (simple_pipeline); g_object_unref (simple_pipeline);
g_assert_cmpint (destroyed_texture_count, ==, 0); g_assert_cmpint (destroyed_texture_count, ==, 0);
/* Destroy the pipeline. This should immediately cause the textures /* Destroy the pipeline. This should immediately cause the textures
* to be freed */ * to be freed */
cogl_object_unref (pipeline); g_object_unref (pipeline);
g_assert_cmpint (destroyed_texture_count, ==, N_TEXTURES); g_assert_cmpint (destroyed_texture_count, ==, N_TEXTURES);

View File

@ -52,7 +52,7 @@ test_pipeline_shader_state (void)
cogl_framebuffer_draw_rectangle (test_fb, draw_pipeline, cogl_framebuffer_draw_rectangle (test_fb, draw_pipeline,
0, 0, width, height); 0, 0, width, height);
cogl_object_unref (draw_pipeline); g_object_unref (draw_pipeline);
cogl_framebuffer_finish (test_fb); cogl_framebuffer_finish (test_fb);
@ -85,7 +85,7 @@ test_pipeline_shader_state (void)
cogl_framebuffer_draw_rectangle (test_fb, draw_pipeline, cogl_framebuffer_draw_rectangle (test_fb, draw_pipeline,
0, 0, width, height); 0, 0, width, height);
cogl_object_unref (draw_pipeline); g_object_unref (draw_pipeline);
test_utils_check_region (test_fb, 0, 0, width, height, test_utils_check_region (test_fb, 0, 0, width, height,

View File

@ -163,15 +163,15 @@ init_long_pipeline_state (TestState *state)
static void static void
destroy_state (TestState *state) destroy_state (TestState *state)
{ {
cogl_object_unref (state->pipeline_red); g_object_unref (state->pipeline_red);
cogl_object_unref (state->pipeline_green); g_object_unref (state->pipeline_green);
cogl_object_unref (state->pipeline_blue); g_object_unref (state->pipeline_blue);
cogl_object_unref (state->matrix_pipeline); g_object_unref (state->matrix_pipeline);
cogl_object_unref (state->vector_pipeline); g_object_unref (state->vector_pipeline);
cogl_object_unref (state->int_pipeline); g_object_unref (state->int_pipeline);
if (state->long_pipeline) if (state->long_pipeline)
cogl_object_unref (state->long_pipeline); g_object_unref (state->long_pipeline);
} }
static void static void
@ -211,7 +211,7 @@ paint_color_pipelines (TestState *state)
paint_pipeline (temp_pipeline, i + 3); paint_pipeline (temp_pipeline, i + 3);
} }
cogl_object_unref (temp_pipeline); g_object_unref (temp_pipeline);
} }
static void static void

View File

@ -124,7 +124,7 @@ paint (TestState *state)
g_object_unref (tex1); g_object_unref (tex1);
g_object_unref (tex0); g_object_unref (tex0);
cogl_object_unref (pipeline); g_object_unref (pipeline);
} }
static void static void

View File

@ -151,7 +151,7 @@ test_pixel_buffer_map (void)
g_object_unref (bitmap); g_object_unref (bitmap);
g_object_unref (texture); g_object_unref (texture);
cogl_object_unref (pipeline); g_object_unref (pipeline);
check_colours (0x0000ffff, check_colours (0x0000ffff,
0x00ff00ff, 0x00ff00ff,
@ -196,7 +196,7 @@ test_pixel_buffer_set_data (void)
g_object_unref (bitmap); g_object_unref (bitmap);
g_object_unref (texture); g_object_unref (texture);
cogl_object_unref (pipeline); g_object_unref (pipeline);
check_colours (0x0000ffff, check_colours (0x0000ffff,
0x00ff00ff, 0x00ff00ff,
@ -257,7 +257,7 @@ test_pixel_buffer_sub_region (void)
g_object_unref (bitmap); g_object_unref (bitmap);
g_object_unref (texture); g_object_unref (texture);
cogl_object_unref (pipeline); g_object_unref (pipeline);
check_colours (0xffffffff, check_colours (0xffffffff,
0xff0000ff, 0xff0000ff,

View File

@ -124,7 +124,7 @@ do_test (const char *attribute_name,
if (pipeline_setup_func) if (pipeline_setup_func)
pipeline_setup_func (pipeline); pipeline_setup_func (pipeline);
cogl_primitive_draw (primitive, test_fb, pipeline); cogl_primitive_draw (primitive, test_fb, pipeline);
cogl_object_unref (pipeline); g_object_unref (pipeline);
cogl_object_unref (primitive); cogl_object_unref (primitive);
/* Verify all of the points where drawn at the right size */ /* Verify all of the points where drawn at the right size */

View File

@ -83,7 +83,7 @@ test_point_size (void)
cogl_primitive_draw (prim, test_fb, pipeline); cogl_primitive_draw (prim, test_fb, pipeline);
cogl_object_unref (prim); cogl_object_unref (prim);
cogl_object_unref (pipeline); g_object_unref (pipeline);
} }
/* Verify all of the points where drawn at the right size */ /* Verify all of the points where drawn at the right size */

View File

@ -134,8 +134,8 @@ do_test (gboolean check_orientation,
cogl_framebuffer_pop_matrix (test_fb); cogl_framebuffer_pop_matrix (test_fb);
cogl_object_unref (prim); cogl_object_unref (prim);
cogl_object_unref (solid_pipeline); g_object_unref (solid_pipeline);
cogl_object_unref (pipeline); g_object_unref (pipeline);
g_object_unref (tex_2d); g_object_unref (tex_2d);
test_utils_check_pixel (test_fb, test_utils_check_pixel (test_fb,

View File

@ -134,8 +134,8 @@ do_test (gboolean check_orientation,
cogl_framebuffer_pop_matrix (test_fb); cogl_framebuffer_pop_matrix (test_fb);
cogl_object_unref (prim); cogl_object_unref (prim);
cogl_object_unref (solid_pipeline); g_object_unref (solid_pipeline);
cogl_object_unref (pipeline); g_object_unref (pipeline);
g_object_unref (tex_2d); g_object_unref (tex_2d);
test_utils_check_pixel (test_fb, test_utils_check_pixel (test_fb,

View File

@ -202,7 +202,7 @@ test_paint (TestState *state)
cogl_object_unref (prim); cogl_object_unref (prim);
} }
cogl_object_unref (pipeline); g_object_unref (pipeline);
} }
static gboolean static gboolean

View File

@ -61,7 +61,7 @@ simple_fragment_snippet (TestState *state)
cogl_framebuffer_draw_rectangle (test_fb, pipeline, 0, 0, 10, 10); cogl_framebuffer_draw_rectangle (test_fb, pipeline, 0, 0, 10, 10);
cogl_object_unref (pipeline); g_object_unref (pipeline);
test_utils_check_pixel (test_fb, 5, 5, 0xffff00ff); test_utils_check_pixel (test_fb, 5, 5, 0xffff00ff);
} }
@ -85,7 +85,7 @@ simple_vertex_snippet (TestState *state)
cogl_framebuffer_draw_rectangle (test_fb, pipeline, 10, 0, 20, 10); cogl_framebuffer_draw_rectangle (test_fb, pipeline, 10, 0, 20, 10);
cogl_object_unref (pipeline); g_object_unref (pipeline);
test_utils_check_pixel (test_fb, 15, 5, 0xff00ffff); test_utils_check_pixel (test_fb, 15, 5, 0xff00ffff);
} }
@ -121,7 +121,7 @@ shared_uniform (TestState *state)
pipeline, pipeline,
20, 0, 30, 10); 20, 0, 30, 10);
cogl_object_unref (pipeline); g_object_unref (pipeline);
test_utils_check_pixel (test_fb, 25, 5, 0xff0080ff); test_utils_check_pixel (test_fb, 25, 5, 0xff0080ff);
} }
@ -165,7 +165,7 @@ lots_snippets (TestState *state)
cogl_framebuffer_draw_rectangle (test_fb, pipeline, 30, 0, 40, 10); cogl_framebuffer_draw_rectangle (test_fb, pipeline, 30, 0, 40, 10);
cogl_object_unref (pipeline); g_object_unref (pipeline);
test_utils_check_pixel (test_fb, 35, 5, 0x19334cff); test_utils_check_pixel (test_fb, 35, 5, 0x19334cff);
} }
@ -191,7 +191,7 @@ shared_variable_pre_post (TestState *state)
cogl_framebuffer_draw_rectangle (test_fb, pipeline, 40, 0, 50, 10); cogl_framebuffer_draw_rectangle (test_fb, pipeline, 40, 0, 50, 10);
cogl_object_unref (pipeline); g_object_unref (pipeline);
test_utils_check_pixel (test_fb, 45, 5, 0xff0000ff); test_utils_check_pixel (test_fb, 45, 5, 0xff0000ff);
} }
@ -217,12 +217,12 @@ test_pipeline_caching (TestState *state)
pipeline = cogl_pipeline_new (test_ctx); pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_add_snippet (pipeline, snippet); cogl_pipeline_add_snippet (pipeline, snippet);
cogl_framebuffer_draw_rectangle (test_fb, pipeline, 50, 0, 60, 10); cogl_framebuffer_draw_rectangle (test_fb, pipeline, 50, 0, 60, 10);
cogl_object_unref (pipeline); g_object_unref (pipeline);
pipeline = cogl_pipeline_new (test_ctx); pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_add_snippet (pipeline, snippet); cogl_pipeline_add_snippet (pipeline, snippet);
cogl_framebuffer_draw_rectangle (test_fb, pipeline, 60, 0, 70, 10); cogl_framebuffer_draw_rectangle (test_fb, pipeline, 60, 0, 70, 10);
cogl_object_unref (pipeline); g_object_unref (pipeline);
g_object_unref (snippet); g_object_unref (snippet);
@ -250,7 +250,7 @@ test_replace_string (TestState *state)
pipeline = cogl_pipeline_new (test_ctx); pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_add_snippet (pipeline, snippet); cogl_pipeline_add_snippet (pipeline, snippet);
cogl_framebuffer_draw_rectangle (test_fb, pipeline, 70, 0, 80, 10); cogl_framebuffer_draw_rectangle (test_fb, pipeline, 70, 0, 80, 10);
cogl_object_unref (pipeline); g_object_unref (pipeline);
g_object_unref (snippet); g_object_unref (snippet);
@ -277,7 +277,7 @@ test_texture_lookup_hook (TestState *state)
pipeline, pipeline,
80, 0, 90, 10, 80, 0, 90, 10,
0, 0, 0, 0); 0, 0, 0, 0);
cogl_object_unref (pipeline); g_object_unref (pipeline);
g_object_unref (snippet); g_object_unref (snippet);
@ -303,7 +303,7 @@ test_multiple_samples (TestState *state)
pipeline = create_texture_pipeline (state); pipeline = create_texture_pipeline (state);
cogl_pipeline_add_layer_snippet (pipeline, 0, snippet); cogl_pipeline_add_layer_snippet (pipeline, 0, snippet);
cogl_framebuffer_draw_rectangle (test_fb, pipeline, 0, 0, 10, 10); cogl_framebuffer_draw_rectangle (test_fb, pipeline, 0, 0, 10, 10);
cogl_object_unref (pipeline); g_object_unref (pipeline);
g_object_unref (snippet); g_object_unref (snippet);
@ -326,7 +326,7 @@ test_replace_lookup_hook (TestState *state)
pipeline, pipeline,
90, 0, 100, 10, 90, 0, 100, 10,
0, 0, 0, 0); 0, 0, 0, 0);
cogl_object_unref (pipeline); g_object_unref (pipeline);
g_object_unref (snippet); g_object_unref (snippet);
@ -359,7 +359,7 @@ test_replace_snippet (TestState *state)
pipeline, pipeline,
100, 0, 110, 10, 100, 0, 110, 10,
0, 0, 0, 0); 0, 0, 0, 0);
cogl_object_unref (pipeline); g_object_unref (pipeline);
test_utils_check_pixel (test_fb, 105, 5, 0xff0000ff); test_utils_check_pixel (test_fb, 105, 5, 0xff0000ff);
} }
@ -391,7 +391,7 @@ test_replace_fragment_layer (TestState *state)
pipeline, pipeline,
110, 0, 120, 10, 110, 0, 120, 10,
0, 0, 0, 0); 0, 0, 0, 0);
cogl_object_unref (pipeline); g_object_unref (pipeline);
test_utils_check_pixel (test_fb, 115, 5, 0xff00ffff); test_utils_check_pixel (test_fb, 115, 5, 0xff00ffff);
} }
@ -420,7 +420,7 @@ test_modify_fragment_layer (TestState *state)
pipeline, pipeline,
120, 0, 130, 10, 120, 0, 130, 10,
0, 0, 0, 0); 0, 0, 0, 0);
cogl_object_unref (pipeline); g_object_unref (pipeline);
test_utils_check_pixel (test_fb, 125, 5, 0xff80ffff); test_utils_check_pixel (test_fb, 125, 5, 0xff80ffff);
} }
@ -449,7 +449,7 @@ test_modify_vertex_layer (TestState *state)
pipeline, pipeline,
130, 0, 140, 10, 130, 0, 140, 10,
0, 0, 0, 0); 0, 0, 0, 0);
cogl_object_unref (pipeline); g_object_unref (pipeline);
test_utils_check_pixel (test_fb, 135, 5, 0xffff00ff); test_utils_check_pixel (test_fb, 135, 5, 0xffff00ff);
} }
@ -479,7 +479,7 @@ test_replace_vertex_layer (TestState *state)
pipeline, pipeline,
140, 0, 150, 10, 140, 0, 150, 10,
0, 0, 0, 0); 0, 0, 0, 0);
cogl_object_unref (pipeline); g_object_unref (pipeline);
test_utils_check_pixel (test_fb, 145, 5, 0x00ff00ff); test_utils_check_pixel (test_fb, 145, 5, 0x00ff00ff);
} }
@ -526,7 +526,7 @@ test_vertex_transform_hook (TestState *state)
cogl_framebuffer_set_projection_matrix (test_fb, &identity_matrix); cogl_framebuffer_set_projection_matrix (test_fb, &identity_matrix);
cogl_framebuffer_draw_rectangle (test_fb, pipeline, 150, 0, 160, 10); cogl_framebuffer_draw_rectangle (test_fb, pipeline, 150, 0, 160, 10);
cogl_object_unref (pipeline); g_object_unref (pipeline);
/* Restore the projection matrix */ /* Restore the projection matrix */
cogl_framebuffer_set_projection_matrix (test_fb, &matrix); cogl_framebuffer_set_projection_matrix (test_fb, &matrix);
@ -582,7 +582,7 @@ test_global_vertex_hook (TestState *state)
10.0f * 2.0f / state->fb_width - 1.0f, 10.0f * 2.0f / state->fb_width - 1.0f,
10.0f * 2.0f / state->fb_height - 1.0f); 10.0f * 2.0f / state->fb_height - 1.0f);
cogl_object_unref (pipeline); g_object_unref (pipeline);
test_utils_check_pixel (test_fb, 5, 5, 0xff0000ff); test_utils_check_pixel (test_fb, 5, 5, 0xff0000ff);
} }
@ -632,7 +632,7 @@ test_global_fragment_hook (TestState *state)
pipeline, pipeline,
0, 0, 10, 10); 0, 0, 10, 10);
cogl_object_unref (pipeline); g_object_unref (pipeline);
test_utils_check_pixel (test_fb, 5, 5, 0xff0000ff); test_utils_check_pixel (test_fb, 5, 5, 0xff0000ff);
} }
@ -670,7 +670,7 @@ test_snippet_order (TestState *state)
g_object_unref (snippet); g_object_unref (snippet);
cogl_framebuffer_draw_rectangle (test_fb, pipeline, 160, 0, 170, 10); cogl_framebuffer_draw_rectangle (test_fb, pipeline, 160, 0, 170, 10);
cogl_object_unref (pipeline); g_object_unref (pipeline);
test_utils_check_pixel (test_fb, 165, 5, 0x80ff00ff); test_utils_check_pixel (test_fb, 165, 5, 0x80ff00ff);
} }
@ -705,7 +705,7 @@ test_naming_texture_units (TestState *state)
cogl_framebuffer_draw_rectangle (test_fb, pipeline, 0, 0, 10, 10); cogl_framebuffer_draw_rectangle (test_fb, pipeline, 0, 0, 10, 10);
cogl_object_unref (pipeline); g_object_unref (pipeline);
g_object_unref (snippet); g_object_unref (snippet);
g_object_unref (tex1); g_object_unref (tex1);
g_object_unref (tex2); g_object_unref (tex2);

View File

@ -37,7 +37,7 @@ test_sparse_layer_combine (TestState *state)
test_utils_check_pixel (test_fb, 2, 2, 0xffff00ff); test_utils_check_pixel (test_fb, 2, 2, 0xffff00ff);
cogl_object_unref (pipeline); g_object_unref (pipeline);
g_object_unref (tex1); g_object_unref (tex1);
g_object_unref (tex2); g_object_unref (tex2);
} }

View File

@ -149,7 +149,7 @@ paint (TestState *state)
0.0f, SOURCE_SIZE * 2.0f, 0.0f, SOURCE_SIZE * 2.0f,
10.0f, SOURCE_SIZE * 2.0f + 10.0f); 10.0f, SOURCE_SIZE * 2.0f + 10.0f);
cogl_object_unref (pipeline); g_object_unref (pipeline);
} }
static void static void

View File

@ -70,7 +70,7 @@ on_paint (ClutterActor *actor,
COGL_PIPELINE_FILTER_NEAREST); COGL_PIPELINE_FILTER_NEAREST);
cogl_rectangle (1, 0, 2, 1); cogl_rectangle (1, 0, 2, 1);
cogl_object_unref (pipeline); g_object_unref (pipeline);
/* Read back the two pixels we rendered */ /* Read back the two pixels we rendered */
cogl_read_pixels (0, 0, 2, 1, cogl_read_pixels (0, 0, 2, 1,

View File

@ -75,7 +75,7 @@ test_texture_rg (void)
0); 0);
} }
cogl_object_unref (pipeline); g_object_unref (pipeline);
g_object_unref (tex); g_object_unref (tex);
} }

View File

@ -95,7 +95,7 @@ draw_tests (TestState *state)
(i + 2) * TEX_SIZE, (i + 2) * TEX_SIZE,
TEX_SIZE * 2, TEX_SIZE * 2,
0, 0, 2, 2); 0, 0, 2, 2);
cogl_object_unref (pipeline); g_object_unref (pipeline);
} }
} }
@ -130,7 +130,7 @@ draw_tests_polygon (TestState *state)
vertices); vertices);
cogl_primitive_draw (primitive, test_fb, pipeline); cogl_primitive_draw (primitive, test_fb, pipeline);
cogl_object_unref (primitive); cogl_object_unref (primitive);
cogl_object_unref (pipeline); g_object_unref (pipeline);
cogl_framebuffer_pop_matrix (test_fb); cogl_framebuffer_pop_matrix (test_fb);
} }
} }

View File

@ -82,7 +82,7 @@ check_pipeline_pruning (void)
* should run the garbage collector again but this time the * should run the garbage collector again but this time the
* pipelines won't be in use so it should free some of them */ * pipelines won't be in use so it should free some of them */
for (i = 0; i < 18; i++) for (i = 0; i < 18; i++)
cogl_object_unref (pipelines[i]); g_object_unref (pipelines[i]);
create_pipelines (pipelines, 18); create_pipelines (pipelines, 18);
@ -96,7 +96,7 @@ check_pipeline_pruning (void)
g_assert_cmpint (combined_hash->expected_min_size, ==, 17); g_assert_cmpint (combined_hash->expected_min_size, ==, 17);
for (i = 0; i < 18; i++) for (i = 0; i < 18; i++)
cogl_object_unref (pipelines[i]); g_object_unref (pipelines[i]);
} }
COGL_TEST_SUITE ( COGL_TEST_SUITE (

View File

@ -35,7 +35,7 @@ test_pipeline_opengl_blend_enable (void)
* then blending should be disabled */ * then blending should be disabled */
g_assert_cmpint (test_ctx->gl_blend_enable_cache, ==, 0); g_assert_cmpint (test_ctx->gl_blend_enable_cache, ==, 0);
cogl_object_unref (pipeline); g_object_unref (pipeline);
} }
COGL_TEST_SUITE ( COGL_TEST_SUITE (

View File

@ -23,7 +23,7 @@ test_pipeline_state_uniform_ancestry (void)
int uniform_location; int uniform_location;
tmp_pipeline = cogl_pipeline_copy (pipeline); tmp_pipeline = cogl_pipeline_copy (pipeline);
cogl_object_unref (pipeline); g_object_unref (pipeline);
pipeline = tmp_pipeline; pipeline = tmp_pipeline;
uniform_location = uniform_location =
@ -37,7 +37,7 @@ test_pipeline_state_uniform_ancestry (void)
g_assert_cmpint (pipeline_length, <=, 2); g_assert_cmpint (pipeline_length, <=, 2);
cogl_object_unref (pipeline); g_object_unref (pipeline);
} }
COGL_TEST_SUITE ( COGL_TEST_SUITE (

View File

@ -27,7 +27,7 @@ test_pipeline_state_blend_constant_ancestry (void)
cogl_color_init_from_4f (&color, i / 20.0f, 0.0f, 0.0f, 1.0f); cogl_color_init_from_4f (&color, i / 20.0f, 0.0f, 0.0f, 1.0f);
tmp_pipeline = cogl_pipeline_copy (pipeline); tmp_pipeline = cogl_pipeline_copy (pipeline);
cogl_object_unref (pipeline); g_object_unref (pipeline);
pipeline = tmp_pipeline; pipeline = tmp_pipeline;
cogl_pipeline_set_blend_constant (pipeline, &color); cogl_pipeline_set_blend_constant (pipeline, &color);
@ -38,7 +38,7 @@ test_pipeline_state_blend_constant_ancestry (void)
g_assert_cmpint (pipeline_length, <=, 2); g_assert_cmpint (pipeline_length, <=, 2);
cogl_object_unref (pipeline); g_object_unref (pipeline);
} }
COGL_TEST_SUITE ( COGL_TEST_SUITE (

View File

@ -61,7 +61,7 @@ test_pipeline_vertend_glsl_point_size_shader (void)
g_assert (shader_states[0] == shader_states[3]); g_assert (shader_states[0] == shader_states[3]);
for (i = 0; i < G_N_ELEMENTS (pipelines); i++) for (i = 0; i < G_N_ELEMENTS (pipelines); i++)
cogl_object_unref (pipelines[i]); g_object_unref (pipelines[i]);
} }
COGL_TEST_SUITE ( COGL_TEST_SUITE (