# HG changeset patch # User Claus Gittinger # Date 845999804 -7200 # Node ID 3513a4cae87beeb42298308aa4980c412ad1c21f # Parent 9c433066e960a05d0bc4f792b6f67cf60735b6b5 handle depth1-images with a mask diff -r 9c433066e960 -r 3513a4cae87b DevGC.st --- a/DevGC.st Mon Oct 21 12:47:57 1996 +0200 +++ b/DevGC.st Tue Oct 22 17:56:44 1996 +0200 @@ -17,7 +17,7 @@ category:'Graphics-Support' ! -!DeviceGraphicsContext class methodsFor:'documentation'! +!DeviceGraphicsContext class methodsFor:'documentation'! copyright " @@ -75,7 +75,7 @@ " ! ! -!DeviceGraphicsContext class methodsFor:'initialization'! +!DeviceGraphicsContext class methodsFor:'initialization'! initialize Lobby isNil ifTrue:[ @@ -83,7 +83,7 @@ ] ! ! -!DeviceGraphicsContext class methodsFor:'instance creation'! +!DeviceGraphicsContext class methodsFor:'instance creation'! new "create a new drawable - take the current display as @@ -120,7 +120,7 @@ ^ newDrawable ! ! -!DeviceGraphicsContext class methodsFor:'cleanup'! +!DeviceGraphicsContext class methodsFor:'cleanup'! lowSpaceCleanup CachedScaledForms := CachedScales := nil @@ -1845,102 +1845,120 @@ id := deviceForm id. id isNil ifTrue:[ - deviceForm := aForm asFormOn:device. - id := deviceForm id. - id isNil ifTrue:[ - 'DEVGC: invalid form draw - ignored' errorPrintNL. - ^ self - ]. + deviceForm := aForm asFormOn:device. + id := deviceForm id. + id isNil ifTrue:[ + 'DEVGC: invalid form draw - ignored' errorPrintNL. + ^ self + ]. ]. gcId isNil ifTrue:[ - self initGC + self initGC ]. " a deep form ignores paint/bgPaint settings " - (aForm depth ~~ 1) ifTrue:[ - (mask := aForm mask) notNil ifTrue:[ - mask depth == 1 ifFalse:[ - 'DEVGC: alpha channel not yet supported' errorPrintCR. - ] ifTrue:[ - deviceMask := mask asFormOn:device. - maskId := deviceMask id. - maskId notNil ifTrue:[ - " - create temp-form; - " - tmpForm := Form width:w height:h depth:device depth on:device. - tmpForm initGC. - - " - fill tempform with image - " - device - copyFromId:id - x:0 y:0 gc:gcId - to:tmpForm id - x:0 y:0 gc:(tmpForm gcId) - width:w height:h. - - allColor := Color allColor. - allBits := allColor colorId. - - " - stamp out mask in temp form - " - device setForeground:allBits background:0 in:tmpForm gcId. - device setFunction:#and in:tmpForm gcId. - device - copyPlaneFromId:maskId - x:0 y:0 gc:(deviceMask gcId) - to:tmpForm id - x:0 y:0 gc:tmpForm gcId - width:w height:h. - - - " - stamp out mask in destination - " - device setForeground:0 background:allBits in:gcId. - device setFunction:#and in:gcId. - device - copyPlaneFromId:maskId - x:0 y:0 gc:(deviceMask gcId) - to:drawableId - x:pX y:pY gc:gcId - width:w height:h. + mask := aForm mask. + + ((aForm depth ~~ 1) + or:[mask notNil]) ifTrue:[ + mask notNil ifTrue:[ + mask depth == 1 ifFalse:[ + 'DEVGC: alpha channel not yet supported' errorPrintCR. + ] ifTrue:[ + deviceMask := mask asFormOn:device. + maskId := deviceMask id. + maskId notNil ifTrue:[ + " + create temp-form; + " + tmpForm := Form width:w height:h depth:device depth on:device. + tmpForm initGC. + + " + fill tempform with image + " + aForm depth == 1 ifTrue:[ + aForm colorMap notNil ifTrue:[ + device + setForeground:((aForm colorMap at:2) on:device) colorId + background:((aForm colorMap at:1) on:device) colorId + in:tmpForm gcId. + ]. + device + copyPlaneFromId:id + x:0 y:0 gc:gcId + to:tmpForm id + x:0 y:0 gc:tmpForm gcId + width:w height:h. + ] ifFalse:[ + device + copyFromId:id + x:0 y:0 gc:gcId + to:tmpForm id + x:0 y:0 gc:(tmpForm gcId) + width:w height:h. + ]. + + allColor := Color allColor. + allBits := allColor colorId. + + " + stamp out mask in temp form + " + device setForeground:allBits background:0 in:tmpForm gcId. + device setFunction:#and in:tmpForm gcId. + device + copyPlaneFromId:maskId + x:0 y:0 gc:(deviceMask gcId) + to:tmpForm id + x:0 y:0 gc:tmpForm gcId + width:w height:h. + + + " + stamp out mask in destination + " + device setForeground:0 background:allBits in:gcId. + device setFunction:#and in:gcId. + device + copyPlaneFromId:maskId + x:0 y:0 gc:(deviceMask gcId) + to:drawableId + x:pX y:pY gc:gcId + width:w height:h. "/ Delay waitForSeconds:3. - " - or-in tempform-bits ... - " - device setFunction:#or in:gcId. - device - copyFromId:tmpForm id - x:0 y:0 gc:tmpForm gcId - to:drawableId - x:pX y:pY gc:gcId - width:w height:h. - - foreground notNil ifTrue:[ - device setForeground:foreground colorId in:gcId. - ]. - background notNil ifTrue:[ - device setBackground:background colorId in:gcId. - ]. - device setFunction:function in:gcId. - ^ self - ] - ] - ]. - - device - copyFromId:id - x:0 y:0 gc:deviceForm gcId - to:drawableId - x:pX y:pY gc:gcId - width:w height:h. - ^ self + " + or-in tempform-bits ... + " + device setFunction:#or in:gcId. + device + copyFromId:tmpForm id + x:0 y:0 gc:tmpForm gcId + to:drawableId + x:pX y:pY gc:gcId + width:w height:h. + + foreground notNil ifTrue:[ + device setForeground:foreground colorId in:gcId. + ]. + background notNil ifTrue:[ + device setBackground:background colorId in:gcId. + ]. + device setFunction:function in:gcId. + ^ self + ] + ] + ]. + + device + copyFromId:id + x:0 y:0 gc:deviceForm gcId + to:drawableId + x:pX y:pY gc:gcId + width:w height:h. + ^ self ]. " @@ -1955,66 +1973,66 @@ " easy := (function == #copy). easy ifTrue:[ - paint isColor ifFalse:[ - paintDither := paint. - easy := false - ] ifTrue:[ - paintDither := paint ditherForm. - paintDither notNil ifTrue:[ - easy := false. - ] - ]. + paint isColor ifFalse:[ + paintDither := paint. + easy := false + ] ifTrue:[ + paintDither := paint ditherForm. + paintDither notNil ifTrue:[ + easy := false. + ] + ]. ]. allColor := Color allColor. allBits := allColor colorId. easy ifTrue:[ - " - paint is a real color - " - - " - if paint color is all-0 or all-1's, we can do it in one - operation ... - " - fgId := paint colorId. - - ((fgId ~~ ((1 bitShift:device depth)-1)) - and:[fgId ~~ allBits]) ifTrue:[ - " - clear fg-bits ... - " - device setForeground:0 background:allBits in:gcId. - device setFunction:#and in:gcId. - device - copyPlaneFromId:id - x:0 y:0 gc:(deviceForm gcId) - to:drawableId - x:pX y:pY gc:gcId - width:w height:h. - ]. - - fgId ~~ 0 ifTrue:[ - " - or-in fg-bits ... - " - device setForeground:fgId background:0 in:gcId. - device setFunction:#or in:gcId. - device - copyPlaneFromId:id - x:0 y:0 gc:(deviceForm gcId) - to:drawableId - x:pX y:pY gc:gcId - width:w height:h - ]. - " - flush foreground/background cache - " - foreground := nil. - background := nil. - device setFunction:function in:gcId. - ^ self + " + paint is a real color + " + + " + if paint color is all-0 or all-1's, we can do it in one + operation ... + " + fgId := paint colorId. + + ((fgId ~~ ((1 bitShift:device depth)-1)) + and:[fgId ~~ allBits]) ifTrue:[ + " + clear fg-bits ... + " + device setForeground:0 background:allBits in:gcId. + device setFunction:#and in:gcId. + device + copyPlaneFromId:id + x:0 y:0 gc:(deviceForm gcId) + to:drawableId + x:pX y:pY gc:gcId + width:w height:h. + ]. + + fgId ~~ 0 ifTrue:[ + " + or-in fg-bits ... + " + device setForeground:fgId background:0 in:gcId. + device setFunction:#or in:gcId. + device + copyPlaneFromId:id + x:0 y:0 gc:(deviceForm gcId) + to:drawableId + x:pX y:pY gc:gcId + width:w height:h + ]. + " + flush foreground/background cache + " + foreground := nil. + background := nil. + device setFunction:function in:gcId. + ^ self ]. @@ -2045,11 +2063,11 @@ device setForeground:0 background:allBits in:gcId. device setFunction:#and in:gcId. device - copyPlaneFromId:id - x:0 y:0 gc:(deviceForm gcId) - to:drawableId - x:pX y:pY gc:gcId - width:w height:h. + copyPlaneFromId:id + x:0 y:0 gc:(deviceForm gcId) + to:drawableId + x:pX y:pY gc:gcId + width:w height:h. " or-in temp into destination " @@ -2057,11 +2075,11 @@ device setFunction:#or in:gcId. device - copyFromId:tmpForm id - x:0 y:0 gc:tmpForm gcId - to:drawableId - x:pX y:pY gc:gcId - width:w height:h. + copyFromId:tmpForm id + x:0 y:0 gc:tmpForm gcId + to:drawableId + x:pX y:pY gc:gcId + width:w height:h. " flush foreground/background cache " @@ -2069,7 +2087,7 @@ background := nil. device setFunction:function in:gcId. - "Modified: 5.7.1996 / 17:57:02 / cg" + "Modified: 22.10.1996 / 16:55:29 / cg" ! displayDeviceLineFromX:x0 y:y0 toX:x1 y:y1 @@ -2109,16 +2127,16 @@ "temporary ..." (id isNil or:[aForm graphicsDevice ~~ device]) ifTrue:[ - deviceForm := deviceForm asFormOn:device. - id := deviceForm id. - id isNil ifTrue:[ - 'DEVGC: invalid form draw - ignored' errorPrintNL. - ^ self - ]. + deviceForm := deviceForm asFormOn:device. + id := deviceForm id. + id isNil ifTrue:[ + 'DEVGC: invalid form draw - ignored' errorPrintNL. + ^ self + ]. ]. gcId isNil ifTrue:[ - self initGC + self initGC ]. " @@ -2126,20 +2144,20 @@ and is always drawn opaque. " (aForm depth ~~ 1) ifTrue:[ - device - copyFromId:id - x:0 y:0 gc:deviceForm gcId - to:drawableId - x:pX y:pY gc:gcId - width:w height:h. - ^ self + device + copyFromId:id + x:0 y:0 gc:deviceForm gcId + to:drawableId + x:pX y:pY gc:gcId + width:w height:h. + ^ self ]. "/ if no bgPaint is set, this is a non-opaque draw bgPaint isNil ifTrue:[ - self displayDeviceForm:aForm x:x y:y. - ^ self + self displayDeviceForm:aForm x:x y:y. + ^ self ]. "the following code is somewhat complicated, since it has to deal @@ -2153,38 +2171,38 @@ " easy := true. paint isColor ifFalse:[ - easy := false + easy := false ] ifTrue:[ - fgId := paint colorId. - fgId isNil ifTrue:[ - easy := false - ] + fgId := paint colorId. + fgId isNil ifTrue:[ + easy := false + ] ]. bgPaint isColor ifFalse:[ - easy := false + easy := false ] ifTrue:[ - bgId := bgPaint colorId. - bgId isNil ifTrue:[ - easy := false - ] + bgId := bgPaint colorId. + bgId isNil ifTrue:[ + easy := false + ] ]. easy ifTrue:[ - " - easy: both paint and bgPaint are real colors - " - ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[ - device setForeground:fgId background:bgId in:gcId. - foreground := paint. - background := bgPaint. - ]. - device - copyPlaneFromId:id - x:0 y:0 gc:(deviceForm gcId) - to:drawableId - x:pX y:pY gc:gcId - width:w height:h. - ^ self + " + easy: both paint and bgPaint are real colors + " + ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[ + device setForeground:fgId background:bgId in:gcId. + foreground := paint. + background := bgPaint. + ]. + device + copyPlaneFromId:id + x:0 y:0 gc:(deviceForm gcId) + to:drawableId + x:pX y:pY gc:gcId + width:w height:h. + ^ self ]. " @@ -2195,100 +2213,100 @@ deviceDepth := device depth. (fgId notNil and:[function == #copy]) ifTrue:[ - " - only bg is dithered; fill with bg first ... - " - savedPaint := paint. - self paint:bgPaint. - self fillDeviceRectangleX:pX y:pY width:w height:h. - self paint:savedPaint. - - " - if paint color is all-0 or all-1's, we can do it in one - operation ... - " - ((fgId ~~ ((1 bitShift:deviceDepth)-1)) - and:[fgId ~~ allBits]) ifTrue:[ - " - clear fg-bits ... - " - device setForeground:0 background:allBits in:gcId. - device setFunction:#and in:gcId. - device - copyPlaneFromId:id - x:0 y:0 gc:(deviceForm gcId) - to:drawableId - x:pX y:pY gc:gcId - width:w height:h - ]. - - fgId ~~ 0 ifTrue:[ - " - or-in fg-bits ... - " - device setForeground:fgId background:0 in:gcId. - device setFunction:#or in:gcId. - device - copyPlaneFromId:id - x:0 y:0 gc:(deviceForm gcId) - to:drawableId - x:pX y:pY gc:gcId - width:w height:h - ]. - " - flush foreground/background cache - " - foreground := nil. - background := nil. - device setFunction:function in:gcId. - ^ self + " + only bg is dithered; fill with bg first ... + " + savedPaint := paint. + self paint:bgPaint. + self fillDeviceRectangleX:pX y:pY width:w height:h. + self paint:savedPaint. + + " + if paint color is all-0 or all-1's, we can do it in one + operation ... + " + ((fgId ~~ ((1 bitShift:deviceDepth)-1)) + and:[fgId ~~ allBits]) ifTrue:[ + " + clear fg-bits ... + " + device setForeground:0 background:allBits in:gcId. + device setFunction:#and in:gcId. + device + copyPlaneFromId:id + x:0 y:0 gc:(deviceForm gcId) + to:drawableId + x:pX y:pY gc:gcId + width:w height:h + ]. + + fgId ~~ 0 ifTrue:[ + " + or-in fg-bits ... + " + device setForeground:fgId background:0 in:gcId. + device setFunction:#or in:gcId. + device + copyPlaneFromId:id + x:0 y:0 gc:(deviceForm gcId) + to:drawableId + x:pX y:pY gc:gcId + width:w height:h + ]. + " + flush foreground/background cache + " + foreground := nil. + background := nil. + device setFunction:function in:gcId. + ^ self ]. (bgId notNil and:[function == #copy]) ifTrue:[ - " - only fg is dithered; fill with fg first ... - " - self fillDeviceRectangleX:pX y:pY width:w height:h. - - " - if paint color is all-0 or all-1's, we can do it in one - operation ... - " - ((bgId ~~ ((1 bitShift:deviceDepth)-1)) - and:[bgId ~~ allBits]) ifTrue:[ - " - clear bg-bits ... - " - device setForeground:allBits background:0 in:gcId. - device setFunction:#and in:gcId. - device - copyPlaneFromId:id - x:0 y:0 gc:(deviceForm gcId) - to:drawableId - x:pX y:pY gc:gcId - width:w height:h - ]. - - " - or-in bg-bits ... - " - bgId ~~ 0 ifTrue:[ - device setForeground:0 background:bgId in:gcId. - device setFunction:#or in:gcId. - device - copyPlaneFromId:id - x:0 y:0 gc:(deviceForm gcId) - to:drawableId - x:pX y:pY gc:gcId - width:w height:h - ]. - " - flush foreground/background cache - " - foreground := nil. - background := nil. - device setFunction:function in:gcId. - ^ self + " + only fg is dithered; fill with fg first ... + " + self fillDeviceRectangleX:pX y:pY width:w height:h. + + " + if paint color is all-0 or all-1's, we can do it in one + operation ... + " + ((bgId ~~ ((1 bitShift:deviceDepth)-1)) + and:[bgId ~~ allBits]) ifTrue:[ + " + clear bg-bits ... + " + device setForeground:allBits background:0 in:gcId. + device setFunction:#and in:gcId. + device + copyPlaneFromId:id + x:0 y:0 gc:(deviceForm gcId) + to:drawableId + x:pX y:pY gc:gcId + width:w height:h + ]. + + " + or-in bg-bits ... + " + bgId ~~ 0 ifTrue:[ + device setForeground:0 background:bgId in:gcId. + device setFunction:#or in:gcId. + device + copyPlaneFromId:id + x:0 y:0 gc:(deviceForm gcId) + to:drawableId + x:pX y:pY gc:gcId + width:w height:h + ]. + " + flush foreground/background cache + " + foreground := nil. + background := nil. + device setFunction:function in:gcId. + ^ self ]. " @@ -2308,8 +2326,8 @@ " dx := dy := 0. maskOrigin notNil ifTrue:[ - dx := maskOrigin x. - dy := maskOrigin y + dx := maskOrigin x. + dy := maskOrigin y ]. bgForm paint:bgPaint. @@ -2352,18 +2370,18 @@ " device setForeground:0 background:allBits in:gcId. device - copyFromId:tmpForm id - x:0 y:0 gc:tmpForm gcId - to:drawableId - x:pX y:pY gc:gcId - width:w height:h. + copyFromId:tmpForm id + x:0 y:0 gc:tmpForm gcId + to:drawableId + x:pX y:pY gc:gcId + width:w height:h. " flush foreground/background cache " foreground := nil. background := nil. - "Modified: 22.6.1996 / 16:45:35 / cg" + "Modified: 22.10.1996 / 16:48:32 / cg" ! displayDeviceOpaqueString:aString from:index1 to:index2 in:font x:x y:y @@ -3326,9 +3344,9 @@ ^ device verticalPixelPerMillimeter * millis ! ! -!DeviceGraphicsContext class methodsFor:'documentation'! +!DeviceGraphicsContext class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libview/Attic/DevGC.st,v 1.19 1996-10-01 17:41:57 cg Exp $' + ^ '$Header: /cvs/stx/stx/libview/Attic/DevGC.st,v 1.20 1996-10-22 15:56:44 cg Exp $' ! ! DeviceGraphicsContext initialize! diff -r 9c433066e960 -r 3513a4cae87b DeviceGraphicsContext.st --- a/DeviceGraphicsContext.st Mon Oct 21 12:47:57 1996 +0200 +++ b/DeviceGraphicsContext.st Tue Oct 22 17:56:44 1996 +0200 @@ -17,7 +17,7 @@ category:'Graphics-Support' ! -!DeviceGraphicsContext class methodsFor:'documentation'! +!DeviceGraphicsContext class methodsFor:'documentation'! copyright " @@ -75,7 +75,7 @@ " ! ! -!DeviceGraphicsContext class methodsFor:'initialization'! +!DeviceGraphicsContext class methodsFor:'initialization'! initialize Lobby isNil ifTrue:[ @@ -83,7 +83,7 @@ ] ! ! -!DeviceGraphicsContext class methodsFor:'instance creation'! +!DeviceGraphicsContext class methodsFor:'instance creation'! new "create a new drawable - take the current display as @@ -120,7 +120,7 @@ ^ newDrawable ! ! -!DeviceGraphicsContext class methodsFor:'cleanup'! +!DeviceGraphicsContext class methodsFor:'cleanup'! lowSpaceCleanup CachedScaledForms := CachedScales := nil @@ -1845,102 +1845,120 @@ id := deviceForm id. id isNil ifTrue:[ - deviceForm := aForm asFormOn:device. - id := deviceForm id. - id isNil ifTrue:[ - 'DEVGC: invalid form draw - ignored' errorPrintNL. - ^ self - ]. + deviceForm := aForm asFormOn:device. + id := deviceForm id. + id isNil ifTrue:[ + 'DEVGC: invalid form draw - ignored' errorPrintNL. + ^ self + ]. ]. gcId isNil ifTrue:[ - self initGC + self initGC ]. " a deep form ignores paint/bgPaint settings " - (aForm depth ~~ 1) ifTrue:[ - (mask := aForm mask) notNil ifTrue:[ - mask depth == 1 ifFalse:[ - 'DEVGC: alpha channel not yet supported' errorPrintCR. - ] ifTrue:[ - deviceMask := mask asFormOn:device. - maskId := deviceMask id. - maskId notNil ifTrue:[ - " - create temp-form; - " - tmpForm := Form width:w height:h depth:device depth on:device. - tmpForm initGC. - - " - fill tempform with image - " - device - copyFromId:id - x:0 y:0 gc:gcId - to:tmpForm id - x:0 y:0 gc:(tmpForm gcId) - width:w height:h. - - allColor := Color allColor. - allBits := allColor colorId. - - " - stamp out mask in temp form - " - device setForeground:allBits background:0 in:tmpForm gcId. - device setFunction:#and in:tmpForm gcId. - device - copyPlaneFromId:maskId - x:0 y:0 gc:(deviceMask gcId) - to:tmpForm id - x:0 y:0 gc:tmpForm gcId - width:w height:h. - - - " - stamp out mask in destination - " - device setForeground:0 background:allBits in:gcId. - device setFunction:#and in:gcId. - device - copyPlaneFromId:maskId - x:0 y:0 gc:(deviceMask gcId) - to:drawableId - x:pX y:pY gc:gcId - width:w height:h. + mask := aForm mask. + + ((aForm depth ~~ 1) + or:[mask notNil]) ifTrue:[ + mask notNil ifTrue:[ + mask depth == 1 ifFalse:[ + 'DEVGC: alpha channel not yet supported' errorPrintCR. + ] ifTrue:[ + deviceMask := mask asFormOn:device. + maskId := deviceMask id. + maskId notNil ifTrue:[ + " + create temp-form; + " + tmpForm := Form width:w height:h depth:device depth on:device. + tmpForm initGC. + + " + fill tempform with image + " + aForm depth == 1 ifTrue:[ + aForm colorMap notNil ifTrue:[ + device + setForeground:((aForm colorMap at:2) on:device) colorId + background:((aForm colorMap at:1) on:device) colorId + in:tmpForm gcId. + ]. + device + copyPlaneFromId:id + x:0 y:0 gc:gcId + to:tmpForm id + x:0 y:0 gc:tmpForm gcId + width:w height:h. + ] ifFalse:[ + device + copyFromId:id + x:0 y:0 gc:gcId + to:tmpForm id + x:0 y:0 gc:(tmpForm gcId) + width:w height:h. + ]. + + allColor := Color allColor. + allBits := allColor colorId. + + " + stamp out mask in temp form + " + device setForeground:allBits background:0 in:tmpForm gcId. + device setFunction:#and in:tmpForm gcId. + device + copyPlaneFromId:maskId + x:0 y:0 gc:(deviceMask gcId) + to:tmpForm id + x:0 y:0 gc:tmpForm gcId + width:w height:h. + + + " + stamp out mask in destination + " + device setForeground:0 background:allBits in:gcId. + device setFunction:#and in:gcId. + device + copyPlaneFromId:maskId + x:0 y:0 gc:(deviceMask gcId) + to:drawableId + x:pX y:pY gc:gcId + width:w height:h. "/ Delay waitForSeconds:3. - " - or-in tempform-bits ... - " - device setFunction:#or in:gcId. - device - copyFromId:tmpForm id - x:0 y:0 gc:tmpForm gcId - to:drawableId - x:pX y:pY gc:gcId - width:w height:h. - - foreground notNil ifTrue:[ - device setForeground:foreground colorId in:gcId. - ]. - background notNil ifTrue:[ - device setBackground:background colorId in:gcId. - ]. - device setFunction:function in:gcId. - ^ self - ] - ] - ]. - - device - copyFromId:id - x:0 y:0 gc:deviceForm gcId - to:drawableId - x:pX y:pY gc:gcId - width:w height:h. - ^ self + " + or-in tempform-bits ... + " + device setFunction:#or in:gcId. + device + copyFromId:tmpForm id + x:0 y:0 gc:tmpForm gcId + to:drawableId + x:pX y:pY gc:gcId + width:w height:h. + + foreground notNil ifTrue:[ + device setForeground:foreground colorId in:gcId. + ]. + background notNil ifTrue:[ + device setBackground:background colorId in:gcId. + ]. + device setFunction:function in:gcId. + ^ self + ] + ] + ]. + + device + copyFromId:id + x:0 y:0 gc:deviceForm gcId + to:drawableId + x:pX y:pY gc:gcId + width:w height:h. + ^ self ]. " @@ -1955,66 +1973,66 @@ " easy := (function == #copy). easy ifTrue:[ - paint isColor ifFalse:[ - paintDither := paint. - easy := false - ] ifTrue:[ - paintDither := paint ditherForm. - paintDither notNil ifTrue:[ - easy := false. - ] - ]. + paint isColor ifFalse:[ + paintDither := paint. + easy := false + ] ifTrue:[ + paintDither := paint ditherForm. + paintDither notNil ifTrue:[ + easy := false. + ] + ]. ]. allColor := Color allColor. allBits := allColor colorId. easy ifTrue:[ - " - paint is a real color - " - - " - if paint color is all-0 or all-1's, we can do it in one - operation ... - " - fgId := paint colorId. - - ((fgId ~~ ((1 bitShift:device depth)-1)) - and:[fgId ~~ allBits]) ifTrue:[ - " - clear fg-bits ... - " - device setForeground:0 background:allBits in:gcId. - device setFunction:#and in:gcId. - device - copyPlaneFromId:id - x:0 y:0 gc:(deviceForm gcId) - to:drawableId - x:pX y:pY gc:gcId - width:w height:h. - ]. - - fgId ~~ 0 ifTrue:[ - " - or-in fg-bits ... - " - device setForeground:fgId background:0 in:gcId. - device setFunction:#or in:gcId. - device - copyPlaneFromId:id - x:0 y:0 gc:(deviceForm gcId) - to:drawableId - x:pX y:pY gc:gcId - width:w height:h - ]. - " - flush foreground/background cache - " - foreground := nil. - background := nil. - device setFunction:function in:gcId. - ^ self + " + paint is a real color + " + + " + if paint color is all-0 or all-1's, we can do it in one + operation ... + " + fgId := paint colorId. + + ((fgId ~~ ((1 bitShift:device depth)-1)) + and:[fgId ~~ allBits]) ifTrue:[ + " + clear fg-bits ... + " + device setForeground:0 background:allBits in:gcId. + device setFunction:#and in:gcId. + device + copyPlaneFromId:id + x:0 y:0 gc:(deviceForm gcId) + to:drawableId + x:pX y:pY gc:gcId + width:w height:h. + ]. + + fgId ~~ 0 ifTrue:[ + " + or-in fg-bits ... + " + device setForeground:fgId background:0 in:gcId. + device setFunction:#or in:gcId. + device + copyPlaneFromId:id + x:0 y:0 gc:(deviceForm gcId) + to:drawableId + x:pX y:pY gc:gcId + width:w height:h + ]. + " + flush foreground/background cache + " + foreground := nil. + background := nil. + device setFunction:function in:gcId. + ^ self ]. @@ -2045,11 +2063,11 @@ device setForeground:0 background:allBits in:gcId. device setFunction:#and in:gcId. device - copyPlaneFromId:id - x:0 y:0 gc:(deviceForm gcId) - to:drawableId - x:pX y:pY gc:gcId - width:w height:h. + copyPlaneFromId:id + x:0 y:0 gc:(deviceForm gcId) + to:drawableId + x:pX y:pY gc:gcId + width:w height:h. " or-in temp into destination " @@ -2057,11 +2075,11 @@ device setFunction:#or in:gcId. device - copyFromId:tmpForm id - x:0 y:0 gc:tmpForm gcId - to:drawableId - x:pX y:pY gc:gcId - width:w height:h. + copyFromId:tmpForm id + x:0 y:0 gc:tmpForm gcId + to:drawableId + x:pX y:pY gc:gcId + width:w height:h. " flush foreground/background cache " @@ -2069,7 +2087,7 @@ background := nil. device setFunction:function in:gcId. - "Modified: 5.7.1996 / 17:57:02 / cg" + "Modified: 22.10.1996 / 16:55:29 / cg" ! displayDeviceLineFromX:x0 y:y0 toX:x1 y:y1 @@ -2109,16 +2127,16 @@ "temporary ..." (id isNil or:[aForm graphicsDevice ~~ device]) ifTrue:[ - deviceForm := deviceForm asFormOn:device. - id := deviceForm id. - id isNil ifTrue:[ - 'DEVGC: invalid form draw - ignored' errorPrintNL. - ^ self - ]. + deviceForm := deviceForm asFormOn:device. + id := deviceForm id. + id isNil ifTrue:[ + 'DEVGC: invalid form draw - ignored' errorPrintNL. + ^ self + ]. ]. gcId isNil ifTrue:[ - self initGC + self initGC ]. " @@ -2126,20 +2144,20 @@ and is always drawn opaque. " (aForm depth ~~ 1) ifTrue:[ - device - copyFromId:id - x:0 y:0 gc:deviceForm gcId - to:drawableId - x:pX y:pY gc:gcId - width:w height:h. - ^ self + device + copyFromId:id + x:0 y:0 gc:deviceForm gcId + to:drawableId + x:pX y:pY gc:gcId + width:w height:h. + ^ self ]. "/ if no bgPaint is set, this is a non-opaque draw bgPaint isNil ifTrue:[ - self displayDeviceForm:aForm x:x y:y. - ^ self + self displayDeviceForm:aForm x:x y:y. + ^ self ]. "the following code is somewhat complicated, since it has to deal @@ -2153,38 +2171,38 @@ " easy := true. paint isColor ifFalse:[ - easy := false + easy := false ] ifTrue:[ - fgId := paint colorId. - fgId isNil ifTrue:[ - easy := false - ] + fgId := paint colorId. + fgId isNil ifTrue:[ + easy := false + ] ]. bgPaint isColor ifFalse:[ - easy := false + easy := false ] ifTrue:[ - bgId := bgPaint colorId. - bgId isNil ifTrue:[ - easy := false - ] + bgId := bgPaint colorId. + bgId isNil ifTrue:[ + easy := false + ] ]. easy ifTrue:[ - " - easy: both paint and bgPaint are real colors - " - ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[ - device setForeground:fgId background:bgId in:gcId. - foreground := paint. - background := bgPaint. - ]. - device - copyPlaneFromId:id - x:0 y:0 gc:(deviceForm gcId) - to:drawableId - x:pX y:pY gc:gcId - width:w height:h. - ^ self + " + easy: both paint and bgPaint are real colors + " + ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[ + device setForeground:fgId background:bgId in:gcId. + foreground := paint. + background := bgPaint. + ]. + device + copyPlaneFromId:id + x:0 y:0 gc:(deviceForm gcId) + to:drawableId + x:pX y:pY gc:gcId + width:w height:h. + ^ self ]. " @@ -2195,100 +2213,100 @@ deviceDepth := device depth. (fgId notNil and:[function == #copy]) ifTrue:[ - " - only bg is dithered; fill with bg first ... - " - savedPaint := paint. - self paint:bgPaint. - self fillDeviceRectangleX:pX y:pY width:w height:h. - self paint:savedPaint. - - " - if paint color is all-0 or all-1's, we can do it in one - operation ... - " - ((fgId ~~ ((1 bitShift:deviceDepth)-1)) - and:[fgId ~~ allBits]) ifTrue:[ - " - clear fg-bits ... - " - device setForeground:0 background:allBits in:gcId. - device setFunction:#and in:gcId. - device - copyPlaneFromId:id - x:0 y:0 gc:(deviceForm gcId) - to:drawableId - x:pX y:pY gc:gcId - width:w height:h - ]. - - fgId ~~ 0 ifTrue:[ - " - or-in fg-bits ... - " - device setForeground:fgId background:0 in:gcId. - device setFunction:#or in:gcId. - device - copyPlaneFromId:id - x:0 y:0 gc:(deviceForm gcId) - to:drawableId - x:pX y:pY gc:gcId - width:w height:h - ]. - " - flush foreground/background cache - " - foreground := nil. - background := nil. - device setFunction:function in:gcId. - ^ self + " + only bg is dithered; fill with bg first ... + " + savedPaint := paint. + self paint:bgPaint. + self fillDeviceRectangleX:pX y:pY width:w height:h. + self paint:savedPaint. + + " + if paint color is all-0 or all-1's, we can do it in one + operation ... + " + ((fgId ~~ ((1 bitShift:deviceDepth)-1)) + and:[fgId ~~ allBits]) ifTrue:[ + " + clear fg-bits ... + " + device setForeground:0 background:allBits in:gcId. + device setFunction:#and in:gcId. + device + copyPlaneFromId:id + x:0 y:0 gc:(deviceForm gcId) + to:drawableId + x:pX y:pY gc:gcId + width:w height:h + ]. + + fgId ~~ 0 ifTrue:[ + " + or-in fg-bits ... + " + device setForeground:fgId background:0 in:gcId. + device setFunction:#or in:gcId. + device + copyPlaneFromId:id + x:0 y:0 gc:(deviceForm gcId) + to:drawableId + x:pX y:pY gc:gcId + width:w height:h + ]. + " + flush foreground/background cache + " + foreground := nil. + background := nil. + device setFunction:function in:gcId. + ^ self ]. (bgId notNil and:[function == #copy]) ifTrue:[ - " - only fg is dithered; fill with fg first ... - " - self fillDeviceRectangleX:pX y:pY width:w height:h. - - " - if paint color is all-0 or all-1's, we can do it in one - operation ... - " - ((bgId ~~ ((1 bitShift:deviceDepth)-1)) - and:[bgId ~~ allBits]) ifTrue:[ - " - clear bg-bits ... - " - device setForeground:allBits background:0 in:gcId. - device setFunction:#and in:gcId. - device - copyPlaneFromId:id - x:0 y:0 gc:(deviceForm gcId) - to:drawableId - x:pX y:pY gc:gcId - width:w height:h - ]. - - " - or-in bg-bits ... - " - bgId ~~ 0 ifTrue:[ - device setForeground:0 background:bgId in:gcId. - device setFunction:#or in:gcId. - device - copyPlaneFromId:id - x:0 y:0 gc:(deviceForm gcId) - to:drawableId - x:pX y:pY gc:gcId - width:w height:h - ]. - " - flush foreground/background cache - " - foreground := nil. - background := nil. - device setFunction:function in:gcId. - ^ self + " + only fg is dithered; fill with fg first ... + " + self fillDeviceRectangleX:pX y:pY width:w height:h. + + " + if paint color is all-0 or all-1's, we can do it in one + operation ... + " + ((bgId ~~ ((1 bitShift:deviceDepth)-1)) + and:[bgId ~~ allBits]) ifTrue:[ + " + clear bg-bits ... + " + device setForeground:allBits background:0 in:gcId. + device setFunction:#and in:gcId. + device + copyPlaneFromId:id + x:0 y:0 gc:(deviceForm gcId) + to:drawableId + x:pX y:pY gc:gcId + width:w height:h + ]. + + " + or-in bg-bits ... + " + bgId ~~ 0 ifTrue:[ + device setForeground:0 background:bgId in:gcId. + device setFunction:#or in:gcId. + device + copyPlaneFromId:id + x:0 y:0 gc:(deviceForm gcId) + to:drawableId + x:pX y:pY gc:gcId + width:w height:h + ]. + " + flush foreground/background cache + " + foreground := nil. + background := nil. + device setFunction:function in:gcId. + ^ self ]. " @@ -2308,8 +2326,8 @@ " dx := dy := 0. maskOrigin notNil ifTrue:[ - dx := maskOrigin x. - dy := maskOrigin y + dx := maskOrigin x. + dy := maskOrigin y ]. bgForm paint:bgPaint. @@ -2352,18 +2370,18 @@ " device setForeground:0 background:allBits in:gcId. device - copyFromId:tmpForm id - x:0 y:0 gc:tmpForm gcId - to:drawableId - x:pX y:pY gc:gcId - width:w height:h. + copyFromId:tmpForm id + x:0 y:0 gc:tmpForm gcId + to:drawableId + x:pX y:pY gc:gcId + width:w height:h. " flush foreground/background cache " foreground := nil. background := nil. - "Modified: 22.6.1996 / 16:45:35 / cg" + "Modified: 22.10.1996 / 16:48:32 / cg" ! displayDeviceOpaqueString:aString from:index1 to:index2 in:font x:x y:y @@ -3326,9 +3344,9 @@ ^ device verticalPixelPerMillimeter * millis ! ! -!DeviceGraphicsContext class methodsFor:'documentation'! +!DeviceGraphicsContext class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libview/DeviceGraphicsContext.st,v 1.19 1996-10-01 17:41:57 cg Exp $' + ^ '$Header: /cvs/stx/stx/libview/DeviceGraphicsContext.st,v 1.20 1996-10-22 15:56:44 cg Exp $' ! ! DeviceGraphicsContext initialize!