]> gitweb.factorcode.org Git - factor.git/commitdiff
ui.text.pango: lazy render images like core-text backend.
authorJohn Benediktsson <mrjbq7@gmail.com>
Fri, 21 Sep 2012 15:16:13 +0000 (08:16 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 21 Sep 2012 15:16:48 +0000 (08:16 -0700)
basis/ui/text/pango/pango.factor

index 51c1fca3ec7c53dce936c794d77bd5a4c74b96dd..8499acf15e6297e0c16baff8d0421827f980e0d0 100644 (file)
@@ -163,7 +163,6 @@ MEMO: missing-font-metrics ( font -- metrics )
             dup [ string>> ] [ font>> ] bi <PangoLayout> >>layout
             dup layout>> layout-extents [ >>ink-rect ] [ >>logical-rect ] bi*
             dup layout-metrics >>metrics
-            dup draw-layout >>image
     ] with-destructors ;
 
 M: layout dispose* layout>> g_object_unref ;
@@ -176,6 +175,9 @@ SYMBOL: cached-layouts
 : cached-line ( font string -- line )
     cached-layout layout>> first-line ;
 
+: layout>image ( layout -- image )
+    dup image>> [ dup draw-layout >>image ] unless image>> ;
+
 SINGLETON: pango-renderer
 
 M: pango-renderer string-dim
@@ -186,7 +188,7 @@ M: pango-renderer flush-layout-cache
     cached-layouts get purge-cache ;
 
 M: pango-renderer string>image ( font string -- image loc )
-    cached-layout [ image>> ] [ text-position vneg ] bi ;
+    cached-layout [ layout>image ] [ text-position vneg ] bi ;
 
 M: pango-renderer x>offset ( x font string -- n )
     cached-layout swap x>line-offset ;