MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / DebugNodeDrawList

Method DebugNodeDrawList

3rdparty/imgui/src/imgui.cpp:17255–17348  ·  view source on GitHub ↗

[DEBUG] Display contents of ImDrawList

Source from the content-addressed store, hash-verified

17253
17254// [DEBUG] Display contents of ImDrawList
17255void ImGui::DebugNodeDrawList(ImGuiWindow* window, ImGuiViewportP* viewport, const ImDrawList* draw_list, const char* label)
17256{
17257 ImGuiContext& g = *GImGui;
17258 IM_UNUSED(viewport); // Used in docking branch
17259 ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig;
17260 int cmd_count = draw_list->CmdBuffer.Size;
17261 if (cmd_count > 0 && draw_list->CmdBuffer.back().ElemCount == 0 && draw_list->CmdBuffer.back().UserCallback == NULL)
17262 cmd_count--;
17263 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);
17264 if (draw_list == GetWindowDrawList())
17265 {
17266 SameLine();
17267 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)
17268 if (node_open)
17269 TreePop();
17270 return;
17271 }
17272
17273 ImDrawList* fg_draw_list = GetForegroundDrawList(window); // Render additional visuals into the top-most draw list
17274 if (window && IsItemHovered() && fg_draw_list)
17275 fg_draw_list->AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255, 255, 0, 255));
17276 if (!node_open)
17277 return;
17278
17279 if (window && !window->WasActive)
17280 TextDisabled("Warning: owning Window is inactive. This DrawList is not being rendered!");
17281
17282 for (const ImDrawCmd* pcmd = draw_list->CmdBuffer.Data; pcmd < draw_list->CmdBuffer.Data + cmd_count; pcmd++)
17283 {
17284 if (pcmd->UserCallback)
17285 {
17286 BulletText("Callback %p, user_data %p", pcmd->UserCallback, pcmd->UserCallbackData);
17287 continue;
17288 }
17289
17290 char texid_desc[30];
17291 FormatTextureRefForDebugDisplay(texid_desc, IM_COUNTOF(texid_desc), pcmd->TexRef);
17292 char buf[300];
17293 ImFormatString(buf, IM_COUNTOF(buf), "DrawCmd:%5d tris, Tex %s, ClipRect (%4.0f,%4.0f)-(%4.0f,%4.0f)",
17294 pcmd->ElemCount / 3, texid_desc, pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w);
17295 bool pcmd_node_open = TreeNode((void*)(pcmd - draw_list->CmdBuffer.begin()), "%s", buf);
17296 if (IsItemHovered() && (cfg->ShowDrawCmdMesh || cfg->ShowDrawCmdBoundingBoxes) && fg_draw_list)
17297 DebugNodeDrawCmdShowMeshAndBoundingBox(fg_draw_list, draw_list, pcmd, cfg->ShowDrawCmdMesh, cfg->ShowDrawCmdBoundingBoxes);
17298 if (!pcmd_node_open)
17299 continue;
17300
17301 // Calculate approximate coverage area (touched pixel count)
17302 // This will be in pixels squared as long there's no post-scaling happening to the renderer output.
17303 const ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL;
17304 const ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data + pcmd->VtxOffset;
17305 float total_area = 0.0f;
17306 for (unsigned int idx_n = pcmd->IdxOffset; idx_n < pcmd->IdxOffset + pcmd->ElemCount; )
17307 {
17308 ImVec2 triangle[3];
17309 for (int n = 0; n < 3; n++, idx_n++)
17310 triangle[n] = vtx_buffer[idx_buffer ? idx_buffer[idx_n] : idx_n].pos;
17311 total_area += ImTriangleArea(triangle[0], triangle[1], triangle[2]);
17312 }

Callers

nothing calls this directly

Calls 11

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

Tested by

no test coverage detected