@ -488,9 +488,10 @@ void ImDrawList::AddCallback(ImDrawCallback callback, void* callback_data)
}
// Compare ClipRect, TextureId and VtxOffset with a single memcmp()
# define ImDrawCmd_HeaderSize (IM_OFFSETOF(ImDrawCmd, VtxOffset) + sizeof(unsigned int))
# define ImDrawCmd_HeaderCompare(CMD_LHS, CMD_RHS) (memcmp(CMD_LHS, CMD_RHS, ImDrawCmd_HeaderSize)) // Compare ClipRect, TextureId, VtxOffset
# define ImDrawCmd_HeaderCopy(CMD_DST, CMD_SRC) (memcpy(CMD_DST, CMD_SRC, ImDrawCmd_HeaderSize)) // Copy ClipRect, TextureId, VtxOffset
# define ImDrawCmd_HeaderSize (IM_OFFSETOF(ImDrawCmd, VtxOffset) + sizeof(unsigned int))
# define ImDrawCmd_HeaderCompare(CMD_LHS, CMD_RHS) (memcmp(CMD_LHS, CMD_RHS, ImDrawCmd_HeaderSize)) // Compare ClipRect, TextureId, VtxOffset
# define ImDrawCmd_HeaderCopy(CMD_DST, CMD_SRC) (memcpy(CMD_DST, CMD_SRC, ImDrawCmd_HeaderSize)) // Copy ClipRect, TextureId, VtxOffset
# define ImDrawCmd_AreSequentialIdxOffset(CMD_0, CMD_1) (CMD_0->IdxOffset + CMD_0->ElemCount == CMD_1->IdxOffset)
// Try to merge two last draw commands
void ImDrawList : : _TryMergeDrawCmds ( )
@ -498,7 +499,7 @@ void ImDrawList::_TryMergeDrawCmds()
IM_ASSERT_PARANOID ( CmdBuffer . Size > 0 ) ;
ImDrawCmd * curr_cmd = & CmdBuffer . Data [ CmdBuffer . Size - 1 ] ;
ImDrawCmd * prev_cmd = curr_cmd - 1 ;
if ( ImDrawCmd_HeaderCompare ( curr_cmd , prev_cmd ) = = 0 & & curr_cmd- > UserCallback = = NULL & & prev_cmd - > UserCallback = = NULL )
if ( ImDrawCmd_HeaderCompare ( curr_cmd , prev_cmd ) = = 0 & & ImDrawCmd_AreSequentialIdxOffset( prev_cmd , curr_cmd ) & & curr_cmd- > UserCallback = = NULL & & prev_cmd - > UserCallback = = NULL )
{
prev_cmd - > ElemCount + = curr_cmd - > ElemCount ;
CmdBuffer . pop_back ( ) ;
@ -521,7 +522,7 @@ void ImDrawList::_OnChangedClipRect()
// Try to merge with previous command if it matches, else use current command
ImDrawCmd * prev_cmd = curr_cmd - 1 ;
if ( curr_cmd - > ElemCount = = 0 & & CmdBuffer . Size > 1 & & ImDrawCmd_HeaderCompare ( & _CmdHeader , prev_cmd ) = = 0 & & prev_cmd- > UserCallback = = NULL )
if ( curr_cmd - > ElemCount = = 0 & & CmdBuffer . Size > 1 & & ImDrawCmd_HeaderCompare ( & _CmdHeader , prev_cmd ) = = 0 & & ImDrawCmd_AreSequentialIdxOffset( prev_cmd , curr_cmd ) & & prev_cmd- > UserCallback = = NULL )
{
CmdBuffer . pop_back ( ) ;
return ;
@ -544,7 +545,7 @@ void ImDrawList::_OnChangedTextureID()
// Try to merge with previous command if it matches, else use current command
ImDrawCmd * prev_cmd = curr_cmd - 1 ;
if ( curr_cmd - > ElemCount = = 0 & & CmdBuffer . Size > 1 & & ImDrawCmd_HeaderCompare ( & _CmdHeader , prev_cmd ) = = 0 & & prev_cmd- > UserCallback = = NULL )
if ( curr_cmd - > ElemCount = = 0 & & CmdBuffer . Size > 1 & & ImDrawCmd_HeaderCompare ( & _CmdHeader , prev_cmd ) = = 0 & & ImDrawCmd_AreSequentialIdxOffset( prev_cmd , curr_cmd ) & & prev_cmd- > UserCallback = = NULL )
{
CmdBuffer . pop_back ( ) ;
return ;
@ -1738,6 +1739,8 @@ void ImDrawListSplitter::Merge(ImDrawList* draw_list)
if ( ch . _CmdBuffer . Size > 0 & & last_cmd ! = NULL )
{
// Do not include ImDrawCmd_AreSequentialIdxOffset() in the compare as we rebuild IdxOffset values ourselves.
// Manipulating IdxOffset (e.g. by reordering draw commands like done by RenderDimmedBackgroundBehindWindow()) is not supported within a splitter.
ImDrawCmd * next_cmd = & ch . _CmdBuffer [ 0 ] ;
if ( ImDrawCmd_HeaderCompare ( last_cmd , next_cmd ) = = 0 & & last_cmd - > UserCallback = = NULL & & next_cmd - > UserCallback = = NULL )
{