st: Add more error checking to shadow-related code
The additional error checks should catch quite some warnings (e.g. when trying to create a shadow for a 0-width actor).
This commit is contained in:
parent
c81c564941
commit
c58b8498b3
@ -243,10 +243,11 @@ st_label_paint (ClutterActor *actor)
|
|||||||
priv->text_shadow_material = material;
|
priv->text_shadow_material = material;
|
||||||
}
|
}
|
||||||
|
|
||||||
_st_paint_shadow_with_opacity (shadow_spec,
|
if (priv->text_shadow_material != COGL_INVALID_HANDLE)
|
||||||
priv->text_shadow_material,
|
_st_paint_shadow_with_opacity (shadow_spec,
|
||||||
&allocation,
|
priv->text_shadow_material,
|
||||||
clutter_actor_get_paint_opacity (priv->label));
|
&allocation,
|
||||||
|
clutter_actor_get_paint_opacity (priv->label));
|
||||||
}
|
}
|
||||||
|
|
||||||
clutter_actor_paint (priv->label);
|
clutter_actor_paint (priv->label);
|
||||||
|
@ -604,32 +604,41 @@ _st_create_shadow_material_from_actor (StShadow *shadow_spec,
|
|||||||
{
|
{
|
||||||
CoglHandle buffer, offscreen;
|
CoglHandle buffer, offscreen;
|
||||||
ClutterActorBox box;
|
ClutterActorBox box;
|
||||||
|
CoglColor clear_color;
|
||||||
float width, height;
|
float width, height;
|
||||||
|
|
||||||
clutter_actor_get_allocation_box (actor, &box);
|
clutter_actor_get_allocation_box (actor, &box);
|
||||||
clutter_actor_box_get_size (&box, &width, &height);
|
clutter_actor_box_get_size (&box, &width, &height);
|
||||||
|
|
||||||
|
if (width == 0 || height == 0)
|
||||||
|
return COGL_INVALID_HANDLE;
|
||||||
|
|
||||||
buffer = cogl_texture_new_with_size (width,
|
buffer = cogl_texture_new_with_size (width,
|
||||||
height,
|
height,
|
||||||
COGL_TEXTURE_NO_SLICING,
|
COGL_TEXTURE_NO_SLICING,
|
||||||
COGL_PIXEL_FORMAT_ANY);
|
COGL_PIXEL_FORMAT_ANY);
|
||||||
|
|
||||||
|
if (buffer == COGL_INVALID_HANDLE)
|
||||||
|
return COGL_INVALID_HANDLE;
|
||||||
|
|
||||||
offscreen = cogl_offscreen_new_to_texture (buffer);
|
offscreen = cogl_offscreen_new_to_texture (buffer);
|
||||||
|
|
||||||
if (offscreen != COGL_INVALID_HANDLE)
|
if (offscreen == COGL_INVALID_HANDLE)
|
||||||
{
|
{
|
||||||
CoglColor clear_color;
|
cogl_handle_unref (buffer);
|
||||||
|
return COGL_INVALID_HANDLE;
|
||||||
cogl_color_set_from_4ub (&clear_color, 0, 0, 0, 0);
|
|
||||||
cogl_push_framebuffer (offscreen);
|
|
||||||
cogl_clear (&clear_color, COGL_BUFFER_BIT_COLOR);
|
|
||||||
cogl_ortho (0, width, height, 0, 0, 1.0);
|
|
||||||
clutter_actor_paint (actor);
|
|
||||||
cogl_pop_framebuffer ();
|
|
||||||
cogl_handle_unref (offscreen);
|
|
||||||
|
|
||||||
shadow_material = _st_create_shadow_material (shadow_spec, buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cogl_color_set_from_4ub (&clear_color, 0, 0, 0, 0);
|
||||||
|
cogl_push_framebuffer (offscreen);
|
||||||
|
cogl_clear (&clear_color, COGL_BUFFER_BIT_COLOR);
|
||||||
|
cogl_ortho (0, width, height, 0, 0, 1.0);
|
||||||
|
clutter_actor_paint (actor);
|
||||||
|
cogl_pop_framebuffer ();
|
||||||
|
cogl_handle_unref (offscreen);
|
||||||
|
|
||||||
|
shadow_material = _st_create_shadow_material (shadow_spec, buffer);
|
||||||
|
|
||||||
cogl_handle_unref (buffer);
|
cogl_handle_unref (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user