| 468 | } |
| 469 | |
| 470 | void ImDrawList::UpdateTextureID() |
| 471 | { |
| 472 | // If current command is used with different settings we need to add a new command |
| 473 | const ImTextureID curr_texture_id = GetCurrentTextureId(); |
| 474 | ImDrawCmd* curr_cmd = CmdBuffer.Size ? &CmdBuffer.back() : NULL; |
| 475 | if (!curr_cmd || (curr_cmd->ElemCount != 0 && curr_cmd->TextureId != curr_texture_id) || curr_cmd->UserCallback != NULL) |
| 476 | { |
| 477 | AddDrawCmd(); |
| 478 | return; |
| 479 | } |
| 480 | |
| 481 | // Try to merge with previous command if it matches, else use current command |
| 482 | ImDrawCmd* prev_cmd = CmdBuffer.Size > 1 ? curr_cmd - 1 : NULL; |
| 483 | 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) |
| 484 | CmdBuffer.pop_back(); |
| 485 | else |
| 486 | curr_cmd->TextureId = curr_texture_id; |
| 487 | } |
| 488 | |
| 489 | #undef GetCurrentClipRect |
| 490 | #undef GetCurrentTextureId |