[DEBUG] Display contents of ImDrawList
| 13474 | |
| 13475 | // [DEBUG] Display contents of ImDrawList |
| 13476 | void ImGui::DebugNodeDrawList(ImGuiWindow* window, const ImDrawList* draw_list, const char* label) |
| 13477 | { |
| 13478 | ImGuiContext& g = *GImGui; |
| 13479 | ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig; |
| 13480 | int cmd_count = draw_list->CmdBuffer.Size; |
| 13481 | if (cmd_count > 0 && draw_list->CmdBuffer.back().ElemCount == 0 && draw_list->CmdBuffer.back().UserCallback == NULL) |
| 13482 | cmd_count--; |
| 13483 | bool node_open = TreeNode(draw_list, "%s: '%s' %d vtx, %d indices, %d cmds", label, draw_list->_OwnerName ? draw_list->_OwnerName : "", draw_list->VtxBuffer.Size, draw_list->IdxBuffer.Size, cmd_count); |
| 13484 | if (draw_list == GetWindowDrawList()) |
| 13485 | { |
| 13486 | SameLine(); |
| 13487 | TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f), "CURRENTLY APPENDING"); // Can't display stats for active draw list! (we don't have the data double-buffered) |
| 13488 | if (node_open) |
| 13489 | TreePop(); |
| 13490 | return; |
| 13491 | } |
| 13492 | |
| 13493 | ImDrawList* fg_draw_list = GetForegroundDrawList(window); // Render additional visuals into the top-most draw list |
| 13494 | if (window && IsItemHovered() && fg_draw_list) |
| 13495 | fg_draw_list->AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255, 255, 0, 255)); |
| 13496 | if (!node_open) |
| 13497 | return; |
| 13498 | |
| 13499 | if (window && !window->WasActive) |
| 13500 | TextDisabled("Warning: owning Window is inactive. This DrawList is not being rendered!"); |
| 13501 | |
| 13502 | for (const ImDrawCmd* pcmd = draw_list->CmdBuffer.Data; pcmd < draw_list->CmdBuffer.Data + cmd_count; pcmd++) |
| 13503 | { |
| 13504 | if (pcmd->UserCallback) |
| 13505 | { |
| 13506 | BulletText("Callback %p, user_data %p", pcmd->UserCallback, pcmd->UserCallbackData); |
| 13507 | continue; |
| 13508 | } |
| 13509 | |
| 13510 | char buf[300]; |
| 13511 | ImFormatString(buf, IM_ARRAYSIZE(buf), "DrawCmd:%5d tris, Tex 0x%p, ClipRect (%4.0f,%4.0f)-(%4.0f,%4.0f)", |
| 13512 | pcmd->ElemCount / 3, (void*)(intptr_t)pcmd->TextureId, |
| 13513 | pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w); |
| 13514 | bool pcmd_node_open = TreeNode((void*)(pcmd - draw_list->CmdBuffer.begin()), "%s", buf); |
| 13515 | if (IsItemHovered() && (cfg->ShowDrawCmdMesh || cfg->ShowDrawCmdBoundingBoxes) && fg_draw_list) |
| 13516 | DebugNodeDrawCmdShowMeshAndBoundingBox(fg_draw_list, draw_list, pcmd, cfg->ShowDrawCmdMesh, cfg->ShowDrawCmdBoundingBoxes); |
| 13517 | if (!pcmd_node_open) |
| 13518 | continue; |
| 13519 | |
| 13520 | // Calculate approximate coverage area (touched pixel count) |
| 13521 | // This will be in pixels squared as long there's no post-scaling happening to the renderer output. |
| 13522 | const ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL; |
| 13523 | const ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data + pcmd->VtxOffset; |
| 13524 | float total_area = 0.0f; |
| 13525 | for (unsigned int idx_n = pcmd->IdxOffset; idx_n < pcmd->IdxOffset + pcmd->ElemCount; ) |
| 13526 | { |
| 13527 | ImVec2 triangle[3]; |
| 13528 | for (int n = 0; n < 3; n++, idx_n++) |
| 13529 | triangle[n] = vtx_buffer[idx_buffer ? idx_buffer[idx_n] : idx_n].pos; |
| 13530 | total_area += ImTriangleArea(triangle[0], triangle[1], triangle[2]); |
| 13531 | } |
| 13532 | |
| 13533 | // Display vertex information summary. Hover to get all triangles drawn in wire-frame |
nothing calls this directly
no test coverage detected