[clutter] Pass a CoglContext when calling cogl_pipeline_new
- From: Robert Bragg <rbragg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter] Pass a CoglContext when calling cogl_pipeline_new
- Date: Tue, 21 Feb 2012 17:50:47 +0000 (UTC)
commit fbf94310fc175491090076de887d4bcc02a772ee
Author: Robert Bragg <robert linux intel com>
Date: Tue Feb 21 13:22:17 2012 +0000
Pass a CoglContext when calling cogl_pipeline_new
The experimental cogl_pipeline_new() api was recently changed so it
explicitly takes a CoglContext. This updates all calls to
cogl_pipeline_new() in clutter accordingly.
clutter/clutter-actor.c | 6 +++-
clutter/clutter-blur-effect.c | 6 +++-
clutter/clutter-colorize-effect.c | 6 +++-
clutter/clutter-deform-effect.c | 41 +++++++++++++++-------------
clutter/clutter-desaturate-effect.c | 6 +++-
clutter/clutter-offscreen-effect.c | 29 ++++++++++++--------
clutter/cogl/clutter-stage-cogl.c | 10 +++++--
clutter/wayland/clutter-wayland-surface.c | 4 ++-
8 files changed, 69 insertions(+), 39 deletions(-)
---
diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c
index 2c1b212..e844a9a 100644
--- a/clutter/clutter-actor.c
+++ b/clutter/clutter-actor.c
@@ -2693,7 +2693,11 @@ _clutter_actor_draw_paint_volume_full (ClutterActor *self,
CoglFramebuffer *fb = cogl_get_draw_framebuffer ();
if (outline == NULL)
- outline = cogl_pipeline_new ();
+ {
+ CoglContext *ctx =
+ clutter_backend_get_cogl_context (clutter_get_default_backend ());
+ outline = cogl_pipeline_new (ctx);
+ }
_clutter_paint_volume_complete (pv);
diff --git a/clutter/clutter-blur-effect.c b/clutter/clutter-blur-effect.c
index 69811b1..1e36a0c 100644
--- a/clutter/clutter-blur-effect.c
+++ b/clutter/clutter-blur-effect.c
@@ -41,6 +41,8 @@
#include "config.h"
#endif
+#define CLUTTER_ENABLE_EXPERIMENTAL_API
+
#include "clutter-blur-effect.h"
#include "cogl/cogl.h"
@@ -239,8 +241,10 @@ clutter_blur_effect_init (ClutterBlurEffect *self)
if (G_UNLIKELY (klass->base_pipeline == NULL))
{
CoglSnippet *snippet;
+ CoglContext *ctx =
+ clutter_backend_get_cogl_context (clutter_get_default_backend ());
- klass->base_pipeline = cogl_pipeline_new ();
+ klass->base_pipeline = cogl_pipeline_new (ctx);
snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_TEXTURE_LOOKUP,
box_blur_glsl_declarations,
diff --git a/clutter/clutter-colorize-effect.c b/clutter/clutter-colorize-effect.c
index e55f3ba..c6e8bf1 100644
--- a/clutter/clutter-colorize-effect.c
+++ b/clutter/clutter-colorize-effect.c
@@ -41,6 +41,8 @@
#include "config.h"
#endif
+#define CLUTTER_ENABLE_EXPERIMENTAL_API
+
#include "clutter-colorize-effect.h"
#include "cogl/cogl.h"
@@ -281,8 +283,10 @@ clutter_colorize_effect_init (ClutterColorizeEffect *self)
if (G_UNLIKELY (klass->base_pipeline == NULL))
{
CoglSnippet *snippet;
+ CoglContext *ctx =
+ clutter_backend_get_cogl_context (clutter_get_default_backend ());
- klass->base_pipeline = cogl_pipeline_new ();
+ klass->base_pipeline = cogl_pipeline_new (ctx);
snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT,
colorize_glsl_declarations,
diff --git a/clutter/clutter-deform-effect.c b/clutter/clutter-deform-effect.c
index 58842a2..f1dac52 100644
--- a/clutter/clutter-deform-effect.c
+++ b/clutter/clutter-deform-effect.c
@@ -70,7 +70,7 @@
struct _ClutterDeformEffectPrivate
{
- CoglHandle back_material;
+ CoglPipeline *back_pipeline;
gint x_tiles;
gint y_tiles;
@@ -282,22 +282,22 @@ clutter_deform_effect_paint_target (ClutterOffscreenEffect *effect)
cogl_pipeline_set_depth_state (pipeline, &depth_state, NULL);
/* enable backface culling if we have a back material */
- if (priv->back_material != COGL_INVALID_HANDLE)
+ if (priv->back_pipeline != NULL)
cogl_pipeline_set_cull_face_mode (pipeline,
COGL_PIPELINE_CULL_FACE_MODE_BACK);
/* draw the front */
- if (material != COGL_INVALID_HANDLE)
+ if (material != NULL)
cogl_framebuffer_draw_primitive (fb, pipeline, priv->primitive);
/* draw the back */
- if (priv->back_material != COGL_INVALID_HANDLE)
+ if (priv->back_pipeline != NULL)
{
CoglPipeline *back_pipeline;
/* We probably shouldn't be modifying the user's material so
instead we make a temporary copy */
- back_pipeline = cogl_pipeline_copy (priv->back_material);
+ back_pipeline = cogl_pipeline_copy (priv->back_pipeline);
cogl_pipeline_set_depth_state (back_pipeline, &depth_state, NULL);
cogl_pipeline_set_cull_face_mode (pipeline,
COGL_PIPELINE_CULL_FACE_MODE_FRONT);
@@ -309,7 +309,9 @@ clutter_deform_effect_paint_target (ClutterOffscreenEffect *effect)
if (G_UNLIKELY (priv->lines_primitive != NULL))
{
- CoglPipeline *lines_pipeline = cogl_pipeline_new ();
+ CoglContext *ctx =
+ clutter_backend_get_cogl_context (clutter_get_default_backend ());
+ CoglPipeline *lines_pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_color4f (lines_pipeline, 1.0, 0, 0, 1.0);
cogl_framebuffer_draw_primitive (fb, lines_pipeline,
priv->lines_primitive);
@@ -482,14 +484,14 @@ clutter_deform_effect_init_arrays (ClutterDeformEffect *self)
}
static inline void
-clutter_deform_effect_free_back_material (ClutterDeformEffect *self)
+clutter_deform_effect_free_back_pipeline (ClutterDeformEffect *self)
{
ClutterDeformEffectPrivate *priv = self->priv;
- if (priv->back_material != NULL)
+ if (priv->back_pipeline != NULL)
{
- cogl_handle_unref (priv->back_material);
- priv->back_material = COGL_INVALID_HANDLE;
+ cogl_object_unref (priv->back_pipeline);
+ priv->back_pipeline = NULL;
}
}
@@ -499,7 +501,7 @@ clutter_deform_effect_finalize (GObject *gobject)
ClutterDeformEffect *self = CLUTTER_DEFORM_EFFECT (gobject);
clutter_deform_effect_free_arrays (self);
- clutter_deform_effect_free_back_material (self);
+ clutter_deform_effect_free_back_pipeline (self);
G_OBJECT_CLASS (clutter_deform_effect_parent_class)->finalize (gobject);
}
@@ -553,7 +555,7 @@ clutter_deform_effect_get_property (GObject *gobject,
break;
case PROP_BACK_MATERIAL:
- g_value_set_boxed (value, priv->back_material);
+ g_value_set_boxed (value, priv->back_pipeline);
break;
default:
@@ -641,7 +643,7 @@ clutter_deform_effect_init (ClutterDeformEffect *self)
ClutterDeformEffectPrivate);
self->priv->x_tiles = self->priv->y_tiles = DEFAULT_N_TILES;
- self->priv->back_material = COGL_INVALID_HANDLE;
+ self->priv->back_pipeline = NULL;
clutter_deform_effect_init_arrays (self);
}
@@ -664,17 +666,18 @@ clutter_deform_effect_set_back_material (ClutterDeformEffect *effect,
CoglHandle material)
{
ClutterDeformEffectPrivate *priv;
+ CoglPipeline *pipeline = COGL_PIPELINE (material);
g_return_if_fail (CLUTTER_IS_DEFORM_EFFECT (effect));
- g_return_if_fail (material == COGL_INVALID_HANDLE || cogl_is_material (material));
+ g_return_if_fail (pipeline == NULL || cogl_is_pipeline (pipeline));
priv = effect->priv;
- clutter_deform_effect_free_back_material (effect);
+ clutter_deform_effect_free_back_pipeline (effect);
- priv->back_material = material;
- if (priv->back_material != COGL_INVALID_HANDLE)
- cogl_handle_ref (priv->back_material);
+ priv->back_pipeline = material;
+ if (priv->back_pipeline != NULL)
+ cogl_object_ref (priv->back_pipeline);
clutter_deform_effect_invalidate (effect);
}
@@ -696,7 +699,7 @@ clutter_deform_effect_get_back_material (ClutterDeformEffect *effect)
{
g_return_val_if_fail (CLUTTER_IS_DEFORM_EFFECT (effect), NULL);
- return effect->priv->back_material;
+ return effect->priv->back_pipeline;
}
/**
diff --git a/clutter/clutter-desaturate-effect.c b/clutter/clutter-desaturate-effect.c
index d127bd5..c5fd04b 100644
--- a/clutter/clutter-desaturate-effect.c
+++ b/clutter/clutter-desaturate-effect.c
@@ -43,6 +43,8 @@
#include "config.h"
#endif
+#define CLUTTER_ENABLE_EXPERIMENTAL_API
+
#include <math.h>
#include "clutter-desaturate-effect.h"
@@ -285,9 +287,11 @@ clutter_desaturate_effect_init (ClutterDesaturateEffect *self)
if (G_UNLIKELY (klass->base_pipeline == NULL))
{
+ CoglContext *ctx =
+ clutter_backend_get_cogl_context (clutter_get_default_backend ());
CoglSnippet *snippet;
- klass->base_pipeline = cogl_pipeline_new ();
+ klass->base_pipeline = cogl_pipeline_new (ctx);
snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT,
desaturate_glsl_declarations,
diff --git a/clutter/clutter-offscreen-effect.c b/clutter/clutter-offscreen-effect.c
index 0b28fa4..cbd1dbe 100644
--- a/clutter/clutter-offscreen-effect.c
+++ b/clutter/clutter-offscreen-effect.c
@@ -65,6 +65,8 @@
#include "config.h"
#endif
+#define CLUTTER_ENABLE_EXPERIMENTAL_API
+
#include "clutter-offscreen-effect.h"
#include "cogl/cogl.h"
@@ -77,7 +79,7 @@
struct _ClutterOffscreenEffectPrivate
{
CoglHandle offscreen;
- CoglMaterial *target;
+ CoglPipeline *target;
CoglHandle texture;
ClutterActor *actor;
@@ -163,17 +165,20 @@ update_fbo (ClutterEffect *effect, int fbo_width, int fbo_height)
priv->offscreen != COGL_INVALID_HANDLE)
return TRUE;
- if (priv->target == COGL_INVALID_HANDLE)
+ if (priv->target == NULL)
{
- priv->target = cogl_material_new ();
+ CoglContext *ctx =
+ clutter_backend_get_cogl_context (clutter_get_default_backend ());
+
+ priv->target = cogl_pipeline_new (ctx);
/* We're always going to render the texture at a 1:1 texel:pixel
ratio so we can use 'nearest' filtering to decrease the
effects of rounding errors in the geometry calculation */
- cogl_material_set_layer_filters (priv->target,
+ cogl_pipeline_set_layer_filters (priv->target,
0, /* layer_index */
- COGL_MATERIAL_FILTER_NEAREST,
- COGL_MATERIAL_FILTER_NEAREST);
+ COGL_PIPELINE_FILTER_NEAREST,
+ COGL_PIPELINE_FILTER_NEAREST);
}
if (priv->texture != COGL_INVALID_HANDLE)
@@ -187,7 +192,7 @@ update_fbo (ClutterEffect *effect, int fbo_width, int fbo_height)
if (priv->texture == COGL_INVALID_HANDLE)
return FALSE;
- cogl_material_set_layer (priv->target, 0, priv->texture);
+ cogl_pipeline_set_layer_texture (priv->target, 0, priv->texture);
priv->fbo_width = fbo_width;
priv->fbo_height = fbo_height;
@@ -201,7 +206,7 @@ update_fbo (ClutterEffect *effect, int fbo_width, int fbo_height)
g_warning ("%s: Unable to create an Offscreen buffer", G_STRLOC);
cogl_handle_unref (priv->target);
- priv->target = COGL_INVALID_HANDLE;
+ priv->target = NULL;
priv->fbo_width = 0;
priv->fbo_height = 0;
@@ -342,7 +347,7 @@ clutter_offscreen_effect_real_paint_target (ClutterOffscreenEffect *effect)
paint_opacity = clutter_actor_get_paint_opacity (priv->actor);
- cogl_material_set_color4ub (priv->target,
+ cogl_pipeline_set_color4ub (priv->target,
paint_opacity,
paint_opacity,
paint_opacity,
@@ -393,7 +398,7 @@ clutter_offscreen_effect_post_paint (ClutterEffect *effect)
ClutterOffscreenEffectPrivate *priv = self->priv;
if (priv->offscreen == COGL_INVALID_HANDLE ||
- priv->target == COGL_INVALID_HANDLE ||
+ priv->target == NULL ||
priv->actor == NULL)
return;
@@ -528,9 +533,9 @@ CoglMaterial *
clutter_offscreen_effect_get_target (ClutterOffscreenEffect *effect)
{
g_return_val_if_fail (CLUTTER_IS_OFFSCREEN_EFFECT (effect),
- COGL_INVALID_HANDLE);
+ NULL);
- return effect->priv->target;
+ return (CoglMaterial *)effect->priv->target;
}
/**
diff --git a/clutter/cogl/clutter-stage-cogl.c b/clutter/cogl/clutter-stage-cogl.c
index 1ff92eb..6412b2c 100644
--- a/clutter/cogl/clutter-stage-cogl.c
+++ b/clutter/cogl/clutter-stage-cogl.c
@@ -30,6 +30,8 @@
#include "config.h"
#endif
+#define CLUTTER_ENABLE_EXPERIMENTAL_API
+
#include "clutter-config.h"
#include "clutter-stage-cogl.h"
@@ -406,7 +408,9 @@ clutter_stage_cogl_redraw (ClutterStageWindow *stage_window)
if (may_use_clipped_redraw &&
G_UNLIKELY ((clutter_paint_debug_flags & CLUTTER_DEBUG_REDRAWS)))
{
- static CoglMaterial *outline = NULL;
+ CoglContext *ctx =
+ clutter_backend_get_cogl_context (clutter_get_default_backend ());
+ static CoglPipeline *outline = NULL;
cairo_rectangle_int_t *clip = &stage_cogl->bounding_redraw_clip;
ClutterActor *actor = CLUTTER_ACTOR (wrapper);
CoglHandle vbo;
@@ -424,8 +428,8 @@ clutter_stage_cogl_redraw (ClutterStageWindow *stage_window)
if (outline == NULL)
{
- outline = cogl_material_new ();
- cogl_material_set_color4ub (outline, 0xff, 0x00, 0x00, 0xff);
+ outline = cogl_pipeline_new (ctx);
+ cogl_pipeline_set_color4ub (outline, 0xff, 0x00, 0x00, 0xff);
}
vbo = cogl_vertex_buffer_new (4);
diff --git a/clutter/wayland/clutter-wayland-surface.c b/clutter/wayland/clutter-wayland-surface.c
index c829b41..27ad3d0 100644
--- a/clutter/wayland/clutter-wayland-surface.c
+++ b/clutter/wayland/clutter-wayland-surface.c
@@ -283,9 +283,11 @@ clutter_wayland_surface_paint (ClutterActor *self)
if (G_UNLIKELY (priv->pipeline == NULL))
{
+ CoglContext *ctx =
+ clutter_backend_get_cogl_context (clutter_get_default_backend ());
guint8 paint_opacity = clutter_actor_get_paint_opacity (self);
- priv->pipeline = cogl_pipeline_new ();
+ priv->pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_color4ub (priv->pipeline,
paint_opacity,
paint_opacity,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]