-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ImDrawList: Fixed an issue when draw command merging or cancelling wh…
…ile crossing the VtxOffset boundary would lead to draw command being emitted with wrong VtxOffset value. (#3129, #3163, #3232)
- Loading branch information
Showing
3 changed files
with
26 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -460,11 +460,17 @@ void ImDrawList::UpdateClipRect() | |
} | ||
|
||
// Try to merge with previous command if it matches, else use current command | ||
ImDrawCmd* prev_cmd = CmdBuffer.Size > 1 ? curr_cmd - 1 : NULL; | ||
if (curr_cmd->ElemCount == 0 && prev_cmd && memcmp(&prev_cmd->ClipRect, &curr_clip_rect, sizeof(ImVec4)) == 0 && prev_cmd->TextureId == GetCurrentTextureId() && prev_cmd->UserCallback == NULL) | ||
CmdBuffer.pop_back(); | ||
else | ||
curr_cmd->ClipRect = curr_clip_rect; | ||
if (curr_cmd->ElemCount == 0 && CmdBuffer.Size > 1) | ||
{ | ||
ImDrawCmd* prev_cmd = curr_cmd - 1; | ||
if (memcmp(&prev_cmd->ClipRect, &curr_clip_rect, sizeof(ImVec4)) == 0 && prev_cmd->VtxOffset == _VtxCurrentOffset && prev_cmd->TextureId == GetCurrentTextureId() && prev_cmd->UserCallback == NULL) | ||
{ | ||
CmdBuffer.pop_back(); | ||
return; | ||
} | ||
} | ||
|
||
curr_cmd->ClipRect = curr_clip_rect; | ||
} | ||
|
||
void ImDrawList::UpdateTextureID() | ||
|
@@ -479,11 +485,17 @@ void ImDrawList::UpdateTextureID() | |
} | ||
|
||
// Try to merge with previous command if it matches, else use current command | ||
ImDrawCmd* prev_cmd = CmdBuffer.Size > 1 ? curr_cmd - 1 : NULL; | ||
if (curr_cmd->ElemCount == 0 && prev_cmd && prev_cmd->TextureId == curr_texture_id && memcmp(&prev_cmd->ClipRect, &GetCurrentClipRect(), sizeof(ImVec4)) == 0 && prev_cmd->UserCallback == NULL) | ||
CmdBuffer.pop_back(); | ||
else | ||
curr_cmd->TextureId = curr_texture_id; | ||
if (curr_cmd->ElemCount == 0 && CmdBuffer.Size > 1) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ocornut
Owner
|
||
{ | ||
ImDrawCmd* prev_cmd = curr_cmd - 1; | ||
if (prev_cmd->TextureId == curr_texture_id && memcmp(&prev_cmd->ClipRect, &GetCurrentClipRect(), sizeof(ImVec4)) == 0 && prev_cmd->VtxOffset == _VtxCurrentOffset && prev_cmd->UserCallback == NULL) | ||
{ | ||
CmdBuffer.pop_back(); | ||
return; | ||
} | ||
} | ||
|
||
curr_cmd->TextureId = curr_texture_id; | ||
} | ||
|
||
#undef GetCurrentClipRect | ||
|
maybe extract equal code into a third function?