Skip to content

Commit

Permalink
test simplified masking approach
Browse files Browse the repository at this point in the history
  • Loading branch information
nicbarker committed Feb 3, 2025
1 parent d08b04a commit dec77ec
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions clay.h
Original file line number Diff line number Diff line change
Expand Up @@ -3313,24 +3313,33 @@ void Clay__CalculateDeclarationPaddingMask(const Clay_ElementDeclaration dec, Cl
}
}
}
//
//void Clay__CreateGarbagePaddingStruct(Clay_Context* context) {
// Clay__CalculateDeclarationPaddingMask(CLAY__INIT(Clay_ElementDeclaration) {
// .id = { 0 },
// .layout = { 0 },
// .backgroundColor = { 0 },
// .cornerRadius = { 0 },
// .image = { 0 },
// .floating = { 0 },
// .custom = { 0 },
// .scroll = { 0 },
// .border = { 0 },
// }, context);
//}

void Clay__CreateGarbagePaddingStruct(Clay_Context* context) {
Clay__CalculateDeclarationPaddingMask(CLAY__INIT(Clay_ElementDeclaration) {
.id = { 0 },
.layout = { 0 },
.backgroundColor = { 0 },
.cornerRadius = { 0 },
.image = { 0 },
.floating = { 0 },
.custom = { 0 },
.scroll = { 0 },
.border = { 0 },
}, context);
}
typedef union {
Clay_ElementDeclaration key;
char mask[sizeof(Clay_ElementDeclaration)];
} DeclarationPaddingMask;

void Clay__InitDeclarationPaddingMask(Clay_Context *context) {
Clay__PoisonStack(context);
Clay__CreateGarbagePaddingStruct(context);
DeclarationPaddingMask helper;
for (int i = 0; i < sizeof(helper); i++) {
((char*)&helper)[i] = 0xff;
}
helper.key = (Clay_ElementDeclaration) { 0 }; // Let compiler do its thing
Clay__CalculateDeclarationPaddingMask(helper.key, context);
}

CLAY_WASM_EXPORT("Clay_Initialize")
Expand Down

0 comments on commit dec77ec

Please sign in to comment.