Remove deprecated CoglHandle

Prefer something a bit more type-safe instead and in the meantime use
the newly available `cogl_clear_object` to simplify some code a bit.
This commit is contained in:
Niels De Graef 2018-11-24 12:37:19 +01:00 committed by Florian Müllner
parent b57832716a
commit 7c4e43c84f
7 changed files with 116 additions and 231 deletions

View File

@ -102,7 +102,7 @@ shell_invert_lightness_effect_pre_paint (ClutterEffect *effect)
{ {
ClutterOffscreenEffect *offscreen_effect = ClutterOffscreenEffect *offscreen_effect =
CLUTTER_OFFSCREEN_EFFECT (effect); CLUTTER_OFFSCREEN_EFFECT (effect);
CoglHandle texture; CoglTexture *texture;
texture = clutter_offscreen_effect_get_texture (offscreen_effect); texture = clutter_offscreen_effect_get_texture (offscreen_effect);
self->tex_width = cogl_texture_get_width (texture); self->tex_width = cogl_texture_get_width (texture);

View File

@ -108,7 +108,7 @@ struct _StEntryPrivate
gboolean capslock_warning_shown; gboolean capslock_warning_shown;
gboolean has_ibeam; gboolean has_ibeam;
CoglHandle text_shadow_material; CoglPipeline *text_shadow_material;
gfloat shadow_width; gfloat shadow_width;
gfloat shadow_height; gfloat shadow_height;
}; };
@ -261,11 +261,7 @@ st_entry_dispose (GObject *object)
StEntryPrivate *priv = ST_ENTRY_PRIV (entry); StEntryPrivate *priv = ST_ENTRY_PRIV (entry);
GdkKeymap *keymap; GdkKeymap *keymap;
if (priv->text_shadow_material != COGL_INVALID_HANDLE) cogl_clear_object (&priv->text_shadow_material);
{
cogl_handle_unref (priv->text_shadow_material);
priv->text_shadow_material = COGL_INVALID_HANDLE;
}
keymap = gdk_keymap_get_for_display (gdk_display_get_default ()); keymap = gdk_keymap_get_for_display (gdk_display_get_default ());
g_signal_handlers_disconnect_by_func (keymap, keymap_state_changed, entry); g_signal_handlers_disconnect_by_func (keymap, keymap_state_changed, entry);
@ -301,11 +297,7 @@ st_entry_style_changed (StWidget *self)
gchar *font_string, *font_name; gchar *font_string, *font_name;
gdouble size; gdouble size;
if (priv->text_shadow_material != COGL_INVALID_HANDLE) cogl_clear_object (&priv->text_shadow_material);
{
cogl_handle_unref (priv->text_shadow_material);
priv->text_shadow_material = COGL_INVALID_HANDLE;
}
theme_node = st_widget_get_theme_node (self); theme_node = st_widget_get_theme_node (self);
@ -623,11 +615,7 @@ clutter_text_changed_cb (GObject *object,
StEntryPrivate *priv = ST_ENTRY_PRIV (entry); StEntryPrivate *priv = ST_ENTRY_PRIV (entry);
/* Since the text changed, force a regen of the shadow texture */ /* Since the text changed, force a regen of the shadow texture */
if (priv->text_shadow_material != COGL_INVALID_HANDLE) cogl_clear_object (&priv->text_shadow_material);
{
cogl_handle_unref (priv->text_shadow_material);
priv->text_shadow_material = COGL_INVALID_HANDLE;
}
} }
static void static void
@ -863,14 +851,13 @@ st_entry_paint (ClutterActor *actor)
clutter_actor_get_allocation_box (priv->entry, &allocation); clutter_actor_get_allocation_box (priv->entry, &allocation);
clutter_actor_box_get_size (&allocation, &width, &height); clutter_actor_box_get_size (&allocation, &width, &height);
if (priv->text_shadow_material == COGL_INVALID_HANDLE || if (priv->text_shadow_material == NULL ||
width != priv->shadow_width || width != priv->shadow_width ||
height != priv->shadow_height) height != priv->shadow_height)
{ {
CoglHandle material; CoglPipeline *material;
if (priv->text_shadow_material != COGL_INVALID_HANDLE) cogl_clear_object (&priv->text_shadow_material);
cogl_handle_unref (priv->text_shadow_material);
material = _st_create_shadow_pipeline_from_actor (shadow_spec, material = _st_create_shadow_pipeline_from_actor (shadow_spec,
priv->entry); priv->entry);
@ -880,7 +867,7 @@ st_entry_paint (ClutterActor *actor)
priv->text_shadow_material = material; priv->text_shadow_material = material;
} }
if (priv->text_shadow_material != COGL_INVALID_HANDLE) if (priv->text_shadow_material != NULL)
_st_paint_shadow_with_opacity (shadow_spec, _st_paint_shadow_with_opacity (shadow_spec,
priv->text_shadow_material, priv->text_shadow_material,
&allocation, &allocation,
@ -1063,7 +1050,7 @@ st_entry_init (StEntry *entry)
priv->spacing = 6.0f; priv->spacing = 6.0f;
priv->text_shadow_material = COGL_INVALID_HANDLE; priv->text_shadow_material = NULL;
priv->shadow_width = -1.; priv->shadow_width = -1.;
priv->shadow_height = -1.; priv->shadow_height = -1.;

View File

@ -61,7 +61,7 @@ enum {
PROP_FADE_EDGES PROP_FADE_EDGES
}; };
static CoglHandle static CoglTexture *
st_scroll_view_fade_create_texture (ClutterOffscreenEffect *effect, st_scroll_view_fade_create_texture (ClutterOffscreenEffect *effect,
gfloat min_width, gfloat min_width,
gfloat min_height) gfloat min_height)
@ -69,7 +69,7 @@ st_scroll_view_fade_create_texture (ClutterOffscreenEffect *effect,
CoglContext *ctx = CoglContext *ctx =
clutter_backend_get_cogl_context (clutter_get_default_backend ()); clutter_backend_get_cogl_context (clutter_get_default_backend ());
return cogl_texture_2d_new_with_size (ctx, min_width, min_height); return COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx, min_width, min_height));
} }
static char * static char *

View File

@ -66,13 +66,13 @@ elliptical_arc (cairo_t *cr,
cairo_restore (cr); cairo_restore (cr);
} }
static CoglHandle static CoglTexture *
create_corner_material (StCornerSpec *corner) create_corner_material (StCornerSpec *corner)
{ {
ClutterBackend *backend = clutter_get_default_backend (); ClutterBackend *backend = clutter_get_default_backend ();
CoglContext *ctx = clutter_backend_get_cogl_context (backend); CoglContext *ctx = clutter_backend_get_cogl_context (backend);
CoglError *error = NULL; CoglError *error = NULL;
CoglHandle texture; CoglTexture *texture;
cairo_t *cr; cairo_t *cr;
cairo_surface_t *surface; cairo_surface_t *surface;
guint rowstride; guint rowstride;
@ -198,7 +198,7 @@ corner_to_string (StCornerSpec *corner)
corner->border_width_2); corner->border_width_2);
} }
static CoglHandle static CoglTexture *
load_corner (StTextureCache *cache, load_corner (StTextureCache *cache,
const char *key, const char *key,
void *datap, void *datap,
@ -348,13 +348,14 @@ st_theme_node_get_corner_border_widths (StThemeNode *node,
} }
} }
static CoglHandle static CoglPipeline *
st_theme_node_lookup_corner (StThemeNode *node, st_theme_node_lookup_corner (StThemeNode *node,
float width, float width,
float height, float height,
StCorner corner_id) StCorner corner_id)
{ {
CoglHandle texture, material = COGL_INVALID_HANDLE; CoglTexture *texture = NULL;
CoglPipeline *material = NULL;
char *key; char *key;
StTextureCache *cache; StTextureCache *cache;
StCornerSpec corner; StCornerSpec corner;
@ -365,7 +366,7 @@ st_theme_node_lookup_corner (StThemeNode *node,
st_theme_node_reduce_border_radius (node, width, height, radius); st_theme_node_reduce_border_radius (node, width, height, radius);
if (radius[corner_id] == 0) if (radius[corner_id] == 0)
return COGL_INVALID_HANDLE; return NULL;
corner.radius = radius[corner_id]; corner.radius = radius[corner_id];
corner.color = node->background_color; corner.color = node->background_color;
@ -399,7 +400,7 @@ st_theme_node_lookup_corner (StThemeNode *node,
if (corner.color.alpha == 0 && if (corner.color.alpha == 0 &&
corner.border_color_1.alpha == 0 && corner.border_color_1.alpha == 0 &&
corner.border_color_2.alpha == 0) corner.border_color_2.alpha == 0)
return COGL_INVALID_HANDLE; return NULL;
key = corner_to_string (&corner); key = corner_to_string (&corner);
texture = st_texture_cache_load (cache, key, ST_TEXTURE_CACHE_POLICY_FOREVER, load_corner, &corner, NULL); texture = st_texture_cache_load (cache, key, ST_TEXTURE_CACHE_POLICY_FOREVER, load_corner, &corner, NULL);
@ -407,7 +408,7 @@ st_theme_node_lookup_corner (StThemeNode *node,
if (texture) if (texture)
{ {
material = _st_create_texture_pipeline (texture); material = _st_create_texture_pipeline (texture);
cogl_handle_unref (texture); cogl_object_unref (texture);
} }
g_free (key); g_free (key);
@ -962,7 +963,7 @@ paint_inset_box_shadow_to_cairo_context (StThemeNode *node,
* we need to use cairo. This function is a slow fallback path for those * we need to use cairo. This function is a slow fallback path for those
* cases (gradients, background images, etc). * cases (gradients, background images, etc).
*/ */
static CoglHandle static CoglTexture *
st_theme_node_prerender_background (StThemeNode *node, st_theme_node_prerender_background (StThemeNode *node,
float actor_width, float actor_width,
float actor_height) float actor_height)
@ -971,7 +972,7 @@ st_theme_node_prerender_background (StThemeNode *node,
CoglContext *ctx = clutter_backend_get_cogl_context (backend); CoglContext *ctx = clutter_backend_get_cogl_context (backend);
CoglError *error = NULL; CoglError *error = NULL;
StBorderImage *border_image; StBorderImage *border_image;
CoglHandle texture; CoglTexture *texture;
guint radius[4]; guint radius[4];
int i; int i;
cairo_t *cr; cairo_t *cr;
@ -1312,23 +1313,14 @@ static void st_theme_node_paint_borders (StThemeNodePaintState *state,
void void
st_theme_node_invalidate_border_image (StThemeNode *node) st_theme_node_invalidate_border_image (StThemeNode *node)
{ {
if (node->border_slices_texture != COGL_INVALID_HANDLE) cogl_clear_object (&node->border_slices_texture);
{ cogl_clear_object (&node->border_slices_pipeline);
cogl_handle_unref (node->border_slices_texture);
node->border_slices_texture = COGL_INVALID_HANDLE;
}
if (node->border_slices_pipeline != COGL_INVALID_HANDLE)
{
cogl_handle_unref (node->border_slices_pipeline);
node->border_slices_pipeline = COGL_INVALID_HANDLE;
}
} }
static gboolean static gboolean
st_theme_node_load_border_image (StThemeNode *node) st_theme_node_load_border_image (StThemeNode *node)
{ {
if (node->border_slices_texture == COGL_INVALID_HANDLE) if (node->border_slices_texture == NULL)
{ {
StBorderImage *border_image; StBorderImage *border_image;
GFile *file; GFile *file;
@ -1344,42 +1336,28 @@ st_theme_node_load_border_image (StThemeNode *node)
node->border_slices_texture = st_texture_cache_load_file_to_cogl_texture (st_texture_cache_get_default (), node->border_slices_texture = st_texture_cache_load_file_to_cogl_texture (st_texture_cache_get_default (),
file, scale_factor); file, scale_factor);
if (node->border_slices_texture == COGL_INVALID_HANDLE) if (node->border_slices_texture == NULL)
goto out; goto out;
node->border_slices_pipeline = _st_create_texture_pipeline (node->border_slices_texture); node->border_slices_pipeline = _st_create_texture_pipeline (node->border_slices_texture);
} }
out: out:
return node->border_slices_texture != COGL_INVALID_HANDLE; return node->border_slices_texture != NULL;
} }
void void
st_theme_node_invalidate_background_image (StThemeNode *node) st_theme_node_invalidate_background_image (StThemeNode *node)
{ {
if (node->background_texture != COGL_INVALID_HANDLE) cogl_clear_object (&node->background_texture);
{ cogl_clear_object (&node->background_pipeline);
cogl_handle_unref (node->background_texture); cogl_clear_object (&node->background_shadow_pipeline);
node->background_texture = COGL_INVALID_HANDLE;
}
if (node->background_pipeline != COGL_INVALID_HANDLE)
{
cogl_handle_unref (node->background_pipeline);
node->background_pipeline = COGL_INVALID_HANDLE;
}
if (node->background_shadow_pipeline != COGL_INVALID_HANDLE)
{
cogl_handle_unref (node->background_shadow_pipeline);
node->background_shadow_pipeline = COGL_INVALID_HANDLE;
}
} }
static gboolean static gboolean
st_theme_node_load_background_image (StThemeNode *node) st_theme_node_load_background_image (StThemeNode *node)
{ {
if (node->background_texture == COGL_INVALID_HANDLE) if (node->background_texture == NULL)
{ {
GFile *background_image; GFile *background_image;
StShadow *background_image_shadow_spec; StShadow *background_image_shadow_spec;
@ -1394,7 +1372,7 @@ st_theme_node_load_background_image (StThemeNode *node)
background_image_shadow_spec = st_theme_node_get_background_image_shadow (node); background_image_shadow_spec = st_theme_node_get_background_image_shadow (node);
node->background_texture = st_texture_cache_load_file_to_cogl_texture (st_texture_cache_get_default (), node->background_texture = st_texture_cache_load_file_to_cogl_texture (st_texture_cache_get_default (),
background_image, scale_factor); background_image, scale_factor);
if (node->background_texture == COGL_INVALID_HANDLE) if (node->background_texture == NULL)
goto out; goto out;
node->background_pipeline = _st_create_texture_pipeline (node->background_texture); node->background_pipeline = _st_create_texture_pipeline (node->background_texture);
@ -1411,7 +1389,7 @@ st_theme_node_load_background_image (StThemeNode *node)
} }
out: out:
return node->background_texture != COGL_INVALID_HANDLE; return node->background_texture != NULL;
} }
static gboolean static gboolean
@ -1536,14 +1514,14 @@ st_theme_node_render_resources (StThemeNodePaintState *state,
if (state->prerendered_texture) if (state->prerendered_texture)
state->prerendered_pipeline = _st_create_texture_pipeline (state->prerendered_texture); state->prerendered_pipeline = _st_create_texture_pipeline (state->prerendered_texture);
else else
state->prerendered_pipeline = COGL_INVALID_HANDLE; state->prerendered_pipeline = NULL;
if (box_shadow_spec && !has_inset_box_shadow) if (box_shadow_spec && !has_inset_box_shadow)
{ {
if (st_theme_node_load_border_image (node)) if (st_theme_node_load_border_image (node))
state->box_shadow_pipeline = _st_create_shadow_pipeline (box_shadow_spec, state->box_shadow_pipeline = _st_create_shadow_pipeline (box_shadow_spec,
node->border_slices_texture); node->border_slices_texture);
else if (state->prerendered_texture != COGL_INVALID_HANDLE) else if (state->prerendered_texture != NULL)
state->box_shadow_pipeline = _st_create_shadow_pipeline (box_shadow_spec, state->box_shadow_pipeline = _st_create_shadow_pipeline (box_shadow_spec,
state->prerendered_texture); state->prerendered_texture);
else if (node->background_color.alpha > 0 || has_border) else if (node->background_color.alpha > 0 || has_border)
@ -1554,7 +1532,7 @@ st_theme_node_render_resources (StThemeNodePaintState *state,
them. */ them. */
if (!node->cached_textures) if (!node->cached_textures)
{ {
if (state->prerendered_pipeline == COGL_INVALID_HANDLE && if (state->prerendered_pipeline == NULL &&
width >= node->box_shadow_min_width && width >= node->box_shadow_min_width &&
height >= node->box_shadow_min_height) height >= node->box_shadow_min_height)
{ {
@ -1577,22 +1555,17 @@ st_theme_node_update_resources (StThemeNodePaintState *state,
g_return_if_fail (width > 0 && height > 0); g_return_if_fail (width > 0 && height > 0);
/* Free handles we can't reuse */ /* Free handles we can't reuse */
if (state->prerendered_texture != COGL_INVALID_HANDLE) had_prerendered_texture = (state->prerendered_texture != NULL);
{ cogl_clear_object (&state->prerendered_texture);
cogl_handle_unref (state->prerendered_texture);
state->prerendered_texture = COGL_INVALID_HANDLE;
had_prerendered_texture = TRUE;
}
if (state->prerendered_pipeline != COGL_INVALID_HANDLE)
{
cogl_handle_unref (state->prerendered_pipeline);
state->prerendered_pipeline = COGL_INVALID_HANDLE;
if (node->border_slices_texture == COGL_INVALID_HANDLE && if (state->prerendered_pipeline != NULL)
state->box_shadow_pipeline != COGL_INVALID_HANDLE) {
cogl_clear_object (&state->prerendered_pipeline);
if (node->border_slices_texture == NULL &&
state->box_shadow_pipeline != NULL)
{ {
cogl_handle_unref (state->box_shadow_pipeline); cogl_clear_object (&state->box_shadow_pipeline);
state->box_shadow_pipeline = COGL_INVALID_HANDLE;
had_box_shadow = TRUE; had_box_shadow = TRUE;
} }
} }
@ -1613,7 +1586,7 @@ st_theme_node_update_resources (StThemeNodePaintState *state,
int corner_id; int corner_id;
for (corner_id = 0; corner_id < 4; corner_id++) for (corner_id = 0; corner_id < 4; corner_id++)
if (state->corner_material[corner_id] == COGL_INVALID_HANDLE) if (state->corner_material[corner_id] == NULL)
state->corner_material[corner_id] = state->corner_material[corner_id] =
st_theme_node_lookup_corner (node, width, height, corner_id); st_theme_node_lookup_corner (node, width, height, corner_id);
} }
@ -1624,7 +1597,7 @@ st_theme_node_update_resources (StThemeNodePaintState *state,
} }
static void static void
paint_material_with_opacity (CoglHandle material, paint_material_with_opacity (CoglPipeline *material,
CoglFramebuffer *framebuffer, CoglFramebuffer *framebuffer,
ClutterActorBox *box, ClutterActorBox *box,
ClutterActorBox *coords, ClutterActorBox *coords,
@ -1647,7 +1620,7 @@ st_theme_node_ensure_color_pipeline (StThemeNode *node)
{ {
static CoglPipeline *color_pipeline_template = NULL; static CoglPipeline *color_pipeline_template = NULL;
if (node->color_pipeline != COGL_INVALID_HANDLE) if (node->color_pipeline != NULL)
return; return;
if (G_UNLIKELY (color_pipeline_template == NULL)) if (G_UNLIKELY (color_pipeline_template == NULL))
@ -1775,7 +1748,7 @@ st_theme_node_paint_borders (StThemeNodePaintState *state,
{ {
for (corner_id = 0; corner_id < 4; corner_id++) for (corner_id = 0; corner_id < 4; corner_id++)
{ {
if (state->corner_material[corner_id] == COGL_INVALID_HANDLE) if (state->corner_material[corner_id] == NULL)
continue; continue;
cogl_pipeline_set_color4ub (state->corner_material[corner_id], cogl_pipeline_set_color4ub (state->corner_material[corner_id],
@ -2250,7 +2223,8 @@ st_theme_node_prerender_shadow (StThemeNodePaintState *state)
guint border_radius[4]; guint border_radius[4];
int max_borders[4]; int max_borders[4];
int center_radius, corner_id; int center_radius, corner_id;
CoglHandle buffer, offscreen = COGL_INVALID_HANDLE; CoglTexture *buffer;
CoglFramebuffer *offscreen = NULL;
CoglError *error = NULL; CoglError *error = NULL;
ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ()); ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ());
@ -2290,9 +2264,9 @@ st_theme_node_prerender_shadow (StThemeNodePaintState *state)
} }
/* Render offscreen */ /* Render offscreen */
buffer = cogl_texture_2d_new_with_size (ctx, buffer = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx,
state->box_shadow_width, state->box_shadow_width,
state->box_shadow_height); state->box_shadow_height));
if (buffer == NULL) if (buffer == NULL)
return; return;
@ -2317,8 +2291,8 @@ st_theme_node_prerender_shadow (StThemeNodePaintState *state)
cogl_error_free (error); cogl_error_free (error);
} }
cogl_handle_unref (offscreen); cogl_clear_object (&offscreen);
cogl_handle_unref (buffer); cogl_clear_object (&buffer);
} }
static void static void
@ -2333,7 +2307,7 @@ st_theme_node_paint_sliced_border_image (StThemeNode *node,
gint border_left, border_right, border_top, border_bottom; gint border_left, border_right, border_top, border_bottom;
float img_width, img_height; float img_width, img_height;
StBorderImage *border_image; StBorderImage *border_image;
CoglHandle pipeline; CoglPipeline *pipeline;
border_image = st_theme_node_get_border_image (node); border_image = st_theme_node_get_border_image (node);
g_assert (border_image != NULL); g_assert (border_image != NULL);
@ -2600,10 +2574,10 @@ st_theme_node_paint (StThemeNode *node,
paint_opacity); paint_opacity);
} }
if (state->prerendered_pipeline != COGL_INVALID_HANDLE || if (state->prerendered_pipeline != NULL ||
st_theme_node_load_border_image (node)) st_theme_node_load_border_image (node))
{ {
if (state->prerendered_pipeline != COGL_INVALID_HANDLE) if (state->prerendered_pipeline != NULL)
{ {
ClutterActorBox paint_box; ClutterActorBox paint_box;
@ -2618,7 +2592,7 @@ st_theme_node_paint (StThemeNode *node,
paint_opacity); paint_opacity);
} }
if (node->border_slices_pipeline != COGL_INVALID_HANDLE) if (node->border_slices_pipeline != NULL)
st_theme_node_paint_sliced_border_image (node, framebuffer, width, height, paint_opacity); st_theme_node_paint_sliced_border_image (node, framebuffer, width, height, paint_opacity);
} }
else else
@ -2628,7 +2602,7 @@ st_theme_node_paint (StThemeNode *node,
st_theme_node_paint_outline (node, framebuffer, box, paint_opacity); st_theme_node_paint_outline (node, framebuffer, box, paint_opacity);
if (state->prerendered_pipeline == COGL_INVALID_HANDLE && if (state->prerendered_pipeline == NULL &&
st_theme_node_load_background_image (node)) st_theme_node_load_background_image (node))
{ {
ClutterActorBox background_box; ClutterActorBox background_box;
@ -2661,7 +2635,7 @@ st_theme_node_paint (StThemeNode *node,
* there is nothing (like a border, or the edge of the background color) * there is nothing (like a border, or the edge of the background color)
* to logically confine it. * to logically confine it.
*/ */
if (node->background_shadow_pipeline != COGL_INVALID_HANDLE) if (node->background_shadow_pipeline != NULL)
_st_paint_shadow_with_opacity (node->background_image_shadow, _st_paint_shadow_with_opacity (node->background_image_shadow,
node->background_shadow_pipeline, node->background_shadow_pipeline,
&background_box, &background_box,
@ -2684,16 +2658,12 @@ st_theme_node_paint_state_node_free_internal (StThemeNodePaintState *state,
{ {
int corner_id; int corner_id;
if (state->prerendered_texture != COGL_INVALID_HANDLE) cogl_clear_object (&state->prerendered_texture);
cogl_handle_unref (state->prerendered_texture); cogl_clear_object (&state->prerendered_pipeline);
if (state->prerendered_pipeline != COGL_INVALID_HANDLE) cogl_clear_object (&state->box_shadow_pipeline);
cogl_handle_unref (state->prerendered_pipeline);
if (state->box_shadow_pipeline != COGL_INVALID_HANDLE)
cogl_handle_unref (state->box_shadow_pipeline);
for (corner_id = 0; corner_id < 4; corner_id++) for (corner_id = 0; corner_id < 4; corner_id++)
if (state->corner_material[corner_id] != COGL_INVALID_HANDLE) cogl_clear_object (&state->corner_material[corner_id]);
cogl_handle_unref (state->corner_material[corner_id]);
if (unref_node) if (unref_node)
st_theme_node_paint_state_set_node (state, NULL); st_theme_node_paint_state_set_node (state, NULL);
@ -2736,12 +2706,12 @@ st_theme_node_paint_state_init (StThemeNodePaintState *state)
state->alloc_width = 0; state->alloc_width = 0;
state->alloc_height = 0; state->alloc_height = 0;
state->node = NULL; state->node = NULL;
state->box_shadow_pipeline = COGL_INVALID_HANDLE; state->box_shadow_pipeline = NULL;
state->prerendered_texture = COGL_INVALID_HANDLE; state->prerendered_texture = NULL;
state->prerendered_pipeline = COGL_INVALID_HANDLE; state->prerendered_pipeline = NULL;
for (corner_id = 0; corner_id < 4; corner_id++) for (corner_id = 0; corner_id < 4; corner_id++)
state->corner_material[corner_id] = COGL_INVALID_HANDLE; state->corner_material[corner_id] = NULL;
} }
void void
@ -2763,14 +2733,14 @@ st_theme_node_paint_state_copy (StThemeNodePaintState *state,
state->box_shadow_height = other->box_shadow_height; state->box_shadow_height = other->box_shadow_height;
if (other->box_shadow_pipeline) if (other->box_shadow_pipeline)
state->box_shadow_pipeline = cogl_handle_ref (other->box_shadow_pipeline); state->box_shadow_pipeline = cogl_object_ref (other->box_shadow_pipeline);
if (other->prerendered_texture) if (other->prerendered_texture)
state->prerendered_texture = cogl_handle_ref (other->prerendered_texture); state->prerendered_texture = cogl_object_ref (other->prerendered_texture);
if (other->prerendered_pipeline) if (other->prerendered_pipeline)
state->prerendered_pipeline = cogl_handle_ref (other->prerendered_pipeline); state->prerendered_pipeline = cogl_object_ref (other->prerendered_pipeline);
for (corner_id = 0; corner_id < 4; corner_id++) for (corner_id = 0; corner_id < 4; corner_id++)
if (other->corner_material[corner_id]) if (other->corner_material[corner_id])
state->corner_material[corner_id] = cogl_handle_ref (other->corner_material[corner_id]); state->corner_material[corner_id] = cogl_object_ref (other->corner_material[corner_id]);
} }
void void

View File

@ -42,13 +42,13 @@ struct _StThemeNodeTransitionPrivate {
StThemeNodePaintState old_paint_state; StThemeNodePaintState old_paint_state;
StThemeNodePaintState new_paint_state; StThemeNodePaintState new_paint_state;
CoglHandle old_texture; CoglTexture *old_texture;
CoglHandle new_texture; CoglTexture *new_texture;
CoglHandle old_offscreen; CoglFramebuffer *old_offscreen;
CoglHandle new_offscreen; CoglFramebuffer *new_offscreen;
CoglHandle material; CoglPipeline *material;
ClutterTimeline *timeline; ClutterTimeline *timeline;
@ -245,7 +245,7 @@ setup_framebuffers (StThemeNodeTransition *transition,
CoglError *catch_error = NULL; CoglError *catch_error = NULL;
/* template material to avoid unnecessary shader compilation */ /* template material to avoid unnecessary shader compilation */
static CoglHandle material_template = COGL_INVALID_HANDLE; static CoglPipeline *material_template = NULL;
ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ()); ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ());
width = priv->offscreen_box.x2 - priv->offscreen_box.x1; width = priv->offscreen_box.x2 - priv->offscreen_box.x1;
@ -254,45 +254,39 @@ setup_framebuffers (StThemeNodeTransition *transition,
g_return_val_if_fail (width > 0, FALSE); g_return_val_if_fail (width > 0, FALSE);
g_return_val_if_fail (height > 0, FALSE); g_return_val_if_fail (height > 0, FALSE);
if (priv->old_texture) cogl_clear_object (&priv->old_texture);
cogl_handle_unref (priv->old_texture); priv->old_texture = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx, width, height));
priv->old_texture = cogl_texture_2d_new_with_size (ctx, width, height);
if (priv->new_texture) cogl_clear_object (&priv->new_texture);
cogl_handle_unref (priv->new_texture); priv->new_texture = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx, width, height));
priv->new_texture = cogl_texture_2d_new_with_size (ctx, width, height);
if (priv->old_texture == COGL_INVALID_HANDLE) if (priv->old_texture == NULL)
return FALSE; return FALSE;
if (priv->new_texture == COGL_INVALID_HANDLE) if (priv->new_texture == NULL)
return FALSE; return FALSE;
if (priv->old_offscreen) cogl_clear_object (&priv->old_offscreen);
cogl_handle_unref (priv->old_offscreen); priv->old_offscreen = COGL_FRAMEBUFFER (cogl_offscreen_new_with_texture (priv->old_texture));
priv->old_offscreen = cogl_offscreen_new_with_texture (priv->old_texture); if (!cogl_framebuffer_allocate (priv->old_offscreen, &catch_error))
if (!cogl_framebuffer_allocate (COGL_FRAMEBUFFER (priv->old_offscreen), &catch_error))
{ {
cogl_object_unref (priv->old_offscreen);
cogl_error_free (catch_error); cogl_error_free (catch_error);
priv->old_offscreen = COGL_INVALID_HANDLE; cogl_clear_object (&priv->old_offscreen);
return FALSE; return FALSE;
} }
if (priv->new_offscreen) cogl_clear_object (&priv->new_offscreen);
cogl_handle_unref (priv->new_offscreen); priv->new_offscreen = COGL_FRAMEBUFFER (cogl_offscreen_new_with_texture (priv->new_texture));
priv->new_offscreen = cogl_offscreen_new_with_texture (priv->new_texture); if (!cogl_framebuffer_allocate (priv->new_offscreen, &catch_error))
if (!cogl_framebuffer_allocate (COGL_FRAMEBUFFER (priv->new_offscreen), &catch_error))
{ {
cogl_object_unref (priv->new_offscreen);
cogl_error_free (catch_error); cogl_error_free (catch_error);
priv->new_offscreen = COGL_INVALID_HANDLE; cogl_clear_object (&priv->new_offscreen);
return FALSE; return FALSE;
} }
if (priv->material == NULL) if (priv->material == NULL)
{ {
if (G_UNLIKELY (material_template == COGL_INVALID_HANDLE)) if (G_UNLIKELY (material_template == NULL))
{ {
CoglContext *ctx = CoglContext *ctx =
clutter_backend_get_cogl_context (clutter_get_default_backend ()); clutter_backend_get_cogl_context (clutter_get_default_backend ());
@ -393,47 +387,16 @@ st_theme_node_transition_dispose (GObject *object)
{ {
StThemeNodeTransitionPrivate *priv = ST_THEME_NODE_TRANSITION (object)->priv; StThemeNodeTransitionPrivate *priv = ST_THEME_NODE_TRANSITION (object)->priv;
if (priv->old_theme_node) g_clear_object (&priv->old_theme_node);
{ g_clear_object (&priv->new_theme_node);
g_object_unref (priv->old_theme_node);
priv->old_theme_node = NULL;
}
if (priv->new_theme_node) cogl_clear_object (&priv->old_texture);
{ cogl_clear_object (&priv->new_texture);
g_object_unref (priv->new_theme_node);
priv->new_theme_node = NULL;
}
if (priv->old_texture) cogl_clear_object (&priv->old_offscreen);
{ cogl_clear_object (&priv->new_offscreen);
cogl_handle_unref (priv->old_texture);
priv->old_texture = NULL;
}
if (priv->new_texture) cogl_clear_object (&priv->material);
{
cogl_handle_unref (priv->new_texture);
priv->new_texture = NULL;
}
if (priv->old_offscreen)
{
cogl_handle_unref (priv->old_offscreen);
priv->old_offscreen = NULL;
}
if (priv->new_offscreen)
{
cogl_handle_unref (priv->new_offscreen);
priv->new_offscreen = NULL;
}
if (priv->material)
{
cogl_handle_unref (priv->material);
priv->material = NULL;
}
if (priv->timeline) if (priv->timeline)
{ {
@ -444,8 +407,7 @@ st_theme_node_transition_dispose (GObject *object)
g_signal_handler_disconnect (priv->timeline, g_signal_handler_disconnect (priv->timeline,
priv->timeline_new_frame_id); priv->timeline_new_frame_id);
g_object_unref (priv->timeline); g_clear_object (&priv->timeline);
priv->timeline = NULL;
} }
priv->timeline_completed_id = 0; priv->timeline_completed_id = 0;

View File

@ -47,12 +47,6 @@ static void
st_theme_node_init (StThemeNode *node) st_theme_node_init (StThemeNode *node)
{ {
node->transition_duration = -1; node->transition_duration = -1;
node->background_texture = COGL_INVALID_HANDLE;
node->background_pipeline = COGL_INVALID_HANDLE;
node->background_shadow_pipeline = COGL_INVALID_HANDLE;
node->border_slices_texture = COGL_INVALID_HANDLE;
node->border_slices_pipeline = COGL_INVALID_HANDLE;
node->color_pipeline = COGL_INVALID_HANDLE;
st_theme_node_paint_state_init (&node->cached_state); st_theme_node_paint_state_init (&node->cached_state);
} }
@ -140,48 +134,20 @@ st_theme_node_finalize (GObject *object)
maybe_free_properties (node); maybe_free_properties (node);
if (node->font_desc) g_clear_pointer (&node->font_desc, pango_font_description_free);
{
pango_font_description_free (node->font_desc);
node->font_desc = NULL;
}
if (node->box_shadow) g_clear_pointer (&node->box_shadow, st_shadow_unref);
{ g_clear_pointer (&node->background_image_shadow, st_shadow_unref);
st_shadow_unref (node->box_shadow); g_clear_pointer (&node->text_shadow, st_shadow_unref);
node->box_shadow = NULL;
}
if (node->background_image_shadow) g_clear_object (&node->background_image);
{
st_shadow_unref (node->background_image_shadow);
node->background_image_shadow = NULL;
}
if (node->text_shadow) cogl_clear_object (&node->background_texture);
{ cogl_clear_object (&node->background_pipeline);
st_shadow_unref (node->text_shadow); cogl_clear_object (&node->background_shadow_pipeline);
node->text_shadow = NULL; cogl_clear_object (&node->border_slices_texture);
} cogl_clear_object (&node->border_slices_pipeline);
cogl_clear_object (&node->color_pipeline);
if (node->background_image)
{
g_object_unref (node->background_image);
node->background_image = NULL;
}
if (node->background_texture != COGL_INVALID_HANDLE)
cogl_handle_unref (node->background_texture);
if (node->background_pipeline != COGL_INVALID_HANDLE)
cogl_handle_unref (node->background_pipeline);
if (node->background_shadow_pipeline != COGL_INVALID_HANDLE)
cogl_handle_unref (node->background_shadow_pipeline);
if (node->border_slices_texture != COGL_INVALID_HANDLE)
cogl_handle_unref (node->border_slices_texture);
if (node->border_slices_pipeline != COGL_INVALID_HANDLE)
cogl_handle_unref (node->border_slices_pipeline);
if (node->color_pipeline != COGL_INVALID_HANDLE)
cogl_handle_unref (node->color_pipeline);
G_OBJECT_CLASS (st_theme_node_parent_class)->finalize (object); G_OBJECT_CLASS (st_theme_node_parent_class)->finalize (object);
} }

View File

@ -107,7 +107,7 @@ struct _StThemeNodePaintState {
CoglPipeline *box_shadow_pipeline; CoglPipeline *box_shadow_pipeline;
CoglPipeline *prerendered_texture; CoglPipeline *prerendered_texture;
CoglPipeline *prerendered_pipeline; CoglPipeline *prerendered_pipeline;
CoglHandle corner_material[4]; CoglPipeline *corner_material[4];
}; };
StThemeNode *st_theme_node_new (StThemeContext *context, StThemeNode *st_theme_node_new (StThemeContext *context,