Hey,

On Wed, 2009-06-03 at 03:04 -0600, Srinivasa Ragavan wrote:
>Sure?. I see the doc, installed headers everything returning int/guint. 
> I checked the rpm/devel, doc [1].
> 
> > 
> 

Just cleaned up the patch a bit, to avoid too many type casts, as discussed 
with 'ebassi', nothing changed otherwise.

-Srini

--- moblin-netbook.c.old        2009-06-01 21:17:21.000000000 +0530
+++ moblin-netbook.c    2009-06-03 20:12:31.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, float aw, float ah)
+{
+  CoglHandle *tex;
+  float 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 = (float) cogl_texture_get_width (tex); /* base texture width */
+  bh = (float) cogl_texture_get_height (tex); /* base texture height */
+
+  /* no comment */
+  if (bw/bh < aw/ah)
+  {
+    /* fit width */
+    v = ((ah * bw) / (aw * bh)) / 2;
+    tx1 = 0;
+    tx2 = 1;
+    ty1 = (0.5 - v);
+    ty2 = (0.5 + v);
+  } else {
+    /* fit height */
+    v = ((aw * bh) / (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, (float) screen_width, (float) screen_height);
 
   g_signal_stop_emission_by_name (actor, "paint");
 }
_______________________________________________
Moblin dev Mailing List
[email protected]

To manage or unsubscribe from this mailing list visit:
https://lists.moblin.org/mailman/listinfo/dev or your user account on 
http://moblin.org once logged in.

For more information on the Moblin Developer Mailing lists visit:
http://moblin.org/community/mailing-lists

Reply via email to