DisplaySurface.st
changeset 4391 7f646ac1b1ea
parent 4291 85475200669d
child 4413 139a64d7cb9a
equal deleted inserted replaced
4390:8d752f4cd9e2 4391:7f646ac1b1ea
   103 
   103 
   104 addUpdateRectangle:newRectangle
   104 addUpdateRectangle:newRectangle
   105     "return true, if the newRectangle is not already contained in the updateRegion
   105     "return true, if the newRectangle is not already contained in the updateRegion
   106      (i.e. if it added any pixels to the region"
   106      (i.e. if it added any pixels to the region"
   107 
   107 
   108     |closure|
   108     |closure lastRect numRect lastTop lastBottom lastLeft lastRight 
       
   109      newTop newBottom newLeft newRight|
   109 
   110 
   110     updateRegion isNil ifTrue:[
   111     updateRegion isNil ifTrue:[
   111         updateRegion := OrderedCollection with:newRectangle.
   112         updateRegion := OrderedCollection with:newRectangle.
   112         ^ true
   113         ^ true
   113     ].
   114     ].
   114     (updateRegion contains:[:oldRectangle | (newRectangle isContainedIn:oldRectangle)]) ifTrue:[
   115     (updateRegion contains:[:oldRectangle | (newRectangle isContainedIn:oldRectangle)]) ifTrue:[
   115         ^ false.
   116         ^ false.
   116     ].
   117     ].
   117 
   118 
   118     updateRegion size > 10 ifTrue:[
   119     numRect := updateRegion size.
       
   120     numRect > 10 ifTrue:[
   119         closure := updateRegion 
   121         closure := updateRegion 
   120                         inject:newRectangle 
   122                         inject:newRectangle 
   121                         into:[:boundsSoFar :thisRectangle |
   123                         into:[:boundsSoFar :thisRectangle |
   122                                 boundsSoFar quickMerge:thisRectangle
   124                                 boundsSoFar quickMerge:thisRectangle
   123                              ].
   125                              ].
   124         updateRegion := OrderedCollection with:closure.
   126         updateRegion := OrderedCollection with:closure.
   125         ^ true
   127         ^ true
       
   128     ].
       
   129 
       
   130     lastRect := updateRegion at:numRect.
       
   131     lastTop := lastRect top.
       
   132     lastBottom := lastRect bottom.
       
   133     lastLeft := lastRect left.
       
   134     lastRight := lastRect right.
       
   135     newTop := newRectangle top.
       
   136     newBottom := newRectangle bottom.
       
   137     newLeft := newRectangle left.
       
   138     newRight := newRectangle right.
       
   139 
       
   140     lastTop = newTop ifTrue:[
       
   141         lastBottom = newBottom ifTrue:[
       
   142             lastLeft <= newLeft ifTrue:[
       
   143                 lastRight >= newLeft ifTrue:[
       
   144                     lastRect right:newRight.
       
   145                     ^ false "/ true
       
   146                 ]
       
   147             ]
       
   148         ].
       
   149     ].
       
   150     lastLeft = newLeft ifTrue:[
       
   151         lastRight = newRight ifTrue:[
       
   152             lastTop <= newTop ifTrue:[
       
   153                 lastBottom >= newTop ifTrue:[
       
   154                     lastRect bottom:newBottom.
       
   155                     ^ false "/ true
       
   156                 ]
       
   157             ]
       
   158         ].
   126     ].
   159     ].
   127 
   160 
   128     updateRegion add:newRectangle.
   161     updateRegion add:newRectangle.
   129     ^ true
   162     ^ true
   130 !
   163 !
  2450 ! !
  2483 ! !
  2451 
  2484 
  2452 !DisplaySurface class methodsFor:'documentation'!
  2485 !DisplaySurface class methodsFor:'documentation'!
  2453 
  2486 
  2454 version
  2487 version
  2455     ^ '$Header: /cvs/stx/stx/libview/DisplaySurface.st,v 1.123 2004-09-27 14:07:41 stefan Exp $'
  2488     ^ '$Header: /cvs/stx/stx/libview/DisplaySurface.st,v 1.124 2005-06-13 18:19:43 cg Exp $'
  2456 ! !
  2489 ! !
  2457 
  2490 
  2458 DisplaySurface initialize!
  2491 DisplaySurface initialize!