mirror of
https://github.com/nicbarker/clay.git
synced 2026-02-06 12:48:49 +00:00
Add a function to reset text measurement cache (#181)
This commit is contained in:
parent
3a4455aa83
commit
afba9f0de6
2 changed files with 31 additions and 0 deletions
16
clay.h
16
clay.h
|
|
@ -525,6 +525,7 @@ int32_t Clay_GetMaxElementCount(void);
|
|||
void Clay_SetMaxElementCount(int32_t maxElementCount);
|
||||
int32_t Clay_GetMaxMeasureTextCacheWordCount(void);
|
||||
void Clay_SetMaxMeasureTextCacheWordCount(int32_t maxMeasureTextCacheWordCount);
|
||||
void Clay_ResetMeasureTextCache(void);
|
||||
|
||||
// Internal API functions required by macros
|
||||
void Clay__OpenElement(void);
|
||||
|
|
@ -4051,6 +4052,21 @@ void Clay_SetMaxMeasureTextCacheWordCount(int32_t maxMeasureTextCacheWordCount)
|
|||
}
|
||||
}
|
||||
|
||||
CLAY_WASM_EXPORT("Clay_ResetMeasureTextCache")
|
||||
void Clay_ResetMeasureTextCache(void) {
|
||||
Clay_Context* context = Clay_GetCurrentContext();
|
||||
context->measureTextHashMapInternal.length = 0;
|
||||
context->measureTextHashMapInternalFreeList.length = 0;
|
||||
context->measureTextHashMap.length = 0;
|
||||
context->measuredWords.length = 0;
|
||||
context->measuredWordsFreeList.length = 0;
|
||||
|
||||
for (int32_t i = 0; i < context->measureTextHashMap.capacity; ++i) {
|
||||
context->measureTextHashMap.internalArray[i] = 0;
|
||||
}
|
||||
context->measureTextHashMapInternal.length = 1; // Reserve the 0 value to mean "no next element"
|
||||
}
|
||||
|
||||
#endif // CLAY_IMPLEMENTATION
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue