Merge branch 'master' of git://onigirihouse.com/git/yuuki

db4
Matthew Willis 2008-06-01 12:47:19 -07:00
commit f10d604bce
2 changed files with 18 additions and 6 deletions

View File

@ -2,7 +2,8 @@
! See http://factorcode.org/license.txt for BSD license.
USING: sequences math opengl.gadgets kernel
byte-arrays cairo.ffi cairo io.backend
opengl.gl arrays ;
ui.gadgets accessors opengl.gl
arrays ;
IN: cairo.gadgets
@ -14,9 +15,17 @@ IN: cairo.gadgets
[ cairo_image_surface_create_for_data ] 3bi
r> with-cairo-from-surface ;
: <cairo-gadget> ( dim quot -- )
over 2^-bounds swap copy-cairo
GL_BGRA rot <texture-gadget> ;
TUPLE: cairo-gadget < texture-gadget quot ;
: <cairo-gadget> ( dim quot -- gadget )
cairo-gadget construct-gadget
swap >>quot
swap >>dim ;
M: cairo-gadget graft* ( gadget -- )
GL_BGRA >>format dup
[ dim>> 2^-bounds ] [ quot>> copy-cairo ] bi
>>bytes call-next-method ;
! maybe also texture>png
! : cairo>png ( gadget path -- )

View File

@ -4,6 +4,7 @@
! pangocairo bindings, from pango/pangocairo.h
USING: cairo.ffi alien.c-types math
alien.syntax system combinators alien
memoize
arrays pango pango.fonts ;
IN: pango.cairo
@ -111,9 +112,11 @@ M: pango-layout dispose ( alien -- ) alien>> g_object_unref ;
0 <int> 0 <int> [ pango_layout_get_pixel_size ] 2keep
[ *int ] bi@ ;
MEMO: dummy-cairo ( -- cr )
CAIRO_FORMAT_ARGB32 0 0 cairo_image_surface_create cairo_create ;
: dummy-pango ( quot -- )
>r CAIRO_FORMAT_ARGB32 0 0 cairo_image_surface_create
r> [ with-pango ] curry with-cairo-from-surface ; inline
>r dummy-cairo cairo r> [ with-pango ] curry with-variable ; inline
: layout-size ( quot -- dim )
[ layout pango-layout-get-pixel-size 2array ] compose dummy-pango ; inline