'From Squeak3.1alpha of 28 February 2001 [latest update: #4127] on 4 June 2001 at 6:02:53 pm'! "Change Set: B2DGradientFix-ar Date: 4 June 2001 Author: Andreas Raab Fixes a long-standing bug in the Balloon engine when linear gradients had a negative orientation."! BalloonCanvas subclass: #BalloonDebugCanvas instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Balloon-Engine'! !BalloonDebugCanvas methodsFor: 'accessing' stamp: 'ar 6/4/2001 17:20'! ensuredEngine engine ifNil:[ engine _ BalloonDebugEngine new. engine aaLevel: aaLevel. engine bitBlt: port. engine destOffset: origin. engine clipRect: clipRect. engine deferred: deferred. engine]. engine colorTransform: colorTransform. engine edgeTransform: transform. ^engine! ! !BalloonDebugEngine methodsFor: 'primitives-access' stamp: 'ar 6/4/2001 17:23'! primClipRectInto: rect ^BalloonEnginePlugin doPrimitive:'primitiveGetClipRect'! ! !BalloonDebugEngine methodsFor: 'primitives-access' stamp: 'ar 6/4/2001 17:23'! primFlushNeeded "Return true if there are no more entries in AET and GET and the last scan line has been displayed" ^BalloonEnginePlugin doPrimitive: 'primitiveNeedsFlush'! ! !BalloonDebugEngine methodsFor: 'primitives-access' stamp: 'ar 6/4/2001 17:23'! primGetAALevel "Set the AA level" ^BalloonEnginePlugin doPrimitive: 'primitiveGetAALevel'! ! !BalloonDebugEngine methodsFor: 'primitives-access' stamp: 'ar 6/4/2001 17:23'! primGetBezierStats: statsArray ^BalloonEnginePlugin doPrimitive: 'primitiveGetBezierStats'! ! !BalloonDebugEngine methodsFor: 'primitives-access' stamp: 'ar 6/4/2001 17:23'! primGetClipRect: rect ^BalloonEnginePlugin doPrimitive: 'primitiveGetClipRect'! ! !BalloonDebugEngine methodsFor: 'primitives-access' stamp: 'ar 6/4/2001 17:23'! primGetCounts: statsArray ^BalloonEnginePlugin doPrimitive: 'primitiveGetCounts'! ! !BalloonDebugEngine methodsFor: 'primitives-access' stamp: 'ar 6/4/2001 17:23'! primGetDepth "Set the AA level" ^BalloonEnginePlugin doPrimitive: 'primitiveGetDepth'! ! !BalloonDebugEngine methodsFor: 'primitives-access' stamp: 'ar 6/4/2001 17:23'! primGetFailureReason ^BalloonEnginePlugin doPrimitive: 'primitiveGetFailureReason'! ! !BalloonDebugEngine methodsFor: 'primitives-access' stamp: 'ar 6/4/2001 17:23'! primGetOffset ^BalloonEnginePlugin doPrimitive: 'primitiveGetOffset'! ! !BalloonDebugEngine methodsFor: 'primitives-access' stamp: 'ar 6/4/2001 17:23'! primGetTimes: statsArray ^BalloonEnginePlugin doPrimitive: 'primitiveGetTimes'! ! !BalloonDebugEngine methodsFor: 'primitives-access' stamp: 'ar 6/4/2001 17:23'! primNeedsFlush "Return true if there are no more entries in AET and GET and the last scan line has been displayed" ^BalloonEnginePlugin doPrimitive: 'primitiveNeedsFlush'! ! !BalloonDebugEngine methodsFor: 'primitives-access' stamp: 'ar 6/4/2001 17:24'! primSetAALevel: level "Set the AA level" ^BalloonEnginePlugin doPrimitive: 'primitiveSetAALevel'! ! !BalloonDebugEngine methodsFor: 'primitives-access' stamp: 'ar 6/4/2001 17:24'! primSetClipRect: rect ^BalloonEnginePlugin doPrimitive: 'primitiveSetClipRect'! ! !BalloonDebugEngine methodsFor: 'primitives-access' stamp: 'ar 6/4/2001 17:24'! primSetColorTransform: transform ^BalloonEnginePlugin doPrimitive: 'primitiveSetColorTransform'! ! !BalloonDebugEngine methodsFor: 'primitives-access' stamp: 'ar 6/4/2001 17:24'! primSetDepth: depth ^BalloonEnginePlugin doPrimitive: 'primitiveSetDepth'! ! !BalloonDebugEngine methodsFor: 'primitives-access' stamp: 'ar 6/4/2001 17:24'! primSetEdgeTransform: transform ^BalloonEnginePlugin doPrimitive: 'primitiveSetEdgeTransform'! ! !BalloonDebugEngine methodsFor: 'primitives-access' stamp: 'ar 6/4/2001 17:24'! primSetOffset: point ^BalloonEnginePlugin doPrimitive: 'primitiveSetOffset'! ! !BalloonDebugEngine methodsFor: 'primitives-adding' stamp: 'ar 6/4/2001 17:22'! primAddBezierFrom: start to: end via: via leftFillIndex: leftFillIndex rightFillIndex: rightFillIndex ^BalloonEnginePlugin doPrimitive: 'primitiveAddBezier'! ! !BalloonDebugEngine methodsFor: 'primitives-adding' stamp: 'ar 6/4/2001 17:22'! primAddBezierShape: points segments: nSegments fill: fillStyle lineWidth: lineWidth lineFill: lineFill ^BalloonEnginePlugin doPrimitive: 'primitiveAddBezierShape'! ! !BalloonDebugEngine methodsFor: 'primitives-adding' stamp: 'ar 6/4/2001 17:22'! primAddBitmapFill: form colormap: cmap tile: tileFlag from: origin along: direction normal: normal xIndex: xIndex ^BalloonEnginePlugin doPrimitive: 'primitiveAddBitmapFill'! ! !BalloonDebugEngine methodsFor: 'primitives-adding' stamp: 'ar 6/4/2001 17:22'! primAddCompressedShape: points segments: nSegments leftFills: leftFills rightFills: rightFills lineWidths: lineWidths lineFills: lineFills fillIndexList: fillIndexList ^BalloonEnginePlugin doPrimitive: 'primitiveAddCompressedShape'! ! !BalloonDebugEngine methodsFor: 'primitives-adding' stamp: 'ar 6/4/2001 17:22'! primAddExternalEdge: index initialX: initialX initialY: initialY initialZ: initialZ leftFillIndex: leftFillIndex rightFillIndex: rightFillIndex ^BalloonEnginePlugin doPrimitive: 'primitiveRegisterExternalEdge'! ! !BalloonDebugEngine methodsFor: 'primitives-adding' stamp: 'ar 6/4/2001 17:22'! primAddExternalFill: index ^BalloonEnginePlugin doPrimitive: 'primitiveRegisterExternalFill'! ! !BalloonDebugEngine methodsFor: 'primitives-adding' stamp: 'ar 6/4/2001 17:22'! primAddGradientFill: colorRamp from: origin along: direction normal: normal radial: isRadial ^BalloonEnginePlugin doPrimitive: 'primitiveAddGradientFill'! ! !BalloonDebugEngine methodsFor: 'primitives-adding' stamp: 'ar 6/4/2001 17:22'! primAddLineFrom: start to: end leftFillIndex: leftFillIndex rightFillIndex: rightFillIndex ^BalloonEnginePlugin doPrimitive: 'primitiveAddLine'! ! !BalloonDebugEngine methodsFor: 'primitives-adding' stamp: 'ar 6/4/2001 17:23'! primAddOvalFrom: start to: end fillIndex: fillIndex borderWidth: width borderColor: pixelValue32 ^BalloonEnginePlugin doPrimitive: 'primitiveAddOval'! ! !BalloonDebugEngine methodsFor: 'primitives-adding' stamp: 'ar 6/4/2001 17:23'! primAddPolygon: points segments: nSegments fill: fillStyle lineWidth: lineWidth lineFill: lineFill ^BalloonEnginePlugin doPrimitive: 'primitiveAddPolygon'! ! !BalloonDebugEngine methodsFor: 'primitives-adding' stamp: 'ar 6/4/2001 17:23'! primAddRectFrom: start to: end fillIndex: fillIndex borderWidth: width borderColor: pixelValue32 ^BalloonEnginePlugin doPrimitive: 'primitiveAddRect'! ! !BalloonDebugEngine methodsFor: 'primitives-incremental' stamp: 'ar 6/4/2001 17:21'! primAddActiveEdgeTableEntryFrom: edgeEntry "Add edge entry to the AET." ^BalloonEnginePlugin doPrimitive: 'primitiveAddActiveEdgeEntry'! ! !BalloonDebugEngine methodsFor: 'primitives-incremental' stamp: 'ar 6/4/2001 17:21'! primChangeActiveEdgeTableEntryFrom: edgeEntry "Change the entry in the active edge table from edgeEntry" ^BalloonEnginePlugin doPrimitive: 'primitiveChangedActiveEdgeEntry'! ! !BalloonDebugEngine methodsFor: 'primitives-incremental' stamp: 'ar 6/4/2001 17:21'! primDisplaySpanBuffer "Display the current scan line if necessary" ^BalloonEnginePlugin doPrimitive: 'primitiveDisplaySpanBuffer'! ! !BalloonDebugEngine methodsFor: 'primitives-incremental' stamp: 'ar 6/4/2001 17:21'! primFinishedProcessing "Return true if there are no more entries in AET and GET and the last scan line has been displayed" ^BalloonEnginePlugin doPrimitive: 'primitiveFinishedProcessing'! ! !BalloonDebugEngine methodsFor: 'primitives-incremental' stamp: 'ar 6/4/2001 17:21'! primInitializeProcessing "Initialize processing in the GE. Create the active edge table and sort it." ^BalloonEnginePlugin doPrimitive: 'primitiveInitializeProcessing'! ! !BalloonDebugEngine methodsFor: 'primitives-incremental' stamp: 'ar 6/4/2001 17:21'! primMergeFill: fillBitmap from: fill "Merge the filled bitmap into the current output buffer." ^BalloonEnginePlugin doPrimitive: 'primitiveMergeFillFrom'! ! !BalloonDebugEngine methodsFor: 'primitives-incremental' stamp: 'ar 6/4/2001 17:21'! primNextActiveEdgeEntryInto: edgeEntry "Store the next entry of the AET at the current y-value in edgeEntry. Return false if there is no entry, true otherwise." ^BalloonEnginePlugin doPrimitive: 'primitiveNextActiveEdgeEntry'! ! !BalloonDebugEngine methodsFor: 'primitives-incremental' stamp: 'ar 6/4/2001 17:21'! primNextFillEntryInto: fillEntry "Store the next fill entry of the active edge table in fillEntry. Return false if there is no such entry, true otherwise" ^BalloonEnginePlugin doPrimitive: 'primitiveNextFillEntry'! ! !BalloonDebugEngine methodsFor: 'primitives-incremental' stamp: 'ar 6/4/2001 17:22'! primNextGlobalEdgeEntryInto: edgeEntry "Store the next entry of the GET at the current y-value in edgeEntry. Return false if there is no entry, true otherwise." ^BalloonEnginePlugin doPrimitive: 'primitiveNextGlobalEdgeEntry'! ! !BalloonDebugEngine methodsFor: 'primitives-incremental' stamp: 'ar 6/4/2001 17:22'! primRenderImage: edge with: fill "Start/Proceed rendering the current scan line" ^BalloonEnginePlugin doPrimitive: 'primitiveRenderImage'! ! !BalloonDebugEngine methodsFor: 'primitives-incremental' stamp: 'ar 6/4/2001 17:22'! primRenderScanline: edge with: fill "Start/Proceed rendering the current scan line" ^BalloonEnginePlugin doPrimitive: 'primitiveRenderScanline'! ! !BalloonDebugEngine methodsFor: 'primitives-misc' stamp: 'ar 6/4/2001 17:22'! primCopyBufferFrom: oldBuffer to: newBuffer "Copy the contents of oldBuffer into the (larger) newBuffer" ^BalloonEnginePlugin doPrimitive: 'primitiveCopyBuffer'! ! !BalloonDebugEngine methodsFor: 'primitives-misc' stamp: 'ar 6/4/2001 17:22'! primInitializeBuffer: buffer ^BalloonEnginePlugin doPrimitive: 'primitiveInitializeBuffer'! ! !BalloonEnginePlugin methodsFor: 'fills-gradient' stamp: 'ar 6/4/2001 17:59'! fillLinearGradient: fill from: leftX to: rightX at: yValue "Draw a linear gradient fill." | x0 x1 ramp rampSize dsX ds x rampIndex | self inline: false. self var: #ramp declareC:'int *ramp'. ramp _ self gradientRampOf: fill. rampSize _ self gradientRampLengthOf: fill. dsX _ self fillDirectionXOf: fill. ds _ ((leftX - (self fillOriginXOf: fill)) * dsX) + ((yValue - (self fillOriginYOf: fill)) * (self fillDirectionYOf: fill)). x _ x0 _ leftX. x1 _ rightX. "Note: The inner loop has been divided into three parts for speed" "Part one: Fill everything outside the left boundary" [((rampIndex _ ds // 16r10000) < 0 or:[rampIndex >= rampSize]) and:[x < x1]] whileTrue:[ x _ x + 1. ds _ ds + dsX]. x > x0 ifTrue:[ rampIndex < 0 ifTrue:[rampIndex _ 0]. rampIndex >= rampSize ifTrue:[rampIndex _ rampSize - 1]. self fillColorSpan: (self makeUnsignedFrom: (ramp at: rampIndex)) from: x0 to: x]. "Part two: Fill everything inside the boundaries" self aaLevelGet = 1 ifTrue:[ "Fast version w/o anti-aliasing" [((rampIndex _ ds // 16r10000) < rampSize and:[rampIndex >= 0]) and:[x < x1]] whileTrue:[ spanBuffer at: x put: (self makeUnsignedFrom: (ramp at: rampIndex)). x _ x + 1. ds _ ds + dsX. ]. ] ifFalse:[x _ self fillLinearGradientAA: fill ramp: ramp ds: ds dsX: dsX from: x to: rightX]. "Part three fill everything outside right boundary" x < x1 ifTrue:[ rampIndex < 0 ifTrue:[rampIndex _ 0]. rampIndex >= rampSize ifTrue:[rampIndex _ rampSize-1]. self fillColorSpan: (self makeUnsignedFrom: (ramp at: rampIndex)) from: x to: x1]. ! !