[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.
| 23136 | // [DEBUG] Display contents of ImDrawList |
| 23137 | // Note that both 'window' and 'viewport' may be NULL here. Viewport is generally null of destroyed popups which previously owned a viewport. |
| 23138 | void ImGui::DebugNodeDrawList(ImGuiWindow* window, ImGuiViewportP* viewport, const ImDrawList* draw_list, const char* label) |
| 23139 | { |
| 23140 | ImGuiContext& g = *GImGui; |
| 23141 | ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig; |
| 23142 | int cmd_count = draw_list->CmdBuffer.Size; |
| 23143 | if (cmd_count > 0 && draw_list->CmdBuffer.back().ElemCount == 0 && draw_list->CmdBuffer.back().UserCallback == NULL) |
| 23144 | cmd_count--; |
| 23145 | 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); |
| 23146 | if (draw_list == GetWindowDrawList()) |
| 23147 | { |
| 23148 | SameLine(); |
| 23149 | 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) |
| 23150 | if (node_open) |
| 23151 | TreePop(); |
| 23152 | return; |
| 23153 | } |
| 23154 | |
| 23155 | ImDrawList* fg_draw_list = viewport ? GetForegroundDrawList(viewport) : NULL; // Render additional visuals into the top-most draw list |
| 23156 | if (window && IsItemHovered() && fg_draw_list) |
| 23157 | fg_draw_list->AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255, 255, 0, 255)); |
| 23158 | if (!node_open) |
| 23159 | return; |
| 23160 | |
| 23161 | if (window && !window->WasActive) |
| 23162 | TextDisabled("Warning: owning Window is inactive. This DrawList is not being rendered!"); |
| 23163 | |
| 23164 | for (const ImDrawCmd* pcmd = draw_list->CmdBuffer.Data; pcmd < draw_list->CmdBuffer.Data + cmd_count; pcmd++) |
| 23165 | { |
| 23166 | if (pcmd->UserCallback) |
| 23167 | { |
| 23168 | BulletText("Callback %p, user_data %p", pcmd->UserCallback, pcmd->UserCallbackData); |
| 23169 | continue; |
| 23170 | } |
| 23171 | |
| 23172 | char texid_desc[30]; |
| 23173 | FormatTextureRefForDebugDisplay(texid_desc, IM_COUNTOF(texid_desc), pcmd->TexRef); |
| 23174 | char buf[300]; |
| 23175 | ImFormatString(buf, IM_COUNTOF(buf), "DrawCmd:%5d tris, Tex %s, ClipRect (%4.0f,%4.0f)-(%4.0f,%4.0f)", |
| 23176 | pcmd->ElemCount / 3, texid_desc, pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w); |
| 23177 | bool pcmd_node_open = TreeNode((void*)(pcmd - draw_list->CmdBuffer.begin()), "%s", buf); |
| 23178 | if (IsItemHovered() && (cfg->ShowDrawCmdMesh || cfg->ShowDrawCmdBoundingBoxes) && fg_draw_list) |
| 23179 | DebugNodeDrawCmdShowMeshAndBoundingBox(fg_draw_list, draw_list, pcmd, cfg->ShowDrawCmdMesh, cfg->ShowDrawCmdBoundingBoxes); |
| 23180 | if (!pcmd_node_open) |
| 23181 | continue; |
| 23182 | |
| 23183 | // Calculate approximate coverage area (touched pixel count) |
| 23184 | // This will be in pixels squared as long there's no post-scaling happening to the renderer output. |
| 23185 | const ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL; |
| 23186 | const ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data + pcmd->VtxOffset; |
| 23187 | float total_area = 0.0f; |
| 23188 | for (unsigned int idx_n = pcmd->IdxOffset; idx_n < pcmd->IdxOffset + pcmd->ElemCount; ) |
| 23189 | { |
| 23190 | ImVec2 triangle[3]; |
| 23191 | for (int n = 0; n < 3; n++, idx_n++) |
| 23192 | triangle[n] = vtx_buffer[idx_buffer ? idx_buffer[idx_n] : idx_n].pos; |
| 23193 | total_area += ImTriangleArea(triangle[0], triangle[1], triangle[2]); |
| 23194 | } |
| 23195 |
nothing calls this directly
no test coverage detected