1 ! (c) 2008 Joe Groff, see license for details
2 USING: accessors alien.c-types continuations images kernel math
3 sequences ui.gadgets ui.gadgets.private ui.gadgets.worlds
4 ui.private ui ui.backend destructors locals ;
7 TUPLE: offscreen-world < world ;
9 M: offscreen-world world-pixel-format-attributes
10 { offscreen T{ depth-bits { value 16 } } } ;
12 : <offscreen-world> ( gadget title status -- world )
13 offscreen-world new-world ;
15 M: offscreen-world graft*
16 (open-offscreen-buffer) ;
18 M: offscreen-world ungraft*
20 [ handle>> (close-offscreen-buffer) ]
23 : open-offscreen ( gadget -- world )
24 "" f <offscreen-world>
25 [ open-world-window ] [ relayout-1 ] [ ] tri
28 : close-offscreen ( world -- )
29 ungraft notify-queued ;
31 :: bgrx>bitmap ( alien w h -- image )
34 alien w h * 4 * memory>byte-array >>bitmap
35 BGRX >>component-order ;
37 : offscreen-world>bitmap ( world -- image )
38 offscreen-pixels bgrx>bitmap ;
40 : do-offscreen ( gadget quot: ( offscreen-world -- ) -- )
41 [ open-offscreen ] dip
42 over [ slip ] [ close-offscreen ] [ ] cleanup ; inline
44 : gadget>bitmap ( gadget -- image )
45 [ offscreen-world>bitmap ] do-offscreen ;