MCPcopy Create free account
hub / github.com/Wemino/EchoPatch / DebugNodeDrawList

Method DebugNodeDrawList

include/imgui/imgui.cpp:17164–17257  ·  view source on GitHub ↗

[DEBUG] Display contents of ImDrawList

Source from the content-addressed store, hash-verified

17162
17163// [DEBUG] Display contents of ImDrawList
17164void ImGui::DebugNodeDrawList(ImGuiWindow* window, ImGuiViewportP* viewport, const ImDrawList* draw_list, const char* label)
17165{
17166 ImGuiContext& g = *GImGui;
17167 IM_UNUSED(viewport); // Used in docking branch
17168 ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig;
17169 int cmd_count = draw_list->CmdBuffer.Size;
17170 if (cmd_count > 0 && draw_list->CmdBuffer.back().ElemCount == 0 && draw_list->CmdBuffer.back().UserCallback == NULL)
17171 cmd_count--;
17172 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);
17173 if (draw_list == GetWindowDrawList())
17174 {
17175 SameLine();
17176 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)
17177 if (node_open)
17178 TreePop();
17179 return;
17180 }
17181
17182 ImDrawList* fg_draw_list = GetForegroundDrawList(window); // Render additional visuals into the top-most draw list
17183 if (window && IsItemHovered() && fg_draw_list)
17184 fg_draw_list->AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255, 255, 0, 255));
17185 if (!node_open)
17186 return;
17187
17188 if (window && !window->WasActive)
17189 TextDisabled("Warning: owning Window is inactive. This DrawList is not being rendered!");
17190
17191 for (const ImDrawCmd* pcmd = draw_list->CmdBuffer.Data; pcmd < draw_list->CmdBuffer.Data + cmd_count; pcmd++)
17192 {
17193 if (pcmd->UserCallback)
17194 {
17195 BulletText("Callback %p, user_data %p", pcmd->UserCallback, pcmd->UserCallbackData);
17196 continue;
17197 }
17198
17199 char texid_desc[30];
17200 FormatTextureRefForDebugDisplay(texid_desc, IM_COUNTOF(texid_desc), pcmd->TexRef);
17201 char buf[300];
17202 ImFormatString(buf, IM_COUNTOF(buf), "DrawCmd:%5d tris, Tex %s, ClipRect (%4.0f,%4.0f)-(%4.0f,%4.0f)",
17203 pcmd->ElemCount / 3, texid_desc, pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w);
17204 bool pcmd_node_open = TreeNode((void*)(pcmd - draw_list->CmdBuffer.begin()), "%s", buf);
17205 if (IsItemHovered() && (cfg->ShowDrawCmdMesh || cfg->ShowDrawCmdBoundingBoxes) && fg_draw_list)
17206 DebugNodeDrawCmdShowMeshAndBoundingBox(fg_draw_list, draw_list, pcmd, cfg->ShowDrawCmdMesh, cfg->ShowDrawCmdBoundingBoxes);
17207 if (!pcmd_node_open)
17208 continue;
17209
17210 // Calculate approximate coverage area (touched pixel count)
17211 // This will be in pixels squared as long there's no post-scaling happening to the renderer output.
17212 const ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL;
17213 const ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data + pcmd->VtxOffset;
17214 float total_area = 0.0f;
17215 for (unsigned int idx_n = pcmd->IdxOffset; idx_n < pcmd->IdxOffset + pcmd->ElemCount; )
17216 {
17217 ImVec2 triangle[3];
17218 for (int n = 0; n < 3; n++, idx_n++)
17219 triangle[n] = vtx_buffer[idx_buffer ? idx_buffer[idx_n] : idx_n].pos;
17220 total_area += ImTriangleArea(triangle[0], triangle[1], triangle[2]);
17221 }

Callers

nothing calls this directly

Calls 10

ImVec4Class · 0.85
GetForegroundDrawListFunction · 0.85
ImFormatStringFunction · 0.85
ImTriangleAreaFunction · 0.85
AddRectMethod · 0.80
BeginMethod · 0.80
StepMethod · 0.80
AddPolylineMethod · 0.80
beginMethod · 0.45

Tested by

no test coverage detected