ui.pixel-formats,ui.backend.*: new word pixel-format-attributes>int-array

This word replaces usages of the PIXEL-FORMAT-ATTRIBUTE-TABLE: syntax
char-rename
Björn Lindqvist 2017-01-30 05:43:19 +01:00
parent 1b1842f62d
commit 4756c30d3f
4 changed files with 49 additions and 32 deletions

View File

@ -362,33 +362,30 @@ CONSTANT: window-controls>func-flags
] 2tri ; ] 2tri ;
! OpenGL and Pixel formats ! OpenGL and Pixel formats
CONSTANT: perm-attribs ${ GDK_GL_USE_GL GDK_GL_RGBA }
PIXEL-FORMAT-ATTRIBUTE-TABLE: gl-config-attribs CONSTANT: attrib-table H{
${ GDK_GL_USE_GL GDK_GL_RGBA } { double-buffered ${ GDK_GL_DOUBLEBUFFER } }
H{ { stereo ${ GDK_GL_STEREO } }
{ double-buffered ${ GDK_GL_DOUBLEBUFFER } } { color-bits ${ GDK_GL_BUFFER_SIZE } }
{ stereo ${ GDK_GL_STEREO } } { red-bits ${ GDK_GL_RED_SIZE } }
! { offscreen ${ GDK_GL_DRAWABLE_TYPE 2 } } { green-bits ${ GDK_GL_GREEN_SIZE } }
! { fullscreen ${ GDK_GL_DRAWABLE_TYPE 1 } } { blue-bits ${ GDK_GL_BLUE_SIZE } }
! { windowed ${ GDK_GL_DRAWABLE_TYPE 1 } } { alpha-bits ${ GDK_GL_ALPHA_SIZE } }
{ color-bits ${ GDK_GL_BUFFER_SIZE } } { accum-red-bits ${ GDK_GL_ACCUM_RED_SIZE } }
{ red-bits ${ GDK_GL_RED_SIZE } } { accum-green-bits ${ GDK_GL_ACCUM_GREEN_SIZE } }
{ green-bits ${ GDK_GL_GREEN_SIZE } } { accum-blue-bits ${ GDK_GL_ACCUM_BLUE_SIZE } }
{ blue-bits ${ GDK_GL_BLUE_SIZE } } { accum-alpha-bits ${ GDK_GL_ACCUM_ALPHA_SIZE } }
{ alpha-bits ${ GDK_GL_ALPHA_SIZE } } { depth-bits ${ GDK_GL_DEPTH_SIZE } }
{ accum-red-bits ${ GDK_GL_ACCUM_RED_SIZE } } { stencil-bits ${ GDK_GL_STENCIL_SIZE } }
{ accum-green-bits ${ GDK_GL_ACCUM_GREEN_SIZE } } { aux-buffers ${ GDK_GL_AUX_BUFFERS } }
{ accum-blue-bits ${ GDK_GL_ACCUM_BLUE_SIZE } } { sample-buffers ${ GDK_GL_SAMPLE_BUFFERS } }
{ accum-alpha-bits ${ GDK_GL_ACCUM_ALPHA_SIZE } } { samples ${ GDK_GL_SAMPLES } }
{ depth-bits ${ GDK_GL_DEPTH_SIZE } } }
{ stencil-bits ${ GDK_GL_STENCIL_SIZE } }
{ aux-buffers ${ GDK_GL_AUX_BUFFERS } }
{ sample-buffers ${ GDK_GL_SAMPLE_BUFFERS } }
{ samples ${ GDK_GL_SAMPLES } }
}
M: gtk-ui-backend (make-pixel-format) M: gtk-ui-backend (make-pixel-format)
nip >gl-config-attribs-int-array gdk_gl_config_new ; nip perm-attribs attrib-table
pixel-format-attributes>int-array gdk_gl_config_new ;
M: gtk-ui-backend (free-pixel-format) M: gtk-ui-backend (free-pixel-format)
handle>> g_object_unref ; handle>> g_object_unref ;

View File

@ -6,8 +6,8 @@ environment io.encodings.ascii io.encodings.string io.encodings.utf8
kernel literals locals math namespaces sequences specialized-arrays kernel literals locals math namespaces sequences specialized-arrays
strings ui ui.backend ui.backend.x11.keys ui.clipboards ui.event-loop strings ui ui.backend ui.backend.x11.keys ui.clipboards ui.event-loop
ui.gadgets ui.gadgets.private ui.gadgets.worlds ui.gestures ui.gadgets ui.gadgets.private ui.gadgets.worlds ui.gestures
ui.pixel-formats ui.pixel-formats.private ui.private x11 x11.X ui.pixel-formats ui.private x11 x11.X x11.clipboard x11.events x11.glx
x11.clipboard x11.events x11.glx x11.io x11.windows x11.xim x11.xlib ; x11.io x11.windows x11.xim x11.xlib ;
FROM: libc => system ; FROM: libc => system ;
SPECIALIZED-ARRAYS: uchar ulong ; SPECIALIZED-ARRAYS: uchar ulong ;
IN: ui.backend.x11 IN: ui.backend.x11
@ -68,7 +68,8 @@ M: world configure-event
! In case dimensions didn't change ! In case dimensions didn't change
relayout-1 ; relayout-1 ;
PIXEL-FORMAT-ATTRIBUTE-TABLE: glx-visual { $ GLX_RGBA } H{ CONSTANT: perm-attribs { $ GLX_RGBA }
CONSTANT: attrib-table H{
{ double-buffered { $ GLX_DOUBLEBUFFER } } { double-buffered { $ GLX_DOUBLEBUFFER } }
{ stereo { $ GLX_STEREO } } { stereo { $ GLX_STEREO } }
{ color-bits { $ GLX_BUFFER_SIZE } } { color-bits { $ GLX_BUFFER_SIZE } }
@ -88,8 +89,8 @@ PIXEL-FORMAT-ATTRIBUTE-TABLE: glx-visual { $ GLX_RGBA } H{
} }
M: x11-ui-backend (make-pixel-format) M: x11-ui-backend (make-pixel-format)
[ drop dpy get scr get ] dip [ drop dpy get scr get ] dip perm-attribs attrib-table
>glx-visual-int-array glXChooseVisual ; pixel-format-attributes>int-array glXChooseVisual ;
M: x11-ui-backend (free-pixel-format) M: x11-ui-backend (free-pixel-format)
handle>> XFree ; handle>> XFree ;

View File

@ -0,0 +1,14 @@
USING: specialized-arrays.instances.alien.c-types.int tools.test
ui.pixel-formats ;
IN: ui.pixel-formats.tests
CONSTANT: attrib-table {
{ windowed { 99 } }
{ double-buffered { 7 } }
}
! pixel-format-attributes>int-array
{ int-array{ 9 2 99 7 0 } } [
{ windowed double-buffered } { 9 2 } attrib-table
pixel-format-attributes>int-array
] unit-test

View File

@ -1,6 +1,6 @@
USING: alien.c-types alien.data accessors assocs classes USING: accessors alien.c-types alien.data assocs classes destructors
destructors functors kernel lexer math parser sequences fry functors kernel lexer math parser sequences specialized-arrays
specialized-arrays ui.backend words ; ui.backend words ;
SPECIALIZED-ARRAY: int SPECIALIZED-ARRAY: int
IN: ui.pixel-formats IN: ui.pixel-formats
@ -57,6 +57,11 @@ TUPLE: pixel-format < disposable world handle ;
M: pixel-format dispose* M: pixel-format dispose*
[ (free-pixel-format) ] [ f >>handle drop ] bi ; [ (free-pixel-format) ] [ f >>handle drop ] bi ;
: pixel-format-attributes>int-array ( attrs perm table -- arr )
swapd '[ _ at ] map sift concat append
! 0 happens to work as a sentinel value for all ui backends.
0 suffix int >c-array ;
<PRIVATE <PRIVATE
FUNCTOR: define-pixel-format-attribute-table ( NAME PERM TABLE -- ) FUNCTOR: define-pixel-format-attribute-table ( NAME PERM TABLE -- )