ui.pixel-formats: apply @jonenst's patch for #1859.
parent
9cdb209d01
commit
dc001f9a34
|
@ -1,14 +1,24 @@
|
|||
USING: specialized-arrays.instances.alien.c-types.int tools.test
|
||||
USING: alien.c-types literals specialized-arrays tools.test
|
||||
ui.pixel-formats ;
|
||||
SPECIALIZED-ARRAY: int
|
||||
IN: ui.pixel-formats.tests
|
||||
|
||||
CONSTANT: attrib-table {
|
||||
{ windowed { 99 } }
|
||||
{ double-buffered { 7 } }
|
||||
{ samples { 100001 } }
|
||||
}
|
||||
|
||||
SYMBOL: garbageword
|
||||
CONSTANT: garbageint 234
|
||||
|
||||
! pixel-format-attributes>int-array
|
||||
{ int-array{ 9 2 99 7 0 } } [
|
||||
{ windowed double-buffered } { 9 2 } attrib-table
|
||||
! it should ignore garbage, even the color-bits because it's not
|
||||
! in the table
|
||||
{ int-array{ 9 2 99 7 100001 2 0 } } [
|
||||
{
|
||||
windowed "garbage" $ garbageint double-buffered
|
||||
garbageword T{ samples f 2 } T{ color-bits f 24 }
|
||||
} { 9 2 } attrib-table
|
||||
pixel-format-attributes>int-array
|
||||
] unit-test
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
USING: accessors alien.c-types alien.data assocs destructors fry
|
||||
kernel math sequences specialized-arrays ui.backend ;
|
||||
USING: accessors alien.c-types alien.data assocs classes
|
||||
combinators destructors fry kernel math sequences
|
||||
specialized-arrays ui.backend words ;
|
||||
SPECIALIZED-ARRAY: int
|
||||
IN: ui.pixel-formats
|
||||
|
||||
|
@ -57,8 +58,18 @@ TUPLE: pixel-format < disposable world handle ;
|
|||
M: pixel-format dispose*
|
||||
[ (free-pixel-format) ] [ f >>handle drop ] bi ;
|
||||
|
||||
: (pixel-format-attribute) ( attribute table -- arr/f )
|
||||
[ dup class-of ] dip at [ swap value>> suffix ] [ drop f ] if* ;
|
||||
|
||||
: pixel-format-attribute>array ( obj table -- arr/f )
|
||||
{
|
||||
{ [ over pixel-format-attribute? ] [ (pixel-format-attribute) ] }
|
||||
{ [ over word? ] [ at ] }
|
||||
[ 2drop f ]
|
||||
} cond ;
|
||||
|
||||
: pixel-format-attributes>int-array ( attrs perm table -- arr )
|
||||
swapd '[ _ at ] map sift concat append
|
||||
swapd '[ _ pixel-format-attribute>array ] map sift concat append
|
||||
! 0 happens to work as a sentinel value for all ui backends.
|
||||
0 suffix int >c-array ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue