Squeak Class Documentation category index | class index  
 
FXBltSimulation
  category: Graphics-FXBlt
  superclass: InterpreterPlugin
  subclasses: FXBltSimulator

This class implements BitBlt, much as specified in the Blue Book spec.

Performance has been enhanced through the use of pointer variables such as sourceIndex and destIndex, and by separating several special cases of the inner loop.

Operation has been extended to color, with support for 1, 2, 4, 8, 16, and 32-bit pixel sizes. Conversion between different pixel sizes is facilitated by accepting an optional color map.

In addition to the original 16 combination rules, this BitBlt supports
16 fail (for old paint mode)
17 fail (for old mask mode)
18 sourceWord + destinationWord
19 sourceWord - destinationWord
20 rgbAdd: sourceWord with: destinationWord
21 rgbSub: sourceWord with: destinationWord
22 OLDrgbDiff: sourceWord with: destinationWord
23 OLDtallyIntoMap: destinationWord -- old vers doesn't clip to bit boundary
24 alphaBlend: sourceWord with: destinationWord
25 pixPaint: sourceWord with: destinationWord
26 pixMask: sourceWord with: destinationWord
27 rgbMax: sourceWord with: destinationWord
28 rgbMin: sourceWord with: destinationWord
29 rgbMin: sourceWord bitInvert32 with: destinationWord
30 alphaBlendConst: sourceWord with: destinationWord -- alpha passed as an arg
31 alphaPaintConst: sourceWord with: destinationWord -- alpha passed as an arg
32 rgbDiff: sourceWord with: destinationWord
33 tallyIntoMap: destinationWord
34 alphaBlendScaled: sourceWord with: destinationWord
35 srcPaint: sourceWord with: destinationWord
36 dstPaint: sourceWord with: destinationWord

This implementation has also been fitted with an experimental "warp drive" that allows abritrary scaling and rotation (and even limited affine deformations) with all BitBlt storage modes supported.

To add a new rule to BitBlt...
1. add the new rule method or methods in the category 'combination rules' of BBSim
2. describe it in the class comment of BBSim and in the class comment for BitBlt
3. add refs to initializeRuleTable in proper positions
4. add refs to initBBOpTable, following the pattern

instance methods
  accessing
  affectedBottom
affectedLeft
affectedRight
affectedTop
targetForm

  combination rules
  OLDrgbDiff:with:
OLDtallyIntoMap:with:
addWord:with:
alphaBlend:with:
alphaBlendConst:with:
alphaBlendConst:with:paintMode:
alphaBlendScaled:with:
alphaPaintConst:with:
bitAnd:with:
bitAndInvert:with:
bitInvertAnd:with:
bitInvertAndInvert:with:
bitInvertDestination:with:
bitInvertOr:with:
bitInvertOrInvert:with:
bitInvertSource:with:
bitInvertXor:with:
bitOr:with:
bitOrInvert:with:
bitXor:with:
clearWord:with:
destinationWord:with:
dstPaint:with:
partitionedAND:to:nBits:nPartitions:
partitionedAdd:to:nBits:nPartitions:
partitionedMax:with:nBits:nPartitions:
partitionedMin:with:nBits:nPartitions:
partitionedSub:from:nBits:nPartitions:
pixMask:with:
pixPaint:with:
rgbAdd:with:
rgbDiff:with:
rgbMax:with:
rgbMin:with:
rgbMinInvert:with:
rgbSub:with:
sourceWord:with:
srcPaint:with:
subWord:with:
tallyIntoMap:with:

  initialize
  initBBOpTable
initialiseModule
moduleUnloaded:

  inner loop
  alphaSourceBlendBits16
alphaSourceBlendBits32
alphaSourceBlendBits8
copyLoop
copyLoopNoSource
copyLoopNoSourcePixels
copyLoopPixMap
copyLoopPixels
merge:with:function:
warpLoop

  interpreter interface
  drawLoopX:Y:
fetchIntOrFloat:ofObject:
fetchIntOrFloat:ofObject:ifNil:
loadBitBltClipRect
loadBitBltCombinationRule
loadBitBltDestForm
loadBitBltDestRect
loadBitBltFrom:
loadBitBltSourceForm
loadFXAlphaValues
loadFXColorMap
loadFXDestMap
loadFXShiftOrMaskFrom:
loadFXSourceMap
loadFXTallyMap
loadFXWarpQuad
loadFXWarpQuality
loadHalftoneForm
showDisplayBits
version

  memory access
  dstLongAt:
dstLongAt:put:
dstLongAt:put:mask:
halftoneAt:
srcLongAt:

  pixel mapping
  default8To32Table
deltaFrom:to:nSteps:
dither32To16:threshold:
isIdentityMap:with:
mapDestPixel:
mapPixel:
mapSourcePixel:
pickSourcePixels:srcMask:destMask:paintMode:destWord:
pickWarpPixelAtX:y:
rgbMapPixel:shifts:masks:
warpPickSmoothPixels:xDeltah:yDeltah:xDeltav:yDeltav:paintMode:destWord:
warpPickSourcePixels:xDeltah:yDeltah:xDeltav:yDeltav:paintMode:destWord:

  primitives
  primitiveCopyBits
primitiveDrawLoop
primitiveVersion

  setup
  checkSourceOverlap
clipDest
clipSource
copyBits
copyBitsFrom:to:at:
copyBitsLockedAndClipped
copyBitsQuickly
destMaskAndPointerInit
ignoreSourceOrHalftone:
sourceSkewAndPointerInit
warpBits
warpSetup

  special inner loops
  copyLoopPixMapLsbLsb
copyLoopPixMapLsbMsb
copyLoopPixMapMsbLsb
copyLoopPixMapMsbMsb
doCopyLoopPixMap
doWarpLoop
warpLoopLsbLsb
warpLoopLsbMsb
warpLoopMsbLsb
warpLoopMsbMsb

  surface support
  loadSurfacePlugin
lockSurfaces
queryDestSurface:
querySourceSurface:
unlockSurfaces

class methods
  initialization
  initialize
initializeRuleTable
test2
timingTest:

  system simulation
  copyBitsFrom:
fxCopyBitsFrom:
simulatorClass
warpBitsFrom:

  translation
  declareCVarsIn:
moduleName
opTable
specializeLoopsIn:

instance methods
  accessing top  
 

affectedBottom


 

affectedLeft


 

affectedRight


 

affectedTop


 

targetForm

Return the destination form of a copyBits or scanCharacters operation.


  combination rules top  
 

OLDrgbDiff:with:

Subract the pixels in the source and destination
and return the number of differing pixels.
Note that the region is not clipped to bit boundaries, but only to the
nearest (enclosing) word. This is because copyLoop does not do
pre-merge masking. For accurate results, you must subtract the
values obtained from the left and right fringes.


 

OLDtallyIntoMap:with:

Tally pixels into the tally map. Note that the source should be
specified = destination, in order for the proper color map checks
to be performed at setup.
Note that the region is not clipped to bit boundaries, but only to the
nearest (enclosing) word. This is because copyLoop does not do
pre-merge masking. For accurate results, you must subtract the
values obtained from the left and right fringes.


 

addWord:with:


 

alphaBlend:with:

Blend sourceWord with destinationWord, assuming both are 32-bit pixels.
The source is assumed to have 255*alpha in the high 8 bits of each pixel,
while the high 8 bits of the destinationWord will be ignored.
The blend produced is alpha*source + (1-alpha)*dest, with
the computation being performed independently on each color
component. The high byte of the result will be 0.


 

alphaBlendConst:with:


 

alphaBlendConst:with:paintMode:

Blend sourceWord with destinationWord using a constant alpha.
Alpha is encoded as 0 meaning 0.0, and 255 meaning 1.0.
The blend produced is alpha*source + (1.0-alpha)*dest, with the
computation being performed independently on each color component.
This function could eventually blend into any depth destination,
using the same color averaging and mapping as warpBlt.
paintMode = true means do nothing if the source pixel value is zero.


 

alphaBlendScaled:with:

Blend sourceWord with destinationWord using the alpha value from sourceWord.
Alpha is encoded as 0 meaning 0.0, and 255 meaning 1.0.
In contrast to alphaBlend:with: the color produced is

srcColor + (1-srcAlpha) * dstColor

e.g., it is assumed that the source color is already scaled.


 

alphaPaintConst:with:


 

bitAnd:with:


 

bitAndInvert:with:


 

bitInvertAnd:with:


 

bitInvertAndInvert:with:


 

bitInvertDestination:with:


 

bitInvertOr:with:


 

bitInvertOrInvert:with:


 

bitInvertSource:with:


 

bitInvertXor:with:


 

bitOr:with:


 

bitOrInvert:with:


 

bitXor:with:


 

clearWord:with:


 

destinationWord:with:


 

dstPaint:with:

Replace those pixels in destinationWord where the
pixel value is equal to destAlphaKey.


 

partitionedAND:to:nBits:nPartitions:

AND word1 to word2 as nParts partitions of nBits each.
Any field of word1 not all-ones is treated as all-zeroes.
Used for erasing, eg, brush shapes prior to ORing in a color


 

partitionedAdd:to:nBits:nPartitions:

Add word1 to word2 as nParts partitions of nBits each.
This is useful for packed pixels, or packed colors


 

partitionedMax:with:nBits:nPartitions:

Max word1 to word2 as nParts partitions of nBits each


 

partitionedMin:with:nBits:nPartitions:

Min word1 to word2 as nParts partitions of nBits each


 

partitionedSub:from:nBits:nPartitions:

Subtract word1 from word2 as nParts partitions of nBits each.
This is useful for packed pixels, or packed colors


 

pixMask:with:


 

pixPaint:with:


 

rgbAdd:with:


 

rgbDiff:with:

Subract the pixels in the source and destination
and return the number of differing pixels.


 

rgbMax:with:


 

rgbMin:with:


 

rgbMinInvert:with:


 

rgbSub:with:


 

sourceWord:with:


 

srcPaint:with:

Replace those pixels in destinationWord where the
associated pixel in sourceWord is different from sourceAlphaKey.
Note: This will only work for sourceDepth = destDepth.


 

subWord:with:


 

tallyIntoMap:with:

Tally pixels into the color map. Those tallied are exactly those
in the destination rectangle. Note that the source should be
specified == destination, in order for the proper color map checks
to be performed at setup.


  initialize top  
 

initBBOpTable


 

initialiseModule


 

moduleUnloaded:

The module with the given name was just unloaded.
Make sure we have no dangling references.


  inner loop top  
 

alphaSourceBlendBits16

This version assumes
combinationRule = 34
sourcePixSize = 32
destPixSize = 16
sourceForm ~= destForm.


 

alphaSourceBlendBits32

This version assumes
combinationRule = 34
sourcePixSize = destPixSize = 32
sourceForm ~= destForm.
Note: The inner loop has been optimized for dealing
with the special cases of srcAlpha = 0.0 and srcAlpha = 1.0


 

alphaSourceBlendBits8

This version assumes
combinationRule = 34
sourcePixSize = 32
destPixSize = 8
sourceForm ~= destForm.
Note: This is not real blending since we don't have the source colors available.


 

copyLoop

This version of the inner loop assumes sourceDepth = destDepth,
noSource = false, noColorMap = noSourceMap = noDestMap = true


 

copyLoopNoSource

Faster copyLoop when source not used. hDir and vDir are both
positive, and perload and skew are unused.
Note: This is the common fill loop without any fancy stuff.


 

copyLoopNoSourcePixels

This version of the inner loop maps dest pixels one at a time.
Note: This loop is typically used for filling with alpha values.
Note2: There is probably some significant speedup in here
but for now I just need a version that does the job...


 

copyLoopPixMap

This version of the inner loop maps source pixels
to a destination form with different depth.
Note: Special care is taken to handle source paint mode correctly.


 

copyLoopPixels

This version of the inner loop maps source pixels and dest pixels one at a time. This is the most general (and slowest) version which must also keep track of source and dest paint mode by itself.


 

merge:with:function:


 

warpLoop

This version of the inner loop traverses an arbirary quadrilateral
source, thus producing a general affine transformation.


  interpreter interface top  
 

drawLoopX:Y:

This is the primitive implementation of the line-drawing loop.
See the comments in BitBlt>>drawLoopX:Y:


 

fetchIntOrFloat:ofObject:


 

fetchIntOrFloat:ofObject:ifNil:


 

loadBitBltClipRect

Load the clipping rectangle from a BitBlt oop.


 

loadBitBltCombinationRule

Load the combination rule from a BitBlt oop


 

loadBitBltDestForm

Load the dest form for BitBlt. Return false if anything is wrong, true otherwise.


 

loadBitBltDestRect

Load the destination rectangle from a BitBlt oop


 

loadBitBltFrom:

Load context from BitBlt instance. Return false if anything is amiss


 

loadBitBltSourceForm

Load the source form for BitBlt. Return false if anything is wrong, true otherwise.


 

loadFXAlphaValues

Load the source/destination transparency keys


 

loadFXColorMap

Load a color map from FXBlt


 

loadFXDestMap

Load a destination map from destForm to canonical 32bit RGBA values


 

loadFXShiftOrMaskFrom:


 

loadFXSourceMap

Load a source map from sourceForm to canonical 32bit RGBA values


 

loadFXTallyMap

Load the tally map


 

loadFXWarpQuad

Load the new warp quad (used, e.g., for warping)


 

loadFXWarpQuality

Load the warp quality (used, e.g., for warping)


 

loadHalftoneForm

Load the halftone form


 

showDisplayBits


 

version

Return the version of FXBlt


  memory access top  
 

dstLongAt:


 

dstLongAt:put:


 

dstLongAt:put:mask:

Store the given value back into destination form, using dstMask
to mask out the bits to be modified. This is an essiantial
read-modify-write operation on the destination form.


 

halftoneAt:

Return a value from the halftone pattern.


 

srcLongAt:


  pixel mapping top  
 

default8To32Table

Return the default translation table from 1..8 bit indexed colors to 32bit


 

deltaFrom:to:nSteps:

Utility routine for computing Warp increments.


 

dither32To16:threshold:

Dither the given 32bit word to 16 bit. Ignore alpha.


 

isIdentityMap:with:

Return true if shiftTable/maskTable define an identity mapping.


 

mapDestPixel:

Expand the given destination pixel value into canonical RGBA space.


 

mapPixel:

Color map the given source pixel.


 

mapSourcePixel:

Expand the given source pixel value into canonical RGBA space.


 

pickSourcePixels:srcMask:destMask:paintMode:destWord:

Pick nPix pixels starting at srcBitIndex from the source, map by the
color map, and justify them according to dstBitIndex in the resulting destWord.


 

pickWarpPixelAtX:y:

Pick a single pixel from the source for WarpBlt.
Note: This method is crucial for WarpBlt speed w/o smoothing
and still relatively important when smoothing is used.


 

rgbMapPixel:shifts:masks:

Perform the RGBA conversion for the given source pixel


 

warpPickSmoothPixels:xDeltah:yDeltah:xDeltav:yDeltav:paintMode:destWord:

Pick n (sub-) pixels from the source form, mapped by sourceMap,
average the RGB values, map by colorMap and return the new word.
This version is only called from WarpBlt with smoothingCount > 1


 

warpPickSourcePixels:xDeltah:yDeltah:xDeltav:yDeltav:paintMode:destWord:

Pick n pixels from the source form,
map by colorMap and return aligned by dstBitShift.
This version is only called from WarpBlt with smoothingCount = 1


  primitives top  
 

primitiveCopyBits


 

primitiveDrawLoop

Invoke the line drawing primitive.


 

primitiveVersion

Return the version of FXBlt


  setup top  
 

checkSourceOverlap

check for possible overlap of source and destination


 

clipDest

clip and adjust source origin and extent appropriately


 

clipSource

clip and adjust source origin and extent appropriately


 

copyBits


 

copyBitsFrom:to:at:

Support for the balloon engine.


 

copyBitsLockedAndClipped

Perform the actual copyBits operation.
Assume: Surfaces have been locked and clipping was performed.


 

copyBitsQuickly

Shortcut for stuff that's being run from the balloon engine.
Since we do this at each scan line we should avoid the expensive
setup for source and destination.


 

destMaskAndPointerInit

Compute masks for left and right destination words


 

ignoreSourceOrHalftone:


 

sourceSkewAndPointerInit

This is only used when source and dest are same depth,
ie, when the barrel-shift copy loop is used.


 

warpBits

obsolete


 

warpSetup

Setup values for faster pixel fetching in WarpBlt.


  special inner loops top  
 

copyLoopPixMapLsbLsb

Note: This loop is specialized by the CCodeGenerator.


 

copyLoopPixMapLsbMsb

Note: This loop is specialized by the CCodeGenerator.


 

copyLoopPixMapMsbLsb

Note: This loop is specialized by the CCodeGenerator.


 

copyLoopPixMapMsbMsb

Note: This loop is specialized by the CCodeGenerator.


 

doCopyLoopPixMap


 

doWarpLoop


 

warpLoopLsbLsb

Note: This loop is specialized by the CCodeGenerator.


 

warpLoopLsbMsb

Note: This loop is specialized by the CCodeGenerator.


 

warpLoopMsbLsb

Note: This loop is specialized by the CCodeGenerator.


 

warpLoopMsbMsb

Note: This loop is specialized by the CCodeGenerator.


  surface support top  
 

loadSurfacePlugin

Load the surface support plugin


 

lockSurfaces

Get a pointer to the bits of any OS surfaces.


 

queryDestSurface:

Query the dimension of an OS surface.
This method is provided so that in case the inst vars of the
source form are broken, *actual* values of the OS surface
can be obtained. This might, for instance, happen if the user
resizes the main window.
Note: Moved to a separate function for better inlining of the caller.


 

querySourceSurface:

Query the dimension of an OS surface.
This method is provided so that in case the inst vars of the
source form are broken, *actual* values of the OS surface
can be obtained. This might, for instance, happen if the user
resizes the main window.
Note: Moved to a separate function for better inlining of the caller.


 

unlockSurfaces

Unlock the bits of any OS surfaces.


class methods
  initialization top  
 

initialize

BitBltSimulation initialize


 

initializeRuleTable

BitBltSimulation initializeRuleTable


 

test2

BitBltSimulation test2


 

timingTest:

BitBltSimulation timingTest: 640@480


  system simulation top  
 

copyBitsFrom:

Simulate the copyBits primitive


 

fxCopyBitsFrom:

Simulate the copyBits primitive


 

simulatorClass

For running from Smalltalk - answer a class that can be used to
simulate the receiver. By default every plugin can simulate itself.


 

warpBitsFrom:

Simulate the warpBits primitive


  translation top  
 

declareCVarsIn:

Note: This method must be implemented by all subclasses to declare variables.


 

moduleName

FXBltScanner translateLocally


 

opTable


 

specializeLoopsIn:

FXBltScanner translate