[enh] rgbMap:from:to: caching result.

Raab, Andreas Andreas.Raab at disney.com
Wed Dec 8 01:17:17 UTC 1999


John,

> Late last month before I got caught up in deferring updates I
> was looking at
> BitBit>>rgbMap:from:to: It seems this method is called a lot. 

I've done quite a bit of experiments in BB myself and I have found that a
*lot* can be gained by reformulating copyLoopPixmap and warpLoop (the
results were speedups of about 2-2.5 on Mac and 3-4 on Win in the
interesting cases, heh, heh) - mainly because a lot of the things that
happen in pixel mapping can be efficiently precomputed way earlier (e.g.,
during BB setup phase). As an example, the reformulated pixel mapping looked
essentially like this:

BitBltSimulation>>rgbMap: sourcePixel
  "Color map the given source pixel.
  Note: This relies on an accurate setup of the cmShifts and cmMasks
  by BitBlt and can therefore not be used from WarpBlt in smoothing
  mode (but hey, then we have to go over lots of different pixels
  before we even come to the output color conversion so that doesn't
  really matter)."
  self inline: true. "you bet"
  cmDeltaBits < 0 "Compress or expand RGB values?!!"
    ifTrue:[
      ^((sourcePixel bitAnd: cmRedMask) >> cmRedShift) bitOr:
         (((sourcePixel bitAnd: cmGreenMask) >> cmGreenShift) bitOr:
           ((sourcePixel bitAnd: cmBlueMask) >> cmBlueShift))]
    ifFalse:[
      ^((sourcePixel bitAnd: cmRedMask) << cmRedShift) bitOr:
         (((sourcePixel bitAnd: cmGreenMask) << cmGreenShift) bitOr:
           ((sourcePixel bitAnd: cmBlueMask) << cmBlueShift))]

Also, reformulating the loops has the advantage that one does know quite a
bit more about pixel depths in the critical places (such as during
#pickSourcePixels:) and this allows to write much tighter and faster loops.

  Andreas

PS. If you're interested I can send you the change set which is not in the
current update stream because Tim, Dan, and I are working on some more
modifications which will eventually lead to some really exciting stuff ;-)

PPS. Of course, all of this will be "yesterday's snow" (as we say in German)
once we're getting to JITBlt (which is yet another project, heh, heh).





More information about the Squeak-dev mailing list