Skip to content

Commit

Permalink
ImDrawList: remove local vs member indirection as locals were deemed …
Browse files Browse the repository at this point in the history
…better. (2)
  • Loading branch information
ocornut committed Sep 30, 2024
1 parent 3948cd0 commit 0e6bb15
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions imgui_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -731,22 +731,27 @@ void ImDrawList::PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, c
#define IM_POLYLINE_IDX_16_BIT 0
#else
#define IM_POLYLINE_IDX_16_BIT 1
# endif

// Macros that declare, load and save write pointers as local variables
#define IM_POLYLINE_PRIM_MAKE_LOCAL() ImDrawVert* vtx_write = this->_VtxWritePtr; ImDrawIdx* idx_write = this->_IdxWritePtr; unsigned int idx_base = this->_VtxCurrentIdx
#define IM_POLYLINE_PRIM_LOAD_LOCAL() vtx_write = this->_VtxWritePtr; idx_write = this->_IdxWritePtr; idx_base = this->_VtxCurrentIdx
#define IM_POLYLINE_PRIM_SAVE_LOCAL() this->_VtxWritePtr = vtx_write; this->_IdxWritePtr = idx_write; this->_VtxCurrentIdx = idx_base
#endif

// Macros that commit, split and handle vertex offset overflow
#define IM_POLYLINE_PRIM_RESERVE(IDX_COUNT, VTX_COUNT) this->PrimReserve((IDX_COUNT) + IM_POLYLINE_PRIM_EXTRA_IDX_COUNT, VTX_COUNT); IM_POLYLINE_PRIM_MAKE_LOCAL()
#define IM_POLYLINE_PRIM_RESERVE(IDX_COUNT, VTX_COUNT) \
this->PrimReserve((IDX_COUNT) + IM_POLYLINE_PRIM_EXTRA_IDX_COUNT, VTX_COUNT); \
ImDrawVert* vtx_write = this->_VtxWritePtr; \
ImDrawIdx* idx_write = this->_IdxWritePtr; \
unsigned int idx_base = this->_VtxCurrentIdx;

#define IM_POLYLINE_PRIM_COMMIT() \
IM_POLYLINE_PRIM_SAVE_LOCAL(); \
this->_VtxWritePtr = vtx_write; this->_IdxWritePtr = idx_write; this->_VtxCurrentIdx = idx_base; \
const int unused_vtx_count = (int)((this->VtxBuffer.Data + this->VtxBuffer.Size) - this->_VtxWritePtr); \
const int unused_idx_count = (int)((this->IdxBuffer.Data + this->IdxBuffer.Size) - this->_IdxWritePtr); \
this->PrimUnreserve(unused_idx_count, unused_vtx_count)

#define IM_POLYLINE_PRIM_SPLT() IM_POLYLINE_PRIM_COMMIT(); this->PrimReserve(unused_idx_count, unused_vtx_count); IM_POLYLINE_PRIM_LOAD_LOCAL()
#define IM_POLYLINE_PRIM_SPLT() \
IM_POLYLINE_PRIM_COMMIT(); \
this->PrimReserve(unused_idx_count, unused_vtx_count); \
vtx_write = this->_VtxWritePtr; \
idx_write = this->_IdxWritePtr; \
idx_base = this->_VtxCurrentIdx;

#define IM_POLYLINE_VTX_COMMIT(N) \
{ \
Expand Down

0 comments on commit 0e6bb15

Please sign in to comment.