mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-21 23:26:36 +00:00
ImDrawList: AddImageRounded() compare texid from cmdheader as with other functions. + Made the ImGuiMemAllocFunc / ImGuiMemFreeFunc consistent with our other typedefs (#3836)
This commit is contained in:
parent
8dd692c29c
commit
3e6dfd3c1a
13
imgui.cpp
13
imgui.cpp
@ -946,8 +946,8 @@ static void FreeWrapper(void* ptr, void* user_data) { IM_UNUSED(user_d
|
||||
static void* MallocWrapper(size_t size, void* user_data) { IM_UNUSED(user_data); IM_UNUSED(size); IM_ASSERT(0); return NULL; }
|
||||
static void FreeWrapper(void* ptr, void* user_data) { IM_UNUSED(user_data); IM_UNUSED(ptr); IM_ASSERT(0); }
|
||||
#endif
|
||||
static ImGuiMemAllocFunc* GImAllocatorAllocFunc = MallocWrapper;
|
||||
static ImGuiMemFreeFunc* GImAllocatorFreeFunc = FreeWrapper;
|
||||
static ImGuiMemAllocFunc GImAllocatorAllocFunc = MallocWrapper;
|
||||
static ImGuiMemFreeFunc GImAllocatorFreeFunc = FreeWrapper;
|
||||
static void* GImAllocatorUserData = NULL;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -3290,7 +3290,7 @@ void* ImGui::MemAlloc(size_t size)
|
||||
{
|
||||
if (ImGuiContext* ctx = GImGui)
|
||||
ctx->IO.MetricsActiveAllocations++;
|
||||
return GImAllocatorAllocFunc(size, GImAllocatorUserData);
|
||||
return (*GImAllocatorAllocFunc)(size, GImAllocatorUserData);
|
||||
}
|
||||
|
||||
// IM_FREE() == ImGui::MemFree()
|
||||
@ -3299,7 +3299,7 @@ void ImGui::MemFree(void* ptr)
|
||||
if (ptr)
|
||||
if (ImGuiContext* ctx = GImGui)
|
||||
ctx->IO.MetricsActiveAllocations--;
|
||||
return GImAllocatorFreeFunc(ptr, GImAllocatorUserData);
|
||||
return (*GImAllocatorFreeFunc)(ptr, GImAllocatorUserData);
|
||||
}
|
||||
|
||||
const char* ImGui::GetClipboardText()
|
||||
@ -3336,7 +3336,7 @@ void ImGui::SetCurrentContext(ImGuiContext* ctx)
|
||||
#endif
|
||||
}
|
||||
|
||||
void ImGui::SetAllocatorFunctions(ImGuiMemAllocFunc* alloc_func, ImGuiMemFreeFunc* free_func, void* user_data)
|
||||
void ImGui::SetAllocatorFunctions(ImGuiMemAllocFunc alloc_func, ImGuiMemFreeFunc free_func, void* user_data)
|
||||
{
|
||||
GImAllocatorAllocFunc = alloc_func;
|
||||
GImAllocatorFreeFunc = free_func;
|
||||
@ -3344,7 +3344,7 @@ void ImGui::SetAllocatorFunctions(ImGuiMemAllocFunc* alloc_func, ImGuiMemFreeFun
|
||||
}
|
||||
|
||||
// This is provided to facilitate copying allocators from one static/DLL boundary to another (e.g. retrieve default allocator of your executable address space)
|
||||
void ImGui::GetAllocatorFunctions(ImGuiMemAllocFunc** p_alloc_func, ImGuiMemFreeFunc** p_free_func, void** p_user_data)
|
||||
void ImGui::GetAllocatorFunctions(ImGuiMemAllocFunc* p_alloc_func, ImGuiMemFreeFunc* p_free_func, void** p_user_data)
|
||||
{
|
||||
*p_alloc_func = GImAllocatorAllocFunc;
|
||||
*p_free_func = GImAllocatorFreeFunc;
|
||||
@ -6432,6 +6432,7 @@ void ImGui::FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWind
|
||||
FocusWindow(NULL);
|
||||
}
|
||||
|
||||
// Important: this alone doesn't alter current ImDrawList state. This is called by PushFont/PopFont only.
|
||||
void ImGui::SetCurrentFont(ImFont* font)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
8
imgui.h
8
imgui.h
@ -194,8 +194,8 @@ typedef void* ImTextureID; // User data for rendering backend to identi
|
||||
typedef unsigned int ImGuiID; // A unique ID used by widgets, typically hashed from a stack of string.
|
||||
typedef int (*ImGuiInputTextCallback)(ImGuiInputTextCallbackData* data); // Callback function for ImGui::InputText()
|
||||
typedef void (*ImGuiSizeCallback)(ImGuiSizeCallbackData* data); // Callback function for ImGui::SetNextWindowSizeConstraints()
|
||||
typedef void* (ImGuiMemAllocFunc)(size_t sz, void* user_data); // Function signature for ImGui::SetAllocatorFunctions()
|
||||
typedef void (ImGuiMemFreeFunc)(void* ptr, void* user_data); // Function signature for ImGui::SetAllocatorFunctions()
|
||||
typedef void* (*ImGuiMemAllocFunc)(size_t sz, void* user_data); // Function signature for ImGui::SetAllocatorFunctions()
|
||||
typedef void (*ImGuiMemFreeFunc)(void* ptr, void* user_data); // Function signature for ImGui::SetAllocatorFunctions()
|
||||
|
||||
// Character types
|
||||
// (we generally use UTF-8 encoded string in the API. This is storage specifically for a decoded character used for keyboard input and display)
|
||||
@ -875,8 +875,8 @@ namespace ImGui
|
||||
// - Those functions are not reliant on the current context.
|
||||
// - DLL users: heaps and globals are not shared across DLL boundaries! You will need to call SetCurrentContext() + SetAllocatorFunctions()
|
||||
// for each static/DLL boundary you are calling from. Read "Context and Memory Allocators" section of imgui.cpp for more details.
|
||||
IMGUI_API void SetAllocatorFunctions(ImGuiMemAllocFunc* alloc_func, ImGuiMemFreeFunc* free_func, void* user_data = NULL);
|
||||
IMGUI_API void GetAllocatorFunctions(ImGuiMemAllocFunc** p_alloc_func, ImGuiMemFreeFunc** p_free_func, void** p_user_data);
|
||||
IMGUI_API void SetAllocatorFunctions(ImGuiMemAllocFunc alloc_func, ImGuiMemFreeFunc free_func, void* user_data = NULL);
|
||||
IMGUI_API void GetAllocatorFunctions(ImGuiMemAllocFunc* p_alloc_func, ImGuiMemFreeFunc* p_free_func, void** p_user_data);
|
||||
IMGUI_API void* MemAlloc(size_t size);
|
||||
IMGUI_API void MemFree(void* ptr);
|
||||
|
||||
|
@ -1461,7 +1461,7 @@ void ImDrawList::AddImageRounded(ImTextureID user_texture_id, const ImVec2& p_mi
|
||||
return;
|
||||
}
|
||||
|
||||
const bool push_texture_id = _TextureIdStack.empty() || user_texture_id != _TextureIdStack.back();
|
||||
const bool push_texture_id = user_texture_id != _CmdHeader.TextureId;
|
||||
if (push_texture_id)
|
||||
PushTextureID(user_texture_id);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user