MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / UpdateClipRect

Method UpdateClipRect

lib/imgui/imgui_draw.cpp:451–468  ·  view source on GitHub ↗

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. 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.

Source from the content-addressed store, hash-verified

449// 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.
450// 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.
451void ImDrawList::UpdateClipRect()
452{
453 // If current command is used with different settings we need to add a new command
454 const ImVec4 curr_clip_rect = GetCurrentClipRect();
455 ImDrawCmd* curr_cmd = CmdBuffer.Size > 0 ? &CmdBuffer.Data[CmdBuffer.Size-1] : NULL;
456 if (!curr_cmd || (curr_cmd->ElemCount != 0 && memcmp(&curr_cmd->ClipRect, &curr_clip_rect, sizeof(ImVec4)) != 0) || curr_cmd->UserCallback != NULL)
457 {
458 AddDrawCmd();
459 return;
460 }
461
462 // Try to merge with previous command if it matches, else use current command
463 ImDrawCmd* prev_cmd = CmdBuffer.Size > 1 ? curr_cmd - 1 : NULL;
464 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)
465 CmdBuffer.pop_back();
466 else
467 curr_cmd->ClipRect = curr_clip_rect;
468}
469
470void ImDrawList::UpdateTextureID()
471{

Callers 1

MergeMethod · 0.80

Calls 1

pop_backMethod · 0.80

Tested by

no test coverage detected