Update of /cvsroot/freevo/freevo/lib/mevas/mevas
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10381

Modified Files:
        container.py 
Log Message:
speed enhancements
o don't use optimize_for_rendering if too much changed (FIXME, bad hack)
o replace some list += [ foo ] to list.append(foo)
o remove one enhancement for invisible children to make them not dirty
  (see FIXME comment for details)


Index: container.py
===================================================================
RCS file: /cvsroot/freevo/freevo/lib/mevas/mevas/container.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** container.py        23 Aug 2004 13:51:17 -0000      1.6
--- container.py        10 Sep 2004 19:00:47 -0000      1.7
***************
*** 73,77 ****
                        x, y = o._backing_store_info["pos"]
                        w, h = o._backing_store_info["size"]
!                       self._backing_store_info["dirty-rects"] += [( (x, y), (w, h) )]
                        #print "Child delete", o,  
self._backing_store_info["dirty-rects"]
        
--- 73,77 ----
                        x, y = o._backing_store_info["pos"]
                        w, h = o._backing_store_info["size"]
!                       self._backing_store_info["dirty-rects"].append(( (x, y), (w, 
h) ))
                        #print "Child delete", o,  
self._backing_store_info["dirty-rects"]
        
***************
*** 165,174 ****
                will depend on the backend.
                """
-               self.dirty = True
-               self._backing_store_dirty = True
- 
                if child and child not in self.dirty_children:
                        self.dirty_children.append(child)
  
                if check_weakref(self.parent):
                        self.parent().queue_paint(self)
--- 165,176 ----
                will depend on the backend.
                """
                if child and child not in self.dirty_children:
                        self.dirty_children.append(child)
  
+               if self.dirty:
+                       return
+ 
+               self.dirty = True
+               self._backing_store_dirty = True
                if check_weakref(self.parent):
                        self.parent().queue_paint(self)
***************
*** 306,310 ****
                        return None, []
  
!               t0=time.time()
                #print "*** Begin _get_backing_store", self, update_object, 
self._backing_store_dirty
                if not self._backing_store_dirty or (use_cached and 
self._backing_store):
--- 308,312 ----
                        return None, []
  
!               #t0=time.time()
                #print "*** Begin _get_backing_store", self, update_object, 
self._backing_store_dirty
                if not self._backing_store_dirty or (use_cached and 
self._backing_store):
***************
*** 332,336 ****
                        # the backing store as is.  It's up to the caller to blend us 
at
                        # our alpha.
!                       dirty_rects += ( (offset_x, offset_y), (width, height) ),
                        if len(self.dirty_children) == 0 and self._backing_store:
                                if update_object == self and update:
--- 334,338 ----
                        # the backing store as is.  It's up to the caller to blend us 
at
                        # our alpha.
!                       dirty_rects.append(((offset_x, offset_y), (width, height) ))
                        if len(self.dirty_children) == 0 and self._backing_store:
                                if update_object == self and update:
***************
*** 360,364 ****
                # store, so negative coordinates are ok; they will be translated
                # later).
!               t1 = time.time()
                # Sort children in order of their z-index.
                self.children.sort(lambda a, b: cmp(a.zindex, b.zindex))
--- 362,366 ----
                # store, so negative coordinates are ok; they will be translated
                # later).
!               #t1 = time.time()
                # Sort children in order of their z-index.
                self.children.sort(lambda a, b: cmp(a.zindex, b.zindex))
***************
*** 402,408 ****
                        # If the child is invisible (either hidden or alpha of 0) then 
                        # we don't bother with this child.
!                       if ("visible" in bsi and not child.visible and not 
bsi["visible"]) or \
!                          ("alpha" in bsi and child.alpha == 0 and bsi["alpha"] == 0):
!                               continue
  
                        # If the child has either changed positions or changed sizes 
(or
--- 404,416 ----
                        # If the child is invisible (either hidden or alpha of 0) then 
                        # we don't bother with this child.
!                       # *****************************************
!                       # FIXME:
!                       # Dischi to Tack: Isn't that a bad idea? We just made it not
!                       # dirty and by calling continue now, we will never set
!                       # the child to dirty=false
!                       # *****************************************
!                       # if ("visible" in bsi and not child.visible and not 
bsi["visible"]) or \
!                       #    ("alpha" in bsi and child.alpha == 0 and bsi["alpha"] == 
0):
!                       #       continue
  
                        # If the child has either changed positions or changed sizes 
(or
***************
*** 416,432 ****
  
                                # Old rectangle.
!                               dirty_rects += ( (bsi["pos"][0] + child_offset_x, 
bsi["pos"][1] + child_offset_y), bsi["size"]),
                                # New rectangle.
!                               dirty_rects += ( (child_x + child_offset_x, child_y + 
child_offset_y), (child_w, child_h) ),
  
                        # If visibility or zindex has changed, entire child region 
gets invalidated.
                        elif ("visible" in bsi and bsi["visible"] != child.visible) or 
\
                             ("z-index" in bsi and bsi["z-index"] != child.zindex):
!                               dirty_rects += ( (child_x + child_offset_x, child_y + 
child_offset_y), (child_w, child_h) ),
  
                        # If we've gotten this far and the child is an image, then we
                        # assume the whole image needs blitting.
                        elif isinstance(child, CanvasImage):
!                               dirty_rects += ( (child_x, child_y), (child_w, 
child_h) ),
  
                        # Remember the current values.
--- 424,440 ----
  
                                # Old rectangle.
!                               dirty_rects.append(((bsi["pos"][0] + child_offset_x, 
bsi["pos"][1] + child_offset_y), bsi["size"]))
                                # New rectangle.
!                               dirty_rects.append(((child_x + child_offset_x, child_y 
+ child_offset_y), (child_w, child_h) ))
  
                        # If visibility or zindex has changed, entire child region 
gets invalidated.
                        elif ("visible" in bsi and bsi["visible"] != child.visible) or 
\
                             ("z-index" in bsi and bsi["z-index"] != child.zindex):
!                               dirty_rects.append(( (child_x + child_offset_x, 
child_y + child_offset_y), (child_w, child_h) ))
  
                        # If we've gotten this far and the child is an image, then we
                        # assume the whole image needs blitting.
                        elif isinstance(child, CanvasImage):
!                               dirty_rects.append(( (child_x, child_y), (child_w, 
child_h) ))
  
                        # Remember the current values.
***************
*** 457,462 ****
                # list for rendering by removing redundant rectangles (if A is fully
                # contained in B, remove A), and removing interections.
!               dirty_rects = rect.optimize_for_rendering(dirty_rects)
! 
                # Broken code.
                #if self.has_canvas():
--- 465,476 ----
                # list for rendering by removing redundant rectangles (if A is fully
                # contained in B, remove A), and removing interections.
!               # FIXME: Tacl doesm't like this hack, but it is faster
!               if len(dirty_rects) > 10:
!                       # more changes than children, reduce the dirty_rects
!                       # by making all a big union. This is not correct, but will
!                       # speed up the later blitting.
!                       dirty_rects = [ reduce(lambda x,y: rect.union(x,y), 
dirty_rects) ]
!               else:
!                       dirty_rects = rect.optimize_for_rendering(dirty_rects)
                # Broken code.
                #if self.has_canvas():
***************
*** 474,478 ****
                # context means setting those pixels to (0, 0, 0, 0).
  
!               t2 = time.time()
                if not self._backing_store:
                        # First time calling _get_backing_store() on this container or 
it
--- 488,492 ----
                # context means setting those pixels to (0, 0, 0, 0).
  
!               #t2 = time.time()
                if not self._backing_store:
                        # First time calling _get_backing_store() on this container or 
it
***************
*** 506,512 ****
                                        self._backing_store.copy_rect( (0, 0), 
self._backing_store.size, (move_x, move_y))
                                        if move_x < 0:
!                                               dirty_rects += [ ((width + move_x, 0), 
(bs_width-width, bs_height)) ]
                                        if move_y < 0:
!                                               dirty_rects += [ ((0, height + 
move_y), (bs_width, bs_height-height)) ]
  
                        dirty_rects = rect.remove_intersections(dirty_rects)
--- 520,526 ----
                                        self._backing_store.copy_rect( (0, 0), 
self._backing_store.size, (move_x, move_y))
                                        if move_x < 0:
!                                               dirty_rects.append(((width + move_x, 
0), (bs_width-width, bs_height)))
                                        if move_y < 0:
!                                               dirty_rects.append(((0, height + 
move_y), (bs_width, bs_height-height)))
  
                        dirty_rects = rect.remove_intersections(dirty_rects)
***************
*** 529,537 ****
                # Render the intersections between all children and all dirty
                # rectangles.  Children are already sorted in order of z-index.
!               t3 = time.time()
                for child in self.children:
                        if not child.visible or child.alpha <= 0 or not dirty_rects:
                                continue
  
                        if isinstance(child, CanvasContainer):
                                child_offset_x, child_offset_y = 
child._get_child_min_pos()
--- 543,556 ----
                # Render the intersections between all children and all dirty
                # rectangles.  Children are already sorted in order of z-index.
!               #t3 = time.time()
                for child in self.children:
                        if not child.visible or child.alpha <= 0 or not dirty_rects:
                                continue
  
+                       child_size = child.get_size()
+                       if child_size == (0,0):
+                               # ignore this child, it is empty
+                               continue
+                               
                        if isinstance(child, CanvasContainer):
                                child_offset_x, child_offset_y = 
child._get_child_min_pos()
***************
*** 548,552 ****
                        intersects = []
                        for r in dirty_rects:
!                               intersect = rect.intersect( ((child_x + 
child_offset_x, child_y + child_offset_y), child.get_size() ), r)
                                if intersect != rect.empty:
                                        intersects.append(intersect)
--- 567,571 ----
                        intersects = []
                        for r in dirty_rects:
!                               intersect = rect.intersect( ((child_x + 
child_offset_x, child_y + child_offset_y), child_size ), r)
                                if intersect != rect.empty:
                                        intersects.append(intersect)
***************
*** 586,590 ****
                if not update_object or update_object == self:
                        self._backing_store_dirty = False
!               t4 = time.time()
                #print "*!* Return from _get_backing_store", self, " - (0 = %.04f, 1 = 
%.04f, 2 = %.04f, 3 = %.04f, total = %.04f" % (t1-t0, t2-t1, t3-t2, t4-t3, t4-t0)
                return self._backing_store, dirty_rects
--- 605,609 ----
                if not update_object or update_object == self:
                        self._backing_store_dirty = False
!               #t4 = time.time()
                #print "*!* Return from _get_backing_store", self, " - (0 = %.04f, 1 = 
%.04f, 2 = %.04f, 3 = %.04f, total = %.04f" % (t1-t0, t2-t1, t3-t2, t4-t3, t4-t0)
                return self._backing_store, dirty_rects



-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM. 
Deadline: Sept. 13. Go here: http://sf.net/ppc_contest.php
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to