'From Squeak2.6 of 11 October 1999 [latest update: #1559] on 7 December 1999 at 4:29:46 pm'! Object subclass: #BitBltSimulation instanceVariableNames: 'destForm sourceForm halftoneForm combinationRule destX destY width height sourceX sourceY clipX clipY clipWidth clipHeight sourceBits sourceRaster sourcePixSize destBits destRaster destPixSize pixPerWord bitCount skew mask1 mask2 preload nWords destMask hDir vDir sourceIndex sourceDelta destIndex destDelta sx sy dx dy bbW bbH srcWidth srcHeight halftoneHeight noSource noHalftone halftoneBase colorMap sourceAlpha cmBitsPerColor srcBitIndex scanStart scanStop scanString scanRightX scanStopArray scanDisplayFlag scanXTable stopCode bitBltOop affectedL affectedR affectedT affectedB interpreterProxy opTable maskTable ditherMatrix4x4 ditherThresholds16 ditherValues16 cachedSourcePixel cachedNBitsIn cachedNBitsOut cachedResultPixel ' classVariableNames: 'AllOnes BBClipHeightIndex BBClipWidthIndex BBClipXIndex BBClipYIndex BBColorMapIndex BBDestFormIndex BBDestXIndex BBDestYIndex BBHalftoneFormIndex BBHeightIndex BBLastIndex BBRuleIndex BBSourceFormIndex BBSourceXIndex BBSourceYIndex BBWarpBase BBWidthIndex BBXTableIndex BinaryPoint CrossedX EndOfRun FixedPt1 FormBitsIndex FormDepthIndex FormHeightIndex FormWidthIndex OpTable OpTableSize ' poolDictionaries: '' category: 'Squeak-Interpreter'! !BitBltSimulation methodsFor: 'pixel mapping' stamp: 'JMM 12/7/1999 16:29'! rgbMap: sourcePixel from: nBitsIn to: nBitsOut self inline: true. (cachedSourcePixel == sourcePixel) & (cachedNBitsIn == nBitsIn) & (cachedNBitsOut == nBitsOut) ifTrue: [^cachedResultPixel]. cachedSourcePixel _ sourcePixel. cachedNBitsIn _ nBitsIn. cachedNBitsOut _ nBitsOut. cachedResultPixel _ self rgbMapOriginal: sourcePixel from: nBitsIn to: nBitsOut. ^cachedResultPixel! ! !BitBltSimulation methodsFor: 'pixel mapping' stamp: 'jmm 11/17/1999 19:55'! rgbMapOriginal: sourcePixel from: nBitsIn to: nBitsOut "Convert the given pixel value with nBitsIn bits for each color component to a pixel value with nBitsOut bits for each color component. Typical values for nBitsIn/nBitsOut are 3, 5, or 8." | mask d srcPix destPix | self inline: true. (d _ nBitsOut - nBitsIn) > 0 ifTrue: ["Expand to more bits by zero-fill" mask _ (1 << nBitsIn) - 1. "Transfer mask" srcPix _ sourcePixel << d. mask _ mask << d. destPix _ srcPix bitAnd: mask. mask _ mask << nBitsOut. srcPix _ srcPix << d. ^ destPix + (srcPix bitAnd: mask) + (srcPix << d bitAnd: mask << nBitsOut)] ifFalse: ["Compress to fewer bits by truncation" d = 0 ifTrue: [nBitsIn = 5 ifTrue: ["Sometimes called with 16 bits, though pixel is 15, but we must never return more than 15." ^ sourcePixel bitAnd: 16r7FFF]. nBitsIn = 8 ifTrue: ["Sometimes called with 32 bits, though pixel is 24, but we must never return more than 24." ^ sourcePixel bitAnd: 16rFFFFFF]. ^ sourcePixel]. "no compression" sourcePixel = 0 ifTrue: [^ sourcePixel]. "always map 0 (transparent) to 0" d _ nBitsIn - nBitsOut. mask _ (1 << nBitsOut) - 1. "Transfer mask" srcPix _ sourcePixel >> d. destPix _ srcPix bitAnd: mask. mask _ mask << nBitsOut. srcPix _ srcPix >> d. destPix _ destPix + (srcPix bitAnd: mask) + (srcPix >> d bitAnd: mask << nBitsOut). destPix = 0 ifTrue: [^ 1]. "Dont fall into transparent by truncation" ^ destPix]! !