mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-30 18:34:34 +01:00
ImDrawList: Prefixed internal functions with underscore, renamed UpdateClipRect() to _OnChangedClipRect(), UpdateTextureID() -> _OnChangedTextureID()
This commit is contained in:
parent
e35a813d57
commit
b1f2eacdf3
14
imgui.cpp
14
imgui.cpp
@ -2994,7 +2994,7 @@ void ImGui::GcCompactTransientWindowBuffers(ImGuiWindow* window)
|
|||||||
window->MemoryDrawListIdxCapacity = window->DrawList->IdxBuffer.Capacity;
|
window->MemoryDrawListIdxCapacity = window->DrawList->IdxBuffer.Capacity;
|
||||||
window->MemoryDrawListVtxCapacity = window->DrawList->VtxBuffer.Capacity;
|
window->MemoryDrawListVtxCapacity = window->DrawList->VtxBuffer.Capacity;
|
||||||
window->IDStack.clear();
|
window->IDStack.clear();
|
||||||
window->DrawList->ClearFreeMemory();
|
window->DrawList->_ClearFreeMemory();
|
||||||
window->DC.ChildWindows.clear();
|
window->DC.ChildWindows.clear();
|
||||||
window->DC.ItemFlagsStack.clear();
|
window->DC.ItemFlagsStack.clear();
|
||||||
window->DC.ItemWidthStack.clear();
|
window->DC.ItemWidthStack.clear();
|
||||||
@ -3777,11 +3777,11 @@ void ImGui::NewFrame()
|
|||||||
if (g.IO.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset)
|
if (g.IO.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset)
|
||||||
g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AllowVtxOffset;
|
g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AllowVtxOffset;
|
||||||
|
|
||||||
g.BackgroundDrawList.ResetForNewFrame();
|
g.BackgroundDrawList._ResetForNewFrame();
|
||||||
g.BackgroundDrawList.PushTextureID(g.IO.Fonts->TexID);
|
g.BackgroundDrawList.PushTextureID(g.IO.Fonts->TexID);
|
||||||
g.BackgroundDrawList.PushClipRectFullScreen();
|
g.BackgroundDrawList.PushClipRectFullScreen();
|
||||||
|
|
||||||
g.ForegroundDrawList.ResetForNewFrame();
|
g.ForegroundDrawList._ResetForNewFrame();
|
||||||
g.ForegroundDrawList.PushTextureID(g.IO.Fonts->TexID);
|
g.ForegroundDrawList.PushTextureID(g.IO.Fonts->TexID);
|
||||||
g.ForegroundDrawList.PushClipRectFullScreen();
|
g.ForegroundDrawList.PushClipRectFullScreen();
|
||||||
|
|
||||||
@ -4019,8 +4019,8 @@ void ImGui::Shutdown(ImGuiContext* context)
|
|||||||
g.OpenPopupStack.clear();
|
g.OpenPopupStack.clear();
|
||||||
g.BeginPopupStack.clear();
|
g.BeginPopupStack.clear();
|
||||||
g.DrawDataBuilder.ClearFreeMemory();
|
g.DrawDataBuilder.ClearFreeMemory();
|
||||||
g.BackgroundDrawList.ClearFreeMemory();
|
g.BackgroundDrawList._ClearFreeMemory();
|
||||||
g.ForegroundDrawList.ClearFreeMemory();
|
g.ForegroundDrawList._ClearFreeMemory();
|
||||||
|
|
||||||
g.TabBars.Clear();
|
g.TabBars.Clear();
|
||||||
g.CurrentTabBarStack.clear();
|
g.CurrentTabBarStack.clear();
|
||||||
@ -4079,7 +4079,7 @@ static void AddDrawListToDrawData(ImVector<ImDrawList*>* out_list, ImDrawList* d
|
|||||||
{
|
{
|
||||||
// Remove trailing command if unused.
|
// Remove trailing command if unused.
|
||||||
// Technically we could return directly instead of popping, but this make things looks neat in Metrics window as well.
|
// Technically we could return directly instead of popping, but this make things looks neat in Metrics window as well.
|
||||||
draw_list->PopUnusedDrawCmd();
|
draw_list->_PopUnusedDrawCmd();
|
||||||
if (draw_list->CmdBuffer.Size == 0)
|
if (draw_list->CmdBuffer.Size == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -5859,7 +5859,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
// DRAWING
|
// DRAWING
|
||||||
|
|
||||||
// Setup draw list and outer clipping rectangle
|
// Setup draw list and outer clipping rectangle
|
||||||
window->DrawList->ResetForNewFrame();
|
window->DrawList->_ResetForNewFrame();
|
||||||
window->DrawList->PushTextureID(g.Font->ContainerAtlas->TexID);
|
window->DrawList->PushTextureID(g.Font->ContainerAtlas->TexID);
|
||||||
PushClipRect(host_rect.Min, host_rect.Max, false);
|
PushClipRect(host_rect.Min, host_rect.Max, false);
|
||||||
|
|
||||||
|
12
imgui.h
12
imgui.h
@ -1991,7 +1991,7 @@ struct ImDrawList
|
|||||||
// If you want to create ImDrawList instances, pass them ImGui::GetDrawListSharedData() or create and use your own ImDrawListSharedData (so you can use ImDrawList without ImGui)
|
// If you want to create ImDrawList instances, pass them ImGui::GetDrawListSharedData() or create and use your own ImDrawListSharedData (so you can use ImDrawList without ImGui)
|
||||||
ImDrawList(const ImDrawListSharedData* shared_data) { _Data = shared_data; Flags = ImDrawListFlags_None; _VtxCurrentIdx = 0; _VtxWritePtr = NULL; _IdxWritePtr = NULL; _OwnerName = NULL; }
|
ImDrawList(const ImDrawListSharedData* shared_data) { _Data = shared_data; Flags = ImDrawListFlags_None; _VtxCurrentIdx = 0; _VtxWritePtr = NULL; _IdxWritePtr = NULL; _OwnerName = NULL; }
|
||||||
|
|
||||||
~ImDrawList() { ClearFreeMemory(); }
|
~ImDrawList() { _ClearFreeMemory(); }
|
||||||
IMGUI_API void PushClipRect(ImVec2 clip_rect_min, ImVec2 clip_rect_max, bool intersect_with_current_clip_rect = false); // Render-level scissoring. This is passed down to your render function but not used for CPU-side coarse clipping. Prefer using higher-level ImGui::PushClipRect() to affect logic (hit-testing and widget culling)
|
IMGUI_API void PushClipRect(ImVec2 clip_rect_min, ImVec2 clip_rect_max, bool intersect_with_current_clip_rect = false); // Render-level scissoring. This is passed down to your render function but not used for CPU-side coarse clipping. Prefer using higher-level ImGui::PushClipRect() to affect logic (hit-testing and widget culling)
|
||||||
IMGUI_API void PushClipRectFullScreen();
|
IMGUI_API void PushClipRectFullScreen();
|
||||||
IMGUI_API void PopClipRect();
|
IMGUI_API void PopClipRect();
|
||||||
@ -2070,11 +2070,11 @@ struct ImDrawList
|
|||||||
inline void PrimVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col) { PrimWriteIdx((ImDrawIdx)_VtxCurrentIdx); PrimWriteVtx(pos, uv, col); } // Write vertex with unique index
|
inline void PrimVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col) { PrimWriteIdx((ImDrawIdx)_VtxCurrentIdx); PrimWriteVtx(pos, uv, col); } // Write vertex with unique index
|
||||||
|
|
||||||
// [Internal helpers]
|
// [Internal helpers]
|
||||||
IMGUI_API void ResetForNewFrame();
|
IMGUI_API void _ResetForNewFrame();
|
||||||
IMGUI_API void ClearFreeMemory();
|
IMGUI_API void _ClearFreeMemory();
|
||||||
IMGUI_API void PopUnusedDrawCmd();
|
IMGUI_API void _PopUnusedDrawCmd();
|
||||||
IMGUI_API void UpdateClipRect();
|
IMGUI_API void _OnChangedClipRect();
|
||||||
IMGUI_API void UpdateTextureID();
|
IMGUI_API void _OnChangedTextureID();
|
||||||
};
|
};
|
||||||
|
|
||||||
// All draw data to render a Dear ImGui frame
|
// All draw data to render a Dear ImGui frame
|
||||||
|
@ -377,7 +377,7 @@ void ImDrawListSharedData::SetCircleSegmentMaxError(float max_error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialize before use in a new frame. We always have a command ready in the buffer.
|
// Initialize before use in a new frame. We always have a command ready in the buffer.
|
||||||
void ImDrawList::ResetForNewFrame()
|
void ImDrawList::_ResetForNewFrame()
|
||||||
{
|
{
|
||||||
// Verify that the ImDrawCmd fields we want to memcmp() are contiguous in memory.
|
// Verify that the ImDrawCmd fields we want to memcmp() are contiguous in memory.
|
||||||
// (those should be IM_STATIC_ASSERT() in theory but with our pre C++11 setup the whole check doesn't compile with GCC)
|
// (those should be IM_STATIC_ASSERT() in theory but with our pre C++11 setup the whole check doesn't compile with GCC)
|
||||||
@ -400,7 +400,7 @@ void ImDrawList::ResetForNewFrame()
|
|||||||
CmdBuffer.push_back(ImDrawCmd());
|
CmdBuffer.push_back(ImDrawCmd());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::ClearFreeMemory()
|
void ImDrawList::_ClearFreeMemory()
|
||||||
{
|
{
|
||||||
CmdBuffer.clear();
|
CmdBuffer.clear();
|
||||||
IdxBuffer.clear();
|
IdxBuffer.clear();
|
||||||
@ -439,7 +439,7 @@ void ImDrawList::AddDrawCmd()
|
|||||||
|
|
||||||
// Pop trailing draw command (used before merging or presenting to user)
|
// Pop trailing draw command (used before merging or presenting to user)
|
||||||
// Note that this leaves the ImDrawList in a state unfit for further commands, as most code assume that CmdBuffer.Size > 0 && CmdBuffer.back().UserCallback == NULL
|
// Note that this leaves the ImDrawList in a state unfit for further commands, as most code assume that CmdBuffer.Size > 0 && CmdBuffer.back().UserCallback == NULL
|
||||||
void ImDrawList::PopUnusedDrawCmd()
|
void ImDrawList::_PopUnusedDrawCmd()
|
||||||
{
|
{
|
||||||
if (CmdBuffer.Size == 0)
|
if (CmdBuffer.Size == 0)
|
||||||
return;
|
return;
|
||||||
@ -469,7 +469,7 @@ void ImDrawList::AddCallback(ImDrawCallback callback, void* callback_data)
|
|||||||
|
|
||||||
// Our scheme may appears a bit unusual, basically we want the most-common calls AddLine AddRect etc. to not have to perform any check so we always have a command ready in the stack.
|
// Our scheme may appears a bit unusual, basically we want the most-common calls AddLine AddRect etc. to not have to perform any check so we always have a command ready in the stack.
|
||||||
// The cost of figuring out if a new command has to be added or if we can merge is paid in those Update** functions only.
|
// The cost of figuring out if a new command has to be added or if we can merge is paid in those Update** functions only.
|
||||||
void ImDrawList::UpdateClipRect()
|
void ImDrawList::_OnChangedClipRect()
|
||||||
{
|
{
|
||||||
// If current command is used with different settings we need to add a new command
|
// If current command is used with different settings we need to add a new command
|
||||||
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
||||||
@ -490,7 +490,7 @@ void ImDrawList::UpdateClipRect()
|
|||||||
curr_cmd->ClipRect = _CmdHeader.ClipRect;
|
curr_cmd->ClipRect = _CmdHeader.ClipRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::UpdateTextureID()
|
void ImDrawList::_OnChangedTextureID()
|
||||||
{
|
{
|
||||||
// If current command is used with different settings we need to add a new command
|
// If current command is used with different settings we need to add a new command
|
||||||
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
||||||
@ -528,7 +528,7 @@ void ImDrawList::PushClipRect(ImVec2 cr_min, ImVec2 cr_max, bool intersect_with_
|
|||||||
|
|
||||||
_ClipRectStack.push_back(cr);
|
_ClipRectStack.push_back(cr);
|
||||||
_CmdHeader.ClipRect = cr;
|
_CmdHeader.ClipRect = cr;
|
||||||
UpdateClipRect();
|
_OnChangedClipRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::PushClipRectFullScreen()
|
void ImDrawList::PushClipRectFullScreen()
|
||||||
@ -540,21 +540,21 @@ void ImDrawList::PopClipRect()
|
|||||||
{
|
{
|
||||||
_ClipRectStack.pop_back();
|
_ClipRectStack.pop_back();
|
||||||
_CmdHeader.ClipRect = (_ClipRectStack.Size == 0) ? _Data->ClipRectFullscreen : _ClipRectStack.Data[_ClipRectStack.Size - 1];
|
_CmdHeader.ClipRect = (_ClipRectStack.Size == 0) ? _Data->ClipRectFullscreen : _ClipRectStack.Data[_ClipRectStack.Size - 1];
|
||||||
UpdateClipRect();
|
_OnChangedClipRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::PushTextureID(ImTextureID texture_id)
|
void ImDrawList::PushTextureID(ImTextureID texture_id)
|
||||||
{
|
{
|
||||||
_TextureIdStack.push_back(texture_id);
|
_TextureIdStack.push_back(texture_id);
|
||||||
_CmdHeader.TextureId = texture_id;
|
_CmdHeader.TextureId = texture_id;
|
||||||
UpdateTextureID();
|
_OnChangedTextureID();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::PopTextureID()
|
void ImDrawList::PopTextureID()
|
||||||
{
|
{
|
||||||
_TextureIdStack.pop_back();
|
_TextureIdStack.pop_back();
|
||||||
_CmdHeader.TextureId = (_TextureIdStack.Size == 0) ? (ImTextureID)NULL : _TextureIdStack.Data[_TextureIdStack.Size - 1];
|
_CmdHeader.TextureId = (_TextureIdStack.Size == 0) ? (ImTextureID)NULL : _TextureIdStack.Data[_TextureIdStack.Size - 1];
|
||||||
UpdateTextureID();
|
_OnChangedTextureID();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reserve space for a number of vertices and indices.
|
// Reserve space for a number of vertices and indices.
|
||||||
@ -1378,7 +1378,7 @@ void ImDrawListSplitter::Merge(ImDrawList* draw_list)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
SetCurrentChannel(draw_list, 0);
|
SetCurrentChannel(draw_list, 0);
|
||||||
draw_list->PopUnusedDrawCmd();
|
draw_list->_PopUnusedDrawCmd();
|
||||||
|
|
||||||
// Calculate our final buffer sizes. Also fix the incorrect IdxOffset values in each command.
|
// Calculate our final buffer sizes. Also fix the incorrect IdxOffset values in each command.
|
||||||
int new_cmd_buffer_count = 0;
|
int new_cmd_buffer_count = 0;
|
||||||
@ -1427,8 +1427,8 @@ void ImDrawListSplitter::Merge(ImDrawList* draw_list)
|
|||||||
if (int sz = ch._IdxBuffer.Size) { memcpy(idx_write, ch._IdxBuffer.Data, sz * sizeof(ImDrawIdx)); idx_write += sz; }
|
if (int sz = ch._IdxBuffer.Size) { memcpy(idx_write, ch._IdxBuffer.Data, sz * sizeof(ImDrawIdx)); idx_write += sz; }
|
||||||
}
|
}
|
||||||
draw_list->_IdxWritePtr = idx_write;
|
draw_list->_IdxWritePtr = idx_write;
|
||||||
draw_list->UpdateClipRect(); // We call this instead of AddDrawCmd(), so that empty channels won't produce an extra draw call.
|
draw_list->_OnChangedClipRect(); // We call this instead of AddDrawCmd(), so that empty channels won't produce an extra draw call.
|
||||||
draw_list->UpdateTextureID();
|
draw_list->_OnChangedTextureID();
|
||||||
_Count = 1;
|
_Count = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user