mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-28 11:27:32 +09:00
CWebRender pt2
This commit is contained in:
parent
1190eb1c6a
commit
fe181d242f
22 changed files with 1623 additions and 489 deletions
|
|
@ -9,6 +9,13 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
typedef struct wr_context wr_context;
|
||||
typedef uint64_t wr_item_id;
|
||||
|
||||
typedef struct {
|
||||
uint32_t key;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
} wr_image_resource;
|
||||
|
||||
typedef struct {
|
||||
float x;
|
||||
|
|
@ -34,9 +41,24 @@ typedef struct {
|
|||
float m32;
|
||||
} wr_transform;
|
||||
|
||||
typedef struct {
|
||||
wr_rect rect;
|
||||
wr_rect tex_rect;
|
||||
} wr_glyph;
|
||||
|
||||
typedef enum {
|
||||
WR_PRIMITIVE_SOLID = 0,
|
||||
WR_PRIMITIVE_IMAGE = 1
|
||||
} wr_primitive_kind;
|
||||
|
||||
typedef struct {
|
||||
wr_rect rect;
|
||||
wr_color color;
|
||||
wr_rect tex_rect;
|
||||
uint32_t image_key;
|
||||
wr_item_id item_id;
|
||||
uint8_t kind;
|
||||
uint8_t active;
|
||||
} wr_gpu_quad;
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -46,6 +68,8 @@ typedef struct {
|
|||
wr_transform transform;
|
||||
wr_rect clip_rect;
|
||||
uint8_t has_clip;
|
||||
uint8_t kind;
|
||||
uint32_t image_key;
|
||||
} wr_gpu_batch;
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -55,6 +79,14 @@ typedef struct {
|
|||
size_t batch_count;
|
||||
} wr_frame;
|
||||
|
||||
typedef struct {
|
||||
uint32_t version;
|
||||
uint32_t quad_count;
|
||||
uint32_t batch_count;
|
||||
} wr_frame_packet_header;
|
||||
|
||||
#define WR_FRAME_PACKET_VERSION 1
|
||||
|
||||
/* Creates a retained display-list context. */
|
||||
wr_context* wr_context_create(size_t initial_capacity);
|
||||
void wr_context_destroy(wr_context* context);
|
||||
|
|
@ -62,6 +94,21 @@ void wr_context_destroy(wr_context* context);
|
|||
/* Removes every item from the retained display list. */
|
||||
void wr_context_clear(wr_context* context);
|
||||
|
||||
/* Clears transient image resources without releasing retained allocations. */
|
||||
void wr_context_clear_images(wr_context* context);
|
||||
|
||||
/* Begins an atomic retained-scene update. Transactions may be nested. */
|
||||
int wr_context_begin_transaction(wr_context* context);
|
||||
|
||||
/* Commits the innermost retained-scene update. */
|
||||
int wr_context_commit_transaction(wr_context* context);
|
||||
|
||||
/* Rolls back the innermost retained-scene update. */
|
||||
void wr_context_abort_transaction(wr_context* context);
|
||||
|
||||
/* Removes a retained display-list item by stable item ID. */
|
||||
int wr_context_remove_item(wr_context* context, wr_item_id item_id);
|
||||
|
||||
/* Sets the viewport used for coarse CPU-side culling. */
|
||||
void wr_context_set_viewport(wr_context* context, wr_rect viewport);
|
||||
|
||||
|
|
@ -71,6 +118,13 @@ void wr_context_set_transform(wr_context* context, wr_transform transform);
|
|||
/* Sets the opacity applied to subsequently recorded primitives. */
|
||||
void wr_context_set_opacity(wr_context* context, float opacity);
|
||||
|
||||
/* Registers or updates an image resource referenced by display-list commands. */
|
||||
int wr_context_register_image(wr_context* context, uint32_t image_key,
|
||||
uint32_t width, uint32_t height);
|
||||
|
||||
/* Removes an image resource and invalidates frames referencing it. */
|
||||
void wr_context_unregister_image(wr_context* context, uint32_t image_key);
|
||||
|
||||
/* Records a retained stacking-context boundary and restores it on pop. */
|
||||
int wr_display_list_push_stacking_context(wr_context* context,
|
||||
wr_transform transform,
|
||||
|
|
@ -85,14 +139,57 @@ void wr_display_list_pop_clip(wr_context* context);
|
|||
int wr_display_list_push_rect(wr_context* context, wr_rect rect,
|
||||
wr_color color);
|
||||
|
||||
/* Adds a solid rectangle with a caller-supplied stable item ID. */
|
||||
wr_item_id wr_display_list_push_rect_with_id(wr_context* context,
|
||||
wr_item_id item_id,
|
||||
wr_rect rect, wr_color color);
|
||||
|
||||
/* Updates an existing solid rectangle without rebuilding the scene. */
|
||||
int wr_display_list_update_rect(wr_context* context, wr_item_id item_id,
|
||||
wr_rect rect, wr_color color,
|
||||
wr_transform transform);
|
||||
|
||||
/* Adds a GPU-tessellated linear gradient. */
|
||||
int wr_display_list_push_linear_gradient(wr_context* context, wr_rect rect,
|
||||
wr_color start, wr_color end,
|
||||
int horizontal);
|
||||
|
||||
/* Adds a GPU-tessellated rounded rectangle. */
|
||||
int wr_display_list_push_rounded_rect(wr_context* context, wr_rect rect,
|
||||
wr_color color, float radius);
|
||||
|
||||
/* Explicit transform form for display-list builders. */
|
||||
int wr_display_list_push_transformed_rect(wr_context* context, wr_rect rect,
|
||||
wr_color color,
|
||||
wr_transform transform);
|
||||
|
||||
/* Adds an image primitive resolved by the compositor using image_key. */
|
||||
int wr_display_list_push_image(wr_context* context, wr_rect rect,
|
||||
uint32_t image_key, wr_rect tex_rect,
|
||||
wr_color tint);
|
||||
|
||||
/* Adds an image with a caller-supplied stable item ID. */
|
||||
wr_item_id wr_display_list_push_image_with_id(wr_context* context,
|
||||
wr_item_id item_id,
|
||||
wr_rect rect,
|
||||
uint32_t image_key,
|
||||
wr_rect tex_rect,
|
||||
wr_color tint);
|
||||
|
||||
/* Records glyph quads sourced from a registered image atlas. */
|
||||
int wr_display_list_push_glyph_run(wr_context* context, uint32_t image_key,
|
||||
const wr_glyph* glyphs, size_t glyph_count,
|
||||
wr_color color);
|
||||
|
||||
/* Builds the GPU-ready stream from the retained display list. */
|
||||
const wr_frame* wr_context_build_frame(wr_context* context);
|
||||
|
||||
/* Returns the byte size required for a versioned, flat frame packet. */
|
||||
size_t wr_frame_packet_size(const wr_frame* frame);
|
||||
|
||||
/* Serializes a frame into a flat buffer suitable for thread/IPC transfer. */
|
||||
int wr_frame_serialize(const wr_frame* frame, void* buffer, size_t buffer_size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue