DeviceGraphicsContext.st
changeset 7752 81c84fab0aac
parent 7749 f4ad7601ae41
child 7759 45386945d6d7
child 7765 b8189ae681df
equal deleted inserted replaced
7751:b264b5ca7e35 7752:81c84fab0aac
  1909      (i.e. only 1-bits are drawn from the form).
  1909      (i.e. only 1-bits are drawn from the form).
  1910      If its a deep form (i.e. a pixmap) the current paint
  1910      If its a deep form (i.e. a pixmap) the current paint
  1911      settings are ignored and the form is drawn as-is;
  1911      settings are ignored and the form is drawn as-is;
  1912      however, the mask is applied if present.
  1912      however, the mask is applied if present.
  1913 
  1913 
  1914      The form should must have been allocated on the same device,
  1914      The form should have been allocated on the same device,
  1915      otherwise its converted here, which slows down the draw.
  1915      otherwise its converted here, which slows down the draw.
  1916      No transformation or scaling is done.
  1916      No transformation or scaling is done.
  1917      Care must be taken, that the paint color is correctly allocated
  1917      Care must be taken, that the paint color is correctly allocated
  1918      (by sending #on: to the color) before doing so.
  1918      (by sending #on: to the color) before doing so.
  1919      Using functions other than #copy only makes sense if you are
  1919      Using functions other than #copy only makes sense if you are
  1920      certain, that the colors are real colors (actually, only for
  1920      certain, that the colors are real colors (actually, only for
  1921      noColor or allColor)."
  1921      noColor or allColor)."
  1922 
  1922 
  1923     |id w h easy paintDither depth tmpForm tmpId tmpGCId
  1923     |id w h easy paintDither depth tmpForm tmpId tmpGCId
  1924      fgId noColor allColor allBits pX pY
  1924      fgId noColor allColor allBits pX pY
  1925      mask maskId deviceForm deviceFormGCId deviceMask colorMap|
  1925      mask maskId deviceForm deviceFormGCId deviceMask deviceMaskGcId colorMap|
  1926 
  1926 
  1927     w := aForm width.
  1927     w := aForm width.
  1928     h := aForm height.
  1928     h := aForm height.
  1929     (w = 0 or:[h = 0]) ifTrue:[^ self].
  1929     (w = 0 or:[h = 0]) ifTrue:[^ self].
  1930 
  1930 
  1935     deviceForm isNil ifTrue:[
  1935     deviceForm isNil ifTrue:[
  1936         Logger warning:'cannot create device-form'.
  1936         Logger warning:'cannot create device-form'.
  1937         ^self
  1937         ^self
  1938     ].
  1938     ].
  1939     id := deviceForm drawableId.
  1939     id := deviceForm drawableId.
  1940     "temporary ..."
  1940     "temporary ... what the heck is this??"
  1941     (id isNil
  1941     (id isNil
  1942      or:[aForm graphicsDevice ~~ device]) ifTrue:[
  1942      or:[aForm graphicsDevice ~~ device]) ifTrue:[
  1943         deviceForm := deviceForm asFormOn:device.
  1943         deviceForm := deviceForm asFormOn:device.
  1944         id := deviceForm drawableId.
  1944         id := deviceForm drawableId.
  1945         id isNil ifTrue:[
  1945         id isNil ifTrue:[
  1972                     'DeviceGraphicsContext [warning]: cannot create device-mask' errorPrintCR.
  1972                     'DeviceGraphicsContext [warning]: cannot create device-mask' errorPrintCR.
  1973                     ^self
  1973                     ^self
  1974                 ].
  1974                 ].
  1975                 maskId := deviceMask drawableId.
  1975                 maskId := deviceMask drawableId.
  1976                 maskId notNil ifTrue:[
  1976                 maskId notNil ifTrue:[
  1977                     deviceMask gcId isNil ifTrue:[deviceMask initGC].
  1977                     deviceMaskGcId := deviceMask initGC.
  1978                     allColor := Color allColor.
  1978                     allColor := Color allColor.
  1979                     allBits := allColor colorId.
  1979                     allBits := allColor colorId.
  1980 
  1980 
  1981                     (aForm maskedPixelsAre0
  1981                     (aForm maskedPixelsAre0
  1982                      and:[depth == 1 or:[deviceForm depth == device depth]]) ifTrue:[
  1982                      and:[depth == 1 or:[deviceForm depth == device depth]]) ifTrue:[
  1991                             setForeground:0 background:allBits in:gcId;
  1991                             setForeground:0 background:allBits in:gcId;
  1992                             setFunction:#and in:gcId;
  1992                             setFunction:#and in:gcId;
  1993                             copyPlaneFromPixmapId:maskId
  1993                             copyPlaneFromPixmapId:maskId
  1994                                 x:0
  1994                                 x:0
  1995                                 y:0
  1995                                 y:0
  1996                                 gc:(deviceMask gcId)
  1996                                 gc:deviceMaskGcId
  1997                                 to:drawableId
  1997                                 to:drawableId
  1998                                 x:pX
  1998                                 x:pX
  1999                                 y:pY
  1999                                 y:pY
  2000                                 gc:gcId
  2000                                 gc:gcId
  2001                                 width:w
  2001                                 width:w
  2050                         tmpForm := Form width:w height:h depth:device depth onDevice:device.
  2050                         tmpForm := Form width:w height:h depth:device depth onDevice:device.
  2051                         tmpForm isNil ifTrue:[
  2051                         tmpForm isNil ifTrue:[
  2052                             'DeviceGraphicsContext [warning]: cannot create temp form' errorPrintCR.
  2052                             'DeviceGraphicsContext [warning]: cannot create temp form' errorPrintCR.
  2053                             ^ self
  2053                             ^ self
  2054                         ].
  2054                         ].
  2055                         tmpForm initGC.
       
  2056                         tmpId := tmpForm drawableId.
  2055                         tmpId := tmpForm drawableId.
  2057                         tmpGCId := tmpForm gcId.
  2056                         tmpGCId := tmpForm initGC.
  2058 
  2057 
  2059                         "
  2058                         "
  2060                          fill tempform with image
  2059                          fill tempform with image
  2061                         "
  2060                         "
  2062                         depth == 1 ifTrue:[
  2061                         depth == 1 ifTrue:[
  2105                             setForeground:allBits background:0 in:tmpGCId;
  2104                             setForeground:allBits background:0 in:tmpGCId;
  2106                             setFunction:#and in:tmpGCId;
  2105                             setFunction:#and in:tmpGCId;
  2107                             copyPlaneFromPixmapId:maskId
  2106                             copyPlaneFromPixmapId:maskId
  2108                                 x:0
  2107                                 x:0
  2109                                 y:0
  2108                                 y:0
  2110                                 gc:(deviceMask gcId)
  2109                                 gc:deviceMaskGcId
  2111                                 to:tmpId
  2110                                 to:tmpId
  2112                                 x:0
  2111                                 x:0
  2113                                 y:0
  2112                                 y:0
  2114                                 gc:tmpGCId
  2113                                 gc:tmpGCId
  2115                                 width:w
  2114                                 width:w
  2128                             setForeground:0 background:allBits in:gcId;
  2127                             setForeground:0 background:allBits in:gcId;
  2129                             setFunction:#and in:gcId;
  2128                             setFunction:#and in:gcId;
  2130                             copyPlaneFromPixmapId:maskId
  2129                             copyPlaneFromPixmapId:maskId
  2131                                 x:0
  2130                                 x:0
  2132                                 y:0
  2131                                 y:0
  2133                                 gc:(deviceMask gcId)
  2132                                 gc:deviceMaskGcId
  2134                                 to:drawableId
  2133                                 to:drawableId
  2135                                 x:pX
  2134                                 x:pX
  2136                                 y:pY
  2135                                 y:pY
  2137                                 gc:gcId
  2136                                 gc:gcId
  2138                                 width:w
  2137                                 width:w
  2178 
  2177 
  2179         device
  2178         device
  2180             copyFromPixmapId:id
  2179             copyFromPixmapId:id
  2181             x:0
  2180             x:0
  2182             y:0
  2181             y:0
  2183             gc:deviceForm gcId
  2182             gc:deviceFormGCId
  2184             to:drawableId
  2183             to:drawableId
  2185             x:pX
  2184             x:pX
  2186             y:pY
  2185             y:pY
  2187             gc:gcId
  2186             gc:gcId
  2188             width:w
  2187             width:w
  3404 
  3403 
  3405 !DeviceGraphicsContext methodsFor:'finalization'!
  3404 !DeviceGraphicsContext methodsFor:'finalization'!
  3406 
  3405 
  3407 executor
  3406 executor
  3408     drawableType == #window ifTrue:[
  3407     drawableType == #window ifTrue:[
  3409 	^ DeviceWindowGCHandle basicNew
  3408         ^ DeviceWindowGCHandle basicNew
  3410 	    setDevice:self graphicsDevice id:self drawableId gcId:self gcId parentId:parentId.
  3409             setDevice:device id:drawableId gcId:gcId parentId:parentId.
  3411     ] ifFalse:[
  3410     ] ifFalse:[
  3412 	^ DevicePixmapGCHandle basicNew
  3411         ^ DevicePixmapGCHandle basicNew
  3413 	    setDevice:self graphicsDevice id:self drawableId gcId:self gcId.
  3412             setDevice:device id:drawableId gcId:gcId.
  3414     ].
  3413     ].
  3415 !
  3414 !
  3416 
  3415 
  3417 finalizationLobby
  3416 finalizationLobby
  3418     "answer the registry used for finalization.
  3417     "answer the registry used for finalization.