Untitled

 avatar
unknown
plain_text
a month ago
1.9 kB
2
Indexable
/* rdprail.h */
#ifndef WLR_RENDER_ALLOCATOR_RDPRAIL_H
#define WLR_RENDER_ALLOCATOR_RDPRAIL_H

#define _GNU_SOURCE  // For memfd_create

#include <stdint.h>
#include <wlr/render/allocator.h>
#include <wlr/types/wlr_buffer.h>
#include <wlr/interfaces/wlr_buffer.h>

// Define RECTANGLE_16 structure first
typedef struct {
    uint16_t left;
    uint16_t top;
    uint16_t right;
    uint16_t bottom;
} RECTANGLE_16;

// RDP-specific PDU structures
typedef struct {
    uint32_t poolId;
} GFXREDIR_OPEN_POOL_PDU;

typedef struct {
    uint32_t poolId;
    uint32_t bufferId;
    int width;
    int height;
    int format;
} GFXREDIR_CREATE_BUFFER_PDU;

// Surface command definition
#define GFX_REDIR_SURFACE_COMMAND_UPDATEREGION 1

// Context structure
struct _GfxRedirServerContext {
    int (*OpenPool)(struct _GfxRedirServerContext *ctx, 
                   GFXREDIR_OPEN_POOL_PDU *open_pool);
    int (*CreateBuffer)(struct _GfxRedirServerContext *ctx, 
                       GFXREDIR_CREATE_BUFFER_PDU *create_buffer);
    int (*SurfaceCommand)(struct _GfxRedirServerContext *ctx, 
                         void *surface_data,
                         int command, 
                         RECTANGLE_16 *rect, 
                         void *buffer_data);
};

typedef struct _GfxRedirServerContext GfxRedirServerContext;

struct wlr_rdp_allocator {
    struct wlr_allocator base;
    GfxRedirServerContext *redir_ctx;
};

struct wlr_rdp_buffer {
    struct wlr_buffer buffer;
    uint32_t pool_id;
    uint32_t buffer_id;
    void *rdp_memory;
    size_t rdp_memory_size;
    int width;
    int height;
    int fd;  // File descriptor for shared memory
    bool data_access_in_progress;
};

// Function declarations
void* rdp_get_shared_memory(uint32_t pool_id, size_t *size, int *fd);
struct wlr_allocator *wlr_rdp_allocator_create(GfxRedirServerContext *redir_ctx);

#endif // WLR_RENDER_ALLOCATOR_RDPRAIL_H
Leave a Comment