2010-05-25 14:10:37 +00:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
2010-11-10 22:00:45 +00:00
|
|
|
/*
|
|
|
|
* st-theme-node-transition.c: Theme node transitions for StWidget.
|
2010-05-25 14:10:37 +00:00
|
|
|
*
|
2010-11-10 22:00:45 +00:00
|
|
|
* Copyright 2010 Florian Müllner
|
|
|
|
* Copyright 2010 Adel Gadllah
|
2010-05-25 14:10:37 +00:00
|
|
|
*
|
2010-11-10 22:00:45 +00:00
|
|
|
* This program 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.1 of
|
|
|
|
* the License, or (at your option) any later version.
|
2010-05-25 14:10:37 +00:00
|
|
|
*
|
2010-11-10 22:00:45 +00:00
|
|
|
* This program is distributed in the hope 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.
|
2010-05-25 14:10:37 +00:00
|
|
|
*
|
2010-11-10 22:00:45 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-05-25 14:10:37 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "st-theme-node-transition.h"
|
|
|
|
|
|
|
|
enum {
|
|
|
|
COMPLETED,
|
|
|
|
NEW_FRAME,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2015-09-24 14:08:13 +00:00
|
|
|
typedef struct _StThemeNodeTransitionPrivate StThemeNodeTransitionPrivate;
|
|
|
|
|
|
|
|
struct _StThemeNodeTransition {
|
|
|
|
GObject parent;
|
|
|
|
|
|
|
|
StThemeNodeTransitionPrivate *priv;
|
|
|
|
};
|
|
|
|
|
2010-05-25 14:10:37 +00:00
|
|
|
struct _StThemeNodeTransitionPrivate {
|
|
|
|
StThemeNode *old_theme_node;
|
|
|
|
StThemeNode *new_theme_node;
|
|
|
|
|
2013-04-05 00:29:59 +00:00
|
|
|
StThemeNodePaintState old_paint_state;
|
|
|
|
StThemeNodePaintState new_paint_state;
|
|
|
|
|
2018-11-24 11:37:19 +00:00
|
|
|
CoglTexture *old_texture;
|
|
|
|
CoglTexture *new_texture;
|
2010-05-25 14:10:37 +00:00
|
|
|
|
2018-11-24 11:37:19 +00:00
|
|
|
CoglFramebuffer *old_offscreen;
|
|
|
|
CoglFramebuffer *new_offscreen;
|
2010-05-25 14:10:37 +00:00
|
|
|
|
2018-11-24 11:37:19 +00:00
|
|
|
CoglPipeline *material;
|
2010-05-25 14:10:37 +00:00
|
|
|
|
|
|
|
ClutterTimeline *timeline;
|
|
|
|
|
|
|
|
guint timeline_completed_id;
|
|
|
|
guint timeline_new_frame_id;
|
|
|
|
|
|
|
|
ClutterActorBox last_allocation;
|
|
|
|
ClutterActorBox offscreen_box;
|
|
|
|
|
|
|
|
gboolean needs_setup;
|
|
|
|
};
|
|
|
|
|
|
|
|
static guint signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
2015-09-24 16:04:48 +00:00
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (StThemeNodeTransition, st_theme_node_transition, G_TYPE_OBJECT);
|
2010-05-25 14:10:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
on_timeline_completed (ClutterTimeline *timeline,
|
|
|
|
StThemeNodeTransition *transition)
|
|
|
|
{
|
|
|
|
g_signal_emit (transition, signals[COMPLETED], 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
on_timeline_new_frame (ClutterTimeline *timeline,
|
|
|
|
gint frame_num,
|
|
|
|
StThemeNodeTransition *transition)
|
|
|
|
{
|
|
|
|
g_signal_emit (transition, signals[NEW_FRAME], 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
StThemeNodeTransition *
|
|
|
|
st_theme_node_transition_new (StThemeNode *from_node,
|
|
|
|
StThemeNode *to_node,
|
2013-04-05 00:29:59 +00:00
|
|
|
StThemeNodePaintState *old_paint_state,
|
2010-05-25 14:10:37 +00:00
|
|
|
guint duration)
|
|
|
|
{
|
|
|
|
StThemeNodeTransition *transition;
|
|
|
|
g_return_val_if_fail (ST_IS_THEME_NODE (from_node), NULL);
|
|
|
|
g_return_val_if_fail (ST_IS_THEME_NODE (to_node), NULL);
|
|
|
|
|
|
|
|
duration = st_theme_node_get_transition_duration (to_node);
|
|
|
|
|
2015-09-24 14:08:13 +00:00
|
|
|
transition = g_object_new (ST_TYPE_THEME_NODE_TRANSITION, NULL);
|
2010-05-25 14:10:37 +00:00
|
|
|
|
|
|
|
transition->priv->old_theme_node = g_object_ref (from_node);
|
|
|
|
transition->priv->new_theme_node = g_object_ref (to_node);
|
|
|
|
|
2013-04-05 00:29:59 +00:00
|
|
|
st_theme_node_paint_state_copy (&transition->priv->old_paint_state,
|
|
|
|
old_paint_state);
|
|
|
|
|
2010-05-25 14:10:37 +00:00
|
|
|
transition->priv->timeline = clutter_timeline_new (duration);
|
|
|
|
|
|
|
|
transition->priv->timeline_completed_id =
|
|
|
|
g_signal_connect (transition->priv->timeline, "completed",
|
|
|
|
G_CALLBACK (on_timeline_completed), transition);
|
|
|
|
transition->priv->timeline_new_frame_id =
|
|
|
|
g_signal_connect (transition->priv->timeline, "new-frame",
|
|
|
|
G_CALLBACK (on_timeline_new_frame), transition);
|
|
|
|
|
2012-11-11 16:13:07 +00:00
|
|
|
clutter_timeline_set_progress_mode (transition->priv->timeline, CLUTTER_EASE_IN_OUT_QUAD);
|
2010-05-25 14:10:37 +00:00
|
|
|
|
|
|
|
clutter_timeline_start (transition->priv->timeline);
|
|
|
|
|
|
|
|
return transition;
|
|
|
|
}
|
|
|
|
|
2013-04-05 00:29:59 +00:00
|
|
|
StThemeNodePaintState *
|
|
|
|
st_theme_node_transition_get_new_paint_state (StThemeNodeTransition *transition)
|
|
|
|
{
|
|
|
|
return &transition->priv->new_paint_state;
|
|
|
|
}
|
|
|
|
|
2010-05-25 14:10:37 +00:00
|
|
|
void
|
|
|
|
st_theme_node_transition_update (StThemeNodeTransition *transition,
|
|
|
|
StThemeNode *new_node)
|
|
|
|
{
|
2015-09-24 14:08:13 +00:00
|
|
|
StThemeNodeTransitionPrivate *priv;
|
2010-05-25 14:10:37 +00:00
|
|
|
StThemeNode *old_node;
|
|
|
|
ClutterTimelineDirection direction;
|
|
|
|
|
|
|
|
g_return_if_fail (ST_IS_THEME_NODE_TRANSITION (transition));
|
|
|
|
g_return_if_fail (ST_IS_THEME_NODE (new_node));
|
|
|
|
|
2015-09-24 14:08:13 +00:00
|
|
|
priv = transition->priv;
|
2010-05-25 14:10:37 +00:00
|
|
|
direction = clutter_timeline_get_direction (priv->timeline);
|
|
|
|
old_node = (direction == CLUTTER_TIMELINE_FORWARD) ? priv->old_theme_node
|
|
|
|
: priv->new_theme_node;
|
|
|
|
|
|
|
|
/* If the update is the reversal of the current transition,
|
|
|
|
* we reverse the timeline.
|
|
|
|
* Otherwise, we should initiate a new transition from the
|
2010-06-09 08:56:19 +00:00
|
|
|
* current state to the new one; this is hard to do if the
|
|
|
|
* transition is in an intermediate state, so we just cancel
|
|
|
|
* the ongoing transition in that case.
|
2010-05-25 14:10:37 +00:00
|
|
|
* Note that reversing a timeline before any time elapsed
|
|
|
|
* results in the timeline's time position being set to the
|
|
|
|
* full duration - this is not what we want, so we cancel the
|
|
|
|
* transition as well in that case.
|
|
|
|
*/
|
2010-06-09 08:56:19 +00:00
|
|
|
if (st_theme_node_equal (new_node, old_node))
|
2010-05-25 14:10:37 +00:00
|
|
|
{
|
2013-04-05 00:29:59 +00:00
|
|
|
{
|
2013-07-17 17:08:35 +00:00
|
|
|
StThemeNodePaintState tmp;
|
|
|
|
|
|
|
|
st_theme_node_paint_state_init (&tmp);
|
|
|
|
st_theme_node_paint_state_copy (&tmp, &priv->old_paint_state);
|
|
|
|
st_theme_node_paint_state_copy (&priv->old_paint_state, &priv->new_paint_state);
|
|
|
|
st_theme_node_paint_state_copy (&priv->new_paint_state, &tmp);
|
|
|
|
st_theme_node_paint_state_free (&tmp);
|
2013-04-05 00:29:59 +00:00
|
|
|
}
|
|
|
|
|
2010-06-09 08:56:19 +00:00
|
|
|
if (clutter_timeline_get_elapsed_time (priv->timeline) > 0)
|
|
|
|
{
|
|
|
|
if (direction == CLUTTER_TIMELINE_FORWARD)
|
|
|
|
clutter_timeline_set_direction (priv->timeline,
|
|
|
|
CLUTTER_TIMELINE_BACKWARD);
|
|
|
|
else
|
|
|
|
clutter_timeline_set_direction (priv->timeline,
|
|
|
|
CLUTTER_TIMELINE_FORWARD);
|
|
|
|
}
|
2010-05-25 14:10:37 +00:00
|
|
|
else
|
2010-06-09 08:56:19 +00:00
|
|
|
{
|
|
|
|
clutter_timeline_stop (priv->timeline);
|
|
|
|
g_signal_emit (transition, signals[COMPLETED], 0);
|
|
|
|
}
|
2010-05-25 14:10:37 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-06-09 08:56:19 +00:00
|
|
|
if (clutter_timeline_get_elapsed_time (priv->timeline) > 0)
|
|
|
|
{
|
|
|
|
clutter_timeline_stop (priv->timeline);
|
|
|
|
g_signal_emit (transition, signals[COMPLETED], 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
guint new_duration = st_theme_node_get_transition_duration (new_node);
|
|
|
|
|
|
|
|
clutter_timeline_set_duration (priv->timeline, new_duration);
|
2010-08-26 18:10:46 +00:00
|
|
|
|
2010-06-09 08:56:19 +00:00
|
|
|
g_object_unref (priv->new_theme_node);
|
|
|
|
priv->new_theme_node = g_object_ref (new_node);
|
2013-04-05 00:29:59 +00:00
|
|
|
|
|
|
|
st_theme_node_paint_state_invalidate (&priv->new_paint_state);
|
2010-06-09 08:56:19 +00:00
|
|
|
}
|
2010-05-25 14:10:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
calculate_offscreen_box (StThemeNodeTransition *transition,
|
|
|
|
const ClutterActorBox *allocation)
|
2011-01-20 20:15:05 +00:00
|
|
|
{
|
|
|
|
ClutterActorBox paint_box;
|
|
|
|
|
|
|
|
st_theme_node_transition_get_paint_box (transition,
|
|
|
|
allocation,
|
|
|
|
&paint_box);
|
|
|
|
transition->priv->offscreen_box.x1 = paint_box.x1 - allocation->x1;
|
|
|
|
transition->priv->offscreen_box.y1 = paint_box.y1 - allocation->y1;
|
|
|
|
transition->priv->offscreen_box.x2 = paint_box.x2 - allocation->x1;
|
|
|
|
transition->priv->offscreen_box.y2 = paint_box.y2 - allocation->y1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
st_theme_node_transition_get_paint_box (StThemeNodeTransition *transition,
|
|
|
|
const ClutterActorBox *allocation,
|
|
|
|
ClutterActorBox *paint_box)
|
2010-05-25 14:10:37 +00:00
|
|
|
{
|
|
|
|
StThemeNodeTransitionPrivate *priv = transition->priv;
|
|
|
|
ClutterActorBox old_node_box, new_node_box;
|
|
|
|
|
|
|
|
st_theme_node_get_paint_box (priv->old_theme_node,
|
|
|
|
allocation,
|
|
|
|
&old_node_box);
|
|
|
|
|
|
|
|
st_theme_node_get_paint_box (priv->new_theme_node,
|
|
|
|
allocation,
|
|
|
|
&new_node_box);
|
|
|
|
|
2011-01-20 20:15:05 +00:00
|
|
|
paint_box->x1 = MIN (old_node_box.x1, new_node_box.x1);
|
|
|
|
paint_box->y1 = MIN (old_node_box.y1, new_node_box.y1);
|
|
|
|
paint_box->x2 = MAX (old_node_box.x2, new_node_box.x2);
|
|
|
|
paint_box->y2 = MAX (old_node_box.y2, new_node_box.y2);
|
2010-05-25 14:10:37 +00:00
|
|
|
}
|
|
|
|
|
2010-06-12 16:54:08 +00:00
|
|
|
static gboolean
|
2010-05-25 14:10:37 +00:00
|
|
|
setup_framebuffers (StThemeNodeTransition *transition,
|
2010-08-17 11:30:12 +00:00
|
|
|
const ClutterActorBox *allocation)
|
2010-05-25 14:10:37 +00:00
|
|
|
{
|
|
|
|
StThemeNodeTransitionPrivate *priv = transition->priv;
|
2018-11-11 00:41:28 +00:00
|
|
|
CoglContext *ctx;
|
2010-05-25 14:10:37 +00:00
|
|
|
guint width, height;
|
2016-05-17 13:00:04 +00:00
|
|
|
CoglError *catch_error = NULL;
|
2010-05-25 14:10:37 +00:00
|
|
|
|
2010-09-13 22:00:34 +00:00
|
|
|
/* template material to avoid unnecessary shader compilation */
|
2018-11-24 11:37:19 +00:00
|
|
|
static CoglPipeline *material_template = NULL;
|
2010-09-13 22:00:34 +00:00
|
|
|
|
2018-11-11 00:41:28 +00:00
|
|
|
ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ());
|
2010-05-25 14:10:37 +00:00
|
|
|
width = priv->offscreen_box.x2 - priv->offscreen_box.x1;
|
|
|
|
height = priv->offscreen_box.y2 - priv->offscreen_box.y1;
|
|
|
|
|
2010-06-12 16:54:08 +00:00
|
|
|
g_return_val_if_fail (width > 0, FALSE);
|
|
|
|
g_return_val_if_fail (height > 0, FALSE);
|
|
|
|
|
2018-11-24 11:37:19 +00:00
|
|
|
cogl_clear_object (&priv->old_texture);
|
|
|
|
priv->old_texture = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx, width, height));
|
2010-05-25 14:10:37 +00:00
|
|
|
|
2018-11-24 11:37:19 +00:00
|
|
|
cogl_clear_object (&priv->new_texture);
|
|
|
|
priv->new_texture = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx, width, height));
|
2010-05-25 14:10:37 +00:00
|
|
|
|
2018-11-24 11:37:19 +00:00
|
|
|
if (priv->old_texture == NULL)
|
2016-05-17 13:00:04 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2018-11-24 11:37:19 +00:00
|
|
|
if (priv->new_texture == NULL)
|
2016-05-17 13:00:04 +00:00
|
|
|
return FALSE;
|
2010-06-12 16:54:08 +00:00
|
|
|
|
2018-11-24 11:37:19 +00:00
|
|
|
cogl_clear_object (&priv->old_offscreen);
|
|
|
|
priv->old_offscreen = COGL_FRAMEBUFFER (cogl_offscreen_new_with_texture (priv->old_texture));
|
|
|
|
if (!cogl_framebuffer_allocate (priv->old_offscreen, &catch_error))
|
2016-05-17 13:00:04 +00:00
|
|
|
{
|
|
|
|
cogl_error_free (catch_error);
|
2018-11-24 11:37:19 +00:00
|
|
|
cogl_clear_object (&priv->old_offscreen);
|
2016-05-17 13:00:04 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2010-05-25 14:10:37 +00:00
|
|
|
|
2018-11-24 11:37:19 +00:00
|
|
|
cogl_clear_object (&priv->new_offscreen);
|
|
|
|
priv->new_offscreen = COGL_FRAMEBUFFER (cogl_offscreen_new_with_texture (priv->new_texture));
|
|
|
|
if (!cogl_framebuffer_allocate (priv->new_offscreen, &catch_error))
|
2016-05-17 13:00:04 +00:00
|
|
|
{
|
|
|
|
cogl_error_free (catch_error);
|
2018-11-24 11:37:19 +00:00
|
|
|
cogl_clear_object (&priv->new_offscreen);
|
2016-05-17 13:00:04 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2010-06-12 16:54:08 +00:00
|
|
|
|
2010-09-11 22:18:52 +00:00
|
|
|
if (priv->material == NULL)
|
|
|
|
{
|
2018-11-24 11:37:19 +00:00
|
|
|
if (G_UNLIKELY (material_template == NULL))
|
2010-09-11 22:18:52 +00:00
|
|
|
{
|
2015-09-26 02:20:22 +00:00
|
|
|
CoglContext *ctx =
|
|
|
|
clutter_backend_get_cogl_context (clutter_get_default_backend ());
|
|
|
|
material_template = cogl_pipeline_new (ctx);
|
2010-09-11 22:18:52 +00:00
|
|
|
|
2015-09-26 02:20:22 +00:00
|
|
|
cogl_pipeline_set_layer_combine (material_template, 0,
|
2010-09-11 22:18:52 +00:00
|
|
|
"RGBA = REPLACE (TEXTURE)",
|
|
|
|
NULL);
|
2015-09-26 02:20:22 +00:00
|
|
|
cogl_pipeline_set_layer_combine (material_template, 1,
|
2010-09-11 22:18:52 +00:00
|
|
|
"RGBA = INTERPOLATE (PREVIOUS, "
|
|
|
|
"TEXTURE, "
|
|
|
|
"CONSTANT[A])",
|
|
|
|
NULL);
|
2015-09-26 02:20:22 +00:00
|
|
|
cogl_pipeline_set_layer_combine (material_template, 2,
|
2010-09-11 22:18:52 +00:00
|
|
|
"RGBA = MODULATE (PREVIOUS, "
|
2010-09-24 07:31:59 +00:00
|
|
|
"PRIMARY)",
|
2010-09-11 22:18:52 +00:00
|
|
|
NULL);
|
|
|
|
}
|
2015-09-26 02:20:22 +00:00
|
|
|
priv->material = cogl_pipeline_copy (material_template);
|
2010-09-11 22:18:52 +00:00
|
|
|
}
|
2010-05-25 14:10:37 +00:00
|
|
|
|
2015-09-26 02:20:22 +00:00
|
|
|
cogl_pipeline_set_layer_texture (priv->material, 0, priv->new_texture);
|
|
|
|
cogl_pipeline_set_layer_texture (priv->material, 1, priv->old_texture);
|
|
|
|
|
|
|
|
cogl_framebuffer_clear4f (priv->old_offscreen, COGL_BUFFER_BIT_COLOR,
|
|
|
|
0, 0, 0, 0);
|
|
|
|
cogl_framebuffer_orthographic (priv->old_offscreen,
|
|
|
|
priv->offscreen_box.x1,
|
|
|
|
priv->offscreen_box.y1,
|
|
|
|
priv->offscreen_box.x2,
|
|
|
|
priv->offscreen_box.y2, 0.0, 1.0);
|
2010-05-25 14:10:37 +00:00
|
|
|
|
2015-09-26 03:44:56 +00:00
|
|
|
st_theme_node_paint (priv->old_theme_node, &priv->old_paint_state,
|
|
|
|
priv->old_offscreen, allocation, 255);
|
2010-05-25 14:10:37 +00:00
|
|
|
|
2015-09-26 02:20:22 +00:00
|
|
|
cogl_framebuffer_clear4f (priv->new_offscreen, COGL_BUFFER_BIT_COLOR,
|
|
|
|
0, 0, 0, 0);
|
|
|
|
cogl_framebuffer_orthographic (priv->new_offscreen,
|
|
|
|
priv->offscreen_box.x1,
|
|
|
|
priv->offscreen_box.y1,
|
|
|
|
priv->offscreen_box.x2,
|
|
|
|
priv->offscreen_box.y2, 0.0, 1.0);
|
2015-09-26 03:44:56 +00:00
|
|
|
st_theme_node_paint (priv->new_theme_node, &priv->new_paint_state,
|
|
|
|
priv->new_offscreen, allocation, 255);
|
2010-06-12 16:54:08 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2010-05-25 14:10:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
st_theme_node_transition_paint (StThemeNodeTransition *transition,
|
2018-10-06 01:28:10 +00:00
|
|
|
CoglFramebuffer *framebuffer,
|
2010-05-25 14:10:37 +00:00
|
|
|
ClutterActorBox *allocation,
|
|
|
|
guint8 paint_opacity)
|
|
|
|
{
|
|
|
|
StThemeNodeTransitionPrivate *priv = transition->priv;
|
|
|
|
|
2010-06-08 18:38:32 +00:00
|
|
|
CoglColor constant;
|
2010-05-25 14:10:37 +00:00
|
|
|
float tex_coords[] = {
|
|
|
|
0.0, 0.0, 1.0, 1.0,
|
|
|
|
0.0, 0.0, 1.0, 1.0,
|
|
|
|
};
|
|
|
|
|
|
|
|
g_return_if_fail (ST_IS_THEME_NODE (priv->old_theme_node));
|
|
|
|
g_return_if_fail (ST_IS_THEME_NODE (priv->new_theme_node));
|
|
|
|
|
2010-08-17 11:30:12 +00:00
|
|
|
if (!clutter_actor_box_equal (allocation, &priv->last_allocation))
|
2010-05-25 14:10:37 +00:00
|
|
|
priv->needs_setup = TRUE;
|
|
|
|
|
|
|
|
if (priv->needs_setup)
|
|
|
|
{
|
|
|
|
priv->last_allocation = *allocation;
|
|
|
|
|
|
|
|
calculate_offscreen_box (transition, allocation);
|
2010-08-17 11:30:12 +00:00
|
|
|
priv->needs_setup = !setup_framebuffers (transition, allocation);
|
2011-09-21 20:37:06 +00:00
|
|
|
|
|
|
|
if (priv->needs_setup) /* setting up framebuffers failed */
|
|
|
|
return;
|
2010-05-25 14:10:37 +00:00
|
|
|
}
|
|
|
|
|
2015-09-26 02:20:22 +00:00
|
|
|
cogl_color_init_from_4f (&constant, 0., 0., 0.,
|
|
|
|
clutter_timeline_get_progress (priv->timeline));
|
|
|
|
cogl_pipeline_set_layer_combine_constant (priv->material, 1, &constant);
|
2010-05-25 14:10:37 +00:00
|
|
|
|
2015-09-26 02:20:22 +00:00
|
|
|
cogl_pipeline_set_color4ub (priv->material,
|
2010-09-24 07:31:59 +00:00
|
|
|
paint_opacity, paint_opacity,
|
|
|
|
paint_opacity, paint_opacity);
|
2010-08-17 11:30:12 +00:00
|
|
|
|
2018-10-06 01:28:10 +00:00
|
|
|
cogl_framebuffer_draw_multitextured_rectangle (framebuffer,
|
|
|
|
priv->material,
|
2015-09-26 02:20:22 +00:00
|
|
|
priv->offscreen_box.x1,
|
|
|
|
priv->offscreen_box.y1,
|
|
|
|
priv->offscreen_box.x2,
|
|
|
|
priv->offscreen_box.y2,
|
|
|
|
tex_coords, 8);
|
2010-05-25 14:10:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
st_theme_node_transition_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
StThemeNodeTransitionPrivate *priv = ST_THEME_NODE_TRANSITION (object)->priv;
|
|
|
|
|
2018-11-24 11:37:19 +00:00
|
|
|
g_clear_object (&priv->old_theme_node);
|
|
|
|
g_clear_object (&priv->new_theme_node);
|
2010-05-25 14:10:37 +00:00
|
|
|
|
2018-11-24 11:37:19 +00:00
|
|
|
cogl_clear_object (&priv->old_texture);
|
|
|
|
cogl_clear_object (&priv->new_texture);
|
2010-05-25 14:10:37 +00:00
|
|
|
|
2018-11-24 11:37:19 +00:00
|
|
|
cogl_clear_object (&priv->old_offscreen);
|
|
|
|
cogl_clear_object (&priv->new_offscreen);
|
2010-05-25 14:10:37 +00:00
|
|
|
|
2018-11-24 11:37:19 +00:00
|
|
|
cogl_clear_object (&priv->material);
|
2010-05-25 14:10:37 +00:00
|
|
|
|
|
|
|
if (priv->timeline)
|
|
|
|
{
|
|
|
|
if (priv->timeline_completed_id != 0)
|
|
|
|
g_signal_handler_disconnect (priv->timeline,
|
|
|
|
priv->timeline_completed_id);
|
|
|
|
if (priv->timeline_new_frame_id != 0)
|
|
|
|
g_signal_handler_disconnect (priv->timeline,
|
|
|
|
priv->timeline_new_frame_id);
|
|
|
|
|
2018-11-24 11:37:19 +00:00
|
|
|
g_clear_object (&priv->timeline);
|
2010-05-25 14:10:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
priv->timeline_completed_id = 0;
|
|
|
|
priv->timeline_new_frame_id = 0;
|
|
|
|
|
2013-04-05 00:29:59 +00:00
|
|
|
st_theme_node_paint_state_free (&priv->old_paint_state);
|
|
|
|
st_theme_node_paint_state_free (&priv->new_paint_state);
|
|
|
|
|
2010-05-25 14:10:37 +00:00
|
|
|
G_OBJECT_CLASS (st_theme_node_transition_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
st_theme_node_transition_init (StThemeNodeTransition *transition)
|
|
|
|
{
|
2015-09-24 16:04:48 +00:00
|
|
|
transition->priv = st_theme_node_transition_get_instance_private (transition);
|
2010-05-25 14:10:37 +00:00
|
|
|
|
|
|
|
transition->priv->old_theme_node = NULL;
|
|
|
|
transition->priv->new_theme_node = NULL;
|
|
|
|
|
|
|
|
transition->priv->old_texture = NULL;
|
|
|
|
transition->priv->new_texture = NULL;
|
|
|
|
|
|
|
|
transition->priv->old_offscreen = NULL;
|
|
|
|
transition->priv->new_offscreen = NULL;
|
|
|
|
|
2013-04-05 00:29:59 +00:00
|
|
|
st_theme_node_paint_state_init (&transition->priv->old_paint_state);
|
|
|
|
st_theme_node_paint_state_init (&transition->priv->new_paint_state);
|
|
|
|
|
2010-05-25 14:10:37 +00:00
|
|
|
transition->priv->needs_setup = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
st_theme_node_transition_class_init (StThemeNodeTransitionClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->dispose = st_theme_node_transition_dispose;
|
|
|
|
|
|
|
|
signals[COMPLETED] =
|
|
|
|
g_signal_new ("completed",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
2015-10-15 19:41:29 +00:00
|
|
|
0, NULL, NULL, NULL,
|
2010-05-25 14:10:37 +00:00
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
|
|
|
signals[NEW_FRAME] =
|
|
|
|
g_signal_new ("new-frame",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
2015-10-15 19:41:29 +00:00
|
|
|
0, NULL, NULL, NULL,
|
2010-05-25 14:10:37 +00:00
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
}
|