[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.
| 21972 | // [DEBUG] Display contents of ImDrawList |
| 21973 | // Note that both 'window' and 'viewport' may be NULL here. Viewport is generally null of destroyed popups which previously owned a viewport. |
| 21974 | void ImGui::DebugNodeDrawList(ImGuiWindow* window, ImGuiViewportP* viewport, const ImDrawList* draw_list, const char* label) |
| 21975 | { |
| 21976 | ImGuiContext& g = *GImGui; |
| 21977 | ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig; |
| 21978 | int cmd_count = draw_list->CmdBuffer.Size; |
| 21979 | if (cmd_count > 0 && draw_list->CmdBuffer.back().ElemCount == 0 && draw_list->CmdBuffer.back().UserCallback == NULL) |
| 21980 | cmd_count--; |
| 21981 | 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); |
| 21982 | if (draw_list == GetWindowDrawList()) |
| 21983 | { |
| 21984 | SameLine(); |
| 21985 | 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) |
| 21986 | if (node_open) |
| 21987 | TreePop(); |
| 21988 | return; |
| 21989 | } |
| 21990 | |
| 21991 | ImDrawList* fg_draw_list = viewport ? GetForegroundDrawList(viewport) : NULL; // Render additional visuals into the top-most draw list |
| 21992 | if (window && IsItemHovered() && fg_draw_list) |
| 21993 | fg_draw_list->AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255, 255, 0, 255)); |
| 21994 | if (!node_open) |
| 21995 | return; |
| 21996 | |
| 21997 | if (window && !window->WasActive) |
| 21998 | TextDisabled("Warning: owning Window is inactive. This DrawList is not being rendered!"); |
| 21999 | |
| 22000 | for (const ImDrawCmd* pcmd = draw_list->CmdBuffer.Data; pcmd < draw_list->CmdBuffer.Data + cmd_count; pcmd++) |
| 22001 | { |
| 22002 | if (pcmd->UserCallback) |
| 22003 | { |
| 22004 | BulletText("Callback %p, user_data %p", pcmd->UserCallback, pcmd->UserCallbackData); |
| 22005 | continue; |
| 22006 | } |
| 22007 | |
| 22008 | char texid_desc[20]; |
| 22009 | FormatTextureIDForDebugDisplay(texid_desc, IM_ARRAYSIZE(texid_desc), pcmd->TextureId); |
| 22010 | char buf[300]; |
| 22011 | ImFormatString(buf, IM_ARRAYSIZE(buf), "DrawCmd:%5d tris, Tex %s, ClipRect (%4.0f,%4.0f)-(%4.0f,%4.0f)", |
| 22012 | pcmd->ElemCount / 3, texid_desc, pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w); |
| 22013 | bool pcmd_node_open = TreeNode((void*)(pcmd - draw_list->CmdBuffer.begin()), "%s", buf); |
| 22014 | if (IsItemHovered() && (cfg->ShowDrawCmdMesh || cfg->ShowDrawCmdBoundingBoxes) && fg_draw_list) |
| 22015 | DebugNodeDrawCmdShowMeshAndBoundingBox(fg_draw_list, draw_list, pcmd, cfg->ShowDrawCmdMesh, cfg->ShowDrawCmdBoundingBoxes); |
| 22016 | if (!pcmd_node_open) |
| 22017 | continue; |
| 22018 | |
| 22019 | // Calculate approximate coverage area (touched pixel count) |
| 22020 | // This will be in pixels squared as long there's no post-scaling happening to the renderer output. |
| 22021 | const ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL; |
| 22022 | const ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data + pcmd->VtxOffset; |
| 22023 | float total_area = 0.0f; |
| 22024 | for (unsigned int idx_n = pcmd->IdxOffset; idx_n < pcmd->IdxOffset + pcmd->ElemCount; ) |
| 22025 | { |
| 22026 | ImVec2 triangle[3]; |
| 22027 | for (int n = 0; n < 3; n++, idx_n++) |
| 22028 | triangle[n] = vtx_buffer[idx_buffer ? idx_buffer[idx_n] : idx_n].pos; |
| 22029 | total_area += ImTriangleArea(triangle[0], triangle[1], triangle[2]); |
| 22030 | } |
| 22031 |
nothing calls this directly
no test coverage detected