[DEBUG] Display contents of ImDrawList
| 15317 | |
| 15318 | // [DEBUG] Display contents of ImDrawList |
| 15319 | void ImGui::DebugNodeDrawList(ImGuiWindow* window, ImGuiViewportP* viewport, const ImDrawList* draw_list, const char* label) |
| 15320 | { |
| 15321 | ImGuiContext& g = *GImGui; |
| 15322 | IM_UNUSED(viewport); // Used in docking branch |
| 15323 | ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig; |
| 15324 | int cmd_count = draw_list->CmdBuffer.Size; |
| 15325 | if (cmd_count > 0 && draw_list->CmdBuffer.back().ElemCount == 0 && draw_list->CmdBuffer.back().UserCallback == NULL) |
| 15326 | cmd_count--; |
| 15327 | 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); |
| 15328 | if (draw_list == GetWindowDrawList()) |
| 15329 | { |
| 15330 | SameLine(); |
| 15331 | 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) |
| 15332 | if (node_open) |
| 15333 | TreePop(); |
| 15334 | return; |
| 15335 | } |
| 15336 | |
| 15337 | ImDrawList* fg_draw_list = GetForegroundDrawList(window); // Render additional visuals into the top-most draw list |
| 15338 | if (window && IsItemHovered() && fg_draw_list) |
| 15339 | fg_draw_list->AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255, 255, 0, 255)); |
| 15340 | if (!node_open) |
| 15341 | return; |
| 15342 | |
| 15343 | if (window && !window->WasActive) |
| 15344 | TextDisabled("Warning: owning Window is inactive. This DrawList is not being rendered!"); |
| 15345 | |
| 15346 | for (const ImDrawCmd* pcmd = draw_list->CmdBuffer.Data; pcmd < draw_list->CmdBuffer.Data + cmd_count; pcmd++) |
| 15347 | { |
| 15348 | if (pcmd->UserCallback) |
| 15349 | { |
| 15350 | BulletText("Callback %p, user_data %p", pcmd->UserCallback, pcmd->UserCallbackData); |
| 15351 | continue; |
| 15352 | } |
| 15353 | |
| 15354 | char texid_desc[20]; |
| 15355 | FormatTextureIDForDebugDisplay(texid_desc, IM_ARRAYSIZE(texid_desc), pcmd->TextureId); |
| 15356 | char buf[300]; |
| 15357 | ImFormatString(buf, IM_ARRAYSIZE(buf), "DrawCmd:%5d tris, Tex %s, ClipRect (%4.0f,%4.0f)-(%4.0f,%4.0f)", |
| 15358 | pcmd->ElemCount / 3, texid_desc, pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w); |
| 15359 | bool pcmd_node_open = TreeNode((void*)(pcmd - draw_list->CmdBuffer.begin()), "%s", buf); |
| 15360 | if (IsItemHovered() && (cfg->ShowDrawCmdMesh || cfg->ShowDrawCmdBoundingBoxes) && fg_draw_list) |
| 15361 | DebugNodeDrawCmdShowMeshAndBoundingBox(fg_draw_list, draw_list, pcmd, cfg->ShowDrawCmdMesh, cfg->ShowDrawCmdBoundingBoxes); |
| 15362 | if (!pcmd_node_open) |
| 15363 | continue; |
| 15364 | |
| 15365 | // Calculate approximate coverage area (touched pixel count) |
| 15366 | // This will be in pixels squared as long there's no post-scaling happening to the renderer output. |
| 15367 | const ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL; |
| 15368 | const ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data + pcmd->VtxOffset; |
| 15369 | float total_area = 0.0f; |
| 15370 | for (unsigned int idx_n = pcmd->IdxOffset; idx_n < pcmd->IdxOffset + pcmd->ElemCount; ) |
| 15371 | { |
| 15372 | ImVec2 triangle[3]; |
| 15373 | for (int n = 0; n < 3; n++, idx_n++) |
| 15374 | triangle[n] = vtx_buffer[idx_buffer ? idx_buffer[idx_n] : idx_n].pos; |
| 15375 | total_area += ImTriangleArea(triangle[0], triangle[1], triangle[2]); |
| 15376 | } |
nothing calls this directly
no test coverage detected