Compare commits

...

5 Commits

Author SHA1 Message Date
tomatih
27a6c737da
Merge 1c636096e5 into b33ba4ff62 2025-04-16 23:19:03 +02:00
Nic Barker
b33ba4ff62
[Core] Fix a string hash bug with single characters (#384)
Some checks failed
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Has been cancelled
2025-04-16 20:16:05 +12:00
Jackson Novak
f88f0517f7
[Documentation] Fix Clay_String definition in README.md file. (#374) 2025-04-16 20:07:16 +12:00
to_matih
1c636096e5
Fix SDL_Rect argument casting 2025-03-14 18:29:50 +00:00
to_matih
e5bd453f5e
Fix SDL_FRect argument casting 2025-03-14 16:06:33 +00:00
4 changed files with 22 additions and 12 deletions

View File

@ -1787,7 +1787,8 @@ Note: when using the debug tools, their internal colors are represented as 0-255
```C ```C
typedef struct { typedef struct {
int length; bool isStaticallyAllocated;
int32_t length;
const char *chars; const char *chars;
} Clay_String; } Clay_String;
``` ```
@ -1796,7 +1797,14 @@ typedef struct {
**Fields** **Fields**
**`.length`** - `int` **`.isStaticallyAllocated`** - `bool`
Whether or not the string is statically allocated, or in other words, whether
or not it lives for the entire lifetime of the program.
---
**`.length`** - `int32_t`
The number of characters in the string, _not including an optional null terminator._ The number of characters in the string, _not including an optional null terminator._

2
clay.h
View File

@ -1392,6 +1392,7 @@ uint64_t Clay__HashData(const uint8_t* data, size_t length) {
Clay__SIMDARXMix(&v2, &v3); Clay__SIMDARXMix(&v2, &v3);
v0 = _mm_add_epi64(v0, v2); v0 = _mm_add_epi64(v0, v2);
v1 = _mm_add_epi64(v1, v3); v1 = _mm_add_epi64(v1, v3);
v0 = _mm_add_epi64(v0, v1);
uint64_t result[2]; uint64_t result[2];
_mm_storeu_si128((__m128i*)result, v0); _mm_storeu_si128((__m128i*)result, v0);
@ -1445,6 +1446,7 @@ uint64_t Clay__HashData(const uint8_t* data, size_t length) {
Clay__SIMDARXMix(&v2, &v3); Clay__SIMDARXMix(&v2, &v3);
v0 = vaddq_u64(v0, v2); v0 = vaddq_u64(v0, v2);
v1 = vaddq_u64(v1, v3); v1 = vaddq_u64(v1, v3);
v0 = vaddq_u64(v0, v1);
uint64_t result[2]; uint64_t result[2];
vst1q_u64(result, v0); vst1q_u64(result, v0);

View File

@ -22,7 +22,7 @@ FetchContent_MakeAvailable(fontstash)
FetchContent_Declare( FetchContent_Declare(
sokol sokol
GIT_REPOSITORY "https://github.com/floooh/sokol.git" GIT_REPOSITORY "https://github.com/floooh/sokol.git"
GIT_TAG "da9de496f938b7575eff7f01ab774d77469bd390" GIT_TAG "master"
GIT_PROGRESS TRUE GIT_PROGRESS TRUE
GIT_SHALLOW TRUE GIT_SHALLOW TRUE
) )

View File

@ -148,7 +148,7 @@ static void SDL_Clay_RenderClayCommands(Clay_SDL3RendererData *rendererData, Cla
for (size_t i = 0; i < rcommands->length; i++) { for (size_t i = 0; i < rcommands->length; i++) {
Clay_RenderCommand *rcmd = Clay_RenderCommandArray_Get(rcommands, i); Clay_RenderCommand *rcmd = Clay_RenderCommandArray_Get(rcommands, i);
const Clay_BoundingBox bounding_box = rcmd->boundingBox; const Clay_BoundingBox bounding_box = rcmd->boundingBox;
const SDL_FRect rect = { (int)bounding_box.x, (int)bounding_box.y, (int)bounding_box.width, (int)bounding_box.height }; const SDL_FRect rect = { (float)bounding_box.x, (float)bounding_box.y, (float)bounding_box.width, (float)bounding_box.height };
switch (rcmd->commandType) { switch (rcmd->commandType) {
case CLAY_RENDER_COMMAND_TYPE_RECTANGLE: { case CLAY_RENDER_COMMAND_TYPE_RECTANGLE: {
@ -184,27 +184,27 @@ static void SDL_Clay_RenderClayCommands(Clay_SDL3RendererData *rendererData, Cla
if (config->width.left > 0) { if (config->width.left > 0) {
const float starting_y = rect.y + clampedRadii.topLeft; const float starting_y = rect.y + clampedRadii.topLeft;
const float length = rect.h - clampedRadii.topLeft - clampedRadii.bottomLeft; const float length = rect.h - clampedRadii.topLeft - clampedRadii.bottomLeft;
SDL_FRect line = { rect.x, starting_y, config->width.left, length }; SDL_FRect line = { rect.x, starting_y, (float)config->width.left, length };
SDL_RenderFillRect(rendererData->renderer, &line); SDL_RenderFillRect(rendererData->renderer, &line);
} }
if (config->width.right > 0) { if (config->width.right > 0) {
const float starting_x = rect.x + rect.w - (float)config->width.right; const float starting_x = rect.x + rect.w - (float)config->width.right;
const float starting_y = rect.y + clampedRadii.topRight; const float starting_y = rect.y + clampedRadii.topRight;
const float length = rect.h - clampedRadii.topRight - clampedRadii.bottomRight; const float length = rect.h - clampedRadii.topRight - clampedRadii.bottomRight;
SDL_FRect line = { starting_x, starting_y, config->width.right, length }; SDL_FRect line = { starting_x, starting_y, (float)config->width.right, length };
SDL_RenderFillRect(rendererData->renderer, &line); SDL_RenderFillRect(rendererData->renderer, &line);
} }
if (config->width.top > 0) { if (config->width.top > 0) {
const float starting_x = rect.x + clampedRadii.topLeft; const float starting_x = rect.x + clampedRadii.topLeft;
const float length = rect.w - clampedRadii.topLeft - clampedRadii.topRight; const float length = rect.w - clampedRadii.topLeft - clampedRadii.topRight;
SDL_FRect line = { starting_x, rect.y, length, config->width.top }; SDL_FRect line = { starting_x, rect.y, length, (float)config->width.top };
SDL_RenderFillRect(rendererData->renderer, &line); SDL_RenderFillRect(rendererData->renderer, &line);
} }
if (config->width.bottom > 0) { if (config->width.bottom > 0) {
const float starting_x = rect.x + clampedRadii.bottomLeft; const float starting_x = rect.x + clampedRadii.bottomLeft;
const float starting_y = rect.y + rect.h - (float)config->width.bottom; const float starting_y = rect.y + rect.h - (float)config->width.bottom;
const float length = rect.w - clampedRadii.bottomLeft - clampedRadii.bottomRight; const float length = rect.w - clampedRadii.bottomLeft - clampedRadii.bottomRight;
SDL_FRect line = { starting_x, starting_y, length, config->width.bottom }; SDL_FRect line = { starting_x, starting_y, length, (float)config->width.bottom };
SDL_SetRenderDrawColor(rendererData->renderer, config->color.r, config->color.g, config->color.b, config->color.a); SDL_SetRenderDrawColor(rendererData->renderer, config->color.r, config->color.g, config->color.b, config->color.a);
SDL_RenderFillRect(rendererData->renderer, &line); SDL_RenderFillRect(rendererData->renderer, &line);
} }
@ -238,10 +238,10 @@ static void SDL_Clay_RenderClayCommands(Clay_SDL3RendererData *rendererData, Cla
case CLAY_RENDER_COMMAND_TYPE_SCISSOR_START: { case CLAY_RENDER_COMMAND_TYPE_SCISSOR_START: {
Clay_BoundingBox boundingBox = rcmd->boundingBox; Clay_BoundingBox boundingBox = rcmd->boundingBox;
currentClippingRectangle = (SDL_Rect) { currentClippingRectangle = (SDL_Rect) {
.x = boundingBox.x, .x = (int)boundingBox.x,
.y = boundingBox.y, .y = (int)boundingBox.y,
.w = boundingBox.width, .w = (int)boundingBox.width,
.h = boundingBox.height, .h = (int)boundingBox.height,
}; };
SDL_SetRenderClipRect(rendererData->renderer, &currentClippingRectangle); SDL_SetRenderClipRect(rendererData->renderer, &currentClippingRectangle);
break; break;