169 |
169 |
170 "preallocates a nR x nG x nB colorMap for later use in dithering. |
170 "preallocates a nR x nG x nB colorMap for later use in dithering. |
171 Doing so has the advantage that the system will never run out of colors, |
171 Doing so has the advantage that the system will never run out of colors, |
172 however, colors may be either inexact or dithered." |
172 however, colors may be either inexact or dithered." |
173 |
173 |
174 |clr round |
174 |clr round devClr| |
175 devClr| |
|
176 |
175 |
177 round := 0. |
176 round := 0. |
178 1 to:aColorVector size do:[:dstIndex | |
177 1 to:aColorVector size do:[:dstIndex | |
179 clr := aColorVector at:dstIndex. |
178 clr := aColorVector at:dstIndex. |
180 devClr := clr exactOn:aDevice. |
179 devClr := clr exactOn:aDevice. |
181 devClr isNil ifTrue:[ |
180 devClr isNil ifTrue:[ |
182 round == 0 ifTrue:[ |
181 round == 0 ifTrue:[ |
183 'Color [info]: scavenge to reclaim colors' infoPrintCR. |
182 Logger info:'scavenge to reclaim colors'. |
184 ObjectMemory scavenge. |
183 ObjectMemory scavenge. |
185 round := 1. |
184 round := 1. |
186 devClr := clr exactOn:aDevice. |
185 devClr := clr exactOn:aDevice. |
187 ]. |
186 ]. |
188 ]. |
187 devClr isNil ifTrue:[ |
189 devClr isNil ifTrue:[ |
188 round == 1 ifTrue:[ |
190 round == 1 ifTrue:[ |
189 Logger info:'collect garbage to reclaim colors'. |
191 'Color [info]: collect garbage to reclaim colors' infoPrintCR. |
190 ObjectMemory |
192 ObjectMemory performLowSpaceCleanup. |
191 garbageCollect; finalize. |
193 ObjectMemory garbageCollect; finalize. |
192 round := 2. |
194 round := 2. |
193 devClr := clr exactOn:aDevice. |
195 devClr := clr exactOn:aDevice. |
194 ]. |
196 ]. |
195 devClr isNil ifTrue:[ |
197 ]. |
196 round == 2 ifTrue:[ |
198 devClr isNil ifTrue:[ |
197 Logger info:'lowSpaceCleanup and collect garbage to reclaim colors'. |
199 ColorAllocationFailSignal raiseErrorString:'failed to allocate fix color'. |
198 ObjectMemory |
200 ^ self |
199 performLowSpaceCleanup; |
201 ]. |
200 garbageCollect; finalize. |
202 aColorVector at:dstIndex put:devClr. |
201 round := 3. |
203 ]. |
202 devClr := clr exactOn:aDevice. |
|
203 ]. |
|
204 devClr isNil ifTrue:[ |
|
205 ColorAllocationFailSignal raiseErrorString:'failed to allocate fix color'. |
|
206 ^ self |
|
207 ]. |
|
208 ]. |
|
209 ]. |
|
210 ]. |
|
211 aColorVector at:dstIndex put:devClr. |
|
212 ]. |
|
213 |
|
214 "Modified: / 02-03-2017 / 17:43:36 / stefan" |
204 ! |
215 ! |
205 |
216 |
206 colorCubeWithRed:nRed green:nGreen blue:nBlue |
217 colorCubeWithRed:nRed green:nGreen blue:nBlue |
207 "{ Pragma: +optSpace }" |
218 "{ Pragma: +optSpace }" |
208 |
219 |