Changeset 7866 in project


Ignore:
Timestamp:
01/23/08 02:37:58 (12 years ago)
Author:
hans
Message:

added dfb-enum-display-layers and dfb-get-display-layer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • directfb/trunk/directfb.scm

    r7831 r7866  
    3232 (export dfb-init dfb-create
    3333         dfb-release dfb-set-cooperative-level dfb-create-surface
     34         dfb-enum-display-layers dfb-get-display-layer
    3435         dfb-get-input-device dfb-create-event-buffer
    3536         dfb-create-input-event-buffer
     
    122123  DSPF_RGB18 DSPF_LUT2 DSPF_RGB444 DSPF_RGB555)
    123124
     125;; FIXME: is it good to define this with define-foreign-enum?
    124126(define-foreign-enum (dfb-input-device-id unsigned-int)
    125127  DIDID_KEYBOARD DIDID_MOUSE DIDID_JOYSTICK DIDID_REMOTE DIDID_ANY)
     
    141143  DILS_SCROLL DILS_NUM DILS_CAPS)
    142144
     145(define-foreign-type dfb-screen-id unsigned-int)
     146(define-foreign-type dfbdl-id unsigned-int)
     147(define-foreign-type dfbdl-source-id unsigned-int)
     148(define-foreign-type dfb-window-id unsigned-int)
    143149(define-foreign-type dfb-text-encoding-id unsigned-int)
    144150(define-foreign-type dfbid-key-identifier int)
     
    149155(define-foreign-type dfbid-button-state bool)
    150156(define-foreign-type dfbid-axis-identifier int)
     157(define-foreign-type dfbdl-type-flags int)
     158(define-foreign-type dfbdl-capabilities int)
    151159
    152160
     
    184192       (declare (export ,(mksym "~a?" scheme-name))))))
    185193
    186 (define-macro ($dfb$ type obj method args #!key (check-error #t))
     194(define-macro ($dfb$ type obj method args #!key (check-error #t) (safe #f))
    187195  (let ((g-obj (gensym))
    188196        (g-args (map (lambda (x) (gensym)) args))
     
    194202          code))
    195203    (maybe-check-error
    196      `((foreign-lambda*
     204     `((,(if safe 'foreign-safe-lambda* 'foreign-lambda*)
    197205           int ((,scheme-type ,g-obj)
    198206                ,@(map (lambda (arg sym) (list (car arg) sym))
     
    225233
    226234(define-dfb-interface IDirectFB dfb-interface)
     235(define-dfb-interface IDirectFBDisplayLayer dfbdl-interface)
    227236(define-dfb-interface IDirectFBSurface dfbs-interface)
    228237(define-dfb-interface IDirectFBInputDevice dfbid-interface)
     
    298307  (dfb-surface-pixelformat pixelformat flag: DSDESC_PIXELFORMAT)
    299308  (unsigned-long resource-id flag: DSDESC_RESOURCE_ID))
     309
     310(define-dfb-struct (dfbdl-description DFBDisplayLayerDescription)
     311  (export: #t)
     312  (blob-ctor: make-dfbdl-description-from-blob)
     313  (dfbdl-type-flags type)
     314  (dfbdl-capabilities caps)
     315  (c-string name read-only: #t)
     316  (int level)
     317  (int regions)
     318  (int sources)
     319  (int clip-regions))
    300320
    301321(define-dfb-struct (dfb-input-event DFBInputEvent)
     
    332352    (make-dfbs-interface surf)))
    333353
     354(define enumeration-result (make-parameter #f))
     355
     356(define (copy-to-blob ptr len)
     357  (let ((vec (make-u8vector len)))
     358    (do ((i 0 (+ i 1)))
     359        ((fx= i len))
     360      (u8vector-set! vec i (pointer-u8-ref (pointer-offset ptr i))))
     361    (u8vector->blob/shared vec)))
     362
     363#>
     364void store_display_layer_2 (DFBDisplayLayerID, void*);
     365DFBEnumerationResult store_display_layer_1 (DFBDisplayLayerID layer_id,
     366                                            DFBDisplayLayerDescription desc,
     367                                            void *data) {
     368  store_display_layer_2 (layer_id, &desc);
     369  return (0);
     370}
     371<#
     372
     373(define-external (store_display_layer_2 (dfbdl-id layer-id) (c-pointer desc)) void
     374  (enumeration-result
     375   (cons (cons layer-id
     376               (make-dfbdl-description-from-blob
     377                (copy-to-blob desc (foreign-value "sizeof(DFBDisplayLayerDescription)" int))))
     378         (enumeration-result))))
     379
     380(define (dfb-enum-display-layers dfb)
     381  (parameterize ((enumeration-result '()))
     382    ($dfb$ IDirectFB dfb EnumDisplayLayers
     383           ((c-pointer (foreign-value "&store_display_layer_1" c-pointer)) (c-pointer #f))
     384           safe: #t)
     385    (reverse! (enumeration-result))))
     386
     387(define (dfb-get-display-layer dfb layer-id)
     388  (let-location ((dl c-pointer))
     389    ($dfb$ IDirectFB dfb GetDisplayLayer ((dfbdl-id layer-id) (c-pointer #$dl)))
     390    (make-dfbdl-interface dl)))
     391
    334392(define (dfb-get-input-device dfb device-id)
    335393  (let-location ((idev c-pointer))
     
    649707  ($dfb$ IDirectFBFont font SetEncoding ((dfb-text-encoding-id encoding))))
    650708
    651 (define font-encs (make-parameter #f))
    652 
    653709(define-external (font_enc_cb (c-string name) (c-pointer context)) int
    654   (font-encs (cons name (font-encs)))
     710  (enumeration-result (cons name (enumeration-result)))
    655711  0)
    656712
    657713(define (dfbf-enum-encodings font)
    658   (parameterize ((font-encs '()))
     714  (parameterize ((enumeration-result '()))
    659715    ($dfb$ IDirectFBFont font EnumEncodings
    660            ((c-pointer (location font_enc_cb)) (c-pointer #f)))
    661     (reverse! font-encs)))
     716           ((c-pointer (location font_enc_cb)) (c-pointer #f))
     717           safe: #t)
     718    (reverse! (enumeration-result))))
    662719
    663720(define (dfbf-find-encoding font name)
Note: See TracChangeset for help on using the changeset viewer.