release temporary forms early
authorClaus Gittinger <cg@exept.de>
Tue, 22 Apr 1997 21:49:44 +0200
changeset 1637 4e6372dce15d
parent 1636 c30f6644666e
child 1638 a673a91d4ca1
release temporary forms early
DevGC.st
DeviceGraphicsContext.st
--- a/DevGC.st	Tue Apr 22 21:37:04 1997 +0200
+++ b/DevGC.st	Tue Apr 22 21:49:44 1997 +0200
@@ -2063,8 +2063,8 @@
                         "
                          stamp out mask in temp form
                         "
-                        device setForeground:allBits background:0 in:tmpForm gcId.
-                        device setFunction:#and in:tmpForm gcId.
+                        device setForeground:allBits background:0 in:tmpGCId.
+                        device setFunction:#and in:tmpGCId.
                         device
                             copyPlaneFromPixmapId:maskId
                             x:0 
@@ -2109,6 +2109,13 @@
                             gc:gcId
                             width:w 
                             height:h.
+
+                        "
+                         release tempForm immediately
+                         (although GC will eventually do it, 
+                          this creates less stress to the Xserver in the meanwhile ...)
+                        "
+                        tmpForm destroy.
                     ].
 
                     "/ restore GC
@@ -2315,6 +2322,14 @@
         gc:gcId
         width:w 
         height:h.
+
+    "
+     release tempForm immediately
+     (although GC will eventually do it, 
+      this creates less stress to the Xserver in the meanwhile ...)
+    "
+
+    tmpForm destroy.
     "
      flush foreground/background cache
     "
@@ -2322,7 +2337,7 @@
     background := nil.
     device setFunction:function in:gcId.
 
-    "Modified: 15.4.1997 / 09:46:10 / cg"
+    "Modified: 22.4.1997 / 21:48:27 / cg"
 !
 
 displayDeviceLineFromX:x0 y:y0 toX:x1 y:y1
@@ -2648,13 +2663,23 @@
         gc:gcId
         width:w 
         height:h.
+
+    "
+     release tempForms immediately
+     (although GC will eventually do it, 
+      this creates less stress to the Xserver in the meanwhile ...)
+    "
+    fgForm destroy.
+    bgForm destroy.
+    tmpForm destroy.
+
     "
      flush foreground/background cache
     "
     foreground := nil.
     background := nil.
 
-    "Modified: 12.4.1997 / 12:43:09 / cg"
+    "Modified: 22.4.1997 / 21:44:10 / cg"
 !
 
 displayDeviceOpaqueString:aString from:index1 to:index2 in:font x:x y:y
@@ -2673,22 +2698,22 @@
      this is a non-opaque draw
     "
     bgPaint isNil ifTrue:[
-	self displayDeviceString:aString from:index1 to:index2 x:x y:y.
-	^ self
+        self displayDeviceString:aString from:index1 to:index2 x:x y:y.
+        ^ self
     ].
 
     (aString isString not
     or:[aString isText]) ifTrue:[
-	"
-	 hook for non-strings (i.e. attributed text)
-	 that 'thing' should know how to display itself ...
-	"
-	aString displayOpaqueOn:self x:x y:y from:index1 to:index2.
-	^ self
+        "
+         hook for non-strings (i.e. attributed text)
+         that 'thing' should know how to display itself ...
+        "
+        aString displayOpaqueOn:self x:x y:y from:index1 to:index2.
+        ^ self
     ].
 
     gcId isNil ifTrue:[
-	self initGC
+        self initGC
     ].
 
     pX := x rounded.
@@ -2698,22 +2723,22 @@
 
     id := fontUsed fontId.
     id isNil ifTrue:[
-	"
-	 hook for alien fonts
-	 that 'font' should know how to display the string ...
-	"
-	font displayOpaqueString:aString from:index1 to:index2 x:x y:y in:self.
-	^ self
+        "
+         hook for alien fonts
+         that 'font' should know how to display the string ...
+        "
+        font displayOpaqueString:aString from:index1 to:index2 x:x y:y in:self.
+        ^ self
     ].
 
     s := aString.
     s encoding ~~ font encoding ifTrue:[
-	s := s encodeInto:(font encoding).
+        s := s encodeInto:(font encoding).
     ].
 
     deviceFont ~~ fontUsed ifTrue:[
-	device setFont:id in:gcId.
-	deviceFont := fontUsed
+        device setFont:id in:gcId.
+        deviceFont := fontUsed
     ].
 
     "
@@ -2721,53 +2746,53 @@
     "
     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:[
-	device setForeground:fgId background:bgId in:gcId.
-	foreground := paint.
-	background := bgPaint.
-	device displayOpaqueString:s 
-			      from:index1 to:index2
-				 x:pX y:pY 
-				in:drawableId with:gcId.
-	^ self
+        device setForeground:fgId background:bgId in:gcId.
+        foreground := paint.
+        background := bgPaint.
+        device displayOpaqueString:s 
+                              from:index1 to:index2
+                                 x:pX y:pY 
+                                in:drawableId with:gcId.
+        ^ self
     ].
 
     w := fontUsed widthOf:s from:index1 to:index2.
     h := fontUsed height.
 
     (fgId notNil and:[function == #copy]) ifTrue:[
-	"
-	 only bg is dithered; fill with bg first ...
-	"
-	savedPaint := paint.
-	self paint:bgPaint.
-	self fillRectangleX:pX y:(pY - fontUsed ascent) width:w height:h.
-	self paint:savedPaint.
-
-	"
-	 then draw using fgPaint (which is a real color)
-	"
-	device displayString:s 
-			from:index1 to:index2
-			   x:pX y:pY 
-			  in:drawableId with:gcId.
-	^ self
+        "
+         only bg is dithered; fill with bg first ...
+        "
+        savedPaint := paint.
+        self paint:bgPaint.
+        self fillRectangleX:pX y:(pY - fontUsed ascent) width:w height:h.
+        self paint:savedPaint.
+
+        "
+         then draw using fgPaint (which is a real color)
+        "
+        device displayString:s 
+                        from:index1 to:index2
+                           x:pX y:pY 
+                          in:drawableId with:gcId.
+        ^ self
     ].
 
     allColor := Color allColor.
@@ -2825,27 +2850,27 @@
 "/  ].
 
     (bgId notNil and:[function == #copy]) ifTrue:[
-	"
-	 only fg is dithered; fill with bg first ...
-	"
-	device setForeground:bgId in:gcId.
-	device setFunction:#copy in:gcId.
-	device setBitmapMask:nil in:gcId.
-	self fillRectangleX:pX y:(pY - fontUsed ascent) width:w height:h.
-
-	"/ draw fg dithered
-	(mask depth == 1) ifTrue:[
-	    device setBitmapMask:mask id in:gcId.
-	    device setForeground:foreground colorId background:background colorId in:gcId.
-	] ifFalse:[
-	    device setPixmapMask:mask id in:gcId
-	].
-
-	device displayString:s
-		    from:index1 to:index2 
-		       x:pX y:pY
-		      in:drawableId with:gcId.
-	^ self.
+        "
+         only fg is dithered; fill with bg first ...
+        "
+        device setForeground:bgId in:gcId.
+        device setFunction:#copy in:gcId.
+        device setBitmapMask:nil in:gcId.
+        self fillRectangleX:pX y:(pY - fontUsed ascent) width:w height:h.
+
+        "/ draw fg dithered
+        (mask depth == 1) ifTrue:[
+            device setBitmapMask:mask id in:gcId.
+            device setForeground:foreground colorId background:background colorId in:gcId.
+        ] ifFalse:[
+            device setPixmapMask:mask id in:gcId
+        ].
+
+        device displayString:s
+                    from:index1 to:index2 
+                       x:pX y:pY
+                      in:drawableId with:gcId.
+        ^ self.
 "/
 "/      "
 "/       if bgPaint color is all-0 or all-1's, we can do it in one
@@ -2903,8 +2928,8 @@
     dx := 0.
     dy := fontUsed ascent.
     maskOrigin notNil ifTrue:[
-	dx := maskOrigin x.
-	dy := dy + maskOrigin y
+        dx := maskOrigin x.
+        dy := dy + maskOrigin y
     ].
 
     bgForm paint:bgPaint.
@@ -2922,8 +2947,8 @@
     bgForm paint:noColor on:allColor.
     bgForm function:#and.
     bgForm displayString:s 
-		    from:index1 to:index2 
-		       x:0 y:fontUsed ascent.
+                    from:index1 to:index2 
+                       x:0 y:fontUsed ascent.
 
     "
      stamp-out foreground
@@ -2931,8 +2956,8 @@
     maskForm font:fontUsed.
     maskForm paint:allColor on:noColor.
     maskForm displayOpaqueString:s 
-			    from:index1 to:index2 
-			       x:0 y:fontUsed ascent.
+                            from:index1 to:index2 
+                               x:0 y:fontUsed ascent.
 
     fgForm function:#and.
     fgForm copyFrom:maskForm x:0 y:0 toX:0 y:0 width:w height:h.
@@ -2955,18 +2980,29 @@
     "
     device setForeground:0 background:allBits in:gcId.
     device
-	copyFromId:tmpForm id
-		 x:0 y:0 gc:tmpForm gcId
-		to:drawableId
-		 x:pX y:(pY-fontUsed ascent) gc:gcId
-	     width:w height:h.
+        copyFromId:tmpForm id
+                 x:0 y:0 gc:tmpForm gcId
+                to:drawableId
+                 x:pX y:(pY-fontUsed ascent) gc:gcId
+             width:w height:h.
+
+    "
+     release tempForms immediately
+     (although GC will eventually do it, 
+      this creates less stress to the Xserver in the meanwhile ...)
+    "
+    tmpForm destroy.
+    fgForm destroy.
+    bgForm destroy.
+    maskForm destroy.
+
     "
      flush foreground/background cache
     "
     foreground := nil.
     background := nil.
 
-    "Modified: 12.6.1996 / 12:50:12 / cg"
+    "Modified: 22.4.1997 / 21:47:15 / cg"
 !
 
 displayDeviceOpaqueString:aString from:index1 to:index2 x:x y:y
@@ -3649,6 +3685,6 @@
 !DeviceGraphicsContext class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Attic/DevGC.st,v 1.37 1997-04-15 07:47:28 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Attic/DevGC.st,v 1.38 1997-04-22 19:49:44 cg Exp $'
 ! !
 DeviceGraphicsContext initialize!
--- a/DeviceGraphicsContext.st	Tue Apr 22 21:37:04 1997 +0200
+++ b/DeviceGraphicsContext.st	Tue Apr 22 21:49:44 1997 +0200
@@ -2063,8 +2063,8 @@
                         "
                          stamp out mask in temp form
                         "
-                        device setForeground:allBits background:0 in:tmpForm gcId.
-                        device setFunction:#and in:tmpForm gcId.
+                        device setForeground:allBits background:0 in:tmpGCId.
+                        device setFunction:#and in:tmpGCId.
                         device
                             copyPlaneFromPixmapId:maskId
                             x:0 
@@ -2109,6 +2109,13 @@
                             gc:gcId
                             width:w 
                             height:h.
+
+                        "
+                         release tempForm immediately
+                         (although GC will eventually do it, 
+                          this creates less stress to the Xserver in the meanwhile ...)
+                        "
+                        tmpForm destroy.
                     ].
 
                     "/ restore GC
@@ -2315,6 +2322,14 @@
         gc:gcId
         width:w 
         height:h.
+
+    "
+     release tempForm immediately
+     (although GC will eventually do it, 
+      this creates less stress to the Xserver in the meanwhile ...)
+    "
+
+    tmpForm destroy.
     "
      flush foreground/background cache
     "
@@ -2322,7 +2337,7 @@
     background := nil.
     device setFunction:function in:gcId.
 
-    "Modified: 15.4.1997 / 09:46:10 / cg"
+    "Modified: 22.4.1997 / 21:48:27 / cg"
 !
 
 displayDeviceLineFromX:x0 y:y0 toX:x1 y:y1
@@ -2648,13 +2663,23 @@
         gc:gcId
         width:w 
         height:h.
+
+    "
+     release tempForms immediately
+     (although GC will eventually do it, 
+      this creates less stress to the Xserver in the meanwhile ...)
+    "
+    fgForm destroy.
+    bgForm destroy.
+    tmpForm destroy.
+
     "
      flush foreground/background cache
     "
     foreground := nil.
     background := nil.
 
-    "Modified: 12.4.1997 / 12:43:09 / cg"
+    "Modified: 22.4.1997 / 21:44:10 / cg"
 !
 
 displayDeviceOpaqueString:aString from:index1 to:index2 in:font x:x y:y
@@ -2673,22 +2698,22 @@
      this is a non-opaque draw
     "
     bgPaint isNil ifTrue:[
-	self displayDeviceString:aString from:index1 to:index2 x:x y:y.
-	^ self
+        self displayDeviceString:aString from:index1 to:index2 x:x y:y.
+        ^ self
     ].
 
     (aString isString not
     or:[aString isText]) ifTrue:[
-	"
-	 hook for non-strings (i.e. attributed text)
-	 that 'thing' should know how to display itself ...
-	"
-	aString displayOpaqueOn:self x:x y:y from:index1 to:index2.
-	^ self
+        "
+         hook for non-strings (i.e. attributed text)
+         that 'thing' should know how to display itself ...
+        "
+        aString displayOpaqueOn:self x:x y:y from:index1 to:index2.
+        ^ self
     ].
 
     gcId isNil ifTrue:[
-	self initGC
+        self initGC
     ].
 
     pX := x rounded.
@@ -2698,22 +2723,22 @@
 
     id := fontUsed fontId.
     id isNil ifTrue:[
-	"
-	 hook for alien fonts
-	 that 'font' should know how to display the string ...
-	"
-	font displayOpaqueString:aString from:index1 to:index2 x:x y:y in:self.
-	^ self
+        "
+         hook for alien fonts
+         that 'font' should know how to display the string ...
+        "
+        font displayOpaqueString:aString from:index1 to:index2 x:x y:y in:self.
+        ^ self
     ].
 
     s := aString.
     s encoding ~~ font encoding ifTrue:[
-	s := s encodeInto:(font encoding).
+        s := s encodeInto:(font encoding).
     ].
 
     deviceFont ~~ fontUsed ifTrue:[
-	device setFont:id in:gcId.
-	deviceFont := fontUsed
+        device setFont:id in:gcId.
+        deviceFont := fontUsed
     ].
 
     "
@@ -2721,53 +2746,53 @@
     "
     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:[
-	device setForeground:fgId background:bgId in:gcId.
-	foreground := paint.
-	background := bgPaint.
-	device displayOpaqueString:s 
-			      from:index1 to:index2
-				 x:pX y:pY 
-				in:drawableId with:gcId.
-	^ self
+        device setForeground:fgId background:bgId in:gcId.
+        foreground := paint.
+        background := bgPaint.
+        device displayOpaqueString:s 
+                              from:index1 to:index2
+                                 x:pX y:pY 
+                                in:drawableId with:gcId.
+        ^ self
     ].
 
     w := fontUsed widthOf:s from:index1 to:index2.
     h := fontUsed height.
 
     (fgId notNil and:[function == #copy]) ifTrue:[
-	"
-	 only bg is dithered; fill with bg first ...
-	"
-	savedPaint := paint.
-	self paint:bgPaint.
-	self fillRectangleX:pX y:(pY - fontUsed ascent) width:w height:h.
-	self paint:savedPaint.
-
-	"
-	 then draw using fgPaint (which is a real color)
-	"
-	device displayString:s 
-			from:index1 to:index2
-			   x:pX y:pY 
-			  in:drawableId with:gcId.
-	^ self
+        "
+         only bg is dithered; fill with bg first ...
+        "
+        savedPaint := paint.
+        self paint:bgPaint.
+        self fillRectangleX:pX y:(pY - fontUsed ascent) width:w height:h.
+        self paint:savedPaint.
+
+        "
+         then draw using fgPaint (which is a real color)
+        "
+        device displayString:s 
+                        from:index1 to:index2
+                           x:pX y:pY 
+                          in:drawableId with:gcId.
+        ^ self
     ].
 
     allColor := Color allColor.
@@ -2825,27 +2850,27 @@
 "/  ].
 
     (bgId notNil and:[function == #copy]) ifTrue:[
-	"
-	 only fg is dithered; fill with bg first ...
-	"
-	device setForeground:bgId in:gcId.
-	device setFunction:#copy in:gcId.
-	device setBitmapMask:nil in:gcId.
-	self fillRectangleX:pX y:(pY - fontUsed ascent) width:w height:h.
-
-	"/ draw fg dithered
-	(mask depth == 1) ifTrue:[
-	    device setBitmapMask:mask id in:gcId.
-	    device setForeground:foreground colorId background:background colorId in:gcId.
-	] ifFalse:[
-	    device setPixmapMask:mask id in:gcId
-	].
-
-	device displayString:s
-		    from:index1 to:index2 
-		       x:pX y:pY
-		      in:drawableId with:gcId.
-	^ self.
+        "
+         only fg is dithered; fill with bg first ...
+        "
+        device setForeground:bgId in:gcId.
+        device setFunction:#copy in:gcId.
+        device setBitmapMask:nil in:gcId.
+        self fillRectangleX:pX y:(pY - fontUsed ascent) width:w height:h.
+
+        "/ draw fg dithered
+        (mask depth == 1) ifTrue:[
+            device setBitmapMask:mask id in:gcId.
+            device setForeground:foreground colorId background:background colorId in:gcId.
+        ] ifFalse:[
+            device setPixmapMask:mask id in:gcId
+        ].
+
+        device displayString:s
+                    from:index1 to:index2 
+                       x:pX y:pY
+                      in:drawableId with:gcId.
+        ^ self.
 "/
 "/      "
 "/       if bgPaint color is all-0 or all-1's, we can do it in one
@@ -2903,8 +2928,8 @@
     dx := 0.
     dy := fontUsed ascent.
     maskOrigin notNil ifTrue:[
-	dx := maskOrigin x.
-	dy := dy + maskOrigin y
+        dx := maskOrigin x.
+        dy := dy + maskOrigin y
     ].
 
     bgForm paint:bgPaint.
@@ -2922,8 +2947,8 @@
     bgForm paint:noColor on:allColor.
     bgForm function:#and.
     bgForm displayString:s 
-		    from:index1 to:index2 
-		       x:0 y:fontUsed ascent.
+                    from:index1 to:index2 
+                       x:0 y:fontUsed ascent.
 
     "
      stamp-out foreground
@@ -2931,8 +2956,8 @@
     maskForm font:fontUsed.
     maskForm paint:allColor on:noColor.
     maskForm displayOpaqueString:s 
-			    from:index1 to:index2 
-			       x:0 y:fontUsed ascent.
+                            from:index1 to:index2 
+                               x:0 y:fontUsed ascent.
 
     fgForm function:#and.
     fgForm copyFrom:maskForm x:0 y:0 toX:0 y:0 width:w height:h.
@@ -2955,18 +2980,29 @@
     "
     device setForeground:0 background:allBits in:gcId.
     device
-	copyFromId:tmpForm id
-		 x:0 y:0 gc:tmpForm gcId
-		to:drawableId
-		 x:pX y:(pY-fontUsed ascent) gc:gcId
-	     width:w height:h.
+        copyFromId:tmpForm id
+                 x:0 y:0 gc:tmpForm gcId
+                to:drawableId
+                 x:pX y:(pY-fontUsed ascent) gc:gcId
+             width:w height:h.
+
+    "
+     release tempForms immediately
+     (although GC will eventually do it, 
+      this creates less stress to the Xserver in the meanwhile ...)
+    "
+    tmpForm destroy.
+    fgForm destroy.
+    bgForm destroy.
+    maskForm destroy.
+
     "
      flush foreground/background cache
     "
     foreground := nil.
     background := nil.
 
-    "Modified: 12.6.1996 / 12:50:12 / cg"
+    "Modified: 22.4.1997 / 21:47:15 / cg"
 !
 
 displayDeviceOpaqueString:aString from:index1 to:index2 x:x y:y
@@ -3649,6 +3685,6 @@
 !DeviceGraphicsContext class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/DeviceGraphicsContext.st,v 1.37 1997-04-15 07:47:28 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/DeviceGraphicsContext.st,v 1.38 1997-04-22 19:49:44 cg Exp $'
 ! !
 DeviceGraphicsContext initialize!