MCPcopy Create free account
hub / github.com/DISTRHO/Cardinal / DebugNodeDrawList

Method DebugNodeDrawList

plugins/Cardinal/src/DearImGui/imgui.cpp:12023–12114  ·  view source on GitHub ↗

[DEBUG] Display contents of ImDrawList

Source from the content-addressed store, hash-verified

12021
12022// [DEBUG] Display contents of ImDrawList
12023void ImGui::DebugNodeDrawList(ImGuiWindow* window, const ImDrawList* draw_list, const char* label)
12024{
12025 ImGuiContext& g = *GImGui;
12026 ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig;
12027 int cmd_count = draw_list->CmdBuffer.Size;
12028 if (cmd_count > 0 && draw_list->CmdBuffer.back().ElemCount == 0 && draw_list->CmdBuffer.back().UserCallback == NULL)
12029 cmd_count--;
12030 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);
12031 if (draw_list == GetWindowDrawList())
12032 {
12033 SameLine();
12034 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)
12035 if (node_open)
12036 TreePop();
12037 return;
12038 }
12039
12040 ImDrawList* fg_draw_list = GetForegroundDrawList(window); // Render additional visuals into the top-most draw list
12041 if (window && IsItemHovered() && fg_draw_list)
12042 fg_draw_list->AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255, 255, 0, 255));
12043 if (!node_open)
12044 return;
12045
12046 if (window && !window->WasActive)
12047 TextDisabled("Warning: owning Window is inactive. This DrawList is not being rendered!");
12048
12049 for (const ImDrawCmd* pcmd = draw_list->CmdBuffer.Data; pcmd < draw_list->CmdBuffer.Data + cmd_count; pcmd++)
12050 {
12051 if (pcmd->UserCallback)
12052 {
12053 BulletText("Callback %p, user_data %p", pcmd->UserCallback, pcmd->UserCallbackData);
12054 continue;
12055 }
12056
12057 char buf[300];
12058 ImFormatString(buf, IM_ARRAYSIZE(buf), "DrawCmd:%5d tris, Tex 0x%p, ClipRect (%4.0f,%4.0f)-(%4.0f,%4.0f)",
12059 pcmd->ElemCount / 3, (void*)(intptr_t)pcmd->TextureId,
12060 pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w);
12061 bool pcmd_node_open = TreeNode((void*)(pcmd - draw_list->CmdBuffer.begin()), "%s", buf);
12062 if (IsItemHovered() && (cfg->ShowDrawCmdMesh || cfg->ShowDrawCmdBoundingBoxes) && fg_draw_list)
12063 DebugNodeDrawCmdShowMeshAndBoundingBox(fg_draw_list, draw_list, pcmd, cfg->ShowDrawCmdMesh, cfg->ShowDrawCmdBoundingBoxes);
12064 if (!pcmd_node_open)
12065 continue;
12066
12067 // Calculate approximate coverage area (touched pixel count)
12068 // This will be in pixels squared as long there's no post-scaling happening to the renderer output.
12069 const ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL;
12070 const ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data + pcmd->VtxOffset;
12071 float total_area = 0.0f;
12072 for (unsigned int idx_n = pcmd->IdxOffset; idx_n < pcmd->IdxOffset + pcmd->ElemCount; )
12073 {
12074 ImVec2 triangle[3];
12075 for (int n = 0; n < 3; n++, idx_n++)
12076 triangle[n] = vtx_buffer[idx_buffer ? idx_buffer[idx_n] : idx_n].pos;
12077 total_area += ImTriangleArea(triangle[0], triangle[1], triangle[2]);
12078 }
12079
12080 // Display vertex information summary. Hover to get all triangles drawn in wire-frame

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected