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 ;
|
||||
|
||||
: (draw-world) ( rect world -- )
|
||||
: (draw-world) ( world -- )
|
||||
dup world-handle [
|
||||
[ init-gl ] keep draw-gadget
|
||||
[ dup init-gl ] keep draw-gadget
|
||||
] with-gl-context ;
|
||||
|
||||
: draw-world? ( world -- ? )
|
||||
|
@ -87,7 +87,7 @@ SYMBOL: ui-error-hook
|
|||
|
||||
[ rethrow ] ui-error-hook set-global
|
||||
|
||||
: draw-world ( rect world -- )
|
||||
: draw-world ( world -- )
|
||||
dup draw-world? [
|
||||
dup world [
|
||||
[
|
||||
|
@ -99,7 +99,7 @@ SYMBOL: ui-error-hook
|
|||
] recover
|
||||
] with-variable
|
||||
] [
|
||||
2drop
|
||||
drop
|
||||
] if ;
|
||||
|
||||
world H{
|
||||
|
|
|
@ -55,7 +55,7 @@ SYMBOL: windows
|
|||
: open-world-window ( world -- )
|
||||
dup pref-dim over set-gadget-dim
|
||||
dup (open-world-window)
|
||||
dup draw-world ;
|
||||
draw-world ;
|
||||
|
||||
: open-window ( gadget title -- )
|
||||
>r [ 1 track, ] { 0 1 } make-track r>
|
||||
|
@ -77,19 +77,12 @@ SYMBOL: windows
|
|||
dup hand-world get-global eq?
|
||||
[ hand-loc get-global swap move-hand ] [ drop ] if ;
|
||||
|
||||
: post-layout ( hash gadget -- )
|
||||
dup find-world dup [
|
||||
rot [
|
||||
>r screen-rect r> [ rect-union ] when*
|
||||
] change-at
|
||||
] [
|
||||
3drop
|
||||
] if ;
|
||||
|
||||
: layout-queued ( -- hash )
|
||||
H{ } clone invalid [
|
||||
dup layout dupd post-layout
|
||||
] queue-each ;
|
||||
: layout-queued ( -- seq )
|
||||
[
|
||||
invalid [
|
||||
dup layout find-world [ , ] when*
|
||||
] queue-each
|
||||
] { } make ;
|
||||
|
||||
SYMBOL: ui-hook
|
||||
|
||||
|
@ -105,11 +98,8 @@ SYMBOL: ui-hook
|
|||
init-ui ui-hook get call
|
||||
] if ;
|
||||
|
||||
: redraw-worlds ( hash -- )
|
||||
[
|
||||
swap dup update-hand
|
||||
dup world-handle [ draw-world ] [ 2drop ] if
|
||||
] assoc-each ;
|
||||
: redraw-worlds ( seq -- )
|
||||
[ dup update-hand draw-world ] each ;
|
||||
|
||||
: ui-step ( -- )
|
||||
[
|
||||
|
|
|
@ -65,7 +65,7 @@ M: pasteboard set-clipboard-contents drop copy ;
|
|||
<clipboard> selection set-global ;
|
||||
|
||||
! world-handle is a <win>
|
||||
TUPLE: win hWnd hDC hRC swap-hint? world title ;
|
||||
TUPLE: win hWnd hDC hRC world title ;
|
||||
C: <win> win
|
||||
|
||||
SYMBOL: msg-obj
|
||||
|
@ -413,11 +413,8 @@ SYMBOL: hWnd
|
|||
dup wglCreateContext dup win32-error=0/f
|
||||
[ wglMakeCurrent win32-error=0/f ] keep ;
|
||||
|
||||
: setup-gl ( hwnd -- hDC hRC swap-hint? )
|
||||
get-dc
|
||||
dup setup-pixel-format
|
||||
dup get-rc
|
||||
swap-hint-supported? ;
|
||||
: setup-gl ( hwnd -- hDC hRC )
|
||||
get-dc dup setup-pixel-format get-rc ;
|
||||
|
||||
M: windows-ui-backend (open-world-window) ( world -- )
|
||||
[ 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 ;
|
||||
|
||||
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 ;
|
||||
|
||||
! Move window to front
|
||||
|
|
|
@ -12,7 +12,7 @@ TUPLE: x11-ui-backend ;
|
|||
|
||||
: 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
|
||||
|
||||
|
@ -173,8 +173,7 @@ M: world client-event
|
|||
|
||||
: gadget-window ( world -- )
|
||||
dup world-loc over rect-dim glx-window
|
||||
over "Factor" create-xic
|
||||
copy-sub-buffer-supported? <x11-handle>
|
||||
over "Factor" create-xic <x11-handle>
|
||||
2dup x11-handle-window register-window
|
||||
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
|
||||
[ "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 -- )
|
||||
swap-buffer-strategy swap-buffers ;
|
||||
dpy get swap x11-handle-window glXSwapBuffers ;
|
||||
|
||||
M: x11-ui-backend ui ( -- )
|
||||
[
|
||||
|
|
|
@ -101,10 +101,3 @@ FUNCTION: HGLRC wglCreateContext ( HDC hDC ) ;
|
|||
FUNCTION: BOOL wglDeleteContext ( HGLRC hRC ) ;
|
||||
FUNCTION: BOOL wglMakeCurrent ( HDC hDC, HGLRC hglrc ) ;
|
||||
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? ;
|
||||
|
|
|
@ -100,12 +100,3 @@ FUNCTION: void* glXGetProcAddress ( char* procname ) ;
|
|||
|
||||
: destroy-glx ( GLXContext -- )
|
||||
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