MCPcopy Create free account
hub / github.com/RenderKit/embree / _TryMergeDrawCmds

Method _TryMergeDrawCmds

tutorials/common/imgui/imgui_draw.cpp:481–491  ·  view source on GitHub ↗

Try to merge two last draw commands

Source from the content-addressed store, hash-verified

479
480// Try to merge two last draw commands
481void ImDrawList::_TryMergeDrawCmds()
482{
483 IM_ASSERT_PARANOID(CmdBuffer.Size > 0);
484 ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
485 ImDrawCmd* prev_cmd = curr_cmd - 1;
486 if (ImDrawCmd_HeaderCompare(curr_cmd, prev_cmd) == 0 && ImDrawCmd_AreSequentialIdxOffset(prev_cmd, curr_cmd) && curr_cmd->UserCallback == NULL && prev_cmd->UserCallback == NULL)
487 {
488 prev_cmd->ElemCount += curr_cmd->ElemCount;
489 CmdBuffer.pop_back();
490 }
491}
492
493// 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.
494// 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.

Callers 1

EndComboPreviewMethod · 0.80

Calls 1

pop_backMethod · 0.45

Tested by

no test coverage detected