1
0
Fork 0

Deprecate ClutterShader

With the instantiatable ClutterShaderEffect, the only reason for
ClutterShader to exist is to make the ClutterActor::paint implementation
miserable.

Yes, ClutterShader doesn't use a FBO, so it's "more efficient" on
ClutterTextures. It's also generally wrong unless you know *exactly* how
the actor's pipeline is set up — something we cannot even guarantee
internally unless we start doing lame type checks.
This commit is contained in:
Emmanuele Bassi 2011-05-25 16:23:08 +01:00
parent 941d8d23fa
commit 835fc2381c
7 changed files with 73 additions and 4 deletions

View file

@ -9959,6 +9959,8 @@ destroy_shader_data (gpointer data)
* or %NULL if no shader is set. * or %NULL if no shader is set.
* *
* Since: 0.6 * Since: 0.6
*
* Deprecated: 1.8: Use clutter_actor_get_effect() instead.
*/ */
ClutterShader * ClutterShader *
clutter_actor_get_shader (ClutterActor *self) clutter_actor_get_shader (ClutterActor *self)
@ -9991,6 +9993,9 @@ clutter_actor_get_shader (ClutterActor *self)
* or removed * or removed
* *
* Since: 0.6 * Since: 0.6
*
* Deprecated: 1.8: Use #ClutterShaderEffect and
* clutter_actor_add_effect() instead.
*/ */
gboolean gboolean
clutter_actor_set_shader (ClutterActor *self, clutter_actor_set_shader (ClutterActor *self,
@ -10111,6 +10116,8 @@ clutter_actor_shader_post_paint (ClutterActor *actor)
* to @actor. * to @actor.
* *
* Since: 1.0 * Since: 1.0
*
* Deprecated: 1.8: Use clutter_shader_effect_set_uniform_value() instead
*/ */
void void
clutter_actor_set_shader_param (ClutterActor *self, clutter_actor_set_shader_param (ClutterActor *self,
@ -10150,6 +10157,8 @@ clutter_actor_set_shader_param (ClutterActor *self,
* to @actor. * to @actor.
* *
* Since: 0.8 * Since: 0.8
*
* Deprecated: 1.8: Use clutter_shader_effect_set_uniform() instead
*/ */
void void
clutter_actor_set_shader_param_float (ClutterActor *self, clutter_actor_set_shader_param_float (ClutterActor *self,
@ -10176,6 +10185,8 @@ clutter_actor_set_shader_param_float (ClutterActor *self,
* @actor. * @actor.
* *
* Since: 0.8 * Since: 0.8
*
* Deprecated: 1.8: Use clutter_shader_effect_set_uniform() instead
*/ */
void void
clutter_actor_set_shader_param_int (ClutterActor *self, clutter_actor_set_shader_param_int (ClutterActor *self,

View file

@ -537,6 +537,7 @@ gboolean clutter_actor_event (ClutterActor
ClutterActor * clutter_get_actor_by_gid (guint32 id_); ClutterActor * clutter_get_actor_by_gid (guint32 id_);
#endif #endif
#if !defined(CLUTTER_DISABLE_DEPRECATED) || defined(CLUTTER_COMPILATION)
gboolean clutter_actor_set_shader (ClutterActor *self, gboolean clutter_actor_set_shader (ClutterActor *self,
ClutterShader *shader); ClutterShader *shader);
ClutterShader * clutter_actor_get_shader (ClutterActor *self); ClutterShader * clutter_actor_get_shader (ClutterActor *self);
@ -549,6 +550,7 @@ void clutter_actor_set_shader_param_int (ClutterActor
void clutter_actor_set_shader_param_float (ClutterActor *self, void clutter_actor_set_shader_param_float (ClutterActor *self,
const gchar *param, const gchar *param,
gfloat value); gfloat value);
#endif /* CLUTTER_DISABLE_DEPRECATED */
void clutter_actor_set_anchor_point (ClutterActor *self, void clutter_actor_set_anchor_point (ClutterActor *self,
gfloat anchor_x, gfloat anchor_x,

View file

@ -29,7 +29,6 @@
#define __CLUTTER_SHADER_TYPES_H__ #define __CLUTTER_SHADER_TYPES_H__
#include <glib-object.h> #include <glib-object.h>
#include <cogl/cogl.h>
G_BEGIN_DECLS G_BEGIN_DECLS

View file

@ -35,7 +35,10 @@
* possible to override the drawing pipeline by using small programs * possible to override the drawing pipeline by using small programs
* also known as "shaders". * also known as "shaders".
* *
* #ClutterShader is available since Clutter 0.6 * #ClutterShader is available since Clutter 0.6.
*
* #ClutterShader is deprecated since Clutter 1.8; use #ClutterShaderEffect
* in newly written code.
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
@ -52,11 +55,12 @@
#include <glib.h> #include <glib.h>
#include <glib/gi18n-lib.h> #include <glib/gi18n-lib.h>
#include "cogl/cogl.h" #include <cogl/cogl.h>
#include "clutter-shader.h"
#include "clutter-debug.h" #include "clutter-debug.h"
#include "clutter-private.h" #include "clutter-private.h"
#include "clutter-shader.h"
/* global list of shaders */ /* global list of shaders */
static GList *clutter_shaders_list = NULL; static GList *clutter_shaders_list = NULL;
@ -244,6 +248,8 @@ clutter_shader_class_init (ClutterShaderClass *klass)
* program, if any * program, if any
* *
* Since: 0.6 * Since: 0.6
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/ */
pspec = g_param_spec_string ("vertex-source", pspec = g_param_spec_string ("vertex-source",
P_("Vertex Source"), P_("Vertex Source"),
@ -259,6 +265,8 @@ clutter_shader_class_init (ClutterShaderClass *klass)
* GLSL source code for the fragment shader part of the shader program. * GLSL source code for the fragment shader part of the shader program.
* *
* Since: 0.6 * Since: 0.6
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/ */
pspec = g_param_spec_string ("fragment-source", pspec = g_param_spec_string ("fragment-source",
P_("Fragment Source"), P_("Fragment Source"),
@ -275,6 +283,8 @@ clutter_shader_class_init (ClutterShaderClass *klass)
* in the GL context. * in the GL context.
* *
* Since: 0.8 * Since: 0.8
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/ */
pspec = g_param_spec_boolean ("compiled", pspec = g_param_spec_boolean ("compiled",
P_("Compiled"), P_("Compiled"),
@ -290,6 +300,8 @@ clutter_shader_class_init (ClutterShaderClass *klass)
* Whether the shader is currently used in the GL rendering pipeline. * Whether the shader is currently used in the GL rendering pipeline.
* *
* Since: 0.6 * Since: 0.6
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/ */
pspec = g_param_spec_boolean ("enabled", pspec = g_param_spec_boolean ("enabled",
P_("Enabled"), P_("Enabled"),
@ -325,6 +337,8 @@ clutter_shader_init (ClutterShader *self)
* Return value: a new #ClutterShader. * Return value: a new #ClutterShader.
* *
* Since: 0.6 * Since: 0.6
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/ */
ClutterShader * ClutterShader *
clutter_shader_new (void) clutter_shader_new (void)
@ -392,6 +406,8 @@ clutter_shader_set_source (ClutterShader *shader,
* program. * program.
* *
* Since: 0.6 * Since: 0.6
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/ */
void void
clutter_shader_set_fragment_source (ClutterShader *shader, clutter_shader_set_fragment_source (ClutterShader *shader,
@ -414,6 +430,8 @@ clutter_shader_set_fragment_source (ClutterShader *shader,
* program. * program.
* *
* Since: 0.6 * Since: 0.6
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/ */
void void
clutter_shader_set_vertex_source (ClutterShader *shader, clutter_shader_set_vertex_source (ClutterShader *shader,
@ -566,6 +584,8 @@ bind_glsl_shader (ClutterShader *self,
* Return value: returns TRUE if the shader was succesfully compiled. * Return value: returns TRUE if the shader was succesfully compiled.
* *
* Since: 0.8 * Since: 0.8
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/ */
gboolean gboolean
clutter_shader_compile (ClutterShader *shader, clutter_shader_compile (ClutterShader *shader,
@ -614,6 +634,8 @@ clutter_shader_compile (ClutterShader *shader,
* Frees up any GL context resources held by the shader. * Frees up any GL context resources held by the shader.
* *
* Since: 0.6 * Since: 0.6
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/ */
void void
clutter_shader_release (ClutterShader *shader) clutter_shader_release (ClutterShader *shader)
@ -635,6 +657,8 @@ clutter_shader_release (ClutterShader *shader)
* Return value: %TRUE if the shader is compiled, linked and ready for use. * Return value: %TRUE if the shader is compiled, linked and ready for use.
* *
* Since: 0.8 * Since: 0.8
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/ */
gboolean gboolean
clutter_shader_is_compiled (ClutterShader *shader) clutter_shader_is_compiled (ClutterShader *shader)
@ -656,6 +680,8 @@ clutter_shader_is_compiled (ClutterShader *shader)
* used instead. * used instead.
* *
* Since: 0.6 * Since: 0.6
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/ */
void void
clutter_shader_set_is_enabled (ClutterShader *shader, clutter_shader_set_is_enabled (ClutterShader *shader,
@ -703,6 +729,8 @@ clutter_shader_set_is_enabled (ClutterShader *shader,
* Return value: %TRUE if the shader is enabled. * Return value: %TRUE if the shader is enabled.
* *
* Since: 0.6 * Since: 0.6
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/ */
gboolean gboolean
clutter_shader_get_is_enabled (ClutterShader *shader) clutter_shader_get_is_enabled (ClutterShader *shader)
@ -723,6 +751,8 @@ clutter_shader_get_is_enabled (ClutterShader *shader)
* a #ClutterShader. * a #ClutterShader.
* *
* Since: 1.0 * Since: 1.0
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/ */
void void
clutter_shader_set_uniform (ClutterShader *shader, clutter_shader_set_uniform (ClutterShader *shader,
@ -814,6 +844,8 @@ _clutter_shader_release_all (void)
* shader object and should never be modified or freed * shader object and should never be modified or freed
* *
* Since: 0.6 * Since: 0.6
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/ */
G_CONST_RETURN gchar * G_CONST_RETURN gchar *
clutter_shader_get_fragment_source (ClutterShader *shader) clutter_shader_get_fragment_source (ClutterShader *shader)
@ -834,6 +866,8 @@ clutter_shader_get_fragment_source (ClutterShader *shader)
* shader object and should never be modified or freed * shader object and should never be modified or freed
* *
* Since: 0.6 * Since: 0.6
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/ */
G_CONST_RETURN gchar * G_CONST_RETURN gchar *
clutter_shader_get_vertex_source (ClutterShader *shader) clutter_shader_get_vertex_source (ClutterShader *shader)
@ -854,6 +888,8 @@ clutter_shader_get_vertex_source (ClutterShader *shader)
* not be unreferenced * not be unreferenced
* *
* Since: 1.0 * Since: 1.0
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/ */
CoglHandle CoglHandle
clutter_shader_get_cogl_program (ClutterShader *shader) clutter_shader_get_cogl_program (ClutterShader *shader)
@ -874,6 +910,8 @@ clutter_shader_get_cogl_program (ClutterShader *shader)
* and it should not be unreferenced * and it should not be unreferenced
* *
* Since: 1.0 * Since: 1.0
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/ */
CoglHandle CoglHandle
clutter_shader_get_cogl_fragment_shader (ClutterShader *shader) clutter_shader_get_cogl_fragment_shader (ClutterShader *shader)
@ -894,6 +932,8 @@ clutter_shader_get_cogl_fragment_shader (ClutterShader *shader)
* and it should not be unreferenced * and it should not be unreferenced
* *
* Since: 1.0 * Since: 1.0
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/ */
CoglHandle CoglHandle
clutter_shader_get_cogl_vertex_shader (ClutterShader *shader) clutter_shader_get_cogl_vertex_shader (ClutterShader *shader)

View file

@ -29,10 +29,13 @@
#ifndef __CLUTTER_SHADER_H__ #ifndef __CLUTTER_SHADER_H__
#define __CLUTTER_SHADER_H__ #define __CLUTTER_SHADER_H__
#include <clutter/clutter-types.h>
#include <clutter/clutter-shader-types.h> #include <clutter/clutter-shader-types.h>
G_BEGIN_DECLS G_BEGIN_DECLS
#if !defined(CLUTTER_DISABLE_DEPRECATED) || defined(CLUTTER_COMPILATION)
#define CLUTTER_TYPE_SHADER (clutter_shader_get_type ()) #define CLUTTER_TYPE_SHADER (clutter_shader_get_type ())
#define CLUTTER_SHADER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CLUTTER_TYPE_SHADER, ClutterShader)) #define CLUTTER_SHADER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CLUTTER_TYPE_SHADER, ClutterShader))
#define CLUTTER_SHADER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CLUTTER_TYPE_SHADER, ClutterShaderClass)) #define CLUTTER_SHADER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CLUTTER_TYPE_SHADER, ClutterShaderClass))
@ -46,6 +49,8 @@ G_BEGIN_DECLS
* Error domain for #ClutterShader errors * Error domain for #ClutterShader errors
* *
* Since: 0.6 * Since: 0.6
*
* Deprecated: 1.8
*/ */
#define CLUTTER_SHADER_ERROR (clutter_shader_error_quark ()) #define CLUTTER_SHADER_ERROR (clutter_shader_error_quark ())
@ -58,6 +63,8 @@ G_BEGIN_DECLS
* #ClutterShader error enumeration * #ClutterShader error enumeration
* *
* Since: 0.6 * Since: 0.6
*
* Deprecated: 1.8
*/ */
typedef enum { typedef enum {
CLUTTER_SHADER_ERROR_NO_ASM, CLUTTER_SHADER_ERROR_NO_ASM,
@ -75,6 +82,8 @@ typedef struct _ClutterShaderClass ClutterShaderClass;
* and should be accessed using the provided API * and should be accessed using the provided API
* *
* Since: 0.6 * Since: 0.6
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead
*/ */
struct _ClutterShader struct _ClutterShader
{ {
@ -89,6 +98,8 @@ struct _ClutterShader
* The #ClutterShaderClass structure contains only private data * The #ClutterShaderClass structure contains only private data
* *
* Since: 0.6 * Since: 0.6
*
* Deprecated: 1.8: Use #ClutterShaderEffectClass instead
*/ */
struct _ClutterShaderClass struct _ClutterShaderClass
{ {
@ -131,6 +142,8 @@ CoglHandle clutter_shader_get_cogl_vertex_shader (ClutterShader
/* private */ /* private */
void _clutter_shader_release_all (void); void _clutter_shader_release_all (void);
#endif /* CLUTTER_DISABLE_DEPRECATED */
G_END_DECLS G_END_DECLS
#endif /* __CLUTTER_SHADER_H__ */ #endif /* __CLUTTER_SHADER_H__ */

View file

@ -53,7 +53,9 @@ typedef struct _ClutterAction ClutterAction;
typedef struct _ClutterConstraint ClutterConstraint; typedef struct _ClutterConstraint ClutterConstraint;
typedef struct _ClutterEffect ClutterEffect; typedef struct _ClutterEffect ClutterEffect;
#if !defined(CLUTTER_DISABLE_DEPRECATED) || defined(CLUTTER_COMPILATION)
typedef struct _ClutterShader ClutterShader; typedef struct _ClutterShader ClutterShader;
#endif
typedef struct _ClutterColor ClutterColor; typedef struct _ClutterColor ClutterColor;

View file

@ -1,5 +1,7 @@
/*#define TEST_GROUP */ /*#define TEST_GROUP */
#undef CLUTTER_DISABLE_DEPRECATED
#include <clutter/clutter.h> #include <clutter/clutter.h>
#include <errno.h> #include <errno.h>