Beispiel #1
0
void
_st_paint_shadow_with_opacity (StShadow        *shadow_spec,
                               CoglPipeline    *shadow_pipeline,
                               ClutterActorBox *box,
                               guint8           paint_opacity)
{
    CoglFramebuffer *fb = cogl_get_draw_framebuffer ();
    ClutterActorBox shadow_box;
    CoglColor color;

    g_return_if_fail (shadow_spec != NULL);
    g_return_if_fail (shadow_pipeline != NULL);

    st_shadow_get_box (shadow_spec, box, &shadow_box);

    cogl_color_init_from_4ub (&color,
                              shadow_spec->color.red   * paint_opacity / 255,
                              shadow_spec->color.green * paint_opacity / 255,
                              shadow_spec->color.blue  * paint_opacity / 255,
                              shadow_spec->color.alpha * paint_opacity / 255);
    cogl_color_premultiply (&color);
    cogl_pipeline_set_layer_combine_constant (shadow_pipeline, 0, &color);
    cogl_framebuffer_draw_rectangle (fb, shadow_pipeline,
                                     shadow_box.x1, shadow_box.y1,
                                     shadow_box.x2, shadow_box.y2);
}
Beispiel #2
0
void
_st_paint_shadow_with_opacity (StShadow        *shadow_spec,
                               CoglHandle       shadow_material,
                               ClutterActorBox *box,
                               guint8           paint_opacity)
{
  ClutterActorBox shadow_box;
  CoglColor       color;

  g_return_if_fail (shadow_spec != NULL);
  g_return_if_fail (shadow_material != COGL_INVALID_HANDLE);

  st_shadow_get_box (shadow_spec, box, &shadow_box);

  cogl_color_set_from_4ub (&color,
                           shadow_spec->color.red   * paint_opacity / 255,
                           shadow_spec->color.green * paint_opacity / 255,
                           shadow_spec->color.blue  * paint_opacity / 255,
                           shadow_spec->color.alpha * paint_opacity / 255);
  cogl_color_premultiply (&color);

  cogl_material_set_layer_combine_constant (shadow_material, 0, &color);

  cogl_set_source (shadow_material);
  cogl_rectangle_with_texture_coords (shadow_box.x1, shadow_box.y1,
                                      shadow_box.x2, shadow_box.y2,
                                      0, 0, 1, 1);
}