Cairo__PatternSurface.st
changeset 63 054f0513ea65
child 88 9d51db2ba641
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Cairo__PatternSurface.st	Mon Mar 21 22:28:05 2016 +0000
@@ -0,0 +1,31 @@
+"{ Package: 'stx:goodies/libcairo' }"
+
+"{ NameSpace: Cairo }"
+
+Pattern subclass:#PatternSurface
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	category:'Cairo-Objects'
+!
+
+!PatternSurface methodsFor:'accessing'!
+
+surface
+    | surfacePtrCell surface |
+
+    surfacePtrCell := ExternalBytes basicNew allocateBytes: ExternalBytes sizeofPointer clear: false.
+    [ 
+        CPrimitives cairo_pattern_get_surface: self _: surfacePtrCell.
+        surface := Surface basicNew.
+        surface setAddressFromBytes: surfacePtrCell asByteArray.
+        surface := surface reference.
+        surface initialize.
+    ] ensure:[ 
+        surfacePtrCell free.
+    ].
+    ^ surface.
+
+    "Created: / 05-03-2016 / 23:05:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+