Пример #1
0
static void
clutter_colorize_effect_class_init (ClutterColorizeEffectClass *klass)
{
  ClutterEffectClass *effect_class = CLUTTER_EFFECT_CLASS (klass);
  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
  ClutterOffscreenEffectClass *offscreen_class;

  offscreen_class = CLUTTER_OFFSCREEN_EFFECT_CLASS (klass);
  offscreen_class->paint_target = clutter_colorize_effect_paint_target;

  effect_class->pre_paint = clutter_colorize_effect_pre_paint;

  gobject_class->set_property = clutter_colorize_effect_set_property;
  gobject_class->get_property = clutter_colorize_effect_get_property;
  gobject_class->dispose = clutter_colorize_effect_dispose;

  /**
   * ClutterColorizeEffect:tint:
   *
   * The tint to apply to the actor
   *
   * Since: 1.4
   */
  obj_props[PROP_TINT] =
    clutter_param_spec_color ("tint",
                              P_("Tint"),
                              P_("The tint to apply"),
                              &default_tint,
                              CLUTTER_PARAM_READWRITE);

  g_object_class_install_properties (gobject_class, PROP_LAST, obj_props);
}
static void
st_scroll_view_fade_class_init (StScrollViewFadeClass *klass)
{
  ClutterEffectClass *effect_class = CLUTTER_EFFECT_CLASS (klass);
  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
  ClutterOffscreenEffectClass *offscreen_class;
  ClutterActorMetaClass *meta_class = CLUTTER_ACTOR_META_CLASS (klass);

  gobject_class->dispose = st_scroll_view_fade_dispose;
  gobject_class->get_property = st_scroll_view_fade_get_property;
  gobject_class->set_property = st_scroll_view_fade_set_property;

  meta_class->set_actor = st_scroll_view_fade_set_actor;

  effect_class->pre_paint = st_scroll_view_fade_pre_paint;

  offscreen_class = CLUTTER_OFFSCREEN_EFFECT_CLASS (klass);
  offscreen_class->create_texture = st_scroll_view_fade_create_texture;
  offscreen_class->paint_target = st_scroll_view_fade_paint_target;

  g_object_class_install_property (gobject_class,
                                   PROP_FADE_OFFSET,
                                   g_param_spec_float ("fade-offset",
                                                       "Fade Offset",
                                                       "The height of the area which is faded at the edge",
                                                       0.f, G_MAXFLOAT, DEFAULT_FADE_OFFSET,
                                                       G_PARAM_READWRITE));

}
static void
clutter_desaturate_effect_class_init (ClutterDesaturateEffectClass *klass)
{
  ClutterEffectClass *effect_class = CLUTTER_EFFECT_CLASS (klass);
  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
  ClutterOffscreenEffectClass *offscreen_class;

  offscreen_class = CLUTTER_OFFSCREEN_EFFECT_CLASS (klass);
  offscreen_class->paint_target = clutter_desaturate_effect_paint_target;

  effect_class->pre_paint = clutter_desaturate_effect_pre_paint;

  /**
   * ClutterDesaturateEffect:factor:
   *
   * The desaturation factor, between 0.0 (no desaturation) and 1.0 (full
   * desaturation).
   *
   * Since: 1.4
   */
  obj_props[PROP_FACTOR] =
    g_param_spec_double ("factor",
                         P_("Factor"),
                         P_("The desaturation factor"),
                         0.0, 1.0,
                         1.0,
                         CLUTTER_PARAM_READWRITE);

  gobject_class->dispose = clutter_desaturate_effect_dispose;
  gobject_class->set_property = clutter_desaturate_effect_set_property;
  gobject_class->get_property = clutter_desaturate_effect_get_property;

  g_object_class_install_properties (gobject_class, PROP_LAST, obj_props);
}
Пример #4
0
static void
clutter_colorize_effect_paint_target (ClutterOffscreenEffect *effect)
{
  ClutterColorizeEffect *self = CLUTTER_COLORIZE_EFFECT (effect);
  ClutterOffscreenEffectClass *parent;
  CoglHandle material;

  if (self->program == COGL_INVALID_HANDLE)
    goto out;

  if (self->tex_uniform > -1)
    cogl_program_set_uniform_1i (self->program, self->tex_uniform, 0);

  if (self->tint_uniform > -1)
    {
      float tint[3] = {
        self->tint.red / 255.0,
        self->tint.green / 255.0,
        self->tint.blue / 255.0
      };

      cogl_program_set_uniform_float (self->program, self->tint_uniform,
                                      3, 1,
                                      tint);
    }

  material = clutter_offscreen_effect_get_target (effect);
  cogl_material_set_user_program (material, self->program);

out:
  parent = CLUTTER_OFFSCREEN_EFFECT_CLASS (clutter_colorize_effect_parent_class);
  parent->paint_target (effect);
}
static void
shell_anamorphosis_effect_class_init (ShellAnamorphosisEffectClass *klass)
{
  ClutterEffectClass *effect_class = CLUTTER_EFFECT_CLASS (klass);
  ClutterOffscreenEffectClass *offscreen_class = CLUTTER_OFFSCREEN_EFFECT_CLASS (klass);

  offscreen_class->paint_target = shell_anamorphosis_effect_paint_target;
  effect_class->pre_paint = shell_anamorphosis_effect_pre_paint;
}
static void
st_scroll_view_fade_paint_target (ClutterOffscreenEffect *effect)
{
  StScrollViewFade *self = ST_SCROLL_VIEW_FADE (effect);
  ClutterOffscreenEffectClass *parent;
  CoglHandle material;

  gdouble value, lower, upper, page_size;
  ClutterActor *vscroll = st_scroll_view_get_vscroll_bar (ST_SCROLL_VIEW (self->actor));
  ClutterActor *hscroll = st_scroll_view_get_hscroll_bar (ST_SCROLL_VIEW (self->actor));
  gboolean h_scroll_visible, v_scroll_visible;

  g_object_get (ST_SCROLL_VIEW (self->actor),
                "hscrollbar-visible", &h_scroll_visible,
                "vscrollbar-visible", &v_scroll_visible,
                NULL);

  if (self->program == COGL_INVALID_HANDLE)
    goto out;

  st_adjustment_get_values (self->vadjustment, &value, &lower, &upper, NULL, NULL, &page_size);

  if (self->offset_top_uniform > -1) {
    if (value > lower + 0.1)
      cogl_program_set_uniform_1f (self->program, self->offset_top_uniform, self->fade_offset);
    else
      cogl_program_set_uniform_1f (self->program, self->offset_top_uniform, 0.0f);
  }

  if (self->offset_bottom_uniform > -1) {
    if (value < upper - page_size - 0.1)
      cogl_program_set_uniform_1f (self->program, self->offset_bottom_uniform, self->fade_offset);
    else
      cogl_program_set_uniform_1f (self->program, self->offset_bottom_uniform, 0.0f);
  }

  if (self->tex_uniform > -1)
    cogl_program_set_uniform_1i (self->program, self->tex_uniform, 0);
  if (self->height_uniform > -1)
    cogl_program_set_uniform_1f (self->program, self->height_uniform, clutter_actor_get_height (self->actor));
  if (self->width_uniform > -1)
    cogl_program_set_uniform_1f (self->program, self->width_uniform, clutter_actor_get_width (self->actor));
  if (self->scrollbar_width_uniform > -1)
    cogl_program_set_uniform_1f (self->program, self->scrollbar_width_uniform, v_scroll_visible ? clutter_actor_get_width (vscroll) : 0);
  if (self->scrollbar_height_uniform > -1)
    cogl_program_set_uniform_1f (self->program, self->scrollbar_height_uniform, h_scroll_visible ? clutter_actor_get_height (hscroll) : 0);
  if (self->rtl_uniform > -1)
    cogl_program_set_uniform_1i (self->program, self->rtl_uniform, (st_widget_get_direction (ST_WIDGET (self->actor)) == ST_TEXT_DIRECTION_RTL));

  material = clutter_offscreen_effect_get_target (effect);
  cogl_material_set_user_program (material, self->program);

out:
  parent = CLUTTER_OFFSCREEN_EFFECT_CLASS (st_scroll_view_fade_parent_class);
  parent->paint_target (effect);
}
Пример #7
0
static void
cd_icc_effect_class_init (CdIccEffectClass *klass)
{
  ClutterEffectClass *effect_class = CLUTTER_EFFECT_CLASS (klass);
  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
  ClutterOffscreenEffectClass *offscreen_class;

  gobject_class->dispose = cd_icc_effect_dispose;

  effect_class->pre_paint = cd_icc_effect_pre_paint;

  offscreen_class = CLUTTER_OFFSCREEN_EFFECT_CLASS (klass);
  offscreen_class->paint_target = cd_icc_effect_paint_target;
}
Пример #8
0
static CoglHandle
mx_fade_effect_create_texture (ClutterOffscreenEffect *effect,
                               gfloat                  width,
                               gfloat                  height)
{
  MxFadeEffectPrivate *priv = MX_FADE_EFFECT (effect)->priv;

  priv->width = width;
  priv->height = height;
  priv->update_vbo = TRUE;

  return CLUTTER_OFFSCREEN_EFFECT_CLASS (mx_fade_effect_parent_class)->
    create_texture (effect, width, height);
}
static void
shell_grid_desaturate_effect_class_init (ShellGridDesaturateEffectClass *klass)
{
  ClutterEffectClass *effect_class = CLUTTER_EFFECT_CLASS (klass);
  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
  ClutterOffscreenEffectClass *offscreen_class;

  offscreen_class = CLUTTER_OFFSCREEN_EFFECT_CLASS (klass);
  offscreen_class->paint_target = shell_grid_desaturate_effect_paint_target;

  effect_class->pre_paint = shell_grid_desaturate_effect_pre_paint;

  /**
   * ShellGridDesaturateEffect:factor:
   *
   * The desaturation factor, between 0.0 (no desaturation) and 1.0 (full
   * desaturation).
   */
  obj_props[PROP_FACTOR] =
    g_param_spec_double ("factor",
                         "Factor",
                         "The desaturation factor",
                         0.0, 1.0,
                         1.0,
                         G_PARAM_READWRITE);

  /**
   * ShellGridDesaturateEffect:unshaded-rect:
   *
   * The unshaded rectangle.
   */
  obj_props[PROP_UNSHADED_RECT] =
    g_param_spec_boxed ("unshaded-rect",
                        "Unshaded rect",
                        "The unshaded rectangle",
                        CLUTTER_TYPE_RECT,
                        G_PARAM_READWRITE);

  gobject_class->dispose = shell_grid_desaturate_effect_dispose;
  gobject_class->set_property = shell_grid_desaturate_effect_set_property;
  gobject_class->get_property = shell_grid_desaturate_effect_get_property;

  g_object_class_install_properties (gobject_class, PROP_LAST, obj_props);
}
Пример #10
0
static void
clutter_shader_effect_class_init (ClutterShaderEffectClass *klass)
{
  ClutterActorMetaClass *meta_class = CLUTTER_ACTOR_META_CLASS (klass);
  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
  ClutterOffscreenEffectClass *offscreen_class;

  offscreen_class = CLUTTER_OFFSCREEN_EFFECT_CLASS (klass);

  g_type_class_add_private (klass, sizeof (ClutterShaderEffectPrivate));

  /**
   * ClutterShaderEffect:shader-type:
   *
   * The type of shader that is used by the effect. This property
   * should be set by the constructor of #ClutterShaderEffect
   * sub-classes.
   *
   * Since: 1.4
   */
  obj_props[PROP_SHADER_TYPE] =
    g_param_spec_enum ("shader-type",
                       P_("Shader Type"),
                       P_("The type of shader used"),
                       CLUTTER_TYPE_SHADER_TYPE,
                       CLUTTER_FRAGMENT_SHADER,
                       CLUTTER_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);

  gobject_class->set_property = clutter_shader_effect_set_property;
  gobject_class->finalize = clutter_shader_effect_finalize;
  _clutter_object_class_install_properties (gobject_class,
                                            PROP_LAST,
                                            obj_props);

  meta_class->set_actor = clutter_shader_effect_set_actor;

  offscreen_class->paint_target = clutter_shader_effect_paint_target;
}
Пример #11
0
static void
st_background_effect_class_init (StBackgroundEffectClass *klass)
{
  ClutterEffectClass *effect_class = CLUTTER_EFFECT_CLASS (klass);
  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
  ClutterOffscreenEffectClass *offscreen_class;

  effect_class->pre_paint = st_background_effect_pre_paint;
  gobject_class->set_property = st_background_effect_set_property;
  gobject_class->get_property = st_background_effect_get_property;
  gobject_class->dispose = st_background_effect_dispose;
  
  offscreen_class = CLUTTER_OFFSCREEN_EFFECT_CLASS (klass);
  offscreen_class->paint_target = st_background_effect_paint_target;

  obj_props[PROP_BUMPMAP] =
    g_param_spec_string ("bumpmap",
                         "Background effect construct prop",
                         "Set bumpmap path",
                         "/usr/share/cinnamon/bumpmaps/bumpmap.png",
                         G_PARAM_READWRITE);

  g_object_class_install_properties (gobject_class, PROP_LAST, obj_props);
}
Пример #12
0
static void
clutter_deform_effect_class_init (ClutterDeformEffectClass *klass)
{
  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
  ClutterActorMetaClass *meta_class = CLUTTER_ACTOR_META_CLASS (klass);
  ClutterOffscreenEffectClass *offscreen_class = CLUTTER_OFFSCREEN_EFFECT_CLASS (klass);

  klass->deform_vertex = clutter_deform_effect_real_deform_vertex;

  /**
   * ClutterDeformEffect:x-tiles:
   *
   * The number of horizontal tiles. The bigger the number, the
   * smaller the tiles
   *
   * Since: 1.4
   */
  obj_props[PROP_X_TILES] =
    g_param_spec_uint ("x-tiles",
                       P_("Horizontal Tiles"),
                       P_("The number of horizontal tiles"),
                       1, G_MAXUINT,
                       DEFAULT_N_TILES,
                       CLUTTER_PARAM_READWRITE);

  /**
   * ClutterDeformEffect:y-tiles:
   *
   * The number of vertical tiles. The bigger the number, the
   * smaller the tiles
   *
   * Since: 1.4
   */
  obj_props[PROP_Y_TILES] =
    g_param_spec_uint ("y-tiles",
                       P_("Vertical Tiles"),
                       P_("The number of vertical tiles"),
                       1, G_MAXUINT,
                       DEFAULT_N_TILES,
                       CLUTTER_PARAM_READWRITE);

  /**
   * ClutterDeformEffect:back-material:
   *
   * A material to be used when painting the back of the actor
   * to which this effect has been applied
   *
   * By default, no material will be used
   *
   * Since: 1.4
   */
  obj_props[PROP_BACK_MATERIAL] =
    g_param_spec_boxed ("back-material",
                        P_("Back Material"),
                        P_("The material to be used when painting the back of the actor"),
                        COGL_TYPE_HANDLE,
                        CLUTTER_PARAM_READWRITE);

  gobject_class->finalize = clutter_deform_effect_finalize;
  gobject_class->set_property = clutter_deform_effect_set_property;
  gobject_class->get_property = clutter_deform_effect_get_property;
  g_object_class_install_properties (gobject_class,
                                     PROP_LAST,
                                     obj_props);

  meta_class->set_actor = clutter_deform_effect_set_actor;

  offscreen_class->paint_target = clutter_deform_effect_paint_target;
}
static void
st_scroll_view_fade_paint_target (ClutterOffscreenEffect *effect)
{
  StScrollViewFade *self = ST_SCROLL_VIEW_FADE (effect);
  ClutterOffscreenEffectClass *parent;
  CoglHandle material;

  gdouble value, lower, upper, page_size;
  ClutterActor *vscroll = st_scroll_view_get_vscroll_bar (ST_SCROLL_VIEW (self->actor));
  ClutterActor *hscroll = st_scroll_view_get_hscroll_bar (ST_SCROLL_VIEW (self->actor));
  gboolean h_scroll_visible, v_scroll_visible;

  ClutterActorBox allocation, content_box, paint_box;

  /*
   * Used to pass the fade area to the shader
   *
   * [0][0] = x1
   * [0][1] = y1
   * [1][0] = x2
   * [1][1] = y2
   *
   */
  float fade_area[2][2];
  ClutterVertex verts[4];

  if (self->program == COGL_INVALID_HANDLE)
    goto out;

  clutter_actor_get_paint_box (self->actor, &paint_box);
  clutter_actor_get_abs_allocation_vertices (self->actor, verts);

  clutter_actor_get_allocation_box (self->actor, &allocation);
  st_theme_node_get_content_box (st_widget_get_theme_node (ST_WIDGET (self->actor)),
                                (const ClutterActorBox *)&allocation, &content_box);

  /*
   * The FBO is based on the paint_volume's size which can be larger then the actual
   * allocation, so we have to account for that when passing the positions
   */
  fade_area[0][0] = content_box.x1 + (verts[0].x - paint_box.x1);
  fade_area[0][1] = content_box.y1 + (verts[0].y - paint_box.y1);
  fade_area[1][0] = content_box.x2 + (verts[3].x - paint_box.x2);
  fade_area[1][1] = content_box.y2 + (verts[3].y - paint_box.y2);

  g_object_get (ST_SCROLL_VIEW (self->actor),
                "hscrollbar-visible", &h_scroll_visible,
                "vscrollbar-visible", &v_scroll_visible,
                NULL);

  if (v_scroll_visible)
    {
      if (st_widget_get_direction (ST_WIDGET (self->actor)) == ST_TEXT_DIRECTION_RTL)
          fade_area[0][0] += clutter_actor_get_width (vscroll);

      fade_area[1][0] -= clutter_actor_get_width (vscroll);
    }

  if (h_scroll_visible)
      fade_area[1][1] -= clutter_actor_get_height (hscroll);

  st_adjustment_get_values (self->vadjustment, &value, &lower, &upper, NULL, NULL, &page_size);

  if (self->offset_top_uniform > -1) {
    if (value > lower + 0.1)
      cogl_program_set_uniform_1f (self->program, self->offset_top_uniform, self->fade_offset);
    else
      cogl_program_set_uniform_1f (self->program, self->offset_top_uniform, 0.0f);
  }

  if (self->offset_bottom_uniform > -1) {
    if (value < upper - page_size - 0.1)
      cogl_program_set_uniform_1f (self->program, self->offset_bottom_uniform, self->fade_offset);
    else
      cogl_program_set_uniform_1f (self->program, self->offset_bottom_uniform, 0.0f);
  }

  if (self->tex_uniform > -1)
    cogl_program_set_uniform_1i (self->program, self->tex_uniform, 0);
  if (self->height_uniform > -1)
    cogl_program_set_uniform_1f (self->program, self->height_uniform, clutter_actor_get_height (self->actor));
  if (self->width_uniform > -1)
    cogl_program_set_uniform_1f (self->program, self->width_uniform, clutter_actor_get_width (self->actor));
  if (self->fade_area_uniform > -1)
    cogl_program_set_uniform_matrix (self->program, self->fade_area_uniform, 2, 1, FALSE, (const float *)fade_area);

  material = clutter_offscreen_effect_get_target (effect);
  cogl_material_set_user_program (material, self->program);

out:
  parent = CLUTTER_OFFSCREEN_EFFECT_CLASS (st_scroll_view_fade_parent_class);
  parent->paint_target (effect);
}
Пример #14
0
static void
clutter_shader_effect_paint_target (ClutterOffscreenEffect *effect)
{
  ClutterShaderEffectPrivate *priv = CLUTTER_SHADER_EFFECT (effect)->priv;
  ClutterOffscreenEffectClass *parent;
  CoglHandle material;

  /* we haven't been prepared or we don't have support for
   * GLSL shaders in Clutter
   */
  if (priv->program == COGL_INVALID_HANDLE ||
      priv->shader == COGL_INVALID_HANDLE)
    goto out;

  if (!priv->source_set)
    goto out;

  if (!priv->is_compiled)
    {
      CLUTTER_NOTE (SHADER, "Compiling shader effect");

      cogl_shader_compile (priv->shader);
      if (!cogl_shader_is_compiled (priv->shader))
        {
          gchar *log_buf = cogl_shader_get_info_log (priv->shader);

          g_warning ("Unable to compile the GLSL shader: %s", log_buf);
          g_free (log_buf);

          cogl_handle_unref (priv->shader);
          priv->shader = COGL_INVALID_HANDLE;

          cogl_handle_unref (priv->program);
          priv->shader = COGL_INVALID_HANDLE;

          goto out;
        }

      cogl_program_attach_shader (priv->program, priv->shader);
      cogl_handle_unref (priv->shader);

      cogl_program_link (priv->program);

      priv->is_compiled = TRUE;
    }

  CLUTTER_NOTE (SHADER, "Applying the shader effect of type '%s'",
                G_OBJECT_TYPE_NAME (effect));

  clutter_shader_effect_update_uniforms (CLUTTER_SHADER_EFFECT (effect));

  /* associate the program to the offscreen target material */
  material = clutter_offscreen_effect_get_target (effect);
  cogl_material_set_user_program (material, priv->program);

out:
  /* paint the offscreen buffer */
  parent = CLUTTER_OFFSCREEN_EFFECT_CLASS (clutter_shader_effect_parent_class);
  parent->paint_target (effect);

}
Пример #15
0
static void
cd_icc_effect_paint_target (ClutterOffscreenEffect *effect)
{
  CdIccEffect *self = CD_ICC_EFFECT (effect);
  ClutterOffscreenEffectClass *parent;
  CoglHandle material;
  CoglHandle color_data;
  CoglHandle indirect_texture;
  GError *error = NULL;

  if (self->program == COGL_INVALID_HANDLE)
    goto out;

  if (self->main_texture_uniform > -1)
    cogl_program_set_uniform_1i (self->program,
                                 self->main_texture_uniform,
                                 0);

  if (self->color_data1_uniform > -1)
    cogl_program_set_uniform_1i (self->program,
                                 self->color_data1_uniform,
                                 1); /* not the layer number, just co-incidence */
  if (self->color_data2_uniform > -1)
    cogl_program_set_uniform_1i (self->program,
                                 self->color_data2_uniform,
                                 2);

  if (self->indirect_texture_uniform > -1)
    cogl_program_set_uniform_1i (self->program,
                                 self->indirect_texture_uniform,
                                 3);

  material = clutter_offscreen_effect_get_target (effect);




  /* get the color textures */
  color_data = cd_icc_effect_generate_cogl_color_data ("/usr/share/color/icc/FakeBRG.icc",
                                                       &error);
  if (color_data == COGL_INVALID_HANDLE)
    {
      g_warning ("Error creating lookup texture: %s", error->message);
      g_error_free (error);
      goto out;
    }

  /* add the texture into the second layer of the material */
  cogl_material_set_layer (material, GCM_FSCM_LAYER_COLOR1, color_data);

  /* we want to use linear interpolation for the texture */
  cogl_material_set_layer_filters (material, GCM_FSCM_LAYER_COLOR1,
                                   COGL_MATERIAL_FILTER_LINEAR,
                                   COGL_MATERIAL_FILTER_LINEAR);

  /* clamp to the maximum values */
  cogl_material_set_layer_wrap_mode (material, GCM_FSCM_LAYER_COLOR1,
                                     COGL_MATERIAL_WRAP_MODE_CLAMP_TO_EDGE);

  cogl_handle_unref (color_data);





  /* get the color textures */
  color_data = cd_icc_effect_generate_cogl_color_data ("/usr/share/color/icc/FakeRBG.icc",
                                                        &error);
  if (color_data == COGL_INVALID_HANDLE)
    {
      g_warning ("Error creating lookup texture: %s", error->message);
      g_error_free (error);
      goto out;
    }

  /* add the texture into the second layer of the material */
  cogl_material_set_layer (material, GCM_FSCM_LAYER_COLOR2, color_data);

  /* we want to use linear interpolation for the texture */
  cogl_material_set_layer_filters (material, GCM_FSCM_LAYER_COLOR2,
                                   COGL_MATERIAL_FILTER_LINEAR,
                                   COGL_MATERIAL_FILTER_LINEAR);

  /* clamp to the maximum values */
  cogl_material_set_layer_wrap_mode (material, GCM_FSCM_LAYER_COLOR2,
                                     COGL_MATERIAL_WRAP_MODE_CLAMP_TO_EDGE);

  cogl_handle_unref (color_data);





  /* get the indirect texture */
  indirect_texture = cd_icc_effect_generate_indirect_data (self, &error);
  if (indirect_texture == COGL_INVALID_HANDLE)
    {
      g_warning ("Error creating indirect texture: %s", error->message);
      g_error_free (error);
      goto out;
    }

  /* add the texture into the second layer of the material */
  cogl_material_set_layer (material, GCM_FSCM_LAYER_INDIRECT, indirect_texture);

  /* we want to use linear interpolation for the texture */
  cogl_material_set_layer_filters (material, GCM_FSCM_LAYER_INDIRECT,
                                   COGL_MATERIAL_FILTER_LINEAR,
                                   COGL_MATERIAL_FILTER_LINEAR);

  /* clamp to the maximum values */
  cogl_material_set_layer_wrap_mode (material, GCM_FSCM_LAYER_INDIRECT,
                                     COGL_MATERIAL_WRAP_MODE_CLAMP_TO_EDGE);

  cogl_handle_unref (indirect_texture);

  cogl_material_set_user_program (material, self->program);

out:
  parent = CLUTTER_OFFSCREEN_EFFECT_CLASS (cd_icc_effect_parent_class);
  parent->paint_target (effect);
}
Пример #16
0
static void
mx_fade_effect_class_init (MxFadeEffectClass *klass)
{
  GParamSpec *pspec;

  ClutterColor transparent = { 0, };
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
  ClutterEffectClass *effect_class = CLUTTER_EFFECT_CLASS (klass);
  ClutterOffscreenEffectClass *offscreen_class =
    CLUTTER_OFFSCREEN_EFFECT_CLASS (klass);

  g_type_class_add_private (klass, sizeof (MxFadeEffectPrivate));

  object_class->get_property = mx_fade_effect_get_property;
  object_class->set_property = mx_fade_effect_set_property;
  object_class->dispose = mx_fade_effect_dispose;
  object_class->finalize = mx_fade_effect_finalize;

  effect_class->pre_paint = mx_fade_effect_pre_paint;
  effect_class->post_paint = mx_fade_effect_post_paint;

  offscreen_class->create_texture = mx_fade_effect_create_texture;
  offscreen_class->paint_target = mx_fade_effect_paint_target;

  pspec = g_param_spec_int ("bounds-x",
                            "Bounds X",
                            "X-coordinate of the texture bounding box",
                            -G_MAXINT, G_MAXINT, 0,
                            MX_PARAM_READWRITE | MX_PARAM_TRANSLATEABLE);
  g_object_class_install_property (object_class, PROP_BOUNDS_X, pspec);

  pspec = g_param_spec_int ("bounds-y",
                            "Bounds Y",
                            "Y-coordinate of the texture bounding boy",
                            -G_MAXINT, G_MAXINT, 0,
                            MX_PARAM_READWRITE | MX_PARAM_TRANSLATEABLE);
  g_object_class_install_property (object_class, PROP_BOUNDS_Y, pspec);

  pspec = g_param_spec_uint ("bounds-width",
                             "Bounds width",
                             "Width of the texture bounding box",
                             0, G_MAXUINT, 0,
                             MX_PARAM_READWRITE | MX_PARAM_TRANSLATEABLE);
  g_object_class_install_property (object_class, PROP_BOUNDS_WIDTH, pspec);

  pspec = g_param_spec_uint ("bounds-height",
                             "Bounds height",
                             "Height of the texture bounding box",
                             0, G_MAXUINT, 0,
                             MX_PARAM_READWRITE | MX_PARAM_TRANSLATEABLE);
  g_object_class_install_property (object_class, PROP_BOUNDS_HEIGHT, pspec);

  pspec = g_param_spec_uint ("border-top",
                             "Border top",
                             "Border at the top of the effect",
                             0, G_MAXUINT, 0,
                             MX_PARAM_READWRITE | MX_PARAM_TRANSLATEABLE);
  g_object_class_install_property (object_class, PROP_BORDER_TOP, pspec);

  pspec = g_param_spec_uint ("border-right",
                             "Border right",
                             "Border at the right of the effect",
                             0, G_MAXUINT, 0,
                             MX_PARAM_READWRITE | MX_PARAM_TRANSLATEABLE);
  g_object_class_install_property (object_class, PROP_BORDER_RIGHT, pspec);

  pspec = g_param_spec_uint ("border-bottom",
                             "Border bottom",
                             "Border at the bottom of the effect",
                             0, G_MAXUINT, 0,
                             MX_PARAM_READWRITE | MX_PARAM_TRANSLATEABLE);
  g_object_class_install_property (object_class, PROP_BORDER_BOTTOM, pspec);

  pspec = g_param_spec_uint ("border-left",
                             "Border left",
                             "Border at the left of the effect",
                             0, G_MAXUINT, 0,
                             MX_PARAM_READWRITE | MX_PARAM_TRANSLATEABLE);
  g_object_class_install_property (object_class, PROP_BORDER_LEFT, pspec);

  pspec = clutter_param_spec_color ("color",
                                    "Color",
                                    "Color of the faded border",
                                    &transparent,
                                    MX_PARAM_READWRITE |
                                    MX_PARAM_TRANSLATEABLE);
  g_object_class_install_property (object_class, PROP_COLOR, pspec);

  pspec = g_param_spec_boolean ("freeze-update",
                                "Freeze update",
                                "Stop updating the offscreen buffer",
                                FALSE,
                                MX_PARAM_READWRITE |
                                MX_PARAM_TRANSLATEABLE);
  g_object_class_install_property (object_class, PROP_FREEZE_UPDATE, pspec);
}