Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions examples/zr_example_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ static inline uint32_t zr_ex_le32_read(const uint8_t* p) {

/* --- Alignment --- */

static inline uint32_t zr_ex_align4_u32(uint32_t x) { return (x + 3u) & ~3u; }
static inline uint32_t zr_ex_align4_u32(uint32_t x) {
return (x + 3u) & ~3u;
}

/* --- Color --- */

Expand All @@ -40,4 +42,3 @@ static inline uint32_t zr_ex_rgb_u32(uint8_t r, uint8_t g, uint8_t b) {
}

#endif /* ZR_EXAMPLE_COMMON_H_INCLUDED */

8 changes: 8 additions & 0 deletions include/zr/zr_caps.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#ifndef ZR_ZR_CAPS_H_INCLUDED
#define ZR_ZR_CAPS_H_INCLUDED

#ifdef __cplusplus
extern "C" {
#endif

#include "zr/zr_result.h"

#include <stdint.h>
Expand Down Expand Up @@ -46,4 +50,8 @@ zr_limits_t zr_limits_default(void);
/* Validate limit values and relationships. */
zr_result_t zr_limits_validate(const zr_limits_t* limits);

#ifdef __cplusplus
}
#endif

#endif /* ZR_ZR_CAPS_H_INCLUDED */
8 changes: 8 additions & 0 deletions include/zr/zr_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#ifndef ZR_ZR_CONFIG_H_INCLUDED
#define ZR_ZR_CONFIG_H_INCLUDED

#ifdef __cplusplus
extern "C" {
#endif

#include "zr/zr_caps.h"
#include "zr/zr_platform_types.h"
#include "zr/zr_result.h"
Expand Down Expand Up @@ -92,4 +96,8 @@ zr_result_t zr_engine_config_validate(const zr_engine_config_t* cfg);
/* Validate runtime config for engine_set_config. */
zr_result_t zr_engine_runtime_config_validate(const zr_engine_runtime_config_t* cfg);

#ifdef __cplusplus
}
#endif

#endif /* ZR_ZR_CONFIG_H_INCLUDED */
8 changes: 8 additions & 0 deletions include/zr/zr_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
#ifndef ZR_ZR_DEBUG_H_INCLUDED
#define ZR_ZR_DEBUG_H_INCLUDED

#ifdef __cplusplus
extern "C" {
#endif

#include "zr/zr_result.h"

#include <stdint.h>
Expand Down Expand Up @@ -220,4 +224,8 @@ typedef struct zr_debug_stats_t {
*/
zr_debug_config_t zr_debug_config_default(void);

#ifdef __cplusplus
}
#endif

#endif /* ZR_ZR_DEBUG_H_INCLUDED */
8 changes: 8 additions & 0 deletions include/zr/zr_drawlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#ifndef ZR_ZR_DRAWLIST_H_INCLUDED
#define ZR_ZR_DRAWLIST_H_INCLUDED

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>

/* ABI-facing types (little-endian on-wire). */
Expand Down Expand Up @@ -260,4 +264,8 @@ typedef struct zr_dl_cmd_free_resource_t {
uint32_t id;
} zr_dl_cmd_free_resource_t;

#ifdef __cplusplus
}
#endif

#endif /* ZR_ZR_DRAWLIST_H_INCLUDED */
8 changes: 8 additions & 0 deletions include/zr/zr_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#ifndef ZR_ZR_ENGINE_H_INCLUDED
#define ZR_ZR_ENGINE_H_INCLUDED

#ifdef __cplusplus
extern "C" {
#endif

#include "zr/zr_config.h"
#include "zr/zr_debug.h"
#include "zr/zr_metrics.h"
Expand Down Expand Up @@ -199,4 +203,8 @@ int32_t engine_debug_export(zr_engine_t* e, uint8_t* out_buf, size_t out_cap);
/* Clear trace records while keeping tracing enabled. */
void engine_debug_reset(zr_engine_t* e);

#ifdef __cplusplus
}
#endif

#endif /* ZR_ZR_ENGINE_H_INCLUDED */
8 changes: 8 additions & 0 deletions include/zr/zr_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#ifndef ZR_ZR_EVENT_H_INCLUDED
#define ZR_ZR_EVENT_H_INCLUDED

#ifdef __cplusplus
extern "C" {
#endif

#include "zr/zr_version.h"

#include <stddef.h>
Expand Down Expand Up @@ -188,4 +192,8 @@ typedef struct zr_ev_user_t {
uint32_t reserved1;
} zr_ev_user_t;

#ifdef __cplusplus
}
#endif

#endif /* ZR_ZR_EVENT_H_INCLUDED */
12 changes: 10 additions & 2 deletions include/zr/zr_metrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
#ifndef ZR_ZR_METRICS_H_INCLUDED
#define ZR_ZR_METRICS_H_INCLUDED

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>

/*
Expand Down Expand Up @@ -64,8 +68,12 @@ typedef struct zr_metrics_t {
/* --- Damage summary (last frame) --- */
uint32_t damage_rects_last_frame;
uint32_t damage_cells_last_frame;
uint8_t damage_full_frame;
uint8_t _pad2[3];
uint8_t damage_full_frame;
uint8_t _pad2[3];
} zr_metrics_t;

#ifdef __cplusplus
}
#endif

#endif /* ZR_ZR_METRICS_H_INCLUDED */
8 changes: 8 additions & 0 deletions include/zr/zr_platform_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#ifndef ZR_ZR_PLATFORM_TYPES_H_INCLUDED
#define ZR_ZR_PLATFORM_TYPES_H_INCLUDED

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>

/*
Expand Down Expand Up @@ -69,4 +73,8 @@ typedef struct plat_config_t {
uint8_t _pad[3];
} plat_config_t;

#ifdef __cplusplus
}
#endif

#endif /* ZR_ZR_PLATFORM_TYPES_H_INCLUDED */
8 changes: 8 additions & 0 deletions include/zr/zr_result.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#ifndef ZR_ZR_RESULT_H_INCLUDED
#define ZR_ZR_RESULT_H_INCLUDED

#ifdef __cplusplus
extern "C" {
#endif

typedef int zr_result_t;

/* Success. */
Expand All @@ -25,4 +29,8 @@ typedef int zr_result_t;
#define ZR_ERR_FORMAT ((zr_result_t) - 5)
#define ZR_ERR_PLATFORM ((zr_result_t) - 6)

#ifdef __cplusplus
}
#endif

#endif /* ZR_ZR_RESULT_H_INCLUDED */
8 changes: 8 additions & 0 deletions include/zr/zr_terminal_caps.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
#ifndef ZR_ZR_TERMINAL_CAPS_H_INCLUDED
#define ZR_ZR_TERMINAL_CAPS_H_INCLUDED

#ifdef __cplusplus
extern "C" {
#endif

#include "zr/zr_platform_types.h"

#include <stdint.h>
Expand Down Expand Up @@ -157,4 +161,8 @@ typedef struct zr_terminal_caps_t {
zr_terminal_cap_flags_t cap_suppress_flags;
} zr_terminal_caps_t;

#ifdef __cplusplus
}
#endif

#endif /* ZR_ZR_TERMINAL_CAPS_H_INCLUDED */
8 changes: 8 additions & 0 deletions include/zr/zr_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#ifndef ZR_ZR_VERSION_H_INCLUDED
#define ZR_ZR_VERSION_H_INCLUDED

#ifdef __cplusplus
extern "C" {
#endif

/*
NOTE: These version pins are part of the determinism contract. They must not
be overridden by downstream builds.
Expand Down Expand Up @@ -35,4 +39,8 @@
/* Packed event batch binary format versions. */
#define ZR_EVENT_BATCH_VERSION_V1 (1u)

#ifdef __cplusplus
}
#endif

#endif /* ZR_ZR_VERSION_H_INCLUDED */
5 changes: 2 additions & 3 deletions src/core/zr_cursor.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
#include <stdint.h>

typedef uint8_t zr_cursor_shape_t;
#define ZR_CURSOR_SHAPE_BLOCK ((zr_cursor_shape_t)0u)
#define ZR_CURSOR_SHAPE_BLOCK ((zr_cursor_shape_t)0u)
#define ZR_CURSOR_SHAPE_UNDERLINE ((zr_cursor_shape_t)1u)
#define ZR_CURSOR_SHAPE_BAR ((zr_cursor_shape_t)2u)
#define ZR_CURSOR_SHAPE_BAR ((zr_cursor_shape_t)2u)

/*
zr_cursor_state_t:
Expand All @@ -32,4 +32,3 @@ typedef struct zr_cursor_state_t {
} zr_cursor_state_t;

#endif /* ZR_CORE_ZR_CURSOR_H_INCLUDED */

2 changes: 2 additions & 0 deletions src/core/zr_damage.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ static void zr_damage_mark_full(zr_damage_t* d) {
d->rects[0].y0 = 0u;
d->rects[0].x1 = d->cols - 1u;
d->rects[0].y1 = d->rows - 1u;
d->rects[0]._link = UINT32_MAX;
d->rect_count = 1u;
}

Expand Down Expand Up @@ -97,6 +98,7 @@ void zr_damage_add_span(zr_damage_t* d, uint32_t y, uint32_t x0, uint32_t x1) {
r->y0 = y;
r->x1 = x1;
r->y1 = y;
r->_link = UINT32_MAX;
}

uint32_t zr_damage_cells(const zr_damage_t* d) {
Expand Down
28 changes: 18 additions & 10 deletions src/core/zr_damage.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,30 @@ typedef struct zr_damage_rect_t {
uint32_t y0;
uint32_t x1;
uint32_t y1;
/*
Scratch link field for allocation-free damage coalescing.

Why: The diff renderer's indexed damage-walk needs per-rectangle "next"
pointers but must not clobber the rectangle coordinates because the engine
can reuse the computed rectangles after diff emission (e.g. for fb_prev
resync on partial presents).
*/
uint32_t _link;
} zr_damage_rect_t;

typedef struct zr_damage_t {
zr_damage_rect_t* rects;
uint32_t rect_cap;
uint32_t rect_count;
uint32_t cols;
uint32_t rows;
uint8_t full_frame;
uint8_t _pad0[3];
uint32_t rect_cap;
uint32_t rect_count;
uint32_t cols;
uint32_t rows;
uint8_t full_frame;
uint8_t _pad0[3];
} zr_damage_t;

void zr_damage_begin_frame(zr_damage_t* d, zr_damage_rect_t* storage, uint32_t storage_cap, uint32_t cols,
uint32_t rows);
void zr_damage_add_span(zr_damage_t* d, uint32_t y, uint32_t x0, uint32_t x1);
void zr_damage_begin_frame(zr_damage_t* d, zr_damage_rect_t* storage, uint32_t storage_cap, uint32_t cols,
uint32_t rows);
void zr_damage_add_span(zr_damage_t* d, uint32_t y, uint32_t x0, uint32_t x1);
uint32_t zr_damage_cells(const zr_damage_t* d);

#endif /* ZR_CORE_ZR_DAMAGE_H_INCLUDED */

Loading
Loading