Library: @native on DebugNodeFontGlyphsForSrcMask() (the font atlas glyph grids: a 256-entry scan per codepoint block + 256 AddRect/RenderChar per open block) and on small helpers called from native code (IM_ASSERT, IM_ASSERT_USER_ERROR_RET, ImHashStr's memo, ImVector __index/push_back/pop_back/back/iter)
demo_all scene (whole demo open, headless --roblox, interleaved A/B): lib ~10.1 -> ~9.1 ms/frame, user instructions/frame -5%; draw data unchanged.
This commit is contained in:
1 parent
c030fe9bce
commit
9d0dc5ee15
3 files changed
+11
-1
No files matched your search
@@ -4939,6 +4939,7 @@ end
|
||||
local hash_memo, hash_memo_n, HASH_MEMO_MAX = {}, 0, 16384
|
||||
local ImHashStrRaw
|
||||
|
||||
@native
|
||||
function ImHashStr(str, size, seed)
|
||||
if seed == nil then seed = 0 end
|
||||
if size == nil or size == #str then
|
||||
@@ -20972,6 +20973,7 @@ function ImGui.DebugNodeFontGlyph(font, glyph)
|
||||
ImGui.Text("SourceIdx: %d", glyph.SourceIdx)
|
||||
end
|
||||
|
||||
@native
|
||||
function ImGui.DebugNodeFontGlyphsForSrcMask(font, baked, src_mask)
|
||||
local draw_list = ImGui.GetWindowDrawList()
|
||||
local glyph_col = ImGui.GetColorU32(ImGuiCol.Text)
|
||||
|
||||
+8
-1
@@ -148,6 +148,7 @@ function ImGui.GetMetatables() return MT end
|
||||
|
||||
--- @param _EXPR any
|
||||
--- @param _MSG string?
|
||||
@native
|
||||
function IM_ASSERT(_EXPR, _MSG) assert((_EXPR), _MSG) end
|
||||
|
||||
IM_ASSERT_PARANOID = IM_ASSERT
|
||||
@@ -395,12 +396,14 @@ local IM_VECTOR = {}
|
||||
--- @param t ImVector
|
||||
--- @param k string|int
|
||||
--- @return any
|
||||
IM_VECTOR.__index = function(t, k)
|
||||
@native
|
||||
local function IM_VECTOR_index(t, k)
|
||||
local m = IM_VECTOR[k] -- [Port] methods first (hot path)
|
||||
if m ~= nil then return m end
|
||||
if k == "Data" then return nil end -- [Port] Data has already been discarded
|
||||
return t.Data[IM_ASSERT(k >= 1 and k <= t.Size) or k] -- [Port] if the mt access turns out nil, the k must be int index into Data
|
||||
end
|
||||
IM_VECTOR.__index = IM_VECTOR_index
|
||||
|
||||
--- @param t ImVector
|
||||
--- @param k int
|
||||
@@ -422,14 +425,18 @@ local function _grow_capacity(v, sz) local new_capacity = (v.Capacity ~= 0) and
|
||||
--- @nodiscard
|
||||
function ImVector(T, COPY_FUNC) return setmetatable({Data = nil, Size = 0, Capacity = 0, _Constructor = T or _default_constructor, _CopyFunc = COPY_FUNC or _default_copyfunc}, IM_VECTOR) end
|
||||
|
||||
@native
|
||||
function IM_VECTOR:push_back(value) if self.Size == self.Capacity then self:reserve(_grow_capacity(self, self.Size + 1)) end; self._CopyFunc(self.Data, self.Size + 1, value); self.Size = self.Size + 1; return value end
|
||||
@native
|
||||
function IM_VECTOR:pop_back() IM_ASSERT(self.Size > 0); self.Size = self.Size - 1; end
|
||||
function IM_VECTOR:push_front(value) if self.Size == 0 then self:push_back(value) else self:insert(1, value) end end
|
||||
function IM_VECTOR:clear() if self.Data then self.Size = 0; self.Capacity = 0; IM_FREE(self, "Data"); self.Data = nil end end
|
||||
function IM_VECTOR:clear_delete() for i = 1, self.Size do self.Data[i] = nil end self.Size = 0 end
|
||||
function IM_VECTOR:empty() return self.Size == 0 end
|
||||
@native
|
||||
function IM_VECTOR:back() IM_ASSERT(self.Size > 0) return self.Data[self.Size] end
|
||||
function IM_VECTOR:erase(i) IM_ASSERT(i >= 1 and i <= self.Size) local removed = (table.remove(self.Data, i)) ~= nil self.Size = self.Size - 1 return removed end
|
||||
@native
|
||||
local function _iter(v, i) i = i + 1 if i <= v.Size then return i, v.Data[i] end end
|
||||
function IM_VECTOR:iter() return _iter, self, 0 end
|
||||
function IM_VECTOR:find_index(value) for i = 1, self.Size do if self.Data[i] == value then return i end end return nil end
|
||||
|
||||
@@ -537,6 +537,7 @@ IM_DRAWLIST_TEX_LINES_DETAILED_WIDTH_COUNT = ((IM_DRAWLIST_TEX_LINES_DETAILED_WI
|
||||
-- - Read https://github.com/ocornut/imgui/wiki/Error-Handling for details on error handling.
|
||||
-- [Port] Upstream: `if (!(expr) && ErrorLog(msg)) IM_ASSERT(0)`. ErrorLog() returns io.ConfigErrorRecoveryEnableAssert.
|
||||
function IM_ASSERT_USER_ERROR(_EXPR, _MSG) if not (_EXPR) or (_EXPR) == 0 then if not ImGui.ErrorLog or ImGui.ErrorLog(_MSG) then error(_MSG, 2) end end end -- Recoverable User Error
|
||||
@native
|
||||
function IM_ASSERT_USER_ERROR_RET(_EXPR, _MSG) if not (_EXPR) or (_EXPR) == 0 then error(_MSG, 2) end end
|
||||
|
||||
-- Debug Logging for ShowDebugLogWindow(). This is designed for relatively rare events so please don't spam.
|
||||
|
||||
Reference in new issue
Block a user