DeviceGraphicsContext.st
branchjv
changeset 7765 b8189ae681df
parent 7716 3dba89415c91
parent 7752 81c84fab0aac
child 7767 7ba26d21c628
--- a/DeviceGraphicsContext.st	Thu Dec 15 20:11:12 2016 +0000
+++ b/DeviceGraphicsContext.st	Sun Dec 18 12:12:59 2016 +0000
@@ -954,11 +954,7 @@
 copyFrom:aGC x:srcX y:srcY toX:dstX y:dstY width:w height:h depth:depth
     "copy from aDrawable into the receiver;
      the source may be the receiver as well - in this case its a scroll.
-     All coordinates are in device coordinates.
-     If the receiver is a view AND async is true, the call returns immediately
-     - otherwise, it returns when the scroll operation is finished.
-     (not all devices care for this).
-     If the receiver is a pixmap, the call always returns immediately."
+     All coordinates are in device coordinates."
 
     |srcGCId srcDrawableId|
 
@@ -966,8 +962,7 @@
         self initGC
     ].
 
-    aGC initGC.
-    srcGCId := aGC gcId.
+    srcGCId := aGC initGC.
     srcDrawableId := aGC drawableId.
 
     ((depth == 1) and:[device depth ~~ 1]) ifTrue:[
@@ -1038,8 +1033,7 @@
         self initGC
     ].
 
-    aGC initGC.
-    srcGCId := aGC gcId.
+    srcGCId := aGC initGC.
     srcDrawableId := aGC drawableId.
 
     aGC isPixmap ifTrue:[
@@ -1922,7 +1916,7 @@
      settings are ignored and the form is drawn as-is;
      however, the mask is applied if present.
 
-     The form should must have been allocated on the same device,
+     The form should have been allocated on the same device,
      otherwise its converted here, which slows down the draw.
      No transformation or scaling is done.
      Care must be taken, that the paint color is correctly allocated
@@ -1933,7 +1927,7 @@
 
     |id w h easy paintDither depth tmpForm tmpId tmpGCId
      fgId noColor allColor allBits pX pY
-     mask maskId deviceForm deviceFormGCId deviceMask colorMap|
+     mask maskId deviceForm deviceFormGCId deviceMask deviceMaskGcId colorMap|
 
     w := aForm width.
     h := aForm height.
@@ -1948,7 +1942,7 @@
         ^self
     ].
     id := deviceForm drawableId.
-    "temporary ..."
+    "temporary ... what the heck is this??"
     (id isNil
      or:[aForm graphicsDevice ~~ device]) ifTrue:[
         deviceForm := deviceForm asFormOn:device.
@@ -1964,10 +1958,7 @@
     ].
     "/ device needGCForBitmapSource  - i.e. WIN32
     device isWindowsPlatform ifTrue:[
-        (deviceFormGCId := deviceForm gcId) isNil ifTrue:[
-            deviceForm initGC.
-            deviceFormGCId := deviceForm gcId.
-        ]
+        deviceFormGCId := deviceForm initGC.
     ].
 
     "
@@ -1988,7 +1979,7 @@
                 ].
                 maskId := deviceMask drawableId.
                 maskId notNil ifTrue:[
-                    deviceMask gcId isNil ifTrue:[deviceMask initGC].
+                    deviceMaskGcId := deviceMask initGC.
                     allColor := Color allColor.
                     allBits := allColor colorId.
 
@@ -2007,7 +1998,7 @@
                             copyPlaneFromPixmapId:maskId
                                 x:0
                                 y:0
-                                gc:(deviceMask gcId)
+                                gc:deviceMaskGcId
                                 to:drawableId
                                 x:pX
                                 y:pY
@@ -2066,9 +2057,8 @@
                             'DeviceGraphicsContext [warning]: cannot create temp form' errorPrintCR.
                             ^ self
                         ].
-                        tmpForm initGC.
                         tmpId := tmpForm drawableId.
-                        tmpGCId := tmpForm gcId.
+                        tmpGCId := tmpForm initGC.
 
                         "
                          fill tempform with image
@@ -2121,7 +2111,7 @@
                             copyPlaneFromPixmapId:maskId
                                 x:0
                                 y:0
-                                gc:(deviceMask gcId)
+                                gc:deviceMaskGcId
                                 to:tmpId
                                 x:0
                                 y:0
@@ -2144,7 +2134,7 @@
                             copyPlaneFromPixmapId:maskId
                                 x:0
                                 y:0
-                                gc:(deviceMask gcId)
+                                gc:deviceMaskGcId
                                 to:drawableId
                                 x:pX
                                 y:pY
@@ -2194,7 +2184,7 @@
             copyFromPixmapId:id
             x:0
             y:0
-            gc:deviceForm gcId
+            gc:deviceFormGCId
             to:drawableId
             x:pX
             y:pY
@@ -2429,7 +2419,7 @@
 
     |id w h easy savedPaint bgForm fgForm tmpForm
      fgId bgId noColor allColor allBits dx dy
-     pX pY deviceDepth deviceForm map|
+     pX pY deviceDepth deviceForm deviceFormGCId map|
 
     deviceForm := aForm asFormOn:device.
     id := deviceForm drawableId.
@@ -2448,7 +2438,7 @@
     gcId isNil ifTrue:[
         self initGC
     ].
-    deviceForm gcId isNil ifTrue:[deviceForm initGC].
+    deviceFormGCId := deviceForm initGC.
 
     w := aForm width.
     h := aForm height.
@@ -2465,7 +2455,7 @@
             copyFromPixmapId:id
             x:0
             y:0
-            gc:deviceForm gcId
+            gc:deviceFormGCId
             to:drawableId
             x:pX
             y:pY
@@ -2527,7 +2517,7 @@
             copyPlaneFromPixmapId:id
             x:0
             y:0
-            gc:(deviceForm gcId)
+            gc:deviceFormGCId
             to:drawableId
             x:pX
             y:pY
@@ -2568,7 +2558,7 @@
                 copyPlaneFromPixmapId:id
                 x:0
                 y:0
-                gc:(deviceForm gcId)
+                gc:deviceFormGCId
                 to:drawableId
                 x:pX
                 y:pY
@@ -2587,7 +2577,7 @@
                 copyPlaneFromPixmapId:id
                 x:0
                 y:0
-                gc:(deviceForm gcId)
+                gc:deviceFormGCId
                 to:drawableId
                 x:pX
                 y:pY
@@ -2625,7 +2615,7 @@
                 copyPlaneFromPixmapId:id
                 x:0
                 y:0
-                gc:(deviceForm gcId)
+                gc:deviceFormGCId
                 to:drawableId
                 x:pX
                 y:pY
@@ -2644,7 +2634,7 @@
                 copyPlaneFromPixmapId:id
                 x:0
                 y:0
-                gc:(deviceForm gcId)
+                gc:deviceFormGCId
                 to:drawableId
                 x:pX
                 y:pY
@@ -3142,14 +3132,12 @@
      This ignores any transformations. The coordinates must be integers."
 
     gcId isNil ifTrue:[
-	self initGC
+        self initGC
     ].
     device
-	fillRectangleX:x
-		     y:y
-		 width:w
-		height:h
-		    in:drawableId with:gcId
+        fillRectangleX:x y:y
+        width:w height:h
+        in:drawableId with:gcId
 ! !
 
 !DeviceGraphicsContext methodsFor:'evaluating in another context'!
@@ -3422,10 +3410,10 @@
 
 executor
     drawableType == #window ifTrue:[
-	^ DeviceWindowGCHandle basicNew
+        ^ DeviceWindowGCHandle basicNew
             setDevice:device id:drawableId gcId:gcId parentId:parentId.
     ] ifFalse:[
-	^ DevicePixmapGCHandle basicNew
+        ^ DevicePixmapGCHandle basicNew
             setDevice:device id:drawableId gcId:gcId.
     ].
 !
@@ -3500,13 +3488,14 @@
 initGC
     "since we do not need a gc-object for the drawable until something is
      really drawn, none is created.
-     This method is sent, when the first drawing happens"
+     This method is sent, when the first drawing happens.
+     Answer the gcId."
 
     |fgId bgId p fontId|
 
     gcId notNil ifTrue:[
         "already initialized"
-        ^ self
+        ^ gcId
     ].
     drawableId isNil ifTrue:[
         "/
@@ -3597,6 +3586,7 @@
         deviceFont := font.
         device setFont:fontId in:gcId
     ].
+    ^ gcId.
 
     "Modified: / 22-10-2006 / 14:10:53 / cg"
 !