fxplug-sys 0.1.1

Raw C ABI types for Rust-authored FxPlug effects
Documentation
#ifndef FXPLUG_RUST_ABI_H
#define FXPLUG_RUST_ABI_H

#include <stddef.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

#define FXPLUG_RUST_OK 0
#define FXPLUG_RUST_ERROR -1
#define FXPLUG_RUST_NOT_IMPLEMENTED 1

#define FXPLUG_RUST_STRING_CAPACITY 128
#define FXPLUG_RUST_INFO_CAPACITY 256
#define FXPLUG_RUST_UUID_CAPACITY 40

#define FXPLUG_RUST_PARAMETER_KIND_FLOAT_SLIDER 1
#define FXPLUG_RUST_PARAMETER_KIND_INT_SLIDER 2
#define FXPLUG_RUST_PARAMETER_KIND_TOGGLE_BUTTON 3

#define FXPLUG_RUST_RENDER_BACKEND_CPU 0
#define FXPLUG_RUST_RENDER_BACKEND_METAL 1
#define FXPLUG_RUST_RENDER_BACKEND_WGPU 2

#define FXPLUG_RUST_PIXEL_FORMAT_RGBA_F32 1
#define FXPLUG_RUST_PIXEL_FORMAT_BGRA_U8 2

#define FXPLUG_RUST_MTL_PIXEL_FORMAT_RGBA8_UNORM 70
#define FXPLUG_RUST_MTL_PIXEL_FORMAT_RGBA8_UNORM_SRGB 71
#define FXPLUG_RUST_MTL_PIXEL_FORMAT_BGRA8_UNORM 80
#define FXPLUG_RUST_MTL_PIXEL_FORMAT_BGRA8_UNORM_SRGB 81
#define FXPLUG_RUST_MTL_PIXEL_FORMAT_RGBA16_FLOAT 115
#define FXPLUG_RUST_MTL_PIXEL_FORMAT_RGBA32_FLOAT 125

#define FXPLUG_RUST_QUALITY_DRAFT 0
#define FXPLUG_RUST_QUALITY_NORMAL 1
#define FXPLUG_RUST_QUALITY_HIGH 2
#define FXPLUG_RUST_QUALITY_BEST 3

#define FXPLUG_RUST_PIXEL_TRANSFORM_SCALE 1
#define FXPLUG_RUST_PIXEL_TRANSFORM_SCALE_TRANSLATE 3
#define FXPLUG_RUST_PIXEL_TRANSFORM_FULL 6

typedef struct FxPlugRustRect {
    double x;
    double y;
    double width;
    double height;
} FxPlugRustRect;

typedef struct FxPlugRustTime {
    int64_t value;
    int32_t timescale;
    uint32_t flags;
    int64_t epoch;
} FxPlugRustTime;

typedef struct FxPlugRustPluginDescriptor {
    char identifier[FXPLUG_RUST_STRING_CAPACITY];
    char display_name[FXPLUG_RUST_STRING_CAPACITY];
    char group_name[FXPLUG_RUST_STRING_CAPACITY];
    char info[FXPLUG_RUST_INFO_CAPACITY];
    char uuid[FXPLUG_RUST_UUID_CAPACITY];
    uint32_t source_count;
} FxPlugRustPluginDescriptor;

typedef struct FxPlugRustProperties {
    uint8_t may_remap_time;
    uint8_t varies_when_params_are_static;
    uint32_t pixel_transform_support;
} FxPlugRustProperties;

typedef struct FxPlugRustParameterSpec {
    uint32_t parameter_id;
    uint32_t kind;
    uint32_t flags;
    char name[FXPLUG_RUST_STRING_CAPACITY];
    double default_value;
    double parameter_min;
    double parameter_max;
    double slider_min;
    double slider_max;
    double delta;
} FxPlugRustParameterSpec;

typedef struct FxPlugRustParameterValue {
    uint32_t parameter_id;
    uint32_t kind;
    double value;
} FxPlugRustParameterValue;

typedef struct FxPlugRustImageTile {
    const void *data;
    void *data_mut;
    uint32_t width;
    uint32_t height;
    size_t row_bytes;
    uint32_t pixel_format;
    FxPlugRustRect bounds;
    void *io_surface;
    void *metal_texture;
    uintptr_t metal_texture_ptr;
    uint64_t metal_pixel_format;
    uint64_t metal_device_registry_id;
} FxPlugRustImageTile;

typedef struct FxPlugRustVertex2D {
    float position[2];
    float texture_coordinate[2];
} FxPlugRustVertex2D;

typedef struct FxPlugRustMetalRenderPlan {
    uint32_t vertex_count;
    FxPlugRustVertex2D vertices[4];
    float brightness;
} FxPlugRustMetalRenderPlan;

typedef struct FxPlugRustRenderContext {
    FxPlugRustTime time;
    uint32_t quality;
    uint32_t backend;
    FxPlugRustRect tile_rect;
    FxPlugRustImageTile source;
    FxPlugRustImageTile destination;
} FxPlugRustRenderContext;

uint32_t fxplug_rust_plugin_count(void);
int32_t fxplug_rust_plugin_descriptor(uint32_t plugin_index, FxPlugRustPluginDescriptor *out_descriptor);
int32_t fxplug_rust_plugin_properties(uint32_t plugin_index, FxPlugRustProperties *out_properties);
uint32_t fxplug_rust_parameter_count(uint32_t plugin_index);
int32_t fxplug_rust_parameter_spec(uint32_t plugin_index, uint32_t parameter_index, FxPlugRustParameterSpec *out_spec);
int32_t fxplug_rust_plugin_state(uint32_t plugin_index,
                                 const FxPlugRustParameterValue *values,
                                 size_t value_count,
                                 FxPlugRustTime time,
                                 uint32_t quality,
                                 uint8_t **out_data,
                                 size_t *out_len);
void fxplug_rust_free_bytes(uint8_t *data, size_t len);
int32_t fxplug_rust_destination_rect(uint32_t plugin_index,
                                     const uint8_t *state_data,
                                     size_t state_len,
                                     const FxPlugRustRect *source_rects,
                                     size_t source_count,
                                     FxPlugRustRect destination_bounds,
                                     FxPlugRustRect *out_rect);
int32_t fxplug_rust_source_tile_rect(uint32_t plugin_index,
                                     const uint8_t *state_data,
                                     size_t state_len,
                                     uint32_t source_index,
                                     FxPlugRustRect destination_tile_rect,
                                     FxPlugRustRect *out_rect);
int32_t fxplug_rust_render_cpu(uint32_t plugin_index,
                               const uint8_t *state_data,
                               size_t state_len,
                               const FxPlugRustRenderContext *context);
int32_t fxplug_rust_render_gpu(uint32_t plugin_index,
                               const uint8_t *state_data,
                               size_t state_len,
                               const FxPlugRustRenderContext *context);
int32_t fxplug_rust_metal_render_plan(uint32_t plugin_index,
                                      const uint8_t *state_data,
                                      size_t state_len,
                                      const FxPlugRustRenderContext *context,
                                      FxPlugRustMetalRenderPlan *out_plan);

#ifdef __cplusplus
}
#endif

#endif