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 ! |