[DEBUG] Display contents of ImDrawList Note that both 'window' and 'viewport' may be NULL here. Viewport is generally null of destroyed popups which previously owned a viewport.
| 19300 | // [DEBUG] Display contents of ImDrawList |
| 19301 | // Note that both 'window' and 'viewport' may be NULL here. Viewport is generally null of destroyed popups which previously owned a viewport. |
| 19302 | void ImGui::DebugNodeDrawList(ImGuiWindow* window, ImGuiViewportP* viewport, const ImDrawList* draw_list, const char* label) |
| 19303 | { |
| 19304 | ImGuiContext& g = *GImGui; |
| 19305 | ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig; |
| 19306 | int cmd_count = draw_list->CmdBuffer.Size; |
| 19307 | if (cmd_count > 0 && draw_list->CmdBuffer.back().ElemCount == 0 && draw_list->CmdBuffer.back().UserCallback == NULL) |
| 19308 | cmd_count--; |
| 19309 | 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); |
| 19310 | if (draw_list == GetWindowDrawList()) |
| 19311 | { |
| 19312 | SameLine(); |
| 19313 | 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) |
| 19314 | if (node_open) |
| 19315 | TreePop(); |
| 19316 | return; |
| 19317 | } |
| 19318 | |
| 19319 | ImDrawList* fg_draw_list = viewport ? GetForegroundDrawList(viewport) : NULL; // Render additional visuals into the top-most draw list |
| 19320 | if (window && IsItemHovered() && fg_draw_list) |
| 19321 | fg_draw_list->AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255, 255, 0, 255)); |
| 19322 | if (!node_open) |
| 19323 | return; |
| 19324 | |
| 19325 | if (window && !window->WasActive) |
| 19326 | TextDisabled("Warning: owning Window is inactive. This DrawList is not being rendered!"); |
| 19327 | |
| 19328 | for (const ImDrawCmd* pcmd = draw_list->CmdBuffer.Data; pcmd < draw_list->CmdBuffer.Data + cmd_count; pcmd++) |
| 19329 | { |
| 19330 | if (pcmd->UserCallback) |
| 19331 | { |
| 19332 | BulletText("Callback %p, user_data %p", pcmd->UserCallback, pcmd->UserCallbackData); |
| 19333 | continue; |
| 19334 | } |
| 19335 | |
| 19336 | char buf[300]; |
| 19337 | ImFormatString(buf, IM_ARRAYSIZE(buf), "DrawCmd:%5d tris, Tex 0x%p, ClipRect (%4.0f,%4.0f)-(%4.0f,%4.0f)", |
| 19338 | pcmd->ElemCount / 3, (void*)(intptr_t)pcmd->TextureId, |
| 19339 | pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w); |
| 19340 | bool pcmd_node_open = TreeNode((void*)(pcmd - draw_list->CmdBuffer.begin()), "%s", buf); |
| 19341 | if (IsItemHovered() && (cfg->ShowDrawCmdMesh || cfg->ShowDrawCmdBoundingBoxes) && fg_draw_list) |
| 19342 | DebugNodeDrawCmdShowMeshAndBoundingBox(fg_draw_list, draw_list, pcmd, cfg->ShowDrawCmdMesh, cfg->ShowDrawCmdBoundingBoxes); |
| 19343 | if (!pcmd_node_open) |
| 19344 | continue; |
| 19345 | |
| 19346 | // Calculate approximate coverage area (touched pixel count) |
| 19347 | // This will be in pixels squared as long there's no post-scaling happening to the renderer output. |
| 19348 | const ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL; |
| 19349 | const ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data + pcmd->VtxOffset; |
| 19350 | float total_area = 0.0f; |
| 19351 | for (unsigned int idx_n = pcmd->IdxOffset; idx_n < pcmd->IdxOffset + pcmd->ElemCount; ) |
| 19352 | { |
| 19353 | ImVec2 triangle[3]; |
| 19354 | for (int n = 0; n < 3; n++, idx_n++) |
| 19355 | triangle[n] = vtx_buffer[idx_buffer ? idx_buffer[idx_n] : idx_n].pos; |
| 19356 | total_area += ImTriangleArea(triangle[0], triangle[1], triangle[2]); |
| 19357 | } |
| 19358 | |
| 19359 | // Display vertex information summary. Hover to get all triangles drawn in wire-frame |
nothing calls this directly
no test coverage detected