Update of /cvsroot/freevo/freevo/skins/dischi1
In directory sc8-pr-cvs1:/tmp/cvs-serv18779

Modified Files:
        area.py listing_area.py skin_utils.py tvlisting_area.py 
Log Message:
cache images inside the area and some bugfixes to speed up things


Index: area.py
===================================================================
RCS file: /cvsroot/freevo/freevo/skins/dischi1/area.py,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** area.py     18 Mar 2003 09:37:00 -0000      1.25
--- area.py     19 Mar 2003 11:00:22 -0000      1.26
***************
*** 28,31 ****
--- 28,34 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.26  2003/03/19 11:00:22  dischi
+ # cache images inside the area and some bugfixes to speed up things
+ #
  # Revision 1.25  2003/03/18 09:37:00  dischi
  # Added viewitem and infoitem to the menu to set an item which image/info
***************
*** 286,290 ****
      """
  
!     def __init__(self, name, screen):
          self.area_name = name
          self.area_val  = None
--- 289,293 ----
      """
  
!     def __init__(self, name, screen, imagecachesize=5):
          self.area_name = name
          self.area_val  = None
***************
*** 299,303 ****
          self.last_content_objects = []
          
!         self.imagecache = objectcache.ObjectCache(5, desc='%s_image' % self.name)
          self.dummy_layer = pygame.Surface((osd.width, osd.height), 1, 32)
  
--- 302,307 ----
          self.last_content_objects = []
          
!         self.imagecache = objectcache.ObjectCache(imagecachesize,
!                                                   desc='%s_image' % self.name)
          self.dummy_layer = pygame.Surface((osd.width, osd.height), 1, 32)
  
***************
*** 424,428 ****
          if bg_rect[0] < bg_rect[2]:
              self.screen.update('background', bg_rect)
!         if c_rect[0] < c_rect[2]:
              self.screen.update('content', c_rect)
          
--- 428,436 ----
          if bg_rect[0] < bg_rect[2]:
              self.screen.update('background', bg_rect)
!             if c_rect[0] < c_rect[2] and \
!                not (c_rect[0] >= bg_rect[0] and c_rect[1] >= bg_rect[1] and \
!                     c_rect[2] <= bg_rect[2] and c_rect[3] <= bg_rect[3]):
!                 self.screen.update('content', c_rect)
!         elif c_rect[0] < c_rect[2]:
              self.screen.update('content', c_rect)
          
***************
*** 658,662 ****
          height2 = height
          if height2 == -1:
!             height2 = font.h + 10
  
          self.screen.draw('content', ('text', text, font, x, y, width, height, 
height2,
--- 666,670 ----
          height2 = height
          if height2 == -1:
!             height2 = font.h + 2
  
          self.screen.draw('content', ('text', text, font, x, y, width, height, 
height2,

Index: listing_area.py
===================================================================
RCS file: /cvsroot/freevo/freevo/skins/dischi1/listing_area.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** listing_area.py     16 Mar 2003 19:36:05 -0000      1.10
--- listing_area.py     19 Mar 2003 11:00:24 -0000      1.11
***************
*** 10,13 ****
--- 10,16 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.11  2003/03/19 11:00:24  dischi
+ # cache images inside the area and some bugfixes to speed up things
+ #
  # Revision 1.10  2003/03/16 19:36:05  dischi
  # Adjustments to the new xml_parser, added listing type 'image+text' to
***************
*** 79,84 ****
          Skin_Area.__init__(self, 'listing', screen)
          self.last_choices = ( None, None )
! 
! 
      def get_items_geometry(self, settings, menu, display_style):
          """
--- 82,87 ----
          Skin_Area.__init__(self, 'listing', screen)
          self.last_choices = ( None, None )
!         self.last_get_items_geometry = [ None, None ]
!         
      def get_items_geometry(self, settings, menu, display_style):
          """
***************
*** 93,100 ****
          self.init_vars(settings, menu.item_types)
  
!         layout    = self.layout
!         area      = self.area_val
!         content   = self.calc_geometry(layout.content, copy_object=TRUE)
  
          if content.type == 'text':
              items_w = content.width
--- 96,106 ----
          self.init_vars(settings, menu.item_types)
  
!         content   = self.calc_geometry(self.layout.content, copy_object=TRUE)
  
+         if self.last_get_items_geometry[0] == ( menu, content, display_style ):
+             return self.last_get_items_geometry[1]
+         
+         self.last_get_items_geometry[0] = ( menu, content, display_style )
+         
          if content.type == 'text':
              items_w = content.width
***************
*** 181,186 ****
  
          # return cols, rows, item_w, item_h, content.width
!         return (cols, rows, items_w + content.spacing,
!                 items_h + content.spacing, -hskip, -vskip, width)
  
  
--- 187,195 ----
  
          # return cols, rows, item_w, item_h, content.width
!         self.last_get_items_geometry[1] = (cols, rows, items_w + content.spacing,
!                                            items_h + content.spacing, -hskip, -vskip,
!                                            width)
! 
!         return self.last_get_items_geometry[1]
  
  
***************
*** 249,256 ****
              if content.type == 'text':
                  if choice.icon:
!                     image = osd.loadbitmap(choice.icon)
                      if image:
-                         image = pygame.transform.scale(image, 
(vspace-content.spacing,
-                                                                
vspace-content.spacing))
                          self.draw_image(image, (x0, y0))
                          icon_x = vspace
--- 258,271 ----
              if content.type == 'text':
                  if choice.icon:
!                     cname = '%s-%s-%s' % (choice.icon, vspace-content.spacing,
!                                           vspace-content.spacing)
!                     image = self.imagecache[cname]
!                     if not image:
!                         image = osd.loadbitmap(choice.icon)
!                         if image:
!                             image = pygame.transform.scale(image, 
(vspace-content.spacing,
!                                                                    
vspace-content.spacing))
!                             self.imagecache[cname] = image
                      if image:
                          self.draw_image(image, (x0, y0))
                          icon_x = vspace

Index: skin_utils.py
===================================================================
RCS file: /cvsroot/freevo/freevo/skins/dischi1/skin_utils.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** skin_utils.py       15 Mar 2003 17:25:24 -0000      1.6
--- skin_utils.py       19 Mar 2003 11:00:29 -0000      1.7
***************
*** 10,13 ****
--- 10,16 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.7  2003/03/19 11:00:29  dischi
+ # cache images inside the area and some bugfixes to speed up things
+ #
  # Revision 1.6  2003/03/15 17:25:24  dischi
  # don't scale forced images
***************
*** 59,66 ****
--- 62,78 ----
  import osd
  import os
+ import objectcache
  
  osd = osd.get_singleton()
  
+ format_imagecache = objectcache.ObjectCache(20, desc='fomat_image')
+ 
  def format_image(settings, item, width, height, force=0):
+     cname = '%s-%s-%s-%s' % (item, width, height, force)
+     cimage = format_imagecache[cname]
+ 
+     if cimage:
+         return cimage
+     
      if hasattr(item, 'display_type'):
          type = item.display_type
***************
*** 119,122 ****
              height = int(float(width * i_h) / i_w)
  
!     return pygame.transform.scale(image, (width, height))
      
--- 131,136 ----
              height = int(float(width * i_h) / i_w)
  
!     cimage = pygame.transform.scale(image, (width, height))
!     format_imagecache[cname] = cimage
!     return cimage
      

Index: tvlisting_area.py
===================================================================
RCS file: /cvsroot/freevo/freevo/skins/dischi1/tvlisting_area.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** tvlisting_area.py   16 Mar 2003 19:36:07 -0000      1.6
--- tvlisting_area.py   19 Mar 2003 11:00:31 -0000      1.7
***************
*** 10,13 ****
--- 10,16 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.7  2003/03/19 11:00:31  dischi
+ # cache images inside the area and some bugfixes to speed up things
+ #
  # Revision 1.6  2003/03/16 19:36:07  dischi
  # Adjustments to the new xml_parser, added listing type 'image+text' to
***************
*** 81,85 ****
  
      def __init__(self, parent, screen):
!         Skin_Area.__init__(self, 'listing', screen)
          self.last_choices = ( None, None )
          self.last_settings = None
--- 84,88 ----
  
      def __init__(self, parent, screen):
!         Skin_Area.__init__(self, 'listing', screen, imagecachesize=20)
          self.last_choices = ( None, None )
          self.last_settings = None
***************
*** 216,220 ****
              x1 = int(x_contents + (float(w_contents) / n_cols) * (i+1))
              ty0 = content.y
!            
              if head_val.rectangle:
                  r = self.get_item_rectangle(head_val.rectangle, x1-x0, 
head_font.h)[2]
--- 219,223 ----
              x1 = int(x_contents + (float(w_contents) / n_cols) * (i+1))
              ty0 = content.y
! 
              if head_val.rectangle:
                  r = self.get_item_rectangle(head_val.rectangle, x1-x0, 
head_font.h)[2]
***************
*** 245,255 ****
              tx0 = content.x
  
-             channel_logo = config.TV_LOGOS + '/' + to_listing[i].id + '.png'
-             if os.path.isfile(channel_logo):
-                 channel_logo = osd.loadbitmap(channel_logo)
-             else:
-                 channel_logo = None
- 
- 
              logo_geo = [ tx0, ty0, label_width, font_h ]
              
--- 248,251 ----
***************
*** 265,281 ****
                  self.drawroundbox(tx0 + r.x, ty0 + r.y, r.width, r.height, r)
                  
!                 if channel_logo:
!                     logo_geo =[ tx0+r.x+r.size, ty0+r.y+r.size, r.width-2*r.size,
!                                 r.height-2*r.size ]
                      
  
!             if channel_logo:
!                 i_w, i_h = channel_logo.get_size()
!                 if int(float(logo_geo[2] * i_h) / i_w) > logo_geo[3]:
!                     logo_geo[2] = int(float(logo_geo[3] * i_w) / i_h)
                  else:
!                     logo_geo[3] = int(float(logo_geo[2] * i_h) / i_w)
                      
!                 channel_logo = pygame.transform.scale(channel_logo, logo_geo[2:])
                  self.draw_image(channel_logo, (logo_geo[0], logo_geo[1]))
  
--- 261,291 ----
                  self.drawroundbox(tx0 + r.x, ty0 + r.y, r.width, r.height, r)
                  
!                 logo_geo =[ tx0+r.x+r.size, ty0+r.y+r.size, r.width-2*r.size,
!                             r.height-2*r.size ]
                      
  
!             channel_logo = config.TV_LOGOS + '/' + to_listing[i].id + '.png'
!             if os.path.isfile(channel_logo):
!                 image = self.imagecache[to_listing[i].id]
!                 if image:
!                     channel_logo = image
                  else:
!                     image = osd.loadbitmap(channel_logo)
!                     if image:
!                         i_w, i_h = image.get_size()
!                         if int(float(logo_geo[2] * i_h) / i_w) > logo_geo[3]:
!                             logo_geo[2] = int(float(logo_geo[3] * i_w) / i_h)
!                         else:
!                             logo_geo[3] = int(float(logo_geo[2] * i_h) / i_w)
                      
!                         channel_logo = pygame.transform.scale(image, logo_geo[2:])
!                         self.imagecache[to_listing[i].id] = channel_logo
!                     else:
!                         channel_logo = None
!             else:
!                 channel_logo = None
! 
! 
!             if channel_logo:
                  self.draw_image(channel_logo, (logo_geo[0], logo_geo[1]))
  




-------------------------------------------------------
This SF.net email is sponsored by: Does your code think in ink? 
You could win a Tablet PC. Get a free Tablet PC hat just for playing. 
What are you waiting for?
http://ads.sourceforge.net/cgi-bin/redirect.pl?micr5043en
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to