Library: @native on small, frequently called helpers (style color stack, tree push/pop, indent, item size, draw list clip/cmd, glyph lookup, table column helpers)
Picked from a per-function call census of the whole demo opened (hundreds of calls/frame each); +~100 KB of native code. Whole demo open (headless --roblox) 10.35 -> 9.84 ms/frame together with the previous commits; draw data unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
1b7a5ebc93
commit
67af9aa19e
5 files changed
+31
No files matched your search
@@ -6783,6 +6783,7 @@ function ImGui.SameLine(offset_from_start_x, spacing_w)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- @param indent_w? float
|
--- @param indent_w? float
|
||||||
|
@native
|
||||||
function ImGui.Indent(indent_w)
|
function ImGui.Indent(indent_w)
|
||||||
if indent_w == nil then indent_w = 0.0 end
|
if indent_w == nil then indent_w = 0.0 end
|
||||||
|
|
||||||
@@ -6799,6 +6800,7 @@ function ImGui.Indent(indent_w)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- @param indent_w? float
|
--- @param indent_w? float
|
||||||
|
@native
|
||||||
function ImGui.Unindent(indent_w)
|
function ImGui.Unindent(indent_w)
|
||||||
if indent_w == nil then indent_w = 0.0 end
|
if indent_w == nil then indent_w = 0.0 end
|
||||||
|
|
||||||
@@ -6835,6 +6837,7 @@ function ImGui.PushItemWidth(item_width)
|
|||||||
g.NextItemData.HasFlags = bit32.band(g.NextItemData.HasFlags, bit32.bnot(ImGuiNextItemDataFlags.HasWidth))
|
g.NextItemData.HasFlags = bit32.band(g.NextItemData.HasFlags, bit32.bnot(ImGuiNextItemDataFlags.HasWidth))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@native
|
||||||
function ImGui.PopItemWidth()
|
function ImGui.PopItemWidth()
|
||||||
local g = GImGui
|
local g = GImGui
|
||||||
local window = g.CurrentWindow
|
local window = g.CurrentWindow
|
||||||
@@ -7133,12 +7136,14 @@ end
|
|||||||
--- @param default_w float
|
--- @param default_w float
|
||||||
--- @param default_h float
|
--- @param default_h float
|
||||||
--- @return ImVec2
|
--- @return ImVec2
|
||||||
|
@native
|
||||||
function ImGui.CalcItemSize(size, default_w, default_h)
|
function ImGui.CalcItemSize(size, default_w, default_h)
|
||||||
return ImVec2(ImGui._CalcItemSizeXY(size.x, size.y, default_w, default_h)) -- [Luau] 'size' is by value upstream: never written to
|
return ImVec2(ImGui._CalcItemSizeXY(size.x, size.y, default_w, default_h)) -- [Luau] 'size' is by value upstream: never written to
|
||||||
end
|
end
|
||||||
|
|
||||||
-- [Luau] scalar CalcItemSize(): callers that build 'size' themselves skip both ImVec2 allocations
|
-- [Luau] scalar CalcItemSize(): callers that build 'size' themselves skip both ImVec2 allocations
|
||||||
--- @return float, float
|
--- @return float, float
|
||||||
|
@native
|
||||||
function ImGui._CalcItemSizeXY(size_x, size_y, default_w, default_h)
|
function ImGui._CalcItemSizeXY(size_x, size_y, default_w, default_h)
|
||||||
local avail_x, avail_y
|
local avail_x, avail_y
|
||||||
if size_x < 0.0 or size_y < 0.0 then
|
if size_x < 0.0 or size_y < 0.0 then
|
||||||
@@ -7716,6 +7721,7 @@ end
|
|||||||
|
|
||||||
-- Push a given id value ignoring the ID stack as a seed.
|
-- Push a given id value ignoring the ID stack as a seed.
|
||||||
--- @param id ImGuiID
|
--- @param id ImGuiID
|
||||||
|
@native
|
||||||
function ImGui.PushOverrideID(id)
|
function ImGui.PushOverrideID(id)
|
||||||
local g = GImGui
|
local g = GImGui
|
||||||
local window = g.CurrentWindow
|
local window = g.CurrentWindow
|
||||||
@@ -8684,6 +8690,7 @@ end
|
|||||||
--- @param ctx? ImGuiContext
|
--- @param ctx? ImGuiContext
|
||||||
--- @param key ImGuiKey
|
--- @param key ImGuiKey
|
||||||
--- @return ImGuiKeyData, int
|
--- @return ImGuiKeyData, int
|
||||||
|
@native
|
||||||
function ImGui.GetKeyData(ctx, key)
|
function ImGui.GetKeyData(ctx, key)
|
||||||
if ctx == nil then ctx = GImGui end
|
if ctx == nil then ctx = GImGui end
|
||||||
|
|
||||||
@@ -8751,6 +8758,7 @@ end
|
|||||||
-- Consider transitioning from 'IsKeyDown(MY_ENGINE_KEY_A)' (<1.87) to IsKeyDown(ImGuiKey.A) (>= 1.87)
|
-- Consider transitioning from 'IsKeyDown(MY_ENGINE_KEY_A)' (<1.87) to IsKeyDown(ImGuiKey.A) (>= 1.87)
|
||||||
--- @param key ImGuiKey
|
--- @param key ImGuiKey
|
||||||
--- @param owner_id? ImGuiID
|
--- @param owner_id? ImGuiID
|
||||||
|
@native
|
||||||
function ImGui.IsKeyDown(key, owner_id)
|
function ImGui.IsKeyDown(key, owner_id)
|
||||||
if owner_id == nil then owner_id = ImGuiKeyOwner_Any end
|
if owner_id == nil then owner_id = ImGuiKeyOwner_Any end
|
||||||
|
|
||||||
@@ -13993,6 +14001,7 @@ function ImGui.GetScale()
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- @return ImGuiWindow
|
--- @return ImGuiWindow
|
||||||
|
@native
|
||||||
function ImGui.GetCurrentWindowRead()
|
function ImGui.GetCurrentWindowRead()
|
||||||
local g = GImGui
|
local g = GImGui
|
||||||
return g.CurrentWindow
|
return g.CurrentWindow
|
||||||
@@ -15105,6 +15114,7 @@ end
|
|||||||
-- FIXME: This may incur a round-trip (if the end user got their data from a float4) but eventually we aim to store the in-flight colors as ImU32
|
-- FIXME: This may incur a round-trip (if the end user got their data from a float4) but eventually we aim to store the in-flight colors as ImU32
|
||||||
--- @param idx ImGuiCol
|
--- @param idx ImGuiCol
|
||||||
--- @param col ImU32|ImVec4
|
--- @param col ImU32|ImVec4
|
||||||
|
@native
|
||||||
function ImGui.PushStyleColor(idx, col)
|
function ImGui.PushStyleColor(idx, col)
|
||||||
local g = GImGui
|
local g = GImGui
|
||||||
local backup = ImGuiColorMod(idx, g.Style.Colors[idx])
|
local backup = ImGuiColorMod(idx, g.Style.Colors[idx])
|
||||||
@@ -15122,6 +15132,7 @@ function ImGui.PushStyleColor(idx, col)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- @param count? int
|
--- @param count? int
|
||||||
|
@native
|
||||||
function ImGui.PopStyleColor(count)
|
function ImGui.PopStyleColor(count)
|
||||||
if count == nil then count = 1 end
|
if count == nil then count = 1 end
|
||||||
|
|
||||||
|
|||||||
@@ -2834,6 +2834,7 @@ end
|
|||||||
-- Find glyph, load if necessary, return fallback if missing
|
-- Find glyph, load if necessary, return fallback if missing
|
||||||
--- @param c ImWchar
|
--- @param c ImWchar
|
||||||
--- @return ImFontGlyph?
|
--- @return ImFontGlyph?
|
||||||
|
@native
|
||||||
function MT.ImFontBaked:FindGlyph(c)
|
function MT.ImFontBaked:FindGlyph(c)
|
||||||
if c < self.IndexLookup.Size then
|
if c < self.IndexLookup.Size then
|
||||||
local i = self.IndexLookup.Data[c + 1]
|
local i = self.IndexLookup.Data[c + 1]
|
||||||
@@ -4377,6 +4378,7 @@ function MT.ImDrawList:CloneOutput()
|
|||||||
return dst
|
return dst
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@native
|
||||||
function MT.ImDrawList:AddDrawCmd()
|
function MT.ImDrawList:AddDrawCmd()
|
||||||
local draw_cmd = ImDrawCmd()
|
local draw_cmd = ImDrawCmd()
|
||||||
|
|
||||||
@@ -4507,6 +4509,7 @@ end
|
|||||||
|
|
||||||
-- 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.
|
||||||
|
@native
|
||||||
function MT.ImDrawList:_OnChangedClipRect()
|
function MT.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
|
||||||
IM_ASSERT_PARANOID(self.CmdBuffer.Size > 0)
|
IM_ASSERT_PARANOID(self.CmdBuffer.Size > 0)
|
||||||
@@ -4866,6 +4869,7 @@ end
|
|||||||
MT.ImDrawList.PrimReserve = PrimReserve
|
MT.ImDrawList.PrimReserve = PrimReserve
|
||||||
|
|
||||||
-- Release the number of reserved vertices/indices from the end of the last reservation made with PrimReserve().
|
-- Release the number of reserved vertices/indices from the end of the last reservation made with PrimReserve().
|
||||||
|
@native
|
||||||
function MT.ImDrawList:PrimUnreserve(idx_count, vtx_count)
|
function MT.ImDrawList:PrimUnreserve(idx_count, vtx_count)
|
||||||
IM_ASSERT_PARANOID(idx_count >= 0 and vtx_count >= 0)
|
IM_ASSERT_PARANOID(idx_count >= 0 and vtx_count >= 0)
|
||||||
|
|
||||||
@@ -4922,6 +4926,7 @@ end
|
|||||||
--- @param uv_a ImVec2
|
--- @param uv_a ImVec2
|
||||||
--- @param uv_c ImVec2
|
--- @param uv_c ImVec2
|
||||||
--- @param col any
|
--- @param col any
|
||||||
|
@native
|
||||||
function MT.ImDrawList:PrimRectUV(a, c, uv_a, uv_c, col)
|
function MT.ImDrawList:PrimRectUV(a, c, uv_a, uv_c, col)
|
||||||
local idx = self._VtxCurrentIdx
|
local idx = self._VtxCurrentIdx
|
||||||
local idx_data = self.IdxBuffer.Data; local vtx_data = self.VtxBuffer.Buf
|
local idx_data = self.IdxBuffer.Data; local vtx_data = self.VtxBuffer.Buf
|
||||||
@@ -7034,6 +7039,7 @@ function MT.ImDrawList:_CalcCircleAutoSegmentCount(radius)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- 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)
|
-- 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)
|
||||||
|
@native
|
||||||
function MT.ImDrawList:PushClipRect(cr_min, cr_max, intersect_with_current_clip_rect)
|
function MT.ImDrawList:PushClipRect(cr_min, cr_max, intersect_with_current_clip_rect)
|
||||||
-- [Luau] reuse the stack slot's ImVec4 left from earlier frames (each slot stays uniquely owned by the stack)
|
-- [Luau] reuse the stack slot's ImVec4 left from earlier frames (each slot stays uniquely owned by the stack)
|
||||||
local stack = self._ClipRectStack
|
local stack = self._ClipRectStack
|
||||||
@@ -7068,6 +7074,7 @@ function MT.ImDrawList:PushClipRectFullScreen()
|
|||||||
self:PushClipRect(ImVec2(cr.x, cr.y), ImVec2(cr.z, cr.w))
|
self:PushClipRect(ImVec2(cr.x, cr.y), ImVec2(cr.z, cr.w))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@native
|
||||||
function MT.ImDrawList:PopClipRect()
|
function MT.ImDrawList:PopClipRect()
|
||||||
local stack = self._ClipRectStack
|
local stack = self._ClipRectStack
|
||||||
IM_ASSERT(stack.Size > 0)
|
IM_ASSERT(stack.Size > 0)
|
||||||
|
|||||||
@@ -577,6 +577,7 @@ ImGuiKeyOwner_NoOwner = 4294967295 -- Require key to have no owner.
|
|||||||
function ImGui.MouseButtonToKey(button) IM_ASSERT(button >= 0 and button < ImGuiMouseButton.COUNT) return ImGuiKey.MouseLeft + button end
|
function ImGui.MouseButtonToKey(button) IM_ASSERT(button >= 0 and button < ImGuiMouseButton.COUNT) return ImGuiKey.MouseLeft + button end
|
||||||
|
|
||||||
--- @param key ImGuiKey
|
--- @param key ImGuiKey
|
||||||
|
@native
|
||||||
function ImGui.IsNamedKey(key)
|
function ImGui.IsNamedKey(key)
|
||||||
return key >= ImGuiKey.NamedKey_BEGIN and key < ImGuiKey.NamedKey_END
|
return key >= ImGuiKey.NamedKey_BEGIN and key < ImGuiKey.NamedKey_END
|
||||||
end
|
end
|
||||||
@@ -1449,6 +1450,7 @@ MT.ImGuiNextItemData = {}
|
|||||||
MT.ImGuiNextItemData.__index = MT.ImGuiNextItemData
|
MT.ImGuiNextItemData.__index = MT.ImGuiNextItemData
|
||||||
|
|
||||||
-- Also cleared manually by ItemAdd()!
|
-- Also cleared manually by ItemAdd()!
|
||||||
|
@native
|
||||||
function MT.ImGuiNextItemData:ClearFlags()
|
function MT.ImGuiNextItemData:ClearFlags()
|
||||||
self.HasFlags = ImGuiNextItemDataFlags.None
|
self.HasFlags = ImGuiNextItemDataFlags.None
|
||||||
self.ItemFlagsSet = ImGuiItemFlags.None
|
self.ItemFlagsSet = ImGuiItemFlags.None
|
||||||
@@ -1498,6 +1500,7 @@ end
|
|||||||
MT.ImGuiNextWindowData = {}
|
MT.ImGuiNextWindowData = {}
|
||||||
MT.ImGuiNextWindowData.__index = MT.ImGuiNextWindowData
|
MT.ImGuiNextWindowData.__index = MT.ImGuiNextWindowData
|
||||||
|
|
||||||
|
@native
|
||||||
function MT.ImGuiNextWindowData:ClearFlags()
|
function MT.ImGuiNextWindowData:ClearFlags()
|
||||||
self.HasFlags = ImGuiNextWindowDataFlags.None
|
self.HasFlags = ImGuiNextWindowDataFlags.None
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -429,6 +429,7 @@ end
|
|||||||
|
|
||||||
--- @param table_ ImGuiTable
|
--- @param table_ ImGuiTable
|
||||||
--- @param instance_no int
|
--- @param instance_no int
|
||||||
|
@native
|
||||||
function ImGui.TableGetInstanceData(table_, instance_no)
|
function ImGui.TableGetInstanceData(table_, instance_no)
|
||||||
if instance_no == 0 then
|
if instance_no == 0 then
|
||||||
return table_.InstanceDataFirst
|
return table_.InstanceDataFirst
|
||||||
@@ -2512,6 +2513,7 @@ function ImGui.TableGetColumnIndex()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- [Public] Append into a specific column
|
-- [Public] Append into a specific column
|
||||||
|
@native
|
||||||
function ImGui.TableSetColumnIndex(column_n)
|
function ImGui.TableSetColumnIndex(column_n)
|
||||||
local g = GImGui
|
local g = GImGui
|
||||||
local table_ = g.CurrentTable
|
local table_ = g.CurrentTable
|
||||||
@@ -2686,6 +2688,7 @@ end
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
-- Maximum column content width given current layout. Use column.MinX so this value differs on a per-column basis.
|
-- Maximum column content width given current layout. Use column.MinX so this value differs on a per-column basis.
|
||||||
|
@native
|
||||||
function ImGui.TableCalcMaxColumnWidth(table_, column_n)
|
function ImGui.TableCalcMaxColumnWidth(table_, column_n)
|
||||||
local column = table_.Columns[column_n]
|
local column = table_.Columns[column_n]
|
||||||
local max_width = FLT_MAX
|
local max_width = FLT_MAX
|
||||||
@@ -2713,6 +2716,7 @@ function ImGui.TableCalcMaxColumnWidth(table_, column_n)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Note this is meant to be stored in column.WidthAuto, please generally use the WidthAuto field
|
-- Note this is meant to be stored in column.WidthAuto, please generally use the WidthAuto field
|
||||||
|
@native
|
||||||
function ImGui.TableGetColumnWidthAuto(table_, column)
|
function ImGui.TableGetColumnWidthAuto(table_, column)
|
||||||
local content_width_body = mathMax(column.ContentMaxXFrozen, column.ContentMaxXUnfrozen) - column.WorkMinX
|
local content_width_body = mathMax(column.ContentMaxXFrozen, column.ContentMaxXUnfrozen) - column.WorkMinX
|
||||||
local content_width_headers = column.ContentMaxXHeadersIdeal - column.WorkMinX
|
local content_width_headers = column.ContentMaxXHeadersIdeal - column.WorkMinX
|
||||||
|
|||||||
@@ -254,6 +254,7 @@ end
|
|||||||
|
|
||||||
--- @param fmt string
|
--- @param fmt string
|
||||||
--- @param ... any
|
--- @param ... any
|
||||||
|
@native
|
||||||
function ImGui.TextDisabled(fmt, ...)
|
function ImGui.TextDisabled(fmt, ...)
|
||||||
local g = GImGui
|
local g = GImGui
|
||||||
ImGui.PushStyleColor(ImGuiCol.Text, g.Style.Colors[ImGuiCol.TextDisabled])
|
ImGui.PushStyleColor(ImGuiCol.Text, g.Style.Colors[ImGuiCol.TextDisabled])
|
||||||
@@ -7776,6 +7777,7 @@ end
|
|||||||
|
|
||||||
--- @param storage_id ImGuiID
|
--- @param storage_id ImGuiID
|
||||||
--- @param is_open bool
|
--- @param is_open bool
|
||||||
|
@native
|
||||||
function ImGui.TreeNodeSetOpen(storage_id, is_open)
|
function ImGui.TreeNodeSetOpen(storage_id, is_open)
|
||||||
local g = GImGui
|
local g = GImGui
|
||||||
local storage = g.CurrentWindow.DC.StateStorage
|
local storage = g.CurrentWindow.DC.StateStorage
|
||||||
@@ -7784,6 +7786,7 @@ end
|
|||||||
|
|
||||||
--- @param storage_id ImGuiID
|
--- @param storage_id ImGuiID
|
||||||
--- @param flags ImGuiTreeNodeFlags
|
--- @param flags ImGuiTreeNodeFlags
|
||||||
|
@native
|
||||||
function ImGui.TreeNodeUpdateNextOpen(storage_id, flags)
|
function ImGui.TreeNodeUpdateNextOpen(storage_id, flags)
|
||||||
-- Leaf node always open a new tree/id scope. If you never use it, add ImGuiTreeNodeFlags.NoTreePushOnOpen.
|
-- Leaf node always open a new tree/id scope. If you never use it, add ImGuiTreeNodeFlags.NoTreePushOnOpen.
|
||||||
if bit32.band(flags, ImGuiTreeNodeFlags.Leaf) ~= 0 then
|
if bit32.band(flags, ImGuiTreeNodeFlags.Leaf) ~= 0 then
|
||||||
@@ -8239,6 +8242,7 @@ function ImGui.TreePush(str_id)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- @param id ImGuiID
|
--- @param id ImGuiID
|
||||||
|
@native
|
||||||
function ImGui.TreePushOverrideID(id)
|
function ImGui.TreePushOverrideID(id)
|
||||||
local g = GImGui
|
local g = GImGui
|
||||||
local window = g.CurrentWindow
|
local window = g.CurrentWindow
|
||||||
@@ -8247,6 +8251,7 @@ function ImGui.TreePushOverrideID(id)
|
|||||||
ImGui.PushOverrideID(id)
|
ImGui.PushOverrideID(id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@native
|
||||||
function ImGui.TreePop()
|
function ImGui.TreePop()
|
||||||
local g = GImGui
|
local g = GImGui
|
||||||
local window = g.CurrentWindow
|
local window = g.CurrentWindow
|
||||||
@@ -8283,6 +8288,7 @@ end
|
|||||||
-- Set next TreeNode/CollapsingHeader open state.
|
-- Set next TreeNode/CollapsingHeader open state.
|
||||||
--- @param is_open bool
|
--- @param is_open bool
|
||||||
--- @param cond? ImGuiCond
|
--- @param cond? ImGuiCond
|
||||||
|
@native
|
||||||
function ImGui.SetNextItemOpen(is_open, cond)
|
function ImGui.SetNextItemOpen(is_open, cond)
|
||||||
if cond == nil then cond = 0 end
|
if cond == nil then cond = 0 end
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user