From aa1a96f907084c7d85b94a760b8304bf36d254b4 Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 9 Apr 2015 18:34:31 +0100 Subject: [PATCH] ImDrawList: inline AddVtx() calls for profit in highly debug builds --- imgui.cpp | 58 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 6d9d4328..c67303cb 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -7711,47 +7711,51 @@ void ImDrawList::PrimReserve(unsigned int vtx_count) void ImDrawList::PrimTriangle(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col) { const ImVec2 uv = GImGui->FontTexUvWhitePixel; - AddVtx(a, uv, col); - AddVtx(b, uv, col); - AddVtx(c, uv, col); + vtx_write[0].pos = a; vtx_write[0].uv = uv; vtx_write[0].col = col; + vtx_write[1].pos = b; vtx_write[1].uv = uv; vtx_write[1].col = col; + vtx_write[2].pos = c; vtx_write[2].uv = uv; vtx_write[2].col = col; + vtx_write += 3; } void ImDrawList::PrimRect(const ImVec2& a, const ImVec2& c, ImU32 col) { const ImVec2 uv = GImGui->FontTexUvWhitePixel; - ImVec2 b(c.x, a.y); - ImVec2 d(a.x, c.y); - AddVtx(a, uv, col); - AddVtx(b, uv, col); - AddVtx(c, uv, col); - AddVtx(a, uv, col); - AddVtx(c, uv, col); - AddVtx(d, uv, col); + const ImVec2 b(c.x, a.y); + const ImVec2 d(a.x, c.y); + vtx_write[0].pos = a; vtx_write[0].uv = uv; vtx_write[0].col = col; + vtx_write[1].pos = b; vtx_write[1].uv = uv; vtx_write[1].col = col; + vtx_write[2].pos = c; vtx_write[2].uv = uv; vtx_write[2].col = col; + vtx_write[3].pos = a; vtx_write[3].uv = uv; vtx_write[3].col = col; + vtx_write[4].pos = c; vtx_write[4].uv = uv; vtx_write[4].col = col; + vtx_write[5].pos = d; vtx_write[5].uv = uv; vtx_write[5].col = col; + vtx_write += 6; } void ImDrawList::PrimRectUV(const ImVec2& a, const ImVec2& c, const ImVec2& uv_a, const ImVec2& uv_c, ImU32 col) { - ImVec2 b(c.x, a.y); - ImVec2 d(a.x, c.y); - ImVec2 uv_b(uv_c.x, uv_a.y); - ImVec2 uv_d(uv_a.x, uv_c.y); - AddVtx(a, uv_a, col); - AddVtx(b, uv_b, col); - AddVtx(c, uv_c, col); - AddVtx(a, uv_a, col); - AddVtx(c, uv_c, col); - AddVtx(d, uv_d, col); + const ImVec2 b(c.x, a.y); + const ImVec2 d(a.x, c.y); + const ImVec2 uv_b(uv_c.x, uv_a.y); + const ImVec2 uv_d(uv_a.x, uv_c.y); + vtx_write[0].pos = a; vtx_write[0].uv = uv_a; vtx_write[0].col = col; + vtx_write[1].pos = b; vtx_write[1].uv = uv_b; vtx_write[1].col = col; + vtx_write[2].pos = c; vtx_write[2].uv = uv_c; vtx_write[2].col = col; + vtx_write[3].pos = a; vtx_write[3].uv = uv_a; vtx_write[3].col = col; + vtx_write[4].pos = c; vtx_write[4].uv = uv_c; vtx_write[4].col = col; + vtx_write[5].pos = d; vtx_write[5].uv = uv_d; vtx_write[5].col = col; + vtx_write += 6; } void ImDrawList::PrimQuad(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, ImU32 col) { const ImVec2 uv = GImGui->FontTexUvWhitePixel; - AddVtx(a, uv, col); - AddVtx(b, uv, col); - AddVtx(c, uv, col); - AddVtx(a, uv, col); - AddVtx(c, uv, col); - AddVtx(d, uv, col); + vtx_write[0].pos = a; vtx_write[0].uv = uv; vtx_write[0].col = col; + vtx_write[1].pos = b; vtx_write[1].uv = uv; vtx_write[1].col = col; + vtx_write[2].pos = c; vtx_write[2].uv = uv; vtx_write[2].col = col; + vtx_write[3].pos = a; vtx_write[3].uv = uv; vtx_write[3].col = col; + vtx_write[4].pos = c; vtx_write[4].uv = uv; vtx_write[4].col = col; + vtx_write[5].pos = d; vtx_write[5].uv = uv; vtx_write[5].col = col; + vtx_write += 6; } // FIXME-OPT: In many instances the caller could provide a normal.