CairoGraphicsContext.st
changeset 51 5293f2b851ab
parent 50 239120c68187
child 54 209a2b0b721a
--- a/CairoGraphicsContext.st	Thu Feb 25 20:55:41 2016 +0000
+++ b/CairoGraphicsContext.st	Sun Feb 28 14:53:56 2016 +0000
@@ -153,17 +153,20 @@
     "set the clipping rectangle for drawing (in logical coordinates);
      a nil argument turn off clipping (i.e. whole view is drawable)"    
 
+    #todo.
     ^ super clippingBounds:aRectangleOrNil
 
     "Created: / 15-02-2016 / 21:38:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 27-02-2016 / 15:20:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 function:aFunctionSymbol
     "set the drawing function"
 
+    #todo.
     ^ super function:aFunctionSymbol
 
-    "Modified: / 25-02-2016 / 11:23:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 27-02-2016 / 15:21:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 lineWidth: w
@@ -179,7 +182,10 @@
 mask:aForm
     "set the drawing mask"
 
-    ^ self shouldImplement
+    #todo.  
+    super mask: aForm.
+
+    "Modified: / 27-02-2016 / 15:20:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 paint: aColor
@@ -491,27 +497,37 @@
      drawn in current paint color, 0's are ignored.
      If the form has depth ~~ 1, the current fg color setting is ignored."
 
-    | image width height stride data image_surface |
-
-    ^ super displayForm:aFormOrImage x:x y:y.
+    | image width height imageSurface |
 
     image := aFormOrImage asImage.
+    (image mask isNil or:[ image mask depth == 1 ]) ifTrue:[ 
+        cr notNil ifTrue:[ 
+            cr surface flush.
+        ].
+        super displayForm:aFormOrImage x:x y:y.
+        cr notNil ifTrue:[ 
+            cr surface markDirty.
+        ].
+        ^ self.
+    ].
     width := image width.
     height := image height.
-    stride := Cairo::CPrimitives cairo_format_stride_for_width: CAIRO_FORMAT_ARGB32 _: width.
-    data := ExternalBytes basicNew allocateBytes: stride * height clear: false.
+    imageSurface := Cairo::Surface newImageWithFormat: CAIRO_FORMAT_ARGB32  width: width height: height similarTo: cr surface.
     [
-        image bitsARGB32Into: data stride: stride fg: self paint bg:  self backgroundPaint. 
-        image_surface := Cairo::CPrimitives cairo_image_surface_create_for_data: data _: CAIRO_FORMAT_ARGB32 _: width _: height _: stride.
-        Cairo::CPrimitives cairo_set_source_surface: cr _: image_surface _: x asFloat _: y asFloat.
-        Cairo::CPrimitives cairo_paint: cr.
+        image bitsARGB32Into: imageSurface data startingAt: 1 stride: imageSurface stride.
+        imageSurface markDirty.
+        gcId isNil ifTrue:[ 
+            self initGC.
+        ].
+
+        cr sourceSurface: imageSurface x: x y: y.
+        cr paint.
     ] ensure:[ 
-        data finalize.
-        image_surface release.
+        imageSurface release.
     ].
 
     "Created: / 31-12-2014 / 12:08:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 17-02-2016 / 20:58:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 27-02-2016 / 19:16:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 displayLineFrom:p0 to:p1