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

Modified Files:
        area.py skin_dischi1.py 
Log Message:
More speed enhancements. It's now faster than the keyboard control :-)


Index: area.py
===================================================================
RCS file: /cvsroot/freevo/freevo/skins/dischi1/area.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** area.py     5 Mar 2003 19:20:45 -0000       1.13
--- area.py     5 Mar 2003 20:08:17 -0000       1.14
***************
*** 10,18 ****
  # This is the main class for all area.
  #
- # My first draft was an area which redraws only the needed parts and
- # blits it onto the surface.. But there are some problems with that,
- # which makes this a little bit difficult. This version redraws too
- # much, but blits only the needed parts on the screen.
- #
  # If you want to create a new Skin_Area, please keep my problems in mind:
  #
--- 10,13 ----
***************
*** 31,40 ****
  # For more informations contact me ([EMAIL PROTECTED])
  #
- #
- # Todo: make it faster -- DONE
- #       code cleanup
- #
  # -----------------------------------------------------------------------
  # $Log$
  # Revision 1.13  2003/03/05 19:20:45  dischi
  # cleanip
--- 26,34 ----
  # For more informations contact me ([EMAIL PROTECTED])
  #
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.14  2003/03/05 20:08:17  dischi
+ # More speed enhancements. It's now faster than the keyboard control :-)
+ #
  # Revision 1.13  2003/03/05 19:20:45  dischi
  # cleanip
***************
*** 133,140 ****
  
  
- background = None
- alpha = None
- 
- 
  class Screen:
      """
--- 127,130 ----
***************
*** 143,151 ****
  
      def __init__(self):
!         self.surface_background  = pygame.Surface((osd.width, osd.height), 1, 32)
!         self.surface_alpha       = self.surface_background.convert_alpha()
!         self.surface_alpha_bg    = self.surface_background.convert()
  
!         self.surface_alpha.fill((0,0,0,0))
  
          self.updatelist = {}
--- 133,141 ----
  
      def __init__(self):
!         self.s_bg       = pygame.Surface((osd.width, osd.height), 1, 32)
!         self.s_alpha    = self.s_bg.convert_alpha()
!         self.s_content  = self.s_bg.convert()
  
!         self.s_alpha.fill((0,0,0,0))
  
          self.updatelist = {}
***************
*** 161,164 ****
--- 151,155 ----
          self.updatelist['background'] = []
          self.updatelist['content']    = []
+ 
          self.drawlist['background'] = []
          self.drawlist['content']    = []
***************
*** 171,209 ****
      def update(self, layer, rect):
          self.updatelist[layer] += [ rect ]
!         
  
      def show(self, force_redraw=FALSE):
          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.surface_alpha.fill((0,0,0,0))
  
              # and redraw all items
!             for obj in self.drawlist['background']:
!                 if obj[0] == 'image':
                      # redraw only the changed parts of the image
                      for x0, y0, x1, y1 in self.updatelist['background']:
!                         self.surface_background.blit(obj[1], (x0, y0),
!                                                      (x0-obj[2], y0-obj[3], x1-x0, 
y1-y0))
  
!                 elif obj[0] == 'rectangle':
!                     x, y, width, height, color, border_size, border_color, radius = 
obj[1:]
!                     osd.drawroundbox(x, y, width, height, color=color,
!                                      border_size=border_size, 
border_color=border_color,
!                                      radius=radius, layer=self.surface_alpha)
  
              # and than blit only the changed parts of the screen
              for x0, y0, x1, y1 in self.updatelist['background']:
!                 self.surface_alpha_bg.blit(self.surface_background, (x0, y0),
!                                            (x0, y0, x1-x0, y1-y0))
!                 self.surface_alpha_bg.blit(self.surface_alpha, (x0, y0),
!                                            (x0, y0, x1-x0, y1-y0))
!                 osd.screen.blit(self.surface_alpha_bg, (x0, y0), (x0, y0, x1-x0, 
y1-y0))
! 
  
  
--- 162,208 ----
      def update(self, layer, rect):
          self.updatelist[layer] += [ rect ]
! 
! 
!     def in_update(self, x1, y1, x2, y2, update_area):
!         for u in update_area:
!             if not (x2 < u[0] or y2 < u[1] or x1 > u[2] or y1 > u[3]):
!                 return TRUE
!         return FALSE
! 
  
      def show(self, force_redraw=FALSE):
+         """
+         the main drawing function
+         """
+ 
          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
                      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))
  
!                 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))
!                 osd.screen.blit(self.s_content, (x0, y0), (x0, y0, x1-x0, y1-y0))
  
  
***************
*** 212,226 ****
              # ... blit back the alphabg surface
              for x0, y0, x1, y1 in self.updatelist['content']:
!                 osd.screen.blit(self.surface_alpha_bg, (x0, y0), (x0, y0, x1-x0, 
y1-y0))
  
          # if something changed redraw all content objects
          if self.updatelist['background'] or self.updatelist['content']:
!             for obj in self.drawlist['content']:
!                 if obj[0] == 'image':
!                     osd.screen.blit(obj[1], obj[2:])
  
!                 elif obj[0] == 'text':
                      ( text, font, x, y, width, height, align_h, align_v,
!                       mode, ellipses ) = obj[1:]
                      if font.shadow.visible:
                          osd.drawstringframed(text, x+font.shadow.x, y+font.shadow.y,
--- 211,226 ----
              # ... 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':
!                     osd.screen.blit(o[1], o[2:])
  
!                 elif o[0] == 'text':
                      ( text, font, x, y, width, height, align_h, align_v,
!                       mode, ellipses ) = o[1:]
                      if font.shadow.visible:
                          osd.drawstringframed(text, x+font.shadow.x, y+font.shadow.y,
***************
*** 248,269 ****
          self.area_val  = None
          self.redraw    = TRUE
-         self.depends   = ()
          self.layout    = None
          self.name      = name
-         
-         # new test stuff:
-         self.background_cache = []
-         self.last_background_cache = []
-         self.content_cache    = []
-         self.last_content_cache    = []
          self.screen = screen
          
          self.imagecache = objectcache.ObjectCache(5, desc='%s_image' % self.name)
  
  
!     def draw(self, settings, menuw, force_redraw):
          """
!         this is the first part of main draw function. This function draws the
!         background, checks if redraws are needed and calls the two update functions
          for the different types of areas
          """
--- 248,267 ----
          self.area_val  = None
          self.redraw    = TRUE
          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(5, desc='%s_image' % self.name)
  
  
!     def draw(self, settings, menuw):
          """
!         this is the main draw function. This function draws the background,
!         checks if redraws are needed and calls the two update functions
          for the different types of areas
          """
***************
*** 273,280 ****
          self.menu = menu
  
!         self.background_cache = []
!         self.content_cache = []
          
!         self.redraw = force_redraw
          self.mode = 0                   # start draw
          
--- 271,278 ----
          self.menu = menu
  
!         self.bg_objects = []
!         self.content_objects = []
          
!         self.redraw = FALSE
          self.mode = 0                   # start draw
          
***************
*** 300,305 ****
                                                old_area.x + old_area.width,
                                                old_area.y + old_area.height))
!             self.last_background_cache = self.background_cache
!             self.last_content_cache = self.content_cache
  
          if not area.visible:
--- 298,303 ----
                                                old_area.x + old_area.width,
                                                old_area.y + old_area.height))
!             self.last_bg_objects      = []
!             self.last_content_objects = []
  
          if not area.visible:
***************
*** 312,319 ****
              # no update needed: return
              if not self.update_content_needed(settings, menuw):
!                 self.content_cache = self.last_content_cache
                  return
  
!         self.mode = 1                   # draw alpha stuff
          self.update_content(settings, menuw)
  
--- 310,317 ----
              # no update needed: return
              if not self.update_content_needed(settings, menuw):
!                 self.content_objects = self.last_content_objects
                  return
  
!         self.mode = 1 # content
          self.update_content(settings, menuw)
  
***************
*** 323,334 ****
          # FIXME: make this simpler:
          
!         for b in self.background_cache:
!             if not b in self.last_background_cache:
                  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_background_cache:
!             if not b in self.background_cache:
                  bg_rect[0] = min(bg_rect[0], b[1])
                  bg_rect[1] = min(bg_rect[1], b[2])
--- 321,332 ----
          # FIXME: make this simpler:
          
!         for b in self.bg_objects:
!             if not b in self.last_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.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])
***************
*** 336,341 ****
                  bg_rect[3] = max(bg_rect[3], b[2] + b[4])
  
!         for b in self.content_cache:
!             if not b in self.last_content_cache:
                  if b[0] == 'rectangle':
                      bg_rect[0] = min(bg_rect[0], b[1])
--- 334,339 ----
                  bg_rect[3] = max(bg_rect[3], b[2] + b[4])
  
!         for b in self.content_objects:
!             if not b in self.last_content_objects:
                  if b[0] == 'rectangle':
                      bg_rect[0] = min(bg_rect[0], b[1])
***************
*** 349,354 ****
                      c_rect[3] = max(c_rect[3], b[2] + b[4])
  
!         for b in self.last_content_cache:
!             if not b in self.content_cache:
                  if b[0] == 'rectangle':
                      bg_rect[0] = min(bg_rect[0], b[1])
--- 347,352 ----
                      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])
***************
*** 367,372 ****
              self.screen.update('content', c_rect)
          
!         self.last_background_cache = self.background_cache
!         self.last_content_cache = self.content_cache
  
  
--- 365,370 ----
              self.screen.update('content', c_rect)
          
!         self.last_bg_objects = self.bg_objects
!         self.last_content_objects = self.content_objects
  
  
***************
*** 509,513 ****
                      
                  if imagefile:
!                     self.background_cache += [ ( 'image', bg.x, bg.y, bg.width, 
bg.height,
                                                   imagefile ) ]
                      cname = '%s-%s-%s' % (imagefile, bg.width, bg.height)
--- 507,511 ----
                      
                  if imagefile:
!                     self.bg_objects += [ ( 'image', bg.x, bg.y, bg.width, bg.height,
                                                   imagefile ) ]
                      cname = '%s-%s-%s' % (imagefile, bg.width, bg.height)
***************
*** 523,527 ****
              elif isinstance(bg, xml_skin.XML_rectangle):
                  self.calc_geometry(bg)
!                 self.background_cache += [ ( 'rectangle', bg.x, bg.y, bg.width,
                                               bg.height, bg.bgcolor, bg.size, 
bg.color,
                                               bg.radius ) ]
--- 521,525 ----
              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 ) ]
***************
*** 535,542 ****
      def drawroundbox(self, x, y, width, height, rect, redraw=TRUE):
          """
!         draw a round box
          """
          if self.mode == 1:
!             self.content_cache += [ ( 'rectangle', x, y, width,
                                        height, rect.bgcolor, rect.size, rect.color,
                                        rect.radius ) ]
--- 533,541 ----
      def drawroundbox(self, x, y, width, height, rect, redraw=TRUE):
          """
!         draw a round box ... or better stores the information about this call
!         in a variable. The real drawing is done inside draw()
          """
          if self.mode == 1:
!             self.content_objects += [ ( 'rectangle', x, y, width,
                                        height, rect.bgcolor, rect.size, rect.color,
                                        rect.radius ) ]
***************
*** 579,583 ****
              height2 = osd.stringsize('Arj', font=font.name, ptsize=font.size)[1] + 10
  
!         self.content_cache += [ ( 'text', x, y, width, height2, height, text, font, 
align_h,
                                    align_v, mode, ellipses ) ]
  
--- 578,582 ----
              height2 = osd.stringsize('Arj', font=font.name, ptsize=font.size)[1] + 10
  
!         self.content_objects += [ ( 'text', x, y, width, height2, height, text, 
font, align_h,
                                    align_v, mode, ellipses ) ]
  
***************
*** 591,595 ****
          if isinstance(val, tuple):
              self.screen.draw('content', ('image', image, val[0], val[1]))
!             self.content_cache += [ ( 'image', val[0], val[1], image.get_width(),
                                        image.get_height(), image ) ]
              
--- 590,594 ----
          if isinstance(val, tuple):
              self.screen.draw('content', ('image', image, val[0], val[1]))
!             self.content_objects += [ ( 'image', val[0], val[1], image.get_width(),
                                        image.get_height(), image ) ]
              

Index: skin_dischi1.py
===================================================================
RCS file: /cvsroot/freevo/freevo/skins/dischi1/skin_dischi1.py,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** skin_dischi1.py     5 Mar 2003 19:20:47 -0000       1.30
--- skin_dischi1.py     5 Mar 2003 20:08:18 -0000       1.31
***************
*** 10,13 ****
--- 10,16 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.31  2003/03/05 20:08:18  dischi
+ # More speed enhancements. It's now faster than the keyboard control :-)
+ #
  # Revision 1.30  2003/03/05 19:20:47  dischi
  # cleanip
***************
*** 257,271 ****
          
  
-     # This function is called from the rc module and other places
-     def HandleEvent(self, ev):
-         # Handle event (remote control, timer, msg display...)
-         # Some events are handled directly (volume control),
-         # RC cmds are handled using the menu lib, and events
-         # might be passed directly to a foreground application
-         # that handles its' own graphics
-         pass
- 
- 
- 
      # Parse XML files with additional settings
      # TODO: parse also parent directories
--- 260,263 ----
***************
*** 413,423 ****
  
      def Clear(self):
          self.force_redraw = TRUE
          osd.clearscreen(osd.COL_BLACK)
          osd.update()
  
!     # Called from the MenuWidget class to draw a menu page on the
!     # screen
      def DrawMenu(self, menuw):
          if not menuw.visible:
              return
--- 405,421 ----
  
      def Clear(self):
+         """
+         clean the screen
+         """
          self.force_redraw = TRUE
          osd.clearscreen(osd.COL_BLACK)
          osd.update()
  
! 
      def DrawMenu(self, menuw):
+         """
+         Called from the MenuWidget class to draw a menu page on the
+         screen
+         """
          if not menuw.visible:
              return
***************
*** 450,454 ****
          for a in self.area_names:
              area = eval('self.%s_area' % a)
!             area.draw(settings, menuw, self.force_redraw)
  
          self.screen.show(self.force_redraw)
--- 448,452 ----
          for a in self.area_names:
              area = eval('self.%s_area' % a)
!             area.draw(settings, menuw)
  
          self.screen.show(self.force_redraw)
***************
*** 460,463 ****
--- 458,487 ----
      def DrawMP3(self, info):
          osd.update()
+ 
+     # TV Guide:
+ 
+     def DrawTVGuide(self):
+         pass
+     
+     def DrawTVGuide_Clear(self):
+         pass
+ 
+     def DrawTVGuide_getExpand(self):
+         pass
+ 
+     def DrawTVGuide_setExpand(self, expand):
+         pass
+ 
+     def DrawTVGuide_View(self, to_view):
+         pass
+ 
+     def DrawTVGuide_Info(self, to_info):
+         pass
+                          
+     def DrawTVGuide_ItemsPerPage(self):
+         return (2,3)
+ 
+     def DrawTVGuide_Listing(self, to_listing):
+         pass
  
      def format_track (self, array):




-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger 
for complex code. Debugging C/C++ programs can leave you feeling lost and 
disoriented. TotalView can help you find your way. Available on major UNIX 
and Linux platforms. Try it free. www.etnus.com
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to