shove cocoa pixel format attribute conversion into a functor so we can reuse it
parent
65b33c145c
commit
2a7c26c20a
|
@ -9,7 +9,8 @@ core-graphics.types destructors fry generalizations io.thread
|
||||||
kernel libc literals locals math math.rectangles memory
|
kernel libc literals locals math math.rectangles memory
|
||||||
namespaces sequences specialized-arrays.int threads ui
|
namespaces sequences specialized-arrays.int threads ui
|
||||||
ui.backend ui.backend.cocoa.views ui.clipboards ui.gadgets
|
ui.backend ui.backend.cocoa.views ui.clipboards ui.gadgets
|
||||||
ui.gadgets.worlds ui.pixel-formats ui.private words.symbol ;
|
ui.gadgets.worlds ui.pixel-formats ui.pixel-formats.private
|
||||||
|
ui.private words.symbol ;
|
||||||
IN: ui.backend.cocoa
|
IN: ui.backend.cocoa
|
||||||
|
|
||||||
TUPLE: handle ;
|
TUPLE: handle ;
|
||||||
|
@ -23,9 +24,7 @@ SINGLETON: cocoa-ui-backend
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
GENERIC: >NSOpenGLPFA ( attribute -- NSOpenGLPFAs )
|
PIXEL-FORMAT-ATTRIBUTE-TABLE: NSOpenGLPFA H{
|
||||||
|
|
||||||
CONSTANT: attribute>NSOpenGLPFA-map H{
|
|
||||||
{ double-buffered { $ NSOpenGLPFADoubleBuffer } }
|
{ double-buffered { $ NSOpenGLPFADoubleBuffer } }
|
||||||
{ stereo { $ NSOpenGLPFAStereo } }
|
{ stereo { $ NSOpenGLPFAStereo } }
|
||||||
{ offscreen { $ NSOpenGLPFAOffScreen } }
|
{ offscreen { $ NSOpenGLPFAOffScreen } }
|
||||||
|
@ -49,28 +48,20 @@ CONSTANT: attribute>NSOpenGLPFA-map H{
|
||||||
{ samples { $ NSOpenGLPFASamples } }
|
{ samples { $ NSOpenGLPFASamples } }
|
||||||
}
|
}
|
||||||
|
|
||||||
M: object >NSOpenGLPFA
|
|
||||||
drop { } ;
|
|
||||||
M: symbol >NSOpenGLPFA
|
|
||||||
attribute>NSOpenGLPFA-map at [ { } ] unless* ;
|
|
||||||
M: pixel-format-attribute >NSOpenGLPFA
|
|
||||||
dup class attribute>NSOpenGLPFA-map at
|
|
||||||
[ swap value>> suffix ]
|
|
||||||
[ drop { } ] if* ;
|
|
||||||
|
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
M: cocoa-ui-backend (make-pixel-format)
|
M: cocoa-ui-backend (make-pixel-format)
|
||||||
[ >NSOpenGLPFA ] map concat 0 suffix >int-array
|
>NSOpenGLPFA-int-array
|
||||||
NSOpenGLPixelFormat -> alloc swap -> initWithAttributes: ;
|
NSOpenGLPixelFormat -> alloc swap -> initWithAttributes: ;
|
||||||
|
|
||||||
M: cocoa-ui-backend (free-pixel-format)
|
M: cocoa-ui-backend (free-pixel-format)
|
||||||
-> release ;
|
-> release ;
|
||||||
|
|
||||||
M: cocoa-ui-backend (pixel-format-attribute)
|
M: cocoa-ui-backend (pixel-format-attribute)
|
||||||
attribute>NSOpenGLPFA-map at
|
>NSOpenGLPFA
|
||||||
|
[ drop f ]
|
||||||
[ first 0 <int> [ swap 0 -> getValues:forAttribute:forVirtualScreen: ] keep *int ]
|
[ first 0 <int> [ swap 0 -> getValues:forAttribute:forVirtualScreen: ] keep *int ]
|
||||||
[ drop f ] if* ;
|
if-empty ;
|
||||||
|
|
||||||
TUPLE: pasteboard handle ;
|
TUPLE: pasteboard handle ;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
USING: accessors destructors kernel math ui.backend ;
|
USING: accessors assocs classes destructors functors kernel
|
||||||
|
lexer math parser sequences specialized-arrays.int ui.backend
|
||||||
|
words.symbol ;
|
||||||
IN: ui.pixel-formats
|
IN: ui.pixel-formats
|
||||||
|
|
||||||
SYMBOLS:
|
SYMBOLS:
|
||||||
|
@ -59,3 +61,32 @@ M: pixel-format dispose
|
||||||
: pixel-format-attribute ( pixel-format attribute-name -- value )
|
: pixel-format-attribute ( pixel-format attribute-name -- value )
|
||||||
[ handle>> ] dip (pixel-format-attribute) ;
|
[ handle>> ] dip (pixel-format-attribute) ;
|
||||||
|
|
||||||
|
<PRIVATE
|
||||||
|
|
||||||
|
FUNCTOR: define-pixel-format-attribute-table ( NAME TABLE -- )
|
||||||
|
|
||||||
|
>PFA DEFINES >${NAME}
|
||||||
|
>PFA-int-array DEFINES >${NAME}-int-array
|
||||||
|
|
||||||
|
WHERE
|
||||||
|
|
||||||
|
GENERIC: >PFA ( attribute -- pfas )
|
||||||
|
|
||||||
|
M: object >PFA
|
||||||
|
drop { } ;
|
||||||
|
M: symbol >PFA
|
||||||
|
TABLE at [ { } ] unless* ;
|
||||||
|
M: pixel-format-attribute >PFA
|
||||||
|
dup class TABLE at
|
||||||
|
[ swap value>> suffix ]
|
||||||
|
[ drop { } ] if* ;
|
||||||
|
|
||||||
|
: >PFA-int-array ( attribute -- int-array )
|
||||||
|
[ >PFA ] map concat 0 suffix >int-array ;
|
||||||
|
|
||||||
|
;FUNCTOR
|
||||||
|
|
||||||
|
SYNTAX: PIXEL-FORMAT-ATTRIBUTE-TABLE:
|
||||||
|
scan scan-object define-pixel-format-attribute-table ;
|
||||||
|
|
||||||
|
PRIVATE>
|
||||||
|
|
Loading…
Reference in New Issue