Skip to content

Commit

Permalink
Add TesselatedColoredSvgNode
Browse files Browse the repository at this point in the history
  • Loading branch information
fschutt committed May 13, 2024
1 parent f35ca35 commit 996cd5d
Show file tree
Hide file tree
Showing 12 changed files with 980 additions and 29 deletions.
96 changes: 96 additions & 0 deletions api.json
Original file line number Diff line number Diff line change
Expand Up @@ -7491,6 +7491,17 @@
"returns": {"type": "bool"},
"fn_body": "let node = unsafe { &*node }; node.draw(texture, size, color, transforms)"
},
"draw_tesselated_colored_svg_gpu_node": {
"doc": "Draws a `&TessellatedColoredGPUSvgNode` with the given color to the texture",
"fn_args": [
{"self": "refmut"},
{"node": "*const TessellatedColoredGPUSvgNode"},
{"size": "PhysicalSizeU32"},
{"transforms": "StyleTransformVec"}
],
"returns": {"type": "bool"},
"fn_body": "let node = unsafe { &*node }; node.draw(texture, size, color, transforms)"
},
"apply_fxaa": {
"doc": "Applies an FXAA filter to the texture",
"fn_args": [
Expand Down Expand Up @@ -12688,6 +12699,64 @@
}
}
},
"SvgColoredVertex": {
"external": "azul_impl::svg::SvgColoredVertex",
"derive": ["Copy", "Serialize", "Deserialize"],
"struct_fields": [
{"x": {"type": "f32"}},
{"y": {"type": "f32"}},
{"z": {"type": "f32"}},
{"r": {"type": "f32"}},
{"g": {"type": "f32"}},
{"b": {"type": "f32"}},
{"a": {"type": "f32"}}
]
},
"TessellatedColoredSvgNode": {
"external": "azul_impl::svg::TessellatedColoredSvgNode",
"struct_fields": [
{"vertices": {"type": "SvgColoredVertexVec"}},
{"indices": {"type": "U32Vec"}}
],
"constructors": {
"empty": {
"doc": "Returns an empty buffer vertices / indices",
"fn_args": [],
"fn_body": "AzTessellatedColoredSvgNode::empty()"
},
"from_nodes": {
"doc": "Creates a new TessellatedColoredSvgNode by joining all the given nodes together into one array and inserting a `GL_RESTART_INDEX` (`u32::MAX`) into the indices (so that the resulting buffer can be drawn in one draw call).",
"fn_args": [
{"nodes": "TessellatedColoredSvgNodeVecRef"}
],
"fn_body": "azul_impl::svg::join_tessellated_nodes(nodes.as_slice())"
}
}
},
"TessellatedColoredSvgNodeVecRef": {
"doc": "Rust wrapper over a `&[TessellatedColoredSvgNode]` or `&Vec<TessellatedColoredSvgNode>`",
"external": "azul_impl::svg::TessellatedColoredSvgNodeVecRef",
"struct_fields": [
{"ptr": {"type": "*const TessellatedColoredSvgNode"}},
{"len": {"type": "usize"}}
]
},
"TessellatedColoredGPUSvgNode": {
"external": "azul_impl::svg::TessellatedColoredGPUSvgNode",
"derive": ["Debug"],
"struct_fields": [
{"vertex_index_buffer": {"type": "VertexBuffer"}}
],
"constructors": {
"new": {
"fn_args": [
{"tessellated_node": "*const TessellatedColoredSvgNode"},
{"gl": "Gl"}
],
"fn_body": "AzTessellatedColoredGPUSvgNode::new(unsafe { &*tessellated_node }, gl)"
}
}
},
"SvgVertex": {
"external": "azul_impl::svg::SvgVertex",
"derive": ["Copy", "Serialize", "Deserialize"],
Expand Down Expand Up @@ -14196,6 +14265,17 @@
{ "destructor": { "type": "SvgVertexVecDestructor" } }
]
},
"SvgColoredVertexVec": {
"doc": "Wrapper over a Rust-allocated `SvgColoredVertex`",
"custom_destructor": true,
"external": "azul_impl::svg::SvgColoredVertexVec",
"struct_fields": [
{ "ptr": { "type": "*const SvgVertex" } },
{ "len": { "type": "usize" } },
{ "cap": { "type": "usize" } },
{ "destructor": { "type": "SvgColoredVertexVecDestructor" } }
]
},
"U32Vec": {
"doc": "Wrapper over a Rust-allocated `Vec<u32>`",
"custom_destructor": true,
Expand Down Expand Up @@ -15127,6 +15207,22 @@
]
}
},
"SvgColoredVertexVecDestructor": {
"external": "azul_impl::svg::SvgColoredVertexVecDestructor",
"derive": ["Copy"],
"enum_fields": [
{"DefaultRust": {}},
{"NoDestructor": {}},
{"External": {"type": "SvgColoredVertexVecDestructorType"}}
]
},
"SvgColoredVertexVecDestructorType": {
"callback_typedef": {
"fn_args": [
{"type": "SvgColoredVertexVec", "ref": "refmut"}
]
}
},
"U32VecDestructor": {
"external": "azul_impl::css::U32VecDestructor",
"derive": ["Copy"],
Expand Down
1 change: 1 addition & 0 deletions api/_patches/azul-dll/test-sizes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
impl ::core::fmt::Debug for AzVertexAttributeVecDestructor { fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { use AzVertexAttributeVecDestructor::*; match self { DefaultRust => write!(f, "DefaultRust"), NoDestructor => write!(f, "NoDestructor"), External(_) => write!(f, "External"), }}}
impl ::core::fmt::Debug for AzSvgPathElementVecDestructor { fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { use AzSvgPathElementVecDestructor::*; match self { DefaultRust => write!(f, "DefaultRust"), NoDestructor => write!(f, "NoDestructor"), External(_) => write!(f, "External"), }}}
impl ::core::fmt::Debug for AzSvgVertexVecDestructor { fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { use AzSvgVertexVecDestructor::*; match self { DefaultRust => write!(f, "DefaultRust"), NoDestructor => write!(f, "NoDestructor"), External(_) => write!(f, "External"), }}}
impl ::core::fmt::Debug for AzSvgColoredVertexVecDestructor { fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { use AzSvgColoredVertexVecDestructor::*; match self { DefaultRust => write!(f, "DefaultRust"), NoDestructor => write!(f, "NoDestructor"), External(_) => write!(f, "External"), }}}
impl ::core::fmt::Debug for AzU32VecDestructor { fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { use AzU32VecDestructor::*; match self { DefaultRust => write!(f, "DefaultRust"), NoDestructor => write!(f, "NoDestructor"), External(_) => write!(f, "External"), }}}
impl ::core::fmt::Debug for AzXWindowTypeVecDestructor { fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { use AzXWindowTypeVecDestructor::*; match self { DefaultRust => write!(f, "DefaultRust"), NoDestructor => write!(f, "NoDestructor"), External(_) => write!(f, "External"), }}}
impl ::core::fmt::Debug for AzVirtualKeyCodeVecDestructor { fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { use AzVirtualKeyCodeVecDestructor::*; match self { DefaultRust => write!(f, "DefaultRust"), NoDestructor => write!(f, "NoDestructor"), External(_) => write!(f, "External"), }}}
Expand Down
4 changes: 4 additions & 0 deletions api/_patches/azul.rs/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@
impl_vec_clone!(AzMenuItem, AzMenuItemVec, AzMenuItemVecDestructor);
impl_vec!(AzSvgSimpleNode, AzSvgSimpleNodeVec, AzSvgSimpleNodeVecDestructor, az_svg_simple_node_vec_destructor, AzSvgSimpleNodeVec_delete);
impl_vec_clone!(AzSvgSimpleNode, AzSvgSimpleNodeVec, AzSvgSimpleNodeVecDestructor);
impl_vec!(AzSvgColoredVertex, AzSvgColoredVertexVec, AzSvgColoredVertexVecDestructor, az_svg_colored_vertex_vec_destructor, AzSvgColoredVertexVec_delete);
impl_vec_clone!(AzSvgColoredVertex, AzSvgColoredVertexVec, AzSvgColoredVertexVecDestructor);
impl_vec!(AzTessellatedColoredSvgNode, AzTessellatedColoredSvgNodeVec, AzTessellatedColoredSvgNodeVecDestructor, az_tesselated_colored_svg_node_vec_destructor, AzTessellatedColoredSvgNodeVec_delete);
impl_vec_clone!(AzTessellatedColoredSvgNode, AzTessellatedColoredSvgNodeVec, AzTessellatedColoredSvgNodeVecDestructor);

impl From<vec::Vec<string::String>> for crate::vec::StringVec {
fn from(v: vec::Vec<string::String>) -> crate::vec::StringVec {
Expand Down
89 changes: 89 additions & 0 deletions api/c/azul.h
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@ struct AzSvgVertexVec;
typedef struct AzSvgVertexVec AzSvgVertexVec;
typedef void (*AzSvgVertexVecDestructorType)(AzSvgVertexVec* restrict A);

struct AzSvgColoredVertexVec;
typedef struct AzSvgColoredVertexVec AzSvgColoredVertexVec;
typedef void (*AzSvgColoredVertexVecDestructorType)(AzSvgColoredVertexVec* restrict A);

struct AzU32Vec;
typedef struct AzU32Vec AzU32Vec;
typedef void (*AzU32VecDestructorType)(AzU32Vec* restrict A);
Expand Down Expand Up @@ -2003,6 +2007,17 @@ struct AzSvgRect {
};
typedef struct AzSvgRect AzSvgRect;

struct AzSvgColoredVertex {
float x;
float y;
float z;
float r;
float g;
float b;
float a;
};
typedef struct AzSvgColoredVertex AzSvgColoredVertex;

struct AzSvgVertex {
float x;
float y;
Expand Down Expand Up @@ -3062,6 +3077,26 @@ union AzSvgVertexVecDestructor {
};
typedef union AzSvgVertexVecDestructor AzSvgVertexVecDestructor;

enum AzSvgColoredVertexVecDestructorTag {
AzSvgColoredVertexVecDestructorTag_DefaultRust,
AzSvgColoredVertexVecDestructorTag_NoDestructor,
AzSvgColoredVertexVecDestructorTag_External,
};
typedef enum AzSvgColoredVertexVecDestructorTag AzSvgColoredVertexVecDestructorTag;

struct AzSvgColoredVertexVecDestructorVariant_DefaultRust { AzSvgColoredVertexVecDestructorTag tag; };
typedef struct AzSvgColoredVertexVecDestructorVariant_DefaultRust AzSvgColoredVertexVecDestructorVariant_DefaultRust;
struct AzSvgColoredVertexVecDestructorVariant_NoDestructor { AzSvgColoredVertexVecDestructorTag tag; };
typedef struct AzSvgColoredVertexVecDestructorVariant_NoDestructor AzSvgColoredVertexVecDestructorVariant_NoDestructor;
struct AzSvgColoredVertexVecDestructorVariant_External { AzSvgColoredVertexVecDestructorTag tag; AzSvgColoredVertexVecDestructorType payload; };
typedef struct AzSvgColoredVertexVecDestructorVariant_External AzSvgColoredVertexVecDestructorVariant_External;
union AzSvgColoredVertexVecDestructor {
AzSvgColoredVertexVecDestructorVariant_DefaultRust DefaultRust;
AzSvgColoredVertexVecDestructorVariant_NoDestructor NoDestructor;
AzSvgColoredVertexVecDestructorVariant_External External;
};
typedef union AzSvgColoredVertexVecDestructor AzSvgColoredVertexVecDestructor;

enum AzU32VecDestructorTag {
AzU32VecDestructorTag_DefaultRust,
AzU32VecDestructorTag_NoDestructor,
Expand Down Expand Up @@ -6698,6 +6733,14 @@ struct AzSvgVertexVec {
};
typedef struct AzSvgVertexVec AzSvgVertexVec;

struct AzSvgColoredVertexVec {
AzSvgVertex* ptr;
size_t len;
size_t cap;
AzSvgColoredVertexVecDestructor destructor;
};
typedef struct AzSvgColoredVertexVec AzSvgColoredVertexVec;

struct AzU32Vec {
uint32_t* ptr;
size_t len;
Expand Down Expand Up @@ -8448,6 +8491,18 @@ union AzSvgPathElement {
};
typedef union AzSvgPathElement AzSvgPathElement;

struct AzTessellatedColoredSvgNode {
AzSvgColoredVertexVec vertices;
AzU32Vec indices;
};
typedef struct AzTessellatedColoredSvgNode AzTessellatedColoredSvgNode;

struct AzTessellatedColoredSvgNodeVecRef {
AzTessellatedColoredSvgNode* ptr;
size_t len;
};
typedef struct AzTessellatedColoredSvgNodeVecRef AzTessellatedColoredSvgNodeVecRef;

struct AzTessellatedSvgNode {
AzSvgVertexVec vertices;
AzU32Vec indices;
Expand Down Expand Up @@ -10253,6 +10308,11 @@ union AzSvgSimpleNode {
};
typedef union AzSvgSimpleNode AzSvgSimpleNode;

struct AzTessellatedColoredGPUSvgNode {
AzVertexBuffer vertex_index_buffer;
};
typedef struct AzTessellatedColoredGPUSvgNode AzTessellatedColoredGPUSvgNode;

struct AzTessellatedGPUSvgNode {
AzVertexBuffer vertex_index_buffer;
};
Expand Down Expand Up @@ -11153,6 +11213,9 @@ typedef struct AzCss AzCss;
#define AzSvgVertexVecDestructor_DefaultRust { .DefaultRust = { .tag = AzSvgVertexVecDestructorTag_DefaultRust } }
#define AzSvgVertexVecDestructor_NoDestructor { .NoDestructor = { .tag = AzSvgVertexVecDestructorTag_NoDestructor } }
#define AzSvgVertexVecDestructor_External(v) { .External = { .tag = AzSvgVertexVecDestructorTag_External, .payload = v } }
#define AzSvgColoredVertexVecDestructor_DefaultRust { .DefaultRust = { .tag = AzSvgColoredVertexVecDestructorTag_DefaultRust } }
#define AzSvgColoredVertexVecDestructor_NoDestructor { .NoDestructor = { .tag = AzSvgColoredVertexVecDestructorTag_NoDestructor } }
#define AzSvgColoredVertexVecDestructor_External(v) { .External = { .tag = AzSvgColoredVertexVecDestructorTag_External, .payload = v } }
#define AzU32VecDestructor_DefaultRust { .DefaultRust = { .tag = AzU32VecDestructorTag_DefaultRust } }
#define AzU32VecDestructor_NoDestructor { .NoDestructor = { .tag = AzU32VecDestructorTag_NoDestructor } }
#define AzU32VecDestructor_External(v) { .External = { .tag = AzU32VecDestructorTag_External, .payload = v } }
Expand Down Expand Up @@ -12238,6 +12301,10 @@ AzSvgVertex AzSvgVertexVecArray[] = {};
#define AzSvgVertexVec_fromConstArray(v) { .ptr = &v, .len = sizeof(v) / sizeof(AzSvgVertex), .cap = sizeof(v) / sizeof(AzSvgVertex), .destructor = { .NoDestructor = { .tag = AzSvgVertexVecDestructorTag_NoDestructor, }, }, }
#define AzSvgVertexVec_empty { .ptr = &AzSvgVertexVecArray, .len = 0, .cap = 0, .destructor = { .NoDestructor = { .tag = AzSvgVertexVecDestructorTag_NoDestructor, }, }, }

AzSvgVertex AzSvgColoredVertexVecArray[] = {};
#define AzSvgColoredVertexVec_fromConstArray(v) { .ptr = &v, .len = sizeof(v) / sizeof(AzSvgColoredVertex), .cap = sizeof(v) / sizeof(AzSvgColoredVertex), .destructor = { .NoDestructor = { .tag = AzSvgColoredVertexVecDestructorTag_NoDestructor, }, }, }
#define AzSvgColoredVertexVec_empty { .ptr = &AzSvgColoredVertexVecArray, .len = 0, .cap = 0, .destructor = { .NoDestructor = { .tag = AzSvgColoredVertexVecDestructorTag_NoDestructor, }, }, }

uint32_t AzU32VecArray[] = {};
#define AzU32Vec_fromConstArray(v) { .ptr = &v, .len = sizeof(v) / sizeof(uint32_t), .cap = sizeof(v) / sizeof(uint32_t), .destructor = { .NoDestructor = { .tag = AzU32VecDestructorTag_NoDestructor, }, }, }
#define AzU32Vec_empty { .ptr = &AzU32VecArray, .len = 0, .cap = 0, .destructor = { .NoDestructor = { .tag = AzU32VecDestructorTag_NoDestructor, }, }, }
Expand Down Expand Up @@ -12796,6 +12863,7 @@ extern DLLIMPORT AzTexture AzTexture_allocateClipMask(AzGl gl, AzPhysicalSizeU3
extern DLLIMPORT void AzTexture_clear(AzTexture* restrict texture);
extern DLLIMPORT bool AzTexture_drawClipMask(AzTexture* restrict texture, AzTessellatedSvgNode node);
extern DLLIMPORT bool AzTexture_drawTesselatedSvgGpuNode(AzTexture* restrict texture, AzTessellatedGPUSvgNode * node, AzPhysicalSizeU32 size, AzColorU color, AzStyleTransformVec transforms);
extern DLLIMPORT bool AzTexture_drawTesselatedColoredSvgGpuNode(AzTexture* restrict texture, AzTessellatedColoredGPUSvgNode * node, AzPhysicalSizeU32 size, AzStyleTransformVec transforms);
extern DLLIMPORT bool AzTexture_applyFxaa(AzTexture* restrict texture);
extern DLLIMPORT void AzTexture_delete(AzTexture* restrict instance);
extern DLLIMPORT AzTexture AzTexture_deepCopy(AzTexture* const instance);
Expand Down Expand Up @@ -13190,6 +13258,12 @@ extern DLLIMPORT bool AzSvgRect_containsPoint(const AzSvgRect* svgrect, AzSvgPo
extern DLLIMPORT AzSvgRect AzSvgRect_expand(const AzSvgRect* svgrect, float padding_top, float padding_bottom, float padding_left, float padding_right);
extern DLLIMPORT AzTessellatedSvgNode AzSvgRect_tessellateFill(const AzSvgRect* svgrect, AzSvgFillStyle fill_style);
extern DLLIMPORT AzTessellatedSvgNode AzSvgRect_tessellateStroke(const AzSvgRect* svgrect, AzSvgStrokeStyle stroke_style);
extern DLLIMPORT AzTessellatedColoredSvgNode AzTessellatedColoredSvgNode_empty();
extern DLLIMPORT AzTessellatedColoredSvgNode AzTessellatedColoredSvgNode_fromNodes(AzTessellatedColoredSvgNodeVecRef nodes);
extern DLLIMPORT void AzTessellatedColoredSvgNode_delete(AzTessellatedColoredSvgNode* restrict instance);
extern DLLIMPORT void AzTessellatedColoredSvgNodeVecRef_delete(AzTessellatedColoredSvgNodeVecRef* restrict instance);
extern DLLIMPORT AzTessellatedColoredGPUSvgNode AzTessellatedColoredGPUSvgNode_new(AzTessellatedColoredSvgNode * tessellated_node, AzGl gl);
extern DLLIMPORT void AzTessellatedColoredGPUSvgNode_delete(AzTessellatedColoredGPUSvgNode* restrict instance);
extern DLLIMPORT AzTessellatedSvgNode AzTessellatedSvgNode_empty();
extern DLLIMPORT AzTessellatedSvgNode AzTessellatedSvgNode_fromNodes(AzTessellatedSvgNodeVecRef nodes);
extern DLLIMPORT void AzTessellatedSvgNode_delete(AzTessellatedSvgNode* restrict instance);
Expand Down Expand Up @@ -13300,6 +13374,7 @@ extern DLLIMPORT void AzSvgPathVec_delete(AzSvgPathVec* restrict instance);
extern DLLIMPORT void AzVertexAttributeVec_delete(AzVertexAttributeVec* restrict instance);
extern DLLIMPORT void AzSvgPathElementVec_delete(AzSvgPathElementVec* restrict instance);
extern DLLIMPORT void AzSvgVertexVec_delete(AzSvgVertexVec* restrict instance);
extern DLLIMPORT void AzSvgColoredVertexVec_delete(AzSvgColoredVertexVec* restrict instance);
extern DLLIMPORT void AzU32Vec_delete(AzU32Vec* restrict instance);
extern DLLIMPORT void AzXWindowTypeVec_delete(AzXWindowTypeVec* restrict instance);
extern DLLIMPORT void AzVirtualKeyCodeVec_delete(AzVirtualKeyCodeVec* restrict instance);
Expand Down Expand Up @@ -19498,6 +19573,20 @@ bool AzSvgVertexVecDestructor_matchMutExternal(AzSvgVertexVecDestructor* restric
return valid;
}

bool AzSvgColoredVertexVecDestructor_matchRefExternal(const AzSvgColoredVertexVecDestructor* value, const AzSvgColoredVertexVecDestructorType** restrict out) {
const AzSvgColoredVertexVecDestructorVariant_External* casted = (const AzSvgColoredVertexVecDestructorVariant_External*)value;
bool valid = casted->tag == AzSvgColoredVertexVecDestructorTag_External;
if (valid) { *out = &casted->payload; } else { *out = 0; }
return valid;
}

bool AzSvgColoredVertexVecDestructor_matchMutExternal(AzSvgColoredVertexVecDestructor* restrict value, AzSvgColoredVertexVecDestructorType* restrict * restrict out) {
AzSvgColoredVertexVecDestructorVariant_External* restrict casted = (AzSvgColoredVertexVecDestructorVariant_External* restrict)value;
bool valid = casted->tag == AzSvgColoredVertexVecDestructorTag_External;
if (valid) { *out = &casted->payload; } else { *out = 0; }
return valid;
}

bool AzU32VecDestructor_matchRefExternal(const AzU32VecDestructor* value, const AzU32VecDestructorType** restrict out) {
const AzU32VecDestructorVariant_External* casted = (const AzU32VecDestructorVariant_External*)value;
bool valid = casted->tag == AzU32VecDestructorTag_External;
Expand Down
Loading

0 comments on commit 996cd5d

Please sign in to comment.