diff --git a/basis/ui/backend/cocoa/cocoa.factor b/basis/ui/backend/cocoa/cocoa.factor index 8a91dfd94d..ba0a7b9c7e 100755 --- a/basis/ui/backend/cocoa/cocoa.factor +++ b/basis/ui/backend/cocoa/cocoa.factor @@ -9,7 +9,8 @@ core-graphics.types destructors fry generalizations io.thread kernel libc literals locals math math.rectangles memory namespaces sequences specialized-arrays.int threads ui 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 TUPLE: handle ; @@ -23,9 +24,7 @@ SINGLETON: cocoa-ui-backend NSOpenGLPFA ( attribute -- NSOpenGLPFAs ) - -CONSTANT: attribute>NSOpenGLPFA-map H{ +PIXEL-FORMAT-ATTRIBUTE-TABLE: NSOpenGLPFA H{ { double-buffered { $ NSOpenGLPFADoubleBuffer } } { stereo { $ NSOpenGLPFAStereo } } { offscreen { $ NSOpenGLPFAOffScreen } } @@ -49,28 +48,20 @@ CONSTANT: attribute>NSOpenGLPFA-map H{ { 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> M: cocoa-ui-backend (make-pixel-format) - [ >NSOpenGLPFA ] map concat 0 suffix >int-array + >NSOpenGLPFA-int-array NSOpenGLPixelFormat -> alloc swap -> initWithAttributes: ; M: cocoa-ui-backend (free-pixel-format) -> release ; M: cocoa-ui-backend (pixel-format-attribute) - attribute>NSOpenGLPFA-map at + >NSOpenGLPFA + [ drop f ] [ first 0 [ swap 0 -> getValues:forAttribute:forVirtualScreen: ] keep *int ] - [ drop f ] if* ; + if-empty ; TUPLE: pasteboard handle ; diff --git a/basis/ui/pixel-formats/pixel-formats.factor b/basis/ui/pixel-formats/pixel-formats.factor index 3032c2551f..5c16407135 100644 --- a/basis/ui/pixel-formats/pixel-formats.factor +++ b/basis/ui/pixel-formats/pixel-formats.factor @@ -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 SYMBOLS: @@ -59,3 +61,32 @@ M: pixel-format dispose : pixel-format-attribute ( pixel-format attribute-name -- value ) [ handle>> ] dip (pixel-format-attribute) ; +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>