XftFontDescription.st
branchjv
changeset 7718 6e51fc8b207f
parent 7717 bf77414d0c8d
child 7719 c2f802dd340a
--- a/XftFontDescription.st	Thu Nov 24 23:20:54 2016 +0000
+++ b/XftFontDescription.st	Thu Nov 24 23:50:51 2016 +0000
@@ -1,10 +1,9 @@
-"{ Encoding: utf8 }"
 "{ Package: 'stx:libview' }"
 
 "{ NameSpace: Smalltalk }"
 
 FontDescription subclass:#XftFontDescription
-	instanceVariableNames:'device fontId sharedDrawId closestFont minCode maxCode ascent
+	instanceVariableNames:'device fontId closestFont minCode maxCode ascent
 		descent height fixedWidth'
 	classVariableNames:'CachedFontList RecentlyUsedFonts Lobby'
 	poolDictionaries:'FcConstants'
@@ -301,6 +300,21 @@
 
     "Created: / 20-12-2013 / 21:10:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified (format): / 22-02-2016 / 08:15:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+
+!
+
+xftDrawDestroy: xftDrawId
+%{
+#ifdef XFT
+    if (__isExternalAddressLike(xftDrawId)) {
+        XftDraw *xftDraw = XFT_DRAW(xftDrawId);        
+        XftDrawDestroy(xftDraw);
+    }
+    RETURN (self);
+#endif
+%}.
+    self primitiveFailed.
+
 ! !
 
 !XftFontDescription class methodsFor:'queries'!
@@ -424,23 +438,6 @@
     "Created: / 02-01-2014 / 23:29:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
-!XftFontDescription methodsFor:'change & update'!
-
-update:anAspect with:something from:changedObject
-    "I want to be informed when a view that printed something with me is destroyed.
-     Disassociate the view from the XFT drawable"
-
-    |drawableId|
-
-    anAspect == #aboutToDestroy ifTrue:[
-        drawableId := changedObject drawableId.
-        drawableId notNil ifTrue:[
-            self disassociateXftDrawableFrom:drawableId.
-        ].
-        changedObject removeDependent:self.
-    ].
-! !
-
 !XftFontDescription methodsFor:'converting'!
 
 asNonXftFont
@@ -543,9 +540,8 @@
     aGC isForm ifTrue:[
         pixmapDepth := aGC depth.
     ].
-    aGC addDependent:self.      "I need to be informed, when the GC is destroyed"
-
-    aGC class == XGraphicsContext ifTrue:[
+    
+    ((aGC class == XGraphicsContext) or:[aGC isKindOf: XGraphicsContext]) ifTrue:[
         "/ TODO: Following should be done atomically together with drawing...
         drawId := aGC xftDrawId.
         drawIdIsShared := false.
@@ -570,9 +566,8 @@
             aGC xftDrawId: drawId.
         ].
     ] ifFalse:[
-        Logger log: 'GC passed to XftGraphicsContext is not an XGraphicsContext!!' severity: #error.
-        drawId := sharedDrawId.
-        drawIdIsShared := true.
+        self error: 'GC passed to XftGraphicsContext is not an XGraphicsContext!!'.
+        ^self
     ].
 
 %{  /* STACK: 64000 */
@@ -597,33 +592,8 @@
     }
 
     __bytesPerCharacter = __intVal(bytesPerCharacter);
-
-    if (drawIdIsShared == true) {
-    if (__INST(sharedDrawId) == nil) {
-       if (pixmapDepth != nil) {
-            int __pixmapDepth = __intVal(pixmapDepth);
-            if (__pixmapDepth == 1) {      
-                __sharedDrawId =  XftDrawCreateBitmap ( DISPLAY( displayId ) ,
-                                               DRAWABLE( drawableId ) );           
-            } else {
-                __sharedDrawId =  XftDrawCreateAlpha ( DISPLAY( displayId ) ,
-                                               DRAWABLE( drawableId ), __pixmapDepth);                      
-            }          
-        } else {
-            __sharedDrawId = XftDrawCreate(DISPLAY(displayId),
-                                           DRAWABLE(drawableId),
-                                           DefaultVisual(DISPLAY(displayId), SCREEN(screen)),
-                                           DefaultColormap(DISPLAY(displayId), SCREEN(screen)));
-        }
-        __INST(sharedDrawId) = XFT_DRAW_HANDLE_NEW(__sharedDrawId);
-        __STORE(self, __INST(sharedDrawId));
-    } else if (XftDrawDrawable(__sharedDrawId = XFT_DRAW(__INST(sharedDrawId))) != DRAWABLE(drawableId)) {
-        XftDrawChange(__sharedDrawId, DRAWABLE(drawableId));
-        }
-    } else {
-       __sharedDrawId = XFT_DRAW ( drawId );
-    }
-
+    __sharedDrawId = XFT_DRAW ( drawId );
+    
     string = __stringVal(aString) + ((__intVal(index1) - 1 ) * __bytesPerCharacter);
     len = __intVal(index2) - __intVal(index1) + 1;
 
@@ -700,11 +670,6 @@
         XftDrawDestroy(__sharedDrawId);
     }
 
-# if 0 // this has been superseeded by receiving change messages on view destroy
-    // Have to disassociate the drawableId - otherwise we get an X11 error 'RenderBadPicture (invalid Picture parameter)'
-    // when the drawable (the window) is destroyed.
-    XftDrawChange(__sharedDrawId, None);
-# endif
     RETURN(self);
 
 #endif
@@ -894,36 +859,6 @@
 
 !XftFontDescription methodsFor:'primitives'!
 
-disassociateXftDrawableFrom:drawableId
-    "Disassociate the XftDrawable from drawableId.
-     This mist be done before the drawable is destroyed,
-     otherwise the XftDrawable is destroyed together with the drawable,
-     and X11 errors will be signaled."
-
-    | error |
-
-%{
-#ifdef XFT
-    if (!__isExternalAddressLike(__INST(sharedDrawId))) {
-        // nothing to disasassociate from...
-        RETURN(self);
-    }
-    if (!__isExternalAddressLike(drawableId)) {
-        error = @symbol(BadArg);
-        goto err;
-    }
-    if (XftDrawDrawable(XFT_DRAW(__INST(sharedDrawId))) == DRAWABLE(drawableId)) {
-        XftDrawChange(XFT_DRAW(__INST(sharedDrawId)), None);
-    }
-    RETURN(self);
-err:;
-#endif
-%}.
-    self primitiveFailed: error
-
-    "Created: / 26-12-2013 / 12:17:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
 xftDrawChange:xftDrawId drawable:drawableId
     | error |
 
@@ -982,20 +917,6 @@
     "Created: / 21-12-2013 / 21:12:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-xftDrawDestroy
-%{
-#ifdef XFT
-    if (__INST(sharedDrawId) != nil) {
-        XftDraw *xftDrawable = XFT_DRAW(__INST(sharedDrawId));
-        __INST(sharedDrawId) = nil;
-        XftDrawDestroy(xftDrawable);
-    }
-    RETURN (self);
-#endif
-%}.
-    self primitiveFailed.
-!
-
 xftDrawRect: drawIdArg color: aColor x: x y: y width: w height: h
     | error r g b a pix |
 
@@ -1588,29 +1509,6 @@
 
 !XftFontDescription methodsFor:'release'!
 
-releaseDrawIfAssociatedWith: view
-    | drawableId |
-
-    view isNil ifTrue:[ ^ self ].
-    drawableId := view id.
-    drawableId isNil ifTrue: [ ^ self ].
-%{
-#ifdef XFT
-    if ( __INST(sharedDrawId) != nil ) {
-	if (XftDrawDrawable(XFT_DRAW(__INST(sharedDrawId))) == DRAWABLE(drawableId)) {
-	    __INST(sharedDrawId) = nil;
-	    XftDrawDestroy(XFT_DRAW(__INST(sharedDrawId)));
-	}
-    }
-    RETURN (self);
-#endif
-%}.
-    self primitiveFailed
-
-    "Created: / 12-01-2014 / 19:48:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 12-01-2014 / 22:09:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
 releaseFromDevice
     "I am no longer available on the device"
 
@@ -1623,8 +1521,9 @@
     RecentlyUsedFonts := nil.
     device := nil.
     fontId := nil.
-    sharedDrawId := nil.
     closestFont := nil.
+
+    "Modified: / 25-11-2016 / 00:12:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !XftFontDescription methodsFor:'testing'!
@@ -1635,10 +1534,6 @@
     ^ true
 !
 
-isUsed
-    ^ sharedDrawId notNil
-!
-
 isXftFont
     ^ true
 ! !