[totem] Bug 514089 – Optimise BVW logo



commit ae841ae633bc6169c0683d4e2d60789c0094ef83
Author: Philip Withnall <philip tecnocode co uk>
Date:   Sat Aug 8 21:58:06 2009 +0100

    Bug 514089 â?? Optimise BVW logo
    
    Only scale the logo pixbuf when necessary, due to now limiting the size of
    the logo to 256px. Closes: bgo#514089

 src/backend/bacon-video-widget-gst-0.10.c |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)
---
diff --git a/src/backend/bacon-video-widget-gst-0.10.c b/src/backend/bacon-video-widget-gst-0.10.c
index 58d12d3..37a74cc 100644
--- a/src/backend/bacon-video-widget-gst-0.10.c
+++ b/src/backend/bacon-video-widget-gst-0.10.c
@@ -696,7 +696,7 @@ bacon_video_widget_expose_event (GtkWidget *widget, GdkEventExpose *event)
     if (pixbuf != NULL) {
       /* draw logo here */
       GdkPixbuf *logo = NULL;
-      gint s_width, s_height, w_width, w_height;
+      gint s_width, s_height, d_width, d_height;
       gfloat ratio;
       GdkRegion *region;
       GdkRectangle rect;
@@ -716,17 +716,17 @@ bacon_video_widget_expose_event (GtkWidget *widget, GdkEventExpose *event)
 
       s_width = gdk_pixbuf_get_width (pixbuf);
       s_height = gdk_pixbuf_get_height (pixbuf);
-      w_width = widget->allocation.width;
-      w_height = widget->allocation.height;
+      d_width = widget->allocation.width;
+      d_height = widget->allocation.height;
 
       /* Limit the width/height to 256Ã?256 pixels, but only if we're displaying the logo proper */
-      if (!bvw->priv->cover_pixbuf && (w_width > LOGO_SIZE || w_height > LOGO_SIZE))
-        w_width = w_height = LOGO_SIZE;
+      if (!bvw->priv->cover_pixbuf && d_width > LOGO_SIZE && d_height > LOGO_SIZE)
+        d_width = d_height = LOGO_SIZE;
 
-      if ((gfloat) w_width / s_width > (gfloat) w_height / s_height) {
-        ratio = (gfloat) w_height / s_height;
+      if ((gfloat) d_width / s_width > (gfloat) d_height / s_height) {
+        ratio = (gfloat) d_height / s_height;
       } else {
-        ratio = (gfloat) w_width / s_width;
+        ratio = (gfloat) d_width / s_width;
       }
 
       s_width *= ratio;
@@ -739,8 +739,11 @@ bacon_video_widget_expose_event (GtkWidget *widget, GdkEventExpose *event)
 	return TRUE;
       }
 
-      logo = gdk_pixbuf_scale_simple (pixbuf,
-          s_width, s_height, GDK_INTERP_BILINEAR);
+      /* Only scale the logo if necessary */
+      if (d_width != LOGO_SIZE || d_height != LOGO_SIZE)
+        logo = gdk_pixbuf_scale_simple (pixbuf, s_width, s_height, GDK_INTERP_BILINEAR);
+      else
+        logo = g_object_ref (pixbuf);
 
       gdk_draw_pixbuf (win, gtk_widget_get_style (widget)->fg_gc[0], logo,
           0, 0, (widget->allocation.width - s_width) / 2, (widget->allocation.height - s_height) / 2,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]