Remove partial redraw optimization because there are too many broken GL implementations
parent
de0808320e
commit
f50e8de835
|
@ -63,9 +63,9 @@ M: world focusable-child* gadget-child ;
|
||||||
|
|
||||||
M: world children-on nip gadget-children ;
|
M: world children-on nip gadget-children ;
|
||||||
|
|
||||||
: (draw-world) ( rect world -- )
|
: (draw-world) ( world -- )
|
||||||
dup world-handle [
|
dup world-handle [
|
||||||
[ init-gl ] keep draw-gadget
|
[ dup init-gl ] keep draw-gadget
|
||||||
] with-gl-context ;
|
] with-gl-context ;
|
||||||
|
|
||||||
: draw-world? ( world -- ? )
|
: draw-world? ( world -- ? )
|
||||||
|
@ -87,7 +87,7 @@ SYMBOL: ui-error-hook
|
||||||
|
|
||||||
[ rethrow ] ui-error-hook set-global
|
[ rethrow ] ui-error-hook set-global
|
||||||
|
|
||||||
: draw-world ( rect world -- )
|
: draw-world ( world -- )
|
||||||
dup draw-world? [
|
dup draw-world? [
|
||||||
dup world [
|
dup world [
|
||||||
[
|
[
|
||||||
|
@ -99,7 +99,7 @@ SYMBOL: ui-error-hook
|
||||||
] recover
|
] recover
|
||||||
] with-variable
|
] with-variable
|
||||||
] [
|
] [
|
||||||
2drop
|
drop
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
world H{
|
world H{
|
||||||
|
|
|
@ -55,7 +55,7 @@ SYMBOL: windows
|
||||||
: open-world-window ( world -- )
|
: open-world-window ( world -- )
|
||||||
dup pref-dim over set-gadget-dim
|
dup pref-dim over set-gadget-dim
|
||||||
dup (open-world-window)
|
dup (open-world-window)
|
||||||
dup draw-world ;
|
draw-world ;
|
||||||
|
|
||||||
: open-window ( gadget title -- )
|
: open-window ( gadget title -- )
|
||||||
>r [ 1 track, ] { 0 1 } make-track r>
|
>r [ 1 track, ] { 0 1 } make-track r>
|
||||||
|
@ -77,19 +77,12 @@ SYMBOL: windows
|
||||||
dup hand-world get-global eq?
|
dup hand-world get-global eq?
|
||||||
[ hand-loc get-global swap move-hand ] [ drop ] if ;
|
[ hand-loc get-global swap move-hand ] [ drop ] if ;
|
||||||
|
|
||||||
: post-layout ( hash gadget -- )
|
: layout-queued ( -- seq )
|
||||||
dup find-world dup [
|
[
|
||||||
rot [
|
invalid [
|
||||||
>r screen-rect r> [ rect-union ] when*
|
dup layout find-world [ , ] when*
|
||||||
] change-at
|
] queue-each
|
||||||
] [
|
] { } make ;
|
||||||
3drop
|
|
||||||
] if ;
|
|
||||||
|
|
||||||
: layout-queued ( -- hash )
|
|
||||||
H{ } clone invalid [
|
|
||||||
dup layout dupd post-layout
|
|
||||||
] queue-each ;
|
|
||||||
|
|
||||||
SYMBOL: ui-hook
|
SYMBOL: ui-hook
|
||||||
|
|
||||||
|
@ -105,11 +98,8 @@ SYMBOL: ui-hook
|
||||||
init-ui ui-hook get call
|
init-ui ui-hook get call
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
: redraw-worlds ( hash -- )
|
: redraw-worlds ( seq -- )
|
||||||
[
|
[ dup update-hand draw-world ] each ;
|
||||||
swap dup update-hand
|
|
||||||
dup world-handle [ draw-world ] [ 2drop ] if
|
|
||||||
] assoc-each ;
|
|
||||||
|
|
||||||
: ui-step ( -- )
|
: ui-step ( -- )
|
||||||
[
|
[
|
||||||
|
|
|
@ -65,7 +65,7 @@ M: pasteboard set-clipboard-contents drop copy ;
|
||||||
<clipboard> selection set-global ;
|
<clipboard> selection set-global ;
|
||||||
|
|
||||||
! world-handle is a <win>
|
! world-handle is a <win>
|
||||||
TUPLE: win hWnd hDC hRC swap-hint? world title ;
|
TUPLE: win hWnd hDC hRC world title ;
|
||||||
C: <win> win
|
C: <win> win
|
||||||
|
|
||||||
SYMBOL: msg-obj
|
SYMBOL: msg-obj
|
||||||
|
@ -413,11 +413,8 @@ SYMBOL: hWnd
|
||||||
dup wglCreateContext dup win32-error=0/f
|
dup wglCreateContext dup win32-error=0/f
|
||||||
[ wglMakeCurrent win32-error=0/f ] keep ;
|
[ wglMakeCurrent win32-error=0/f ] keep ;
|
||||||
|
|
||||||
: setup-gl ( hwnd -- hDC hRC swap-hint? )
|
: setup-gl ( hwnd -- hDC hRC )
|
||||||
get-dc
|
get-dc dup setup-pixel-format get-rc ;
|
||||||
dup setup-pixel-format
|
|
||||||
dup get-rc
|
|
||||||
swap-hint-supported? ;
|
|
||||||
|
|
||||||
M: windows-ui-backend (open-world-window) ( world -- )
|
M: windows-ui-backend (open-world-window) ( world -- )
|
||||||
[ rect-dim first2 create-window dup setup-gl ] keep
|
[ rect-dim first2 create-window dup setup-gl ] keep
|
||||||
|
@ -430,10 +427,6 @@ M: windows-ui-backend select-gl-context ( handle -- )
|
||||||
[ win-hDC ] keep win-hRC wglMakeCurrent win32-error=0/f ;
|
[ win-hDC ] keep win-hRC wglMakeCurrent win32-error=0/f ;
|
||||||
|
|
||||||
M: windows-ui-backend flush-gl-context ( handle -- )
|
M: windows-ui-backend flush-gl-context ( handle -- )
|
||||||
dup win-swap-hint? [
|
|
||||||
clip get flip-rect fix-coordinates
|
|
||||||
glAddSwapHintRectWIN
|
|
||||||
] when
|
|
||||||
win-hDC SwapBuffers win32-error=0/f ;
|
win-hDC SwapBuffers win32-error=0/f ;
|
||||||
|
|
||||||
! Move window to front
|
! Move window to front
|
||||||
|
|
|
@ -12,7 +12,7 @@ TUPLE: x11-ui-backend ;
|
||||||
|
|
||||||
: XA_NET_WM_NAME "_NET_WM_NAME" x-atom ;
|
: XA_NET_WM_NAME "_NET_WM_NAME" x-atom ;
|
||||||
|
|
||||||
TUPLE: x11-handle window glx xic copy-sub-buffer? ;
|
TUPLE: x11-handle window glx xic ;
|
||||||
|
|
||||||
C: <x11-handle> x11-handle
|
C: <x11-handle> x11-handle
|
||||||
|
|
||||||
|
@ -173,8 +173,7 @@ M: world client-event
|
||||||
|
|
||||||
: gadget-window ( world -- )
|
: gadget-window ( world -- )
|
||||||
dup world-loc over rect-dim glx-window
|
dup world-loc over rect-dim glx-window
|
||||||
over "Factor" create-xic
|
over "Factor" create-xic <x11-handle>
|
||||||
copy-sub-buffer-supported? <x11-handle>
|
|
||||||
2dup x11-handle-window register-window
|
2dup x11-handle-window register-window
|
||||||
swap set-world-handle ;
|
swap set-world-handle ;
|
||||||
|
|
||||||
|
@ -238,49 +237,8 @@ M: x11-ui-backend select-gl-context ( handle -- )
|
||||||
dup x11-handle-window swap x11-handle-glx glXMakeCurrent
|
dup x11-handle-window swap x11-handle-glx glXMakeCurrent
|
||||||
[ "Failed to set current GLX context" throw ] unless ;
|
[ "Failed to set current GLX context" throw ] unless ;
|
||||||
|
|
||||||
: swap-buffers-mesa ( handle -- )
|
|
||||||
dpy get swap x11-handle-window
|
|
||||||
clip get flip-rect fix-coordinates
|
|
||||||
glXCopySubBufferMESA ;
|
|
||||||
|
|
||||||
: swap-buffers-full ( handle -- )
|
|
||||||
dpy get swap x11-handle-window glXSwapBuffers ;
|
|
||||||
|
|
||||||
: gl-raster-pos ( loc -- )
|
|
||||||
first2 [ >fixnum ] 2apply glRasterPos2i ;
|
|
||||||
|
|
||||||
: gl-copy-pixels ( loc dim buffer -- )
|
|
||||||
>r fix-coordinates r> glCopyPixels ;
|
|
||||||
|
|
||||||
: swap-buffers-slow ( -- )
|
|
||||||
GL_BACK glReadBuffer
|
|
||||||
GL_FRONT glDrawBuffer
|
|
||||||
GL_SCISSOR_TEST glDisable
|
|
||||||
GL_ONE GL_ZERO glBlendFunc
|
|
||||||
clip get rect-bounds { 0 1 } v* v+ gl-raster-pos
|
|
||||||
clip get flip-rect GL_COLOR gl-copy-pixels
|
|
||||||
GL_BACK glDrawBuffer
|
|
||||||
glFlush ;
|
|
||||||
|
|
||||||
: swap-buffer-strategy
|
|
||||||
"swap-buffer-strategy" get "slow" or ;
|
|
||||||
|
|
||||||
: can-swap-full? ( -- ? )
|
|
||||||
clip get world get delegates [ rect? ] find nip = ;
|
|
||||||
|
|
||||||
: swap-buffers ( handle strategy -- )
|
|
||||||
{
|
|
||||||
{ "mesa" [ swap-buffers-mesa ] }
|
|
||||||
{ "full" [ swap-buffers-full ] }
|
|
||||||
{ "slow" [
|
|
||||||
can-swap-full?
|
|
||||||
[ swap-buffers-full ]
|
|
||||||
[ drop swap-buffers-slow ] if
|
|
||||||
] }
|
|
||||||
} case ;
|
|
||||||
|
|
||||||
M: x11-ui-backend flush-gl-context ( handle -- )
|
M: x11-ui-backend flush-gl-context ( handle -- )
|
||||||
swap-buffer-strategy swap-buffers ;
|
dpy get swap x11-handle-window glXSwapBuffers ;
|
||||||
|
|
||||||
M: x11-ui-backend ui ( -- )
|
M: x11-ui-backend ui ( -- )
|
||||||
[
|
[
|
||||||
|
|
|
@ -101,10 +101,3 @@ FUNCTION: HGLRC wglCreateContext ( HDC hDC ) ;
|
||||||
FUNCTION: BOOL wglDeleteContext ( HGLRC hRC ) ;
|
FUNCTION: BOOL wglDeleteContext ( HGLRC hRC ) ;
|
||||||
FUNCTION: BOOL wglMakeCurrent ( HDC hDC, HGLRC hglrc ) ;
|
FUNCTION: BOOL wglMakeCurrent ( HDC hDC, HGLRC hglrc ) ;
|
||||||
FUNCTION: void* wglGetProcAddress ( char* name ) ;
|
FUNCTION: void* wglGetProcAddress ( char* name ) ;
|
||||||
|
|
||||||
: glAddSwapHintRectWIN ( x y width height -- )
|
|
||||||
"glAddSwapHintRectWIN" wglGetProcAddress check-ptr
|
|
||||||
"void" { "int" "int" "int" "int" } "stdcall" alien-indirect ;
|
|
||||||
|
|
||||||
: swap-hint-supported? ( -- ? )
|
|
||||||
"GL_WIN_swap_hint" GL_EXTENSIONS glGetString subseq? ;
|
|
||||||
|
|
|
@ -99,13 +99,4 @@ FUNCTION: void* glXGetProcAddress ( char* procname ) ;
|
||||||
[ "Failed to create GLX context" throw ] unless* ;
|
[ "Failed to create GLX context" throw ] unless* ;
|
||||||
|
|
||||||
: destroy-glx ( GLXContext -- )
|
: destroy-glx ( GLXContext -- )
|
||||||
dpy get swap glXDestroyContext ;
|
dpy get swap glXDestroyContext ;
|
||||||
|
|
||||||
: copy-sub-buffer-supported? ( -- ? )
|
|
||||||
"GLX_MESA_copy_sub_buffer"
|
|
||||||
dpy get scr get glXQueryExtensionsString subseq? ;
|
|
||||||
|
|
||||||
: glXCopySubBufferMESA ( dpy drawable x y width height -- )
|
|
||||||
"glXCopySubBufferMESA" glXGetProcAddress
|
|
||||||
"void" { "Display*" "GLXDrawable" "int" "int" "int" "int" }
|
|
||||||
"cdecl" alien-indirect ;
|
|
Loading…
Reference in New Issue