ui.backend.*: the offscreen buffer hooks appear unused - let's delete!
parent
dac179bc33
commit
73893693d3
|
@ -15,18 +15,12 @@ HOOK: (open-window) ui-backend ( world -- )
|
|||
|
||||
HOOK: (close-window) ui-backend ( handle -- )
|
||||
|
||||
HOOK: (open-offscreen-buffer) ui-backend ( world -- )
|
||||
|
||||
HOOK: (close-offscreen-buffer) ui-backend ( handle -- )
|
||||
|
||||
HOOK: raise-window* ui-backend ( world -- )
|
||||
|
||||
GENERIC: select-gl-context ( handle -- )
|
||||
|
||||
GENERIC: flush-gl-context ( handle -- )
|
||||
|
||||
HOOK: offscreen-pixels ui-backend ( world -- alien w h )
|
||||
|
||||
HOOK: (with-ui) ui-backend ( quot -- )
|
||||
|
||||
HOOK: (grab-input) ui-backend ( handle -- )
|
||||
|
|
|
@ -15,10 +15,8 @@ IN: ui.backend.cocoa
|
|||
|
||||
TUPLE: handle ;
|
||||
TUPLE: window-handle < handle view window ;
|
||||
TUPLE: offscreen-handle < handle context buffer ;
|
||||
|
||||
C: <window-handle> window-handle
|
||||
C: <offscreen-handle> offscreen-handle
|
||||
|
||||
SINGLETON: cocoa-ui-backend
|
||||
|
||||
|
@ -181,31 +179,8 @@ M: cocoa-ui-backend raise-window* ( world -- )
|
|||
NSApp 1 -> activateIgnoringOtherApps:
|
||||
] when* ;
|
||||
|
||||
: pixel-size ( pixel-format -- size )
|
||||
color-bits (pixel-format-attribute) -3 shift ;
|
||||
|
||||
: offscreen-buffer ( world pixel-format -- alien w h pitch )
|
||||
[ dim>> first2 ] [ pixel-size ] bi*
|
||||
{ [ * * malloc ] [ 2drop ] [ drop nip ] [ nip * ] } 3cleave ;
|
||||
|
||||
:: gadget-offscreen-context ( world -- context buffer )
|
||||
world [
|
||||
nip :> pf
|
||||
NSOpenGLContext -> alloc pf handle>> f -> initWithFormat:shareContext:
|
||||
dup world pf offscreen-buffer
|
||||
4 npick [ -> setOffScreen:width:height:rowbytes: ] dip
|
||||
] with-world-pixel-format ;
|
||||
|
||||
M: cocoa-ui-backend (open-offscreen-buffer) ( world -- )
|
||||
dup gadget-offscreen-context <offscreen-handle> >>handle drop ;
|
||||
|
||||
M: cocoa-ui-backend (close-offscreen-buffer) ( handle -- )
|
||||
[ context>> -> release ]
|
||||
[ buffer>> free ] bi ;
|
||||
|
||||
GENERIC: (gl-context) ( handle -- context )
|
||||
M: window-handle (gl-context) view>> -> openGLContext ;
|
||||
M: offscreen-handle (gl-context) context>> ;
|
||||
|
||||
M: handle select-gl-context ( handle -- )
|
||||
(gl-context) -> makeCurrentContext ;
|
||||
|
@ -213,9 +188,6 @@ M: handle select-gl-context ( handle -- )
|
|||
M: handle flush-gl-context ( handle -- )
|
||||
(gl-context) -> flushBuffer ;
|
||||
|
||||
M: cocoa-ui-backend offscreen-pixels ( world -- alien w h )
|
||||
[ handle>> buffer>> ] [ dim>> first2 neg ] bi ;
|
||||
|
||||
M: cocoa-ui-backend beep ( -- )
|
||||
NSBeep ;
|
||||
|
||||
|
|
|
@ -22,9 +22,7 @@ SINGLETON: windows-ui-backend
|
|||
|
||||
TUPLE: win-base hDC hRC ;
|
||||
TUPLE: win < win-base hWnd world title ;
|
||||
TUPLE: win-offscreen < win-base hBitmap bits ;
|
||||
C: <win> win
|
||||
C: <win-offscreen> win-offscreen
|
||||
|
||||
<PRIVATE
|
||||
|
||||
|
@ -734,20 +732,6 @@ M: win-base select-gl-context ( handle -- )
|
|||
M: win-base flush-gl-context ( handle -- )
|
||||
hDC>> SwapBuffers win32-error=0/f ;
|
||||
|
||||
: setup-offscreen-gl ( world -- )
|
||||
dup [ handle>> ] [ dim>> ] bi make-offscreen-dc-and-bitmap
|
||||
[ >>hDC ] [ >>hBitmap ] [ >>bits ] tri* drop [
|
||||
swap [ handle>> hDC>> set-pixel-format ] [ get-rc ] bi
|
||||
] with-world-pixel-format ;
|
||||
|
||||
M: windows-ui-backend (open-offscreen-buffer) ( world -- )
|
||||
win-offscreen new >>handle
|
||||
setup-offscreen-gl ;
|
||||
|
||||
M: windows-ui-backend (close-offscreen-buffer) ( handle -- )
|
||||
[ hDC>> DeleteDC drop ]
|
||||
[ hBitmap>> DeleteObject drop ] bi ;
|
||||
|
||||
! Windows 32-bit bitmaps don't actually use the alpha byte of
|
||||
! each pixel; it's left as zero
|
||||
|
||||
|
@ -759,9 +743,6 @@ M: windows-ui-backend (close-offscreen-buffer) ( handle -- )
|
|||
: (opaque-pixels) ( world -- pixels )
|
||||
[ handle>> bits>> ] [ dim>> ] bi bitmap>byte-array (make-opaque) ;
|
||||
|
||||
M: windows-ui-backend offscreen-pixels ( world -- alien w h )
|
||||
[ (opaque-pixels) ] [ dim>> first2 ] bi ;
|
||||
|
||||
M: windows-ui-backend raise-window* ( world -- )
|
||||
handle>> [ hWnd>> SetFocus drop ] when* ;
|
||||
|
||||
|
|
|
@ -50,10 +50,8 @@ SINGLETON: x11-ui-backend
|
|||
|
||||
TUPLE: x11-handle-base glx ;
|
||||
TUPLE: x11-handle < x11-handle-base window xic ;
|
||||
TUPLE: x11-pixmap-handle < x11-handle-base pixmap glx-pixmap ;
|
||||
|
||||
C: <x11-handle> x11-handle
|
||||
C: <x11-pixmap-handle> x11-pixmap-handle
|
||||
|
||||
M: world expose-event nip relayout ;
|
||||
|
||||
|
@ -367,27 +365,6 @@ M: x11-handle select-gl-context ( handle -- )
|
|||
M: x11-handle flush-gl-context ( handle -- )
|
||||
dpy get swap window>> glXSwapBuffers ;
|
||||
|
||||
M: x11-pixmap-handle select-gl-context ( handle -- )
|
||||
dpy get swap
|
||||
[ glx-pixmap>> ] [ glx>> ] bi glXMakeCurrent
|
||||
[ "Failed to set current GLX context" throw ] unless ;
|
||||
|
||||
M: x11-pixmap-handle flush-gl-context ( handle -- )
|
||||
drop ;
|
||||
|
||||
M: x11-ui-backend (open-offscreen-buffer) ( world -- )
|
||||
dup [ [ dim>> ] [ handle>> ] bi* glx-pixmap ] with-world-pixel-format
|
||||
<x11-pixmap-handle> >>handle drop ;
|
||||
|
||||
M: x11-ui-backend (close-offscreen-buffer) ( handle -- )
|
||||
dpy get swap
|
||||
[ glx-pixmap>> glXDestroyGLXPixmap ]
|
||||
[ pixmap>> XFreePixmap drop ]
|
||||
[ glx>> glXDestroyContext ] 2tri ;
|
||||
|
||||
M: x11-ui-backend offscreen-pixels ( world -- alien w h )
|
||||
[ [ dim>> ] [ handle>> pixmap>> ] bi pixmap-bits ] [ dim>> first2 ] bi ;
|
||||
|
||||
M: x11-ui-backend (with-ui) ( quot -- )
|
||||
[
|
||||
f [
|
||||
|
|
Loading…
Reference in New Issue