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

Modified Files:
        area.py 
Log Message:
Removed all the lists in lists and list += [ blah ] stuff. I think it is
faster now, at least not slower ;-)


Index: area.py
===================================================================
RCS file: /cvsroot/freevo/freevo/skins/dischi1/area.py,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -d -r1.35 -r1.36
*** area.py     30 Mar 2003 14:13:23 -0000      1.35
--- area.py     31 Mar 2003 19:00:37 -0000      1.36
***************
*** 28,31 ****
--- 28,35 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.36  2003/03/31 19:00:37  dischi
+ # Removed all the lists in lists and list += [ blah ] stuff. I think it is
+ # faster now, at least not slower ;-)
+ #
  # Revision 1.35  2003/03/30 14:13:23  dischi
  # (listing.py from prev. checkin has the wrong log message)
***************
*** 205,208 ****
--- 209,219 ----
  
  
+ class SkinObjects:
+     def __init__(self):
+         self.bgimages   = []
+         self.rectangles = []
+         self.images     = []
+         self.text       = []
+ 
  
  class Screen:
***************
*** 222,228 ****
          self.updatelist['content']    = []
  
!         self.drawlist = {}
!         self.drawlist['background'] = []
!         self.drawlist['content']    = []
  
          
--- 233,237 ----
          self.updatelist['content']    = []
  
!         self.drawlist = []
  
          
***************
*** 231,240 ****
          self.updatelist['content']    = []
  
!         self.drawlist['background'] = []
!         self.drawlist['content']    = []
  
  
!     def draw(self, layer, obj):
!         self.drawlist[layer] += [ obj ]
  
  
--- 240,248 ----
          self.updatelist['content']    = []
  
!         self.drawlist = []
  
  
!     def draw(self, obj):
!         self.drawlist.append(obj)
  
  
***************
*** 255,287 ****
          """
  
          if force_redraw:
              self.updatelist['background'] = [ (0,0,osd.width, osd.height) ]
              self.updatelist['content']    = []
  
          # if the background has some changes ...
!         if self.updatelist['background']:
              # ... clear it ...
              self.s_alpha.fill((0,0,0,0))
  
              # and redraw all items
!             for o in self.drawlist['background']:
!                 if o[0] == 'image':
!                     # redraw only the changed parts of the image (BROKEN)
!                     # for x0, y0, x1, y1 in self.updatelist['background']:
!                     # self.s_bg.blit(o[1], (x0, y0), (x0-o[2], y0-o[3], x1-x0, 
y1-y0))
!                     if self.in_update(o[2], o[3], o[2]+o[4], o[3]+o[5],
!                                       self.updatelist['background']):
!                         self.s_bg.blit(o[1], o[2:4])
  
!                 elif o[0] == 'rectangle':
!                     x1, y1, x2, y2, color, border_size, border_color, radius = o[1:]
!                     # only redraw if necessary
!                     if self.in_update(x1, y1, x2, y2, self.updatelist['background']):
!                         osd.drawroundbox(x1, y1, x2, y2, color=color,
!                                          border_size=border_size, 
border_color=border_color,
!                                          radius=radius, layer=self.s_alpha)
  
              # and than blit only the changed parts of the screen
!             for x0, y0, x1, y1 in self.updatelist['background']:
                  self.s_content.blit(self.s_bg, (x0, y0), (x0, y0, x1-x0, y1-y0))
                  self.s_content.blit(self.s_alpha, (x0, y0), (x0, y0, x1-x0, y1-y0))
--- 263,302 ----
          """
  
+         objects = SkinObjects()
+         for area in self.drawlist:
+             objects.bgimages   += area.bgimages
+             objects.rectangles += area.rectangles
+             objects.images     += area.images
+             objects.text       += area.text
+             
          if force_redraw:
              self.updatelist['background'] = [ (0,0,osd.width, osd.height) ]
              self.updatelist['content']    = []
  
+ 
+         update_area = self.updatelist['background']
+ 
          # if the background has some changes ...
!         if update_area:
              # ... clear it ...
              self.s_alpha.fill((0,0,0,0))
  
              # and redraw all items
!             for x1, y1, x2, y2, image in objects.bgimages:
!                 # redraw only the changed parts of the image (BROKEN)
!                 # for x0, y0, x1, y1 in self.updatelist['background']:
!                 # self.s_bg.blit(o[1], (x0, y0), (x0-o[2], y0-o[3], x1-x0, y1-y0))
!                 if self.in_update(x1, y1, x2, y2, update_area):
!                     self.s_bg.blit(image, (x1, y1))
  
!             for x1, y1, x2, y2, bgcolor, size, color, radius in objects.rectangles:
!                 # only redraw if necessary
!                 if self.in_update(x1, y1, x2, y2, update_area):
!                     osd.drawroundbox(x1, y1, x2, y2, color=bgcolor,
!                                      border_size=size, border_color=color,
!                                      radius=radius, layer=self.s_alpha)
  
              # and than blit only the changed parts of the screen
!             for x0, y0, x1, y1 in update_area:
                  self.s_content.blit(self.s_bg, (x0, y0), (x0, y0, x1-x0, y1-y0))
                  self.s_content.blit(self.s_alpha, (x0, y0), (x0, y0, x1-x0, y1-y0))
***************
*** 289,324 ****
  
  
          # if the content has changed ...
!         if self.updatelist['content']:
              # ... blit back the alphabg surface
!             for x0, y0, x1, y1 in self.updatelist['content']:
                  osd.screen.blit(self.s_content, (x0, y0), (x0, y0, x1-x0, y1-y0))
  
  
          # if something changed redraw all content objects
!         if self.updatelist['background'] or self.updatelist['content']:
!             for o in self.drawlist['content']:
!                 if o[0] == 'image':
!                     if self.in_update(o[2], o[3], o[2]+o[4], o[3]+o[5],
!                                       self.updatelist['background'] + \
!                                       self.updatelist['content']):
!                         osd.screen.blit(o[1], o[2:4])
  
!                 elif o[0] == 'text':
!                     ( text, font, x, y, width, height, update_height, align_h, 
align_v,
!                       mode, ellipses ) = o[1:]
!                     if self.in_update(x, y, x+width+10, y+update_height,
!                                       self.updatelist['background'] + \
!                                       self.updatelist['content']):
!                         if font.shadow.visible:
!                             osd.drawstringframed(text, x+font.shadow.x, 
y+font.shadow.y,
!                                                  width, height, font.shadow.color, 
None,
!                                                  font=font.name, ptsize=font.size,
!                                                  align_h = align_h, align_v = 
align_v,
!                                                  mode=mode, ellipses=ellipses)
!                         osd.drawstringframed(text, x, y, width, height, font.color, 
None,
                                               font=font.name, ptsize=font.size,
                                               align_h = align_h, align_v = align_v,
                                               mode=mode, ellipses=ellipses)
  
  
--- 304,341 ----
  
  
+         update_area = self.updatelist['content']
+             
          # if the content has changed ...
!         if update_area:
              # ... blit back the alphabg surface
!             for x0, y0, x1, y1 in update_area:
                  osd.screen.blit(self.s_content, (x0, y0), (x0, y0, x1-x0, y1-y0))
  
  
+         update_area = self.updatelist['background'] + self.updatelist['content']
+ 
          # if something changed redraw all content objects
!         if update_area:
!             for x1, y1, x2, y2, image in objects.images:
!                 # redraw only the changed parts of the image (BROKEN)
!                 # for x0, y0, x1, y1 in self.updatelist['background']:
!                 # self.s_bg.blit(o[1], (x0, y0), (x0-o[2], y0-o[3], x1-x0, y1-y0))
!                 if self.in_update(x1, y1, x2, y2, update_area):
!                     osd.screen.blit(image, (x1, y1))
  
!             for x1, y1, x2, y2, text, font, height, align_h, align_v, mode, \
!                 ellipses in objects.text:
!                 if self.in_update(x1, y1, x2, y2, update_area):
!                     width = x2 - x1
!                     if font.shadow.visible:
!                         osd.drawstringframed(text, x1+font.shadow.x, 
y1+font.shadow.y,
!                                              width, height, font.shadow.color, None,
                                               font=font.name, ptsize=font.size,
                                               align_h = align_h, align_v = align_v,
                                               mode=mode, ellipses=ellipses)
+                     osd.drawstringframed(text, x1, y1, width, height, font.color, 
None,
+                                          font=font.name, ptsize=font.size,
+                                          align_h = align_h, align_v = align_v,
+                                          mode=mode, ellipses=ellipses)
  
  
***************
*** 333,336 ****
--- 350,354 ----
  
  
+ 
  class Skin_Area:
      """
***************
*** 347,356 ****
          self.layout    = None
          self.name      = name
!         self.screen = screen
!         
!         self.bg_objects           = []
!         self.last_bg_objects      = []
!         self.content_objects      = []
!         self.last_content_objects = []
          
          self.imagecache = objectcache.ObjectCache(imagecachesize,
--- 365,370 ----
          self.layout    = None
          self.name      = name
!         self.screen    = screen
!         self.objects   = SkinObjects()
          
          self.imagecache = objectcache.ObjectCache(imagecachesize,
***************
*** 393,402 ****
              self.viewitem = obj
              self.infoitem = obj
!             
!         self.bg_objects = []
!         self.content_objects = []
          
          self.redraw = force_redraw
-         self.mode = 0                   # start draw
          
          area = self.area_val
--- 407,414 ----
              self.viewitem = obj
              self.infoitem = obj
! 
!         self.tmp_objects = SkinObjects()
          
          self.redraw = force_redraw
          
          area = self.area_val
***************
*** 420,427 ****
                                                old_area.x + old_area.width,
                                                old_area.y + old_area.height))
!             self.last_bg_objects      = []
!             self.last_content_objects = []
  
          if not area.visible or not self.layout:
              return
  
--- 432,439 ----
                                                old_area.x + old_area.width,
                                                old_area.y + old_area.height))
!             self.objects = SkinObjects()
  
          if not area.visible or not self.layout:
+             self.objects = SkinObjects()
              return
  
***************
*** 432,489 ****
              # no update needed: return
              if not self.update_content_needed():
!                 self.content_objects = self.last_content_objects
!                 for o in self.content_objects:
!                     self.screen.draw(o[5][0], o[5][1])
                  return
  
-         self.mode = 1 # content
          self.update_content()
  
!         bg_rect = [ osd.width, osd.height, 0, 0 ]
!         c_rect  = [ osd.width, osd.height, 0, 0 ]
  
!         for b in self.bg_objects:
              try:
!                 self.last_bg_objects.remove(b)
              except ValueError:
!                 bg_rect[0] = min(bg_rect[0], b[1])
!                 bg_rect[1] = min(bg_rect[1], b[2])
!                 bg_rect[2] = max(bg_rect[2], b[1] + b[3])
!                 bg_rect[3] = max(bg_rect[3], b[2] + b[4])
!                 
!         for b in self.last_bg_objects:
!             if not b in self.bg_objects:
!                 bg_rect[0] = min(bg_rect[0], b[1])
!                 bg_rect[1] = min(bg_rect[1], b[2])
!                 bg_rect[2] = max(bg_rect[2], b[1] + b[3])
!                 bg_rect[3] = max(bg_rect[3], b[2] + b[4])
  
!         for b in self.content_objects:
              try:
!                 self.last_content_objects.remove(b)
              except ValueError:
!                 if b[0] == 'rectangle':
!                     bg_rect[0] = min(bg_rect[0], b[1])
!                     bg_rect[1] = min(bg_rect[1], b[2])
!                     bg_rect[2] = max(bg_rect[2], b[1] + b[3])
!                     bg_rect[3] = max(bg_rect[3], b[2] + b[4])
!                 if b[0] == 'image' or b[0] == 'text':
!                     c_rect[0] = min(c_rect[0], b[1])
!                     c_rect[1] = min(c_rect[1], b[2])
!                     c_rect[2] = max(c_rect[2], b[1] + b[3])
!                     c_rect[3] = max(c_rect[3], b[2] + b[4])
  
-         for b in self.last_content_objects:
-             if not b in self.content_objects:
-                 if b[0] == 'rectangle':
-                     bg_rect[0] = min(bg_rect[0], b[1])
-                     bg_rect[1] = min(bg_rect[1], b[2])
-                     bg_rect[2] = max(bg_rect[2], b[1] + b[3])
-                     bg_rect[3] = max(bg_rect[3], b[2] + b[4])
-                 if b[0] == 'image' or b[0] == 'text':
-                     c_rect[0] = min(c_rect[0], b[1])
-                     c_rect[1] = min(c_rect[1], b[2])
-                     c_rect[2] = max(c_rect[2], b[1] + b[3])
-                     c_rect[3] = max(c_rect[3], b[2] + b[4])
  
          if bg_rect[0] < bg_rect[2]:
--- 444,511 ----
              # no update needed: return
              if not self.update_content_needed():
!                 self.screen.draw(self.objects)
                  return
  
          self.update_content()
  
!         bg_rect = ( osd.width, osd.height, 0, 0 )
!         c_rect  = ( osd.width, osd.height, 0, 0 )
  
! 
!         for b in self.tmp_objects.bgimages:
              try:
!                 self.objects.bgimages.remove(b)
              except ValueError:
!                 bg_rect = ( min(bg_rect[0], b[0]), min(bg_rect[1], b[1]),
!                             max(bg_rect[2], b[2]), max(bg_rect[3], b[3]) )
  
!         for b in self.objects.bgimages:
!             if not b in self.tmp_objects.bgimages:
!                 bg_rect = ( min(bg_rect[0], b[0]), min(bg_rect[1], b[1]),
!                             max(bg_rect[2], b[2]), max(bg_rect[3], b[3]) )
! 
! 
! 
!         for b in self.tmp_objects.rectangles:
              try:
!                 self.objects.rectangles.remove(b)
              except ValueError:
!                 bg_rect = ( min(bg_rect[0], b[0]), min(bg_rect[1], b[1]),
!                             max(bg_rect[2], b[2]), max(bg_rect[3], b[3]) )
! 
!         for b in self.objects.rectangles:
!             if not b in self.tmp_objects.rectangles:
!                 bg_rect = ( min(bg_rect[0], b[0]), min(bg_rect[1], b[1]),
!                             max(bg_rect[2], b[2]), max(bg_rect[3], b[3]) )
! 
! 
! 
!         for b in self.tmp_objects.images:
!             try:
!                 self.objects.images.remove(b)
!             except ValueError:
!                 c_rect = ( min(c_rect[0], b[0]), min(c_rect[1], b[1]),
!                            max(c_rect[2], b[2]), max(c_rect[3], b[3]) )
! 
!         for b in self.objects.images:
!             if not b in self.tmp_objects.images:
!                 c_rect = ( min(c_rect[0], b[0]), min(c_rect[1], b[1]),
!                            max(c_rect[2], b[2]), max(c_rect[3], b[3]) )
! 
! 
! 
!         for b in self.tmp_objects.text:
!             try:
!                 self.objects.text.remove(b)
!             except ValueError:
!                 c_rect = ( min(c_rect[0], b[0]), min(c_rect[1], b[1]),
!                            max(c_rect[2], b[2]), max(c_rect[3], b[3]) )
! 
!         for b in self.objects.text:
!             if not b in self.tmp_objects.text:
!                 c_rect = ( min(c_rect[0], b[0]), min(c_rect[1], b[1]),
!                            max(c_rect[2], b[2]), max(c_rect[3], b[3]) )
! 
  
  
          if bg_rect[0] < bg_rect[2]:
***************
*** 496,501 ****
              self.screen.update('content', c_rect)
  
!         self.last_bg_objects = self.bg_objects
!         self.last_content_objects = self.content_objects
  
  
--- 518,524 ----
              self.screen.update('content', c_rect)
  
! 
!         self.objects = self.tmp_objects
!         self.screen.draw(self.objects)
  
  
***************
*** 595,601 ****
          else:
              # get the correct <menu>
!             if settings.menu.has_key(display_type):
                  area = settings.menu[display_type]
!             else:
                  area = settings.menu['default']
  
--- 618,624 ----
          else:
              # get the correct <menu>
!             try:
                  area = settings.menu[display_type]
!             except:
                  area = settings.menu['default']
  
***************
*** 650,663 ****
          area = self.area_val
  
-         redraw_watermark = self.redraw
          last_watermark = None
  
          if hasattr(self, 'watermark') and self.watermark:
!             last_watermark = self.watermark[4]
!             #if self.menu.selected.image != self.watermark[4]:
            if hasattr(self.menu.selected,'image') and \
!                self.menu.selected.image != self.watermark[4]:
                  self.watermark = None
!                 redraw_watermark = TRUE
              
          for bg in copy.deepcopy(self.layout.background):
--- 673,685 ----
          area = self.area_val
  
          last_watermark = None
  
          if hasattr(self, 'watermark') and self.watermark:
!             last_watermark = self.watermark
! 
            if hasattr(self.menu.selected,'image') and \
!                self.menu.selected.image != self.watermark:
                  self.watermark = None
!                 self.redraw = TRUE
              
          for bg in copy.deepcopy(self.layout.background):
***************
*** 678,683 ****
                      if last_watermark != imagefile:
                          self.redraw = TRUE
!                         redraw_watermark = TRUE
!                     self.watermark = (bg.x, bg.y, bg.width, bg.height, imagefile)
                  else:
                      imagefile = bg.filename
--- 700,704 ----
                      if last_watermark != imagefile:
                          self.redraw = TRUE
!                     self.watermark = imagefile
                  else:
                      imagefile = bg.filename
***************
*** 687,692 ****
                      
                  if imagefile:
-                     self.bg_objects += [ ( 'image', bg.x, bg.y, bg.width, bg.height,
-                                                  imagefile ) ]
                      cname = '%s-%s-%s' % (imagefile, bg.width, bg.height)
                      image = self.imagecache[cname]
--- 708,711 ----
***************
*** 697,711 ****
                              self.imagecache[cname] = image
                      if image:
!                         self.draw_image(image, bg, redraw=redraw_watermark)
                              
              elif isinstance(bg, xml_skin.XML_rectangle):
                  self.calc_geometry(bg)
!                 self.bg_objects += [ ( 'rectangle', bg.x, bg.y, bg.width,
!                                              bg.height, bg.bgcolor, bg.size, 
bg.color,
!                                              bg.radius ) ]
!                 self.drawroundbox(bg.x, bg.y, bg.width, bg.height, bg, 
redraw=self.redraw)
  
-         if redraw_watermark:
-             self.redraw = TRUE
              
  
--- 716,725 ----
                              self.imagecache[cname] = image
                      if image:
!                         self.draw_image(image, bg)
                              
              elif isinstance(bg, xml_skin.XML_rectangle):
                  self.calc_geometry(bg)
!                 self.drawroundbox(bg.x, bg.y, bg.width, bg.height, bg)
  
              
  
***************
*** 716,726 ****
          """
  
!         draw = ('background', ('rectangle', x, y, x+width, y+height, rect.bgcolor,
!                                rect.size, rect.color, rect.radius))
!         if self.mode == 1:
!             self.content_objects += [ ( 'rectangle', x, y, width, height, draw ) ]
!             
!         self.screen.draw(draw[0], draw[1])
! 
  
              
--- 730,735 ----
          """
  
!         self.tmp_objects.rectangles.append(( x, y, x + width, y + height, 
rect.bgcolor,
!                                              rect.size, rect.color, rect.radius ))
  
              
***************
*** 759,765 ****
              height2 = font.h + 2
  
-         draw = ('content', ('text', text, font, x, y, width, height, height2,
-                             align_h, align_v, mode, ellipses ))
- 
          if return_area:
              ret = osd.drawstringframed(text, x, y, width, height, None, None,
--- 768,771 ----
***************
*** 768,773 ****
                                         mode=mode, ellipses=ellipses, 
layer=self.dummy_layer)
  
!         self.screen.draw(draw[0], draw[1])
!         self.content_objects += [ ( 'text', x, y, width, height2, draw) ]
  
          if return_area:
--- 774,779 ----
                                         mode=mode, ellipses=ellipses, 
layer=self.dummy_layer)
  
!         self.tmp_objects.text.append((x, y, x+width, y+height2, text, font, height,
!                                             align_h, align_v, mode, ellipses ))
  
          if return_area:
***************
*** 799,803 ****
  
          
!     def draw_image(self, image, val, redraw=TRUE):
          """
          draws an image ... or better stores the information about this call
--- 805,809 ----
  
          
!     def draw_image(self, image, val):
          """
          draws an image ... or better stores the information about this call
***************
*** 815,834 ****
          
          if isinstance(val, tuple):
!             draw = ( 'content', ('image', image, val[0], val[1], image.get_width(),
!                                  image.get_height()) )
!             
!             self.screen.draw(draw[0], draw[1])
!             self.content_objects += [ ( 'image', val[0], val[1], image.get_width(),
!                                       image.get_height(), draw ) ]
              return
          
          elif hasattr(val, 'label') and val.label == 'background':
!             draw = ( 'background', ('image', image, val.x, val.y, val.width,
!                                     val.height) )
          else:
!             draw = ( 'content', ('image', image, val.x, val.y, val.width,
!                                          val.height))
! 
!         self.screen.draw(draw[0], draw[1])
!         self.content_objects += [ ( 'image', val.x, val.y, val.width,
!                                     val.height, draw ) ]
--- 821,832 ----
          
          if isinstance(val, tuple):
!             self.tmp_objects.images.append((val[0], val[1], val[0] + 
image.get_width(),
!                                             val[1] + image.get_height(), image))
              return
          
          elif hasattr(val, 'label') and val.label == 'background':
!             self.tmp_objects.bgimages.append((val.x, val.y, val.x + val.width,
!                                              val.y + val.height, image))
          else:
!             self.tmp_objects.images.append((val.x, val.y, val.x + val.width,
!                                             val.y + val.height, image))




-------------------------------------------------------
This SF.net email is sponsored by: ValueWeb: 
Dedicated Hosting for just $79/mo with 500 GB of bandwidth! 
No other company gives more support or power for your dedicated server
http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to