clutter: remove deprecated ClutterShader

This commit is contained in:
Niels De Graef 2018-11-14 08:32:42 +01:00
parent 1c7472b24d
commit 19137361d7
10 changed files with 0 additions and 1443 deletions

View File

@ -276,7 +276,6 @@ deprecated_h = \
deprecated/clutter-keysyms.h \
deprecated/clutter-main.h \
deprecated/clutter-rectangle.h \
deprecated/clutter-shader.h \
deprecated/clutter-stage-manager.h \
deprecated/clutter-stage.h \
deprecated/clutter-state.h \
@ -305,7 +304,6 @@ deprecated_c = \
deprecated/clutter-input-device-deprecated.c \
deprecated/clutter-layout-manager-deprecated.c \
deprecated/clutter-rectangle.c \
deprecated/clutter-shader.c \
deprecated/clutter-state.c \
deprecated/clutter-table-layout.c \
deprecated/clutter-texture.c \

View File

@ -1108,7 +1108,6 @@ static void clutter_actor_pop_in_cloned_branch (ClutterActor *self,
{ _transform; } \
cogl_matrix_translate ((m), -_tx, -_ty, -_tz); } G_STMT_END
static GQuark quark_shader_data = 0;
static GQuark quark_actor_layout_info = 0;
static GQuark quark_actor_transform_info = 0;
static GQuark quark_actor_animation_info = 0;
@ -3522,12 +3521,6 @@ _clutter_actor_update_last_paint_volume (ClutterActor *self)
priv->last_paint_volume_valid = TRUE;
}
static inline gboolean
actor_has_shader_data (ClutterActor *self)
{
return g_object_get_qdata (G_OBJECT (self), quark_shader_data) != NULL;
}
guint32
_clutter_actor_get_pick_id (ClutterActor *self)
{
@ -3769,7 +3762,6 @@ clutter_actor_paint (ClutterActor *self)
ClutterActorPrivate *priv;
ClutterPickMode pick_mode;
gboolean clip_set = FALSE;
gboolean shader_applied = FALSE;
ClutterStage *stage;
g_return_if_fail (CLUTTER_IS_ACTOR (self));
@ -3940,13 +3932,6 @@ clutter_actor_paint (ClutterActor *self)
if (priv->effects == NULL)
{
if (pick_mode == CLUTTER_PICK_NONE &&
actor_has_shader_data (self))
{
_clutter_actor_shader_pre_paint (self, FALSE);
shader_applied = TRUE;
}
priv->next_effect_to_paint = NULL;
}
else
@ -3955,9 +3940,6 @@ clutter_actor_paint (ClutterActor *self)
clutter_actor_continue_paint (self);
if (shader_applied)
_clutter_actor_shader_post_paint (self);
if (G_UNLIKELY (clutter_paint_debug_flags & CLUTTER_DEBUG_PAINT_VOLUMES &&
pick_mode == CLUTTER_PICK_NONE))
_clutter_actor_draw_paint_volume (self);
@ -6297,7 +6279,6 @@ clutter_actor_class_init (ClutterActorClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
quark_shader_data = g_quark_from_static_string ("-clutter-actor-shader-data");
quark_actor_layout_info = g_quark_from_static_string ("-clutter-actor-layout-info");
quark_actor_transform_info = g_quark_from_static_string ("-clutter-actor-transform-info");
quark_actor_animation_info = g_quark_from_static_string ("-clutter-actor-animation-info");

View File

@ -25,7 +25,6 @@
#include "deprecated/clutter-keysyms.h"
#include "deprecated/clutter-main.h"
#include "deprecated/clutter-rectangle.h"
#include "deprecated/clutter-shader.h"
#include "deprecated/clutter-stage-manager.h"
#include "deprecated/clutter-stage.h"
#include "deprecated/clutter-state.h"

View File

@ -116,7 +116,6 @@ typedef struct _ClutterEventSequence ClutterEventSequence;
typedef struct _ClutterFog ClutterFog; /* deprecated */
typedef struct _ClutterBehaviour ClutterBehaviour; /* deprecated */
typedef struct _ClutterShader ClutterShader; /* deprecated */
/**
* ClutterPaintVolume:

View File

@ -7,314 +7,6 @@
#include "clutter-actor-private.h"
#include "clutter-private.h"
#include "clutter-shader.h"
typedef struct _ShaderData ShaderData;
struct _ShaderData
{
ClutterShader *shader;
/* back pointer to the actor */
ClutterActor *actor;
/* list of values that should be set on the shader
* before each paint cycle
*/
GHashTable *value_hash;
};
static void
shader_value_free (gpointer data)
{
GValue *var = data;
g_value_unset (var);
g_slice_free (GValue, var);
}
static void
destroy_shader_data (gpointer data)
{
ShaderData *shader_data = data;
if (shader_data == NULL)
return;
if (shader_data->shader != NULL)
{
g_object_unref (shader_data->shader);
shader_data->shader = NULL;
}
if (shader_data->value_hash != NULL)
{
g_hash_table_destroy (shader_data->value_hash);
shader_data->value_hash = NULL;
}
g_slice_free (ShaderData, shader_data);
}
/**
* clutter_actor_get_shader:
* @self: a #ClutterActor
*
* Queries the currently set #ClutterShader on @self.
*
* Return value: (transfer none): The currently set #ClutterShader
* or %NULL if no shader is set.
*
* Since: 0.6
*
* Deprecated: 1.8: Use clutter_actor_get_effect() instead.
*/
ClutterShader *
clutter_actor_get_shader (ClutterActor *self)
{
ShaderData *shader_data;
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), NULL);
shader_data = g_object_get_data (G_OBJECT (self), "-clutter-actor-shader-data");
if (shader_data != NULL)
return shader_data->shader;
return NULL;
}
/**
* clutter_actor_set_shader:
* @self: a #ClutterActor
* @shader: (allow-none): a #ClutterShader or %NULL to unset the shader.
*
* Sets the #ClutterShader to be used when rendering @self.
*
* If @shader is %NULL this function will unset any currently set shader
* for the actor.
*
* Any #ClutterEffect applied to @self will take the precedence
* over the #ClutterShader set using this function.
*
* Return value: %TRUE if the shader was successfully applied
* or removed
*
* Since: 0.6
*
* Deprecated: 1.8: Use #ClutterShaderEffect and
* clutter_actor_add_effect() instead.
*/
gboolean
clutter_actor_set_shader (ClutterActor *self,
ClutterShader *shader)
{
ShaderData *shader_data;
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), FALSE);
g_return_val_if_fail (shader == NULL || CLUTTER_IS_SHADER (shader), FALSE);
if (shader != NULL)
g_object_ref (shader);
else
{
/* if shader passed in is NULL we destroy the shader */
g_object_set_data (G_OBJECT (self), "-clutter-actor-shader-data", NULL);
return TRUE;
}
shader_data = g_object_get_data (G_OBJECT (self), "-clutter-actor-shader-data");
if (shader_data == NULL)
{
shader_data = g_slice_new (ShaderData);
shader_data->actor = self;
shader_data->shader = NULL;
shader_data->value_hash =
g_hash_table_new_full (g_str_hash, g_str_equal,
g_free,
shader_value_free);
g_object_set_data_full (G_OBJECT (self), "-clutter-actor-shader-data",
shader_data,
destroy_shader_data);
}
if (shader_data->shader != NULL)
g_object_unref (shader_data->shader);
shader_data->shader = shader;
clutter_actor_queue_redraw (self);
return TRUE;
}
static void
set_each_param (gpointer key,
gpointer value,
gpointer user_data)
{
ClutterShader *shader = user_data;
const gchar *uniform = key;
GValue *var = value;
clutter_shader_set_uniform (shader, uniform, var);
}
void
_clutter_actor_shader_pre_paint (ClutterActor *actor,
gboolean repeat)
{
ShaderData *shader_data;
ClutterShader *shader;
shader_data = g_object_get_data (G_OBJECT (actor), "-clutter-actor-shader-data");
if (shader_data == NULL)
return;
shader = shader_data->shader;
if (shader != NULL)
{
clutter_shader_set_is_enabled (shader, TRUE);
g_hash_table_foreach (shader_data->value_hash, set_each_param, shader);
if (!repeat)
_clutter_context_push_shader_stack (actor);
}
}
void
_clutter_actor_shader_post_paint (ClutterActor *actor)
{
ShaderData *shader_data;
ClutterShader *shader;
shader_data = g_object_get_data (G_OBJECT (actor), "-clutter-actor-shader-data");
if (G_LIKELY (shader_data == NULL))
return;
shader = shader_data->shader;
if (shader != NULL)
{
ClutterActor *head;
clutter_shader_set_is_enabled (shader, FALSE);
/* remove the actor from the shaders stack; if there is another
* actor inside it, then call pre-paint again to set its shader
* but this time with the second argument being TRUE, indicating
* that we are re-applying an existing shader and thus should it
* not be prepended to the stack
*/
head = _clutter_context_pop_shader_stack (actor);
if (head != NULL)
_clutter_actor_shader_pre_paint (head, TRUE);
}
}
static inline void
clutter_actor_set_shader_param_internal (ClutterActor *self,
const gchar *param,
const GValue *value)
{
ShaderData *shader_data;
GValue *var;
shader_data = g_object_get_data (G_OBJECT (self), "-clutter-actor-shader-data");
if (shader_data == NULL)
return;
var = g_slice_new0 (GValue);
g_value_init (var, G_VALUE_TYPE (value));
g_value_copy (value, var);
g_hash_table_insert (shader_data->value_hash, g_strdup (param), var);
clutter_actor_queue_redraw (self);
}
/**
* clutter_actor_set_shader_param:
* @self: a #ClutterActor
* @param: the name of the parameter
* @value: the value of the parameter
*
* Sets the value for a named parameter of the shader applied
* to @actor.
*
* Since: 1.0
*
* Deprecated: 1.8: Use clutter_shader_effect_set_uniform_value() instead
*/
void
clutter_actor_set_shader_param (ClutterActor *self,
const gchar *param,
const GValue *value)
{
g_return_if_fail (CLUTTER_IS_ACTOR (self));
g_return_if_fail (param != NULL);
g_return_if_fail (CLUTTER_VALUE_HOLDS_SHADER_FLOAT (value) ||
CLUTTER_VALUE_HOLDS_SHADER_INT (value) ||
CLUTTER_VALUE_HOLDS_SHADER_MATRIX (value) ||
G_VALUE_HOLDS_FLOAT (value) ||
G_VALUE_HOLDS_INT (value));
clutter_actor_set_shader_param_internal (self, param, value);
}
/**
* clutter_actor_set_shader_param_float:
* @self: a #ClutterActor
* @param: the name of the parameter
* @value: the value of the parameter
*
* Sets the value for a named float parameter of the shader applied
* to @actor.
*
* Since: 0.8
*
* Deprecated: 1.8: Use clutter_shader_effect_set_uniform() instead
*/
void
clutter_actor_set_shader_param_float (ClutterActor *self,
const gchar *param,
gfloat value)
{
GValue var = { 0, };
g_value_init (&var, G_TYPE_FLOAT);
g_value_set_float (&var, value);
clutter_actor_set_shader_param_internal (self, param, &var);
g_value_unset (&var);
}
/**
* clutter_actor_set_shader_param_int:
* @self: a #ClutterActor
* @param: the name of the parameter
* @value: the value of the parameter
*
* Sets the value for a named int parameter of the shader applied to
* @actor.
*
* Since: 0.8
*
* Deprecated: 1.8: Use clutter_shader_effect_set_uniform() instead
*/
void
clutter_actor_set_shader_param_int (ClutterActor *self,
const gchar *param,
gint value)
{
GValue var = { 0, };
g_value_init (&var, G_TYPE_INT);
g_value_set_int (&var, value);
clutter_actor_set_shader_param_internal (self, param, &var);
g_value_unset (&var);
}
/**
* clutter_actor_set_geometry:

View File

@ -1,907 +0,0 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Authored By: Matthew Allum <mallum@openedhand.com>
* Øyvind Kolås <pippin@o-hand.com>
* Emmanuele Bassi <ebassi@linux.intel.com>
*
* Copyright (C) 2007, 2008 OpenedHand
* Copyright (C) 2009 Intel Corp
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
/**
* SECTION:clutter-shader
* @short_description: Programmable pipeline abstraction
*
* #ClutterShader is an object providing an abstraction over the
* OpenGL programmable pipeline. By using #ClutterShader<!-- -->s is
* possible to override the drawing pipeline by using small programs
* also known as "shaders".
*
* #ClutterShader is available since Clutter 0.6.
*
* #ClutterShader is deprecated since Clutter 1.8; use #ClutterShaderEffect
* in newly written code, instead.
*/
#include "clutter-build-config.h"
#include <string.h>
#include <stdlib.h>
#define CLUTTER_DISABLE_DEPRECATION_WARNINGS
#include <glib.h>
#include <cogl/cogl.h>
#include "clutter-shader.h"
#include "clutter-debug.h"
#include "clutter-private.h"
/* global list of shaders */
static GList *clutter_shaders_list = NULL;
struct _ClutterShaderPrivate
{
guint compiled : 1; /* Shader is bound to the GL context */
guint is_enabled : 1;
gchar *vertex_source; /* GLSL source for vertex shader */
gchar *fragment_source; /* GLSL source for fragment shader */
CoglHandle program;
CoglHandle vertex_shader;
CoglHandle fragment_shader;
};
enum
{
PROP_0,
PROP_VERTEX_SOURCE,
PROP_FRAGMENT_SOURCE,
PROP_COMPILED,
PROP_ENABLED,
PROP_LAST
};
static GParamSpec *obj_props[PROP_LAST];
G_DEFINE_TYPE_WITH_PRIVATE (ClutterShader, clutter_shader, G_TYPE_OBJECT)
static inline void
clutter_shader_release_internal (ClutterShader *shader)
{
ClutterShaderPrivate *priv = shader->priv;
if (!priv->compiled)
return;
g_assert (priv->program != COGL_INVALID_HANDLE);
if (priv->vertex_shader != COGL_INVALID_HANDLE)
cogl_handle_unref (priv->vertex_shader);
if (priv->fragment_shader != COGL_INVALID_HANDLE)
cogl_handle_unref (priv->fragment_shader);
if (priv->program != COGL_INVALID_HANDLE)
cogl_handle_unref (priv->program);
priv->vertex_shader = COGL_INVALID_HANDLE;
priv->fragment_shader = COGL_INVALID_HANDLE;
priv->program = COGL_INVALID_HANDLE;
priv->compiled = FALSE;
}
static void
clutter_shader_finalize (GObject *object)
{
ClutterShader *shader;
ClutterShaderPrivate *priv;
shader = CLUTTER_SHADER (object);
priv = shader->priv;
clutter_shaders_list = g_list_remove (clutter_shaders_list, object);
g_free (priv->fragment_source);
g_free (priv->vertex_source);
G_OBJECT_CLASS (clutter_shader_parent_class)->finalize (object);
}
static void
clutter_shader_dispose (GObject *object)
{
ClutterShader *shader = CLUTTER_SHADER (object);
clutter_shader_release_internal (shader);
G_OBJECT_CLASS (clutter_shader_parent_class)->finalize (object);
}
static void
clutter_shader_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
ClutterShader *shader = CLUTTER_SHADER(object);
switch (prop_id)
{
case PROP_VERTEX_SOURCE:
clutter_shader_set_vertex_source (shader,
g_value_get_string (value), -1);
break;
case PROP_FRAGMENT_SOURCE:
clutter_shader_set_fragment_source (shader,
g_value_get_string (value), -1);
break;
case PROP_ENABLED:
clutter_shader_set_is_enabled (shader, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
clutter_shader_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
ClutterShader *shader;
ClutterShaderPrivate *priv;
shader = CLUTTER_SHADER(object);
priv = shader->priv;
switch (prop_id)
{
case PROP_VERTEX_SOURCE:
g_value_set_string (value, priv->vertex_source);
break;
case PROP_FRAGMENT_SOURCE:
g_value_set_string (value, priv->fragment_source);
break;
case PROP_COMPILED:
g_value_set_boolean (value, priv->compiled);
break;
case PROP_ENABLED:
g_value_set_boolean (value, priv->is_enabled);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static GObject *
clutter_shader_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GObjectClass *parent_class;
GObject *object;
parent_class = G_OBJECT_CLASS (clutter_shader_parent_class);
object = parent_class->constructor (type, n_params, params);
/* add this instance to the global list of shaders */
clutter_shaders_list = g_list_prepend (clutter_shaders_list, object);
return object;
}
static void
clutter_shader_class_init (ClutterShaderClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GParamSpec *pspec = NULL;
object_class->finalize = clutter_shader_finalize;
object_class->dispose = clutter_shader_dispose;
object_class->set_property = clutter_shader_set_property;
object_class->get_property = clutter_shader_get_property;
object_class->constructor = clutter_shader_constructor;
/**
* ClutterShader:vertex-source:
*
* GLSL source code for the vertex shader part of the shader
* program, if any
*
* Since: 0.6
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/
pspec = g_param_spec_string ("vertex-source",
P_("Vertex Source"),
P_("Source of vertex shader"),
NULL,
CLUTTER_PARAM_READWRITE);
obj_props[PROP_VERTEX_SOURCE] = pspec;
g_object_class_install_property (object_class, PROP_VERTEX_SOURCE, pspec);
/**
* ClutterShader:fragment-source:
*
* GLSL source code for the fragment shader part of the shader program.
*
* Since: 0.6
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/
pspec = g_param_spec_string ("fragment-source",
P_("Fragment Source"),
P_("Source of fragment shader"),
NULL,
CLUTTER_PARAM_READWRITE);
obj_props[PROP_FRAGMENT_SOURCE] = pspec;
g_object_class_install_property (object_class, PROP_FRAGMENT_SOURCE, pspec);
/**
* ClutterShader:compiled:
*
* Whether the shader is compiled and linked, ready for use
* in the GL context.
*
* Since: 0.8
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/
pspec = g_param_spec_boolean ("compiled",
P_("Compiled"),
P_("Whether the shader is compiled and linked"),
FALSE,
CLUTTER_PARAM_READABLE);
obj_props[PROP_COMPILED] = pspec;
g_object_class_install_property (object_class, PROP_COMPILED, pspec);
/**
* ClutterShader:enabled:
*
* Whether the shader is currently used in the GL rendering pipeline.
*
* Since: 0.6
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/
pspec = g_param_spec_boolean ("enabled",
P_("Enabled"),
P_("Whether the shader is enabled"),
FALSE,
CLUTTER_PARAM_READWRITE);
obj_props[PROP_ENABLED] = pspec;
g_object_class_install_property (object_class, PROP_ENABLED, pspec);
}
static void
clutter_shader_init (ClutterShader *self)
{
ClutterShaderPrivate *priv;
priv = self->priv = clutter_shader_get_instance_private (self);
priv->compiled = FALSE;
priv->vertex_source = NULL;
priv->fragment_source = NULL;
priv->program = COGL_INVALID_HANDLE;
priv->vertex_shader = COGL_INVALID_HANDLE;
priv->fragment_shader = COGL_INVALID_HANDLE;
}
/**
* clutter_shader_new:
*
* Create a new #ClutterShader instance.
*
* Return value: a new #ClutterShader.
*
* Since: 0.6
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/
ClutterShader *
clutter_shader_new (void)
{
return g_object_new (CLUTTER_TYPE_SHADER, NULL);
}
static inline void
clutter_shader_set_source (ClutterShader *shader,
ClutterShaderType shader_type,
const gchar *data,
gssize length)
{
ClutterShaderPrivate *priv = shader->priv;
if (length < 0)
length = strlen (data);
g_object_freeze_notify (G_OBJECT (shader));
/* release shader if bound when changing the source, the shader will
* automatically be rebound on the next use.
*/
if (clutter_shader_is_compiled (shader))
clutter_shader_release (shader);
CLUTTER_NOTE (SHADER,
"setting %s shader (len:%" G_GSSIZE_FORMAT ")",
shader_type == CLUTTER_VERTEX_SHADER ? "vertex" : "fragment",
length);
switch (shader_type)
{
case CLUTTER_FRAGMENT_SHADER:
g_free (priv->fragment_source);
priv->fragment_source = g_strndup (data, length);
g_object_notify_by_pspec (G_OBJECT (shader), obj_props[PROP_FRAGMENT_SOURCE]);
break;
case CLUTTER_VERTEX_SHADER:
g_free (priv->vertex_source);
priv->vertex_source = g_strndup (data, length);
g_object_notify_by_pspec (G_OBJECT (shader), obj_props[PROP_VERTEX_SOURCE]);
break;
}
g_object_thaw_notify (G_OBJECT (shader));
}
/**
* clutter_shader_set_fragment_source:
* @shader: a #ClutterShader
* @data: GLSL source code.
* @length: length of source buffer (currently ignored)
*
* Sets the GLSL source code to be used by a #ClutterShader for the fragment
* program.
*
* Since: 0.6
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/
void
clutter_shader_set_fragment_source (ClutterShader *shader,
const gchar *data,
gssize length)
{
g_return_if_fail (CLUTTER_IS_SHADER (shader));
g_return_if_fail (data != NULL);
clutter_shader_set_source (shader, CLUTTER_FRAGMENT_SHADER, data, length);
}
/**
* clutter_shader_set_vertex_source:
* @shader: a #ClutterShader
* @data: GLSL source code.
* @length: length of source buffer (currently ignored)
*
* Sets the GLSL source code to be used by a #ClutterShader for the vertex
* program.
*
* Since: 0.6
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/
void
clutter_shader_set_vertex_source (ClutterShader *shader,
const gchar *data,
gssize length)
{
g_return_if_fail (CLUTTER_IS_SHADER (shader));
g_return_if_fail (data != NULL);
clutter_shader_set_source (shader, CLUTTER_VERTEX_SHADER, data, length);
}
static const gchar *
clutter_shader_get_source (ClutterShader *shader,
ClutterShaderType shader_type)
{
switch (shader_type)
{
case CLUTTER_FRAGMENT_SHADER:
return shader->priv->fragment_source;
case CLUTTER_VERTEX_SHADER:
return shader->priv->vertex_source;
}
return NULL;
}
static CoglHandle
clutter_shader_get_cogl_shader (ClutterShader *shader,
ClutterShaderType shader_type)
{
switch (shader_type)
{
case CLUTTER_FRAGMENT_SHADER:
return shader->priv->fragment_shader;
case CLUTTER_VERTEX_SHADER:
return shader->priv->vertex_shader;
}
return COGL_INVALID_HANDLE;
}
static gboolean
clutter_shader_glsl_bind (ClutterShader *self,
ClutterShaderType shader_type,
GError **error)
{
ClutterShaderPrivate *priv = self->priv;
CoglHandle shader = COGL_INVALID_HANDLE;
switch (shader_type)
{
case CLUTTER_VERTEX_SHADER:
shader = cogl_create_shader (COGL_SHADER_TYPE_VERTEX);
cogl_shader_source (shader, priv->vertex_source);
priv->vertex_shader = shader;
break;
case CLUTTER_FRAGMENT_SHADER:
shader = cogl_create_shader (COGL_SHADER_TYPE_FRAGMENT);
cogl_shader_source (shader, priv->fragment_source);
priv->fragment_shader = shader;
break;
}
g_assert (shader != COGL_INVALID_HANDLE);
cogl_shader_compile (shader);
if (!cogl_shader_is_compiled (shader))
{
gchar *log_buf;
log_buf = cogl_shader_get_info_log (shader);
/* translators: the first %s is the type of the shader, either
* Vertex shader or Fragment shader; the second %s is the actual
* error as reported by COGL
*/
g_set_error (error, CLUTTER_SHADER_ERROR,
CLUTTER_SHADER_ERROR_COMPILE,
_("%s compilation failed: %s"),
shader_type == CLUTTER_VERTEX_SHADER ? _("Vertex shader")
: _("Fragment shader"),
log_buf);
g_free (log_buf);
return FALSE;
}
cogl_program_attach_shader (priv->program, shader);
return TRUE;
}
static gboolean
bind_glsl_shader (ClutterShader *self,
GError **error)
{
ClutterShaderPrivate *priv = self->priv;
GError *bind_error = NULL;
gboolean res;
priv->program = cogl_create_program ();
if (priv->vertex_source != COGL_INVALID_HANDLE)
{
res = clutter_shader_glsl_bind (self,
CLUTTER_VERTEX_SHADER,
&bind_error);
if (!res)
{
g_propagate_error (error, bind_error);
return FALSE;
}
}
if (priv->fragment_source != COGL_INVALID_HANDLE)
{
res = clutter_shader_glsl_bind (self,
CLUTTER_FRAGMENT_SHADER,
&bind_error);
if (!res)
{
g_propagate_error (error, bind_error);
return FALSE;
}
}
cogl_program_link (priv->program);
return TRUE;
}
/**
* clutter_shader_compile:
* @shader: a #ClutterShader
* @error: return location for a #GError, or %NULL
*
* Compiles and links GLSL sources set for vertex and fragment shaders for
* a #ClutterShader. If the compilation fails and a #GError return location is
* provided the error will contain the errors from the compiler, if any.
*
* Return value: returns TRUE if the shader was succesfully compiled.
*
* Since: 0.8
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/
gboolean
clutter_shader_compile (ClutterShader *shader,
GError **error)
{
ClutterShaderPrivate *priv;
g_return_val_if_fail (CLUTTER_IS_SHADER (shader), FALSE);
priv = shader->priv;
if (priv->compiled)
return priv->compiled;
if (!clutter_feature_available (CLUTTER_FEATURE_SHADERS_GLSL))
{
g_set_error (error, CLUTTER_SHADER_ERROR,
CLUTTER_SHADER_ERROR_NO_GLSL,
"GLSL shaders not supported");
priv->compiled = FALSE;
return priv->compiled;
}
priv->compiled = bind_glsl_shader (shader, error);
g_object_notify_by_pspec (G_OBJECT (shader), obj_props[PROP_COMPILED]);
return priv->compiled;
}
/**
* clutter_shader_release:
* @shader: a #ClutterShader
*
* Frees up any GL context resources held by the shader.
*
* Since: 0.6
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/
void
clutter_shader_release (ClutterShader *shader)
{
g_return_if_fail (CLUTTER_IS_SHADER (shader));
clutter_shader_release_internal (shader);
g_object_notify_by_pspec (G_OBJECT (shader), obj_props[PROP_COMPILED]);
}
/**
* clutter_shader_is_compiled:
* @shader: a #ClutterShader
*
* Checks whether @shader is is currently compiled, linked and bound
* to the GL context.
*
* Return value: %TRUE if the shader is compiled, linked and ready for use.
*
* Since: 0.8
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/
gboolean
clutter_shader_is_compiled (ClutterShader *shader)
{
g_return_val_if_fail (CLUTTER_IS_SHADER (shader), FALSE);
return shader->priv->compiled;
}
/**
* clutter_shader_set_is_enabled:
* @shader: a #ClutterShader
* @enabled: The new state of the shader.
*
* Enables a shader. This function will attempt to compile and link
* the shader, if it isn't already.
*
* When @enabled is %FALSE the default state of the GL pipeline will be
* used instead.
*
* Since: 0.6
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/
void
clutter_shader_set_is_enabled (ClutterShader *shader,
gboolean enabled)
{
ClutterShaderPrivate *priv;
g_return_if_fail (CLUTTER_IS_SHADER (shader));
priv = shader->priv;
if (priv->is_enabled != enabled)
{
GError *error = NULL;
gboolean res;
res = clutter_shader_compile (shader, &error);
if (!res)
{
g_warning ("Unable to bind the shader: %s",
error ? error->message : "unknown error");
if (error)
g_error_free (error);
return;
}
priv->is_enabled = enabled;
if (priv->is_enabled)
cogl_program_use (priv->program);
else
cogl_program_use (COGL_INVALID_HANDLE);
g_object_notify_by_pspec (G_OBJECT (shader), obj_props[PROP_ENABLED]);
}
}
/**
* clutter_shader_get_is_enabled:
* @shader: a #ClutterShader
*
* Checks whether @shader is enabled.
*
* Return value: %TRUE if the shader is enabled.
*
* Since: 0.6
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/
gboolean
clutter_shader_get_is_enabled (ClutterShader *shader)
{
g_return_val_if_fail (CLUTTER_IS_SHADER (shader), FALSE);
return shader->priv->is_enabled;
}
/**
* clutter_shader_set_uniform:
* @shader: a #ClutterShader.
* @name: name of uniform in GLSL shader program to set.
* @value: a #ClutterShaderFloat, #ClutterShaderInt or #ClutterShaderMatrix
* #GValue.
*
* Sets a user configurable variable in the GLSL shader programs attached to
* a #ClutterShader.
*
* Since: 1.0
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/
void
clutter_shader_set_uniform (ClutterShader *shader,
const gchar *name,
const GValue *value)
{
ClutterShaderPrivate *priv;
int location = 0;
gsize size;
g_return_if_fail (CLUTTER_IS_SHADER (shader));
g_return_if_fail (name != NULL);
g_return_if_fail (value != NULL);
g_return_if_fail (CLUTTER_VALUE_HOLDS_SHADER_FLOAT (value) ||
CLUTTER_VALUE_HOLDS_SHADER_INT (value) ||
CLUTTER_VALUE_HOLDS_SHADER_MATRIX (value) ||
G_VALUE_HOLDS_FLOAT (value) ||
G_VALUE_HOLDS_INT (value));
priv = shader->priv;
g_return_if_fail (priv->program != COGL_INVALID_HANDLE);
location = cogl_program_get_uniform_location (priv->program, name);
if (CLUTTER_VALUE_HOLDS_SHADER_FLOAT (value))
{
const float *floats;
floats = clutter_value_get_shader_float (value, &size);
cogl_program_set_uniform_float (priv->program,
location, size, 1, floats);
}
else if (CLUTTER_VALUE_HOLDS_SHADER_INT (value))
{
const int *ints;
ints = clutter_value_get_shader_int (value, &size);
cogl_program_set_uniform_int (priv->program,
location, size, 1, ints);
}
else if (CLUTTER_VALUE_HOLDS_SHADER_MATRIX (value))
{
const float *matrix;
matrix = clutter_value_get_shader_matrix (value, &size);
cogl_program_set_uniform_matrix (priv->program,
location, size, 1, FALSE, matrix);
}
else if (G_VALUE_HOLDS_FLOAT (value))
{
float float_val = g_value_get_float (value);
cogl_program_set_uniform_float (priv->program,
location, 1, 1, &float_val);
}
else if (G_VALUE_HOLDS_INT (value))
{
int int_val = g_value_get_int (value);
cogl_program_set_uniform_int (priv->program,
location, 1, 1, &int_val);
}
else
g_assert_not_reached ();
}
/**
* clutter_shader_get_fragment_source:
* @shader: a #ClutterShader
*
* Query the current GLSL fragment source set on @shader.
*
* Return value: the source of the fragment shader for this
* ClutterShader object or %NULL. The returned string is owned by the
* shader object and should never be modified or freed
*
* Since: 0.6
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/
const gchar *
clutter_shader_get_fragment_source (ClutterShader *shader)
{
g_return_val_if_fail (CLUTTER_IS_SHADER (shader), NULL);
return clutter_shader_get_source (shader, CLUTTER_FRAGMENT_SHADER);
}
/**
* clutter_shader_get_vertex_source:
* @shader: a #ClutterShader
*
* Query the current GLSL vertex source set on @shader.
*
* Return value: the source of the vertex shader for this
* ClutterShader object or %NULL. The returned string is owned by the
* shader object and should never be modified or freed
*
* Since: 0.6
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/
const gchar *
clutter_shader_get_vertex_source (ClutterShader *shader)
{
g_return_val_if_fail (CLUTTER_IS_SHADER (shader), NULL);
return clutter_shader_get_source (shader, CLUTTER_VERTEX_SHADER);
}
/**
* clutter_shader_get_cogl_program:
* @shader: a #ClutterShader
*
* Retrieves the underlying #CoglHandle for the shader program.
*
* Return value: (transfer none): A #CoglHandle for the shader program,
* or %NULL. The handle is owned by the #ClutterShader and it should
* not be unreferenced
*
* Since: 1.0
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/
CoglHandle
clutter_shader_get_cogl_program (ClutterShader *shader)
{
g_return_val_if_fail (CLUTTER_IS_SHADER (shader), NULL);
return shader->priv->program;
}
/**
* clutter_shader_get_cogl_fragment_shader:
* @shader: a #ClutterShader
*
* Retrieves the underlying #CoglHandle for the fragment shader.
*
* Return value: (transfer none): A #CoglHandle for the fragment
* shader, or %NULL. The handle is owned by the #ClutterShader
* and it should not be unreferenced
*
* Since: 1.0
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/
CoglHandle
clutter_shader_get_cogl_fragment_shader (ClutterShader *shader)
{
g_return_val_if_fail (CLUTTER_IS_SHADER (shader), NULL);
return clutter_shader_get_cogl_shader (shader, CLUTTER_FRAGMENT_SHADER);
}
/**
* clutter_shader_get_cogl_vertex_shader:
* @shader: a #ClutterShader
*
* Retrieves the underlying #CoglHandle for the vertex shader.
*
* Return value: (transfer none): A #CoglHandle for the vertex
* shader, or %NULL. The handle is owned by the #ClutterShader
* and it should not be unreferenced
*
* Since: 1.0
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead.
*/
CoglHandle
clutter_shader_get_cogl_vertex_shader (ClutterShader *shader)
{
g_return_val_if_fail (CLUTTER_IS_SHADER (shader), NULL);
return clutter_shader_get_cogl_shader (shader, CLUTTER_VERTEX_SHADER);
}
GQuark
clutter_shader_error_quark (void)
{
return g_quark_from_static_string ("clutter-shader-error");
}

View File

@ -1,182 +0,0 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Authored By Matthew Allum <mallum@openedhand.com>
* Øyvind Kolås <pippin@o-hand.com>
*
* Copyright (C) 2007 OpenedHand
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
#error "Only <clutter/clutter.h> can be included directly."
#endif
#ifndef __CLUTTER_SHADER_H__
#define __CLUTTER_SHADER_H__
#include <clutter/clutter-types.h>
#include <clutter/clutter-shader-types.h>
G_BEGIN_DECLS
#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_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CLUTTER_TYPE_SHADER, ClutterShaderClass))
#define CLUTTER_IS_SHADER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CLUTTER_TYPE_SHADER))
#define CLUTTER_IS_SHADER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CLUTTER_TYPE_SHADER))
#define CLUTTER_SHADER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CLUTTER_TYPE_SHADER, ClutterShaderClass))
/**
* CLUTTER_SHADER_ERROR:
*
* Error domain for #ClutterShader errors
*
* Since: 0.6
*
* Deprecated: 1.8
*/
#define CLUTTER_SHADER_ERROR (clutter_shader_error_quark ())
/**
* ClutterShaderError:
* @CLUTTER_SHADER_ERROR_NO_ASM: No ASM shaders support
* @CLUTTER_SHADER_ERROR_NO_GLSL: No GLSL shaders support
* @CLUTTER_SHADER_ERROR_COMPILE: Compilation error
*
* #ClutterShader error enumeration
*
* Since: 0.6
*
* Deprecated: 1.8
*/
typedef enum {
CLUTTER_SHADER_ERROR_NO_ASM,
CLUTTER_SHADER_ERROR_NO_GLSL,
CLUTTER_SHADER_ERROR_COMPILE
} ClutterShaderError;
typedef struct _ClutterShaderPrivate ClutterShaderPrivate;
typedef struct _ClutterShaderClass ClutterShaderClass;
/**
* ClutterShader:
*
* The #ClutterShader structure contains only private data
* and should be accessed using the provided API
*
* Since: 0.6
*
* Deprecated: 1.8: Use #ClutterShaderEffect instead
*/
struct _ClutterShader
{
/*< private >*/
GObject parent;
ClutterShaderPrivate *priv;
};
/**
* ClutterShaderClass:
*
* The #ClutterShaderClass structure contains only private data
*
* Since: 0.6
*
* Deprecated: 1.8: Use #ClutterShaderEffectClass instead
*/
struct _ClutterShaderClass
{
/*< private >*/
GObjectClass parent_class;
};
CLUTTER_DEPRECATED
GQuark clutter_shader_error_quark (void);
CLUTTER_DEPRECATED
GType clutter_shader_get_type (void) G_GNUC_CONST;
CLUTTER_DEPRECATED_FOR(ClutterShaderEffect)
ClutterShader * clutter_shader_new (void);
CLUTTER_DEPRECATED_FOR(ClutterShaderEffect)
void clutter_shader_set_is_enabled (ClutterShader *shader,
gboolean enabled);
CLUTTER_DEPRECATED_FOR(ClutterShaderEffect)
gboolean clutter_shader_get_is_enabled (ClutterShader *shader);
CLUTTER_DEPRECATED_FOR(ClutterShaderEffect)
gboolean clutter_shader_compile (ClutterShader *shader,
GError **error);
CLUTTER_DEPRECATED_FOR(ClutterShaderEffect)
void clutter_shader_release (ClutterShader *shader);
CLUTTER_DEPRECATED_FOR(ClutterShaderEffect)
gboolean clutter_shader_is_compiled (ClutterShader *shader);
CLUTTER_DEPRECATED_FOR(ClutterShaderEffect)
void clutter_shader_set_vertex_source (ClutterShader *shader,
const gchar *data,
gssize length);
CLUTTER_DEPRECATED_FOR(ClutterShaderEffect)
void clutter_shader_set_fragment_source (ClutterShader *shader,
const gchar *data,
gssize length);
CLUTTER_DEPRECATED_FOR(ClutterShaderEffect)
const gchar * clutter_shader_get_vertex_source (ClutterShader *shader);
CLUTTER_DEPRECATED_FOR(ClutterShaderEffect)
const gchar * clutter_shader_get_fragment_source (ClutterShader *shader);
CLUTTER_DEPRECATED_FOR(ClutterShaderEffect)
void clutter_shader_set_uniform (ClutterShader *shader,
const gchar *name,
const GValue *value);
CLUTTER_DEPRECATED_FOR(ClutterShaderEffect)
CoglHandle clutter_shader_get_cogl_program (ClutterShader *shader);
CLUTTER_DEPRECATED_FOR(ClutterShaderEffect)
CoglHandle clutter_shader_get_cogl_fragment_shader (ClutterShader *shader);
CLUTTER_DEPRECATED_FOR(ClutterShaderEffect)
CoglHandle clutter_shader_get_cogl_vertex_shader (ClutterShader *shader);
/* ClutterActor methods */
CLUTTER_DEPRECATED_FOR(clutter_actor_add_effect)
gboolean clutter_actor_set_shader (ClutterActor *self,
ClutterShader *shader);
CLUTTER_DEPRECATED_FOR(clutter_actor_get_effect)
ClutterShader * clutter_actor_get_shader (ClutterActor *self);
CLUTTER_DEPRECATED_FOR(clutter_shader_effect_set_uniform_value)
void clutter_actor_set_shader_param (ClutterActor *self,
const gchar *param,
const GValue *value);
CLUTTER_DEPRECATED_FOR(clutter_shader_effect_set_uniform)
void clutter_actor_set_shader_param_int (ClutterActor *self,
const gchar *param,
gint value);
CLUTTER_DEPRECATED_FOR(clutter_shader_effect_set_uniform)
void clutter_actor_set_shader_param_float (ClutterActor *self,
const gchar *param,
gfloat value);
G_END_DECLS
#endif /* __CLUTTER_SHADER_H__ */

View File

@ -45,9 +45,6 @@
#include "clutter-build-config.h"
/* sadly, we are still using ClutterShader internally */
#define CLUTTER_DISABLE_DEPRECATION_WARNINGS
#include <cogl/cogl.h>
#include "clutter-texture.h"
@ -64,7 +61,6 @@
#include "clutter-stage-private.h"
#include "clutter-backend.h"
#include "deprecated/clutter-shader.h"
#include "deprecated/clutter-texture.h"
#include "deprecated/clutter-util.h"
@ -480,22 +476,10 @@ update_fbo (ClutterActor *self)
{
ClutterTexture *texture = CLUTTER_TEXTURE (self);
ClutterTexturePrivate *priv = texture->priv;
ClutterActor *head;
ClutterShader *shader = NULL;
ClutterActor *stage = NULL;
CoglMatrix projection;
CoglColor transparent_col;
head = _clutter_context_peek_shader_stack ();
if (head != NULL)
shader = clutter_actor_get_shader (head);
/* Temporarily turn off the shader on the top of the context's
* shader stack, to restore the GL pipeline to it's natural state.
*/
if (shader != NULL)
clutter_shader_set_is_enabled (shader, FALSE);
/* Redirect drawing to the fbo */
cogl_push_framebuffer (priv->fbo_handle);
@ -554,10 +538,6 @@ update_fbo (ClutterActor *self)
/* Restore drawing to the previous framebuffer */
cogl_pop_framebuffer ();
/* If there is a shader on top of the shader stack, turn it back on. */
if (shader != NULL)
clutter_shader_set_is_enabled (shader, TRUE);
}
static void

View File

@ -236,7 +236,6 @@ clutter_deprecated_headers = [
'deprecated/clutter-keysyms.h',
'deprecated/clutter-main.h',
'deprecated/clutter-rectangle.h',
'deprecated/clutter-shader.h',
'deprecated/clutter-stage-manager.h',
'deprecated/clutter-stage.h',
'deprecated/clutter-state.h',
@ -264,7 +263,6 @@ clutter_deprecated_sources = [
'deprecated/clutter-input-device-deprecated.c',
'deprecated/clutter-layout-manager-deprecated.c',
'deprecated/clutter-rectangle.c',
'deprecated/clutter-shader.c',
'deprecated/clutter-state.c',
'deprecated/clutter-table-layout.c',
'deprecated/clutter-texture.c',

View File

@ -67,7 +67,6 @@ clutter/clutter/deprecated/clutter-behaviour-scale.c
clutter/clutter/deprecated/clutter-box.c
clutter/clutter/deprecated/clutter-cairo-texture.c
clutter/clutter/deprecated/clutter-rectangle.c
clutter/clutter/deprecated/clutter-shader.c
clutter/clutter/deprecated/clutter-state.c
clutter/clutter/deprecated/clutter-table-layout.c
clutter/clutter/deprecated/clutter-texture.c