--- src/moblin-netbook.c.old 2009-06-01 21:17:21.000000000 +0530 +++ src/moblin-netbook.c 2009-06-01 23:30:00.000000000 +0530 @@ -1069,6 +1069,49 @@ moblin_netbook_plugin_init (MoblinNetboo priv->info.description = _("Effects for Moblin Netbooks"); } +/* Code inspired from penge-magic-texture.c */ +static void +paint_texture (ClutterActor *actor, int aw, int ah) +{ + CoglHandle *tex; + gint bw, bh; + float v; + float tx1, tx2, ty1, ty2; + ClutterColor col = { 0xff, 0xff, 0xff, 0xff }; + + tex = clutter_texture_get_cogl_texture (CLUTTER_TEXTURE (actor)); + + bw = cogl_texture_get_width (tex); /* base texture width */ + bh = cogl_texture_get_height (tex); /* base texture height */ + + /* no comment */ + if ((float)bw/bh < (float)aw/ah) + { + /* fit width */ + v = (((float)ah * bw) / ((float)aw * bh)) / 2; + tx1 = 0; + tx2 = 1; + ty1 = (0.5 - v); + ty2 = (0.5 + v); + } else { + /* fit height */ + v = (((float)aw * bh) / ((float)ah * bw)) / 2; + tx1 = (0.5 - v); + tx2 = (0.5 + v); + ty1 = 0; + ty2 = 1; + } + + col.alpha = clutter_actor_get_paint_opacity (actor); + cogl_set_source_color4ub (col.red, col.green, col.blue, col.alpha); + cogl_rectangle (0, 0, aw, ah); + cogl_set_source_texture (tex); + cogl_rectangle_with_texture_coords (0, 0, + aw, ah, + tx1, ty1, + tx2, ty2); +} + static void on_desktop_pre_paint (ClutterActor *actor, gpointer data) { @@ -1079,35 +1122,14 @@ on_desktop_pre_paint (ClutterActor *acto float t_w, t_h; guint tex_width, tex_height; guint w, h; + gint screen_width, screen_height; - clutter_actor_get_size (priv->parallax_tex, &w, &h); - - cogl_translate (priv->parallax_paint_offset - (gint)w/4, 0 , 0); - - cogl_texture - = clutter_texture_get_cogl_texture (CLUTTER_TEXTURE(priv->parallax_tex)); + mutter_plugin_query_screen_size (plugin, &screen_width, &screen_height); if (cogl_texture == COGL_INVALID_HANDLE) return; - col.alpha = clutter_actor_get_paint_opacity (actor); - cogl_set_source_color4ub (col.red, - col.green, - col.blue, - col.alpha); - - tex_width = cogl_texture_get_width (cogl_texture); - tex_height = cogl_texture_get_height (cogl_texture); - - t_w = (float) w / tex_width; - t_h = (float) h / tex_height; - - /* Parent paint translated us into position */ - cogl_set_source_texture (cogl_texture); - cogl_rectangle_with_texture_coords (0, 0, - w, h, - 0, 0, - t_w, t_h); + paint_texture (actor, screen_width, screen_height); g_signal_stop_emission_by_name (actor, "paint"); }