Revision: 1888
          http://gtkpod.svn.sourceforge.net/gtkpod/?rev=1888&view=rev
Author:   phantom_sf
Date:     2007-12-31 04:03:17 -0800 (Mon, 31 Dec 2007)

Log Message:
-----------
2007-12-30 P.G. Richardson <phantom_sf at users.sourceforge.net>

  * src/display_coverart.h
  * src/display_coverart.c
  
  Visible scaled images are cached to improve performance. Only when
  they are no longer visible is the scaled version unreferenced. If the
  scaled version does not exist then a new scaled version is created as
  usual. Thus, when moving along the collection, only 1 image should
  be scaled when the drawing occurs rather than 9.

Modified Paths:
--------------
    gtkpod/trunk/ChangeLog
    gtkpod/trunk/src/display_coverart.c
    gtkpod/trunk/src/display_coverart.h

Modified: gtkpod/trunk/ChangeLog
===================================================================
--- gtkpod/trunk/ChangeLog      2007-12-31 09:09:57 UTC (rev 1887)
+++ gtkpod/trunk/ChangeLog      2007-12-31 12:03:17 UTC (rev 1888)
@@ -1,3 +1,14 @@
+2007-12-30 P.G. Richardson <phantom_sf at users.sourceforge.net>
+
+  * src/display_coverart.h
+  * src/display_coverart.c
+  
+  Visible scaled images are cached to improve performance. Only when
+  they are no longer visible is the scaled version unreferenced. If the
+  scaled version does not exist then a new scaled version is created as
+  usual. Thus, when moving along the collection, only 1 image should
+  be scaled when the drawing occurs rather than 9.
+
 2007-12-31 Matvey Kozhev <sikon at users.sourceforge.net>
 
   * src/prefs.c:

Modified: gtkpod/trunk/src/display_coverart.c
===================================================================
--- gtkpod/trunk/src/display_coverart.c 2007-12-31 09:09:57 UTC (rev 1887)
+++ gtkpod/trunk/src/display_coverart.c 2007-12-31 12:03:17 UTC (rev 1888)
@@ -422,7 +422,7 @@
        cairo_paint (cairo_context);
        cairo_restore (cairo_context);
        g_free (color);
-       
+               
        Album_Item *album;
        gint i, album_index;
        Cover_Item *cover;
@@ -449,6 +449,11 @@
                {
                        g_object_unref (album->albumart);
                        album->albumart = NULL;
+                       if (album->scaled_art != NULL)
+                       {
+                               g_object_unref (album->scaled_art);
+                               album->scaled_art = NULL;
+                       }
                }
                
                Track *track;
@@ -467,11 +472,14 @@
                
                /* Set the Cover */
                GdkPixbuf *scaled;
-               scaled = gdk_pixbuf_scale_simple (
-                               album->albumart, 
-                               cover->img_width, 
-                               cover->img_height, 
-                               GDK_INTERP_BILINEAR);
+               if (album->scaled_art == NULL)
+                       scaled = gdk_pixbuf_scale_simple (
+                                       album->albumart, 
+                                       cover->img_width, 
+                                       cover->img_height, 
+                                       GDK_INTERP_BILINEAR);
+               else
+                       scaled = album->scaled_art;
 
                gdk_cairo_set_source_pixbuf (
                                cairo_context,
@@ -528,6 +536,31 @@
        }
        
        force_pixbuf_covers = FALSE;
+       
+       /* free the scaled pixbufs from the non visible covers either side of 
the current display.
+        * Experimental feature that should save on memory.
+        */
+       key = g_list_nth_data (album_key_list, cdwidget->first_imgindex - 1);  
+       if (key != NULL)
+       {
+               album  = g_hash_table_lookup (album_hash, key);
+               if (album->scaled_art)
+               {
+                       g_object_unref (album->scaled_art);
+                       album->scaled_art = NULL;
+               }               
+       }
+       
+       key = g_list_nth_data (album_key_list, cdwidget->first_imgindex + 
IMG_TOTAL + 1);
+       if (key != NULL)
+       {
+               album  = g_hash_table_lookup (album_hash, key);
+               if (album->scaled_art)
+               {
+                       g_object_unref (album->scaled_art);
+                       album->scaled_art = NULL;
+               }
+       }
 }
 
 /**
@@ -595,6 +628,7 @@
                                /* Album item not found so create a new one and 
populate */
                                album = g_new0 (Album_Item, 1);
                                album->albumart = NULL;
+                               album->scaled_art = NULL;
                                album->albumname = g_strdup (track->album);
                                album->artist = g_strdup (track->artist);
                                album->tracks = NULL;
@@ -916,6 +950,7 @@
                                /* Album item not found so create a new one and 
populate */
                                album = g_new0 (Album_Item, 1);
                                album->albumart = NULL;
+                               album->scaled_art = NULL;
                                album->albumname = g_strdup (track->album);
                                album->artist = g_strdup (track->artist);
                                album->tracks = NULL;
@@ -1791,6 +1826,11 @@
                /* Nullify so that the album art is picked up from the tracks 
again */
                g_object_unref (cover->album->albumart);
                cover->album->albumart = NULL;
+               if (cover->album->scaled_art != NULL)
+               {
+                       g_object_unref (cover->album->scaled_art);
+                       cover->album->scaled_art = NULL;
+               }
   }
     
   g_free (filename);
@@ -1851,6 +1891,9 @@
                
                if (album->albumart)
                        g_object_unref (album->albumart);
+               
+               if (album->scaled_art)
+                       g_object_unref (album->scaled_art);
        }
 }
 
@@ -2111,6 +2154,11 @@
        }
        /* Nullify so that the album art is picked up from the tracks again */
        cover->album->albumart = NULL;
+       if (cover->album->scaled_art != NULL)
+       {
+               g_object_unref (cover->album->scaled_art);
+               cover->album->scaled_art = NULL;
+       }
                            
        redraw (FALSE);
 

Modified: gtkpod/trunk/src/display_coverart.h
===================================================================
--- gtkpod/trunk/src/display_coverart.h 2007-12-31 09:09:57 UTC (rev 1887)
+++ gtkpod/trunk/src/display_coverart.h 2007-12-31 12:03:17 UTC (rev 1888)
@@ -48,6 +48,7 @@
        gchar *albumname;
        gchar *artist;
        GdkPixbuf *albumart;
+       GdkPixbuf *scaled_art;
 } Album_Item;
 
 typedef struct {


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to