Compare commits

...

7 Commits

Author SHA1 Message Date
Shivam7-1
28eb8f6510
Merge 63a74a92a8 into 19a27b39f2 2025-03-09 04:18:56 +01:00
Daniel Collin
19a27b39f2
[Compilers] Fixed SIMD related compile error on some ARM compilers (#316)
Some checks are pending
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Waiting to run
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Waiting to run
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Waiting to run
2025-03-09 10:28:09 +13:00
Nic Barker
22e8cc318c [Bindings/Odin] Update odin bindings for text config userdata pointer
Some checks are pending
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Waiting to run
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Waiting to run
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Waiting to run
2025-03-08 11:08:04 +13:00
Michael Savage
8e6640f7a2
[Core] Add a userData pointer to Clay_TextElementConfig (#274) 2025-03-08 11:01:26 +13:00
Ethan McCue
4f8957d5d2
[Documentation] Fix typo (#315)
Some checks are pending
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Waiting to run
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Waiting to run
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Waiting to run
2025-03-07 21:45:27 +13:00
Shivam7-1
63a74a92a8
Rename fuzzing_target.cc to fuzzing_target.c 2024-12-22 21:10:58 +05:30
Shivam7-1
8d3cadc52e
initial fuzzing support 2024-12-21 17:04:07 +05:30
12 changed files with 33 additions and 4 deletions

View File

@ -102,6 +102,7 @@ TextAlignment :: enum EnumBackingType {
} }
TextElementConfig :: struct { TextElementConfig :: struct {
userData: rawptr,
textColor: Color, textColor: Color,
fontId: u16, fontId: u16,
fontSize: u16, fontSize: u16,

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -489,7 +489,7 @@ errorHandler :: proc "c" (errorData: clay.ErrorData) {
} }
main :: proc() { main :: proc() {
minMemorySize: u32 = clay.MinMemorySize() minMemorySize: c.size_t = cast(c.size_t)clay.MinMemorySize()
memory := make([^]u8, minMemorySize) memory := make([^]u8, minMemorySize)
arena: clay.Arena = clay.CreateArenaWithCapacityAndMemory(minMemorySize, memory) arena: clay.Arena = clay.CreateArenaWithCapacityAndMemory(minMemorySize, memory)
clay.Initialize(arena, {cast(f32)raylib.GetScreenWidth(), cast(f32)raylib.GetScreenHeight()}, { handler = errorHandler }) clay.Initialize(arena, {cast(f32)raylib.GetScreenWidth(), cast(f32)raylib.GetScreenHeight()}, { handler = errorHandler })

8
clay.h
View File

@ -266,7 +266,7 @@ typedef CLAY_PACKED_ENUM {
CLAY_ALIGN_Y_TOP, CLAY_ALIGN_Y_TOP,
// Aligns child elements to the bottom of this element, offset by padding.width.bottom // Aligns child elements to the bottom of this element, offset by padding.width.bottom
CLAY_ALIGN_Y_BOTTOM, CLAY_ALIGN_Y_BOTTOM,
// Aligns child elements vertiically to the center of this element // Aligns child elements vertically to the center of this element
CLAY_ALIGN_Y_CENTER, CLAY_ALIGN_Y_CENTER,
} Clay_LayoutAlignmentY; } Clay_LayoutAlignmentY;
@ -357,6 +357,8 @@ typedef CLAY_PACKED_ENUM {
// Controls various functionality related to text elements. // Controls various functionality related to text elements.
typedef struct { typedef struct {
// A pointer that will be transparently passed through to the resulting render command.
void *userData;
// The RGBA color of the font to render, conventionally specified as 0-255. // The RGBA color of the font to render, conventionally specified as 0-255.
Clay_Color textColor; Clay_Color textColor;
// An integer transparently passed to Clay_MeasureText to identify the font to use. // An integer transparently passed to Clay_MeasureText to identify the font to use.
@ -1769,7 +1771,7 @@ bool Clay__MemCmp(const char *s1, const char *s2, int32_t length);
uint8x16_t v2 = vld1q_u8((const uint8_t *)s2); uint8x16_t v2 = vld1q_u8((const uint8_t *)s2);
// Compare vectors // Compare vectors
if (vminvq_u32(vceqq_u8(v1, v2)) != 0xFFFFFFFF) { // If there's a difference if (vminvq_u32(vreinterpretq_u32_u8(vceqq_u8(v1, v2))) != 0xFFFFFFFF) { // If there's a difference
return false; return false;
} }
@ -2692,7 +2694,7 @@ void Clay__CalculateFinalLayout(void) {
.letterSpacing = textElementConfig->letterSpacing, .letterSpacing = textElementConfig->letterSpacing,
.lineHeight = textElementConfig->lineHeight, .lineHeight = textElementConfig->lineHeight,
}}, }},
.userData = sharedConfig->userData, .userData = textElementConfig->userData,
.id = Clay__HashNumber(lineIndex, currentElement->id).id, .id = Clay__HashNumber(lineIndex, currentElement->id).id,
.zIndex = root->zIndex, .zIndex = root->zIndex,
.commandType = CLAY_RENDER_COMMAND_TYPE_TEXT, .commandType = CLAY_RENDER_COMMAND_TYPE_TEXT,

View File

@ -119,6 +119,7 @@
{name: 'bottomRight', type: 'float'}, {name: 'bottomRight', type: 'float'},
]}; ]};
let textConfigDefinition = { name: 'text', type: 'struct', members: [ let textConfigDefinition = { name: 'text', type: 'struct', members: [
{ name: 'userData', type: 'uint32_t' },
{ name: 'textColor', ...colorDefinition }, { name: 'textColor', ...colorDefinition },
{ name: 'fontId', type: 'uint16_t' }, { name: 'fontId', type: 'uint16_t' },
{ name: 'fontSize', type: 'uint16_t' }, { name: 'fontSize', type: 'uint16_t' },

View File

@ -119,6 +119,7 @@
{name: 'bottomRight', type: 'float'}, {name: 'bottomRight', type: 'float'},
]}; ]};
let textConfigDefinition = { name: 'text', type: 'struct', members: [ let textConfigDefinition = { name: 'text', type: 'struct', members: [
{ name: 'userData', type: 'uint32_t' },
{ name: 'textColor', ...colorDefinition }, { name: 'textColor', ...colorDefinition },
{ name: 'fontId', type: 'uint16_t' }, { name: 'fontId', type: 'uint16_t' },
{ name: 'fontSize', type: 'uint16_t' }, { name: 'fontSize', type: 'uint16_t' },

24
fuzz/fuzzing_target.c Normal file
View File

@ -0,0 +1,24 @@
#include "clay.h"
#include <stdint.h>
#include <stddef.h>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size < sizeof(Clay_String)) return 0;
Clay_String testString = { .length = size, .chars = (const char *)data };
Clay_Dimensions dimensions = MeasureText(&testString, NULL);
// Call other critical functions
Clay_Arena arena = Clay_CreateArenaWithCapacityAndMemory(1024, (void*)data);
Clay_Initialize(arena, (Clay_Dimensions){1024, 768});
Clay_SetPointerState((Clay_Vector2){0, 0}, false);
Clay_BeginLayout();
Clay_EndLayout();
// Handle pointer state changes
Clay_SetPointerState((Clay_Vector2){1, 1}, true);
Clay_SetPointerState((Clay_Vector2){2, 2}, false);
return 0;
}