[DEBUG] Display contents of ImDrawList
| 11281 | |
| 11282 | // [DEBUG] Display contents of ImDrawList |
| 11283 | void ImGui::DebugNodeDrawList(ImGuiWindow* window, const ImDrawList* draw_list, const char* label) |
| 11284 | { |
| 11285 | ImGuiContext& g = *GImGui; |
| 11286 | ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig; |
| 11287 | int cmd_count = draw_list->CmdBuffer.Size; |
| 11288 | if (cmd_count > 0 && draw_list->CmdBuffer.back().ElemCount == 0 && draw_list->CmdBuffer.back().UserCallback == NULL) |
| 11289 | cmd_count--; |
| 11290 | 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); |
| 11291 | if (draw_list == GetWindowDrawList()) |
| 11292 | { |
| 11293 | SameLine(); |
| 11294 | 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) |
| 11295 | if (node_open) |
| 11296 | TreePop(); |
| 11297 | return; |
| 11298 | } |
| 11299 | |
| 11300 | ImDrawList* fg_draw_list = GetForegroundDrawList(window); // Render additional visuals into the top-most draw list |
| 11301 | if (window && IsItemHovered()) |
| 11302 | fg_draw_list->AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255, 255, 0, 255)); |
| 11303 | if (!node_open) |
| 11304 | return; |
| 11305 | |
| 11306 | if (window && !window->WasActive) |
| 11307 | TextDisabled("Warning: owning Window is inactive. This DrawList is not being rendered!"); |
| 11308 | |
| 11309 | for (const ImDrawCmd* pcmd = draw_list->CmdBuffer.Data; pcmd < draw_list->CmdBuffer.Data + cmd_count; pcmd++) |
| 11310 | { |
| 11311 | if (pcmd->UserCallback) |
| 11312 | { |
| 11313 | BulletText("Callback %p, user_data %p", pcmd->UserCallback, pcmd->UserCallbackData); |
| 11314 | continue; |
| 11315 | } |
| 11316 | |
| 11317 | char buf[300]; |
| 11318 | ImFormatString(buf, IM_ARRAYSIZE(buf), "DrawCmd:%5d tris, Tex 0x%p, ClipRect (%4.0f,%4.0f)-(%4.0f,%4.0f)", |
| 11319 | pcmd->ElemCount / 3, (void*)(intptr_t)pcmd->TextureId, |
| 11320 | pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w); |
| 11321 | bool pcmd_node_open = TreeNode((void*)(pcmd - draw_list->CmdBuffer.begin()), "%s", buf); |
| 11322 | if (IsItemHovered() && (cfg->ShowDrawCmdMesh || cfg->ShowDrawCmdBoundingBoxes) && fg_draw_list) |
| 11323 | DebugNodeDrawCmdShowMeshAndBoundingBox(fg_draw_list, draw_list, pcmd, cfg->ShowDrawCmdMesh, cfg->ShowDrawCmdBoundingBoxes); |
| 11324 | if (!pcmd_node_open) |
| 11325 | continue; |
| 11326 | |
| 11327 | // Calculate approximate coverage area (touched pixel count) |
| 11328 | // This will be in pixels squared as long there's no post-scaling happening to the renderer output. |
| 11329 | const ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL; |
| 11330 | const ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data + pcmd->VtxOffset; |
| 11331 | float total_area = 0.0f; |
| 11332 | for (unsigned int idx_n = pcmd->IdxOffset; idx_n < pcmd->IdxOffset + pcmd->ElemCount; ) |
| 11333 | { |
| 11334 | ImVec2 triangle[3]; |
| 11335 | for (int n = 0; n < 3; n++, idx_n++) |
| 11336 | triangle[n] = vtx_buffer[idx_buffer ? idx_buffer[idx_n] : idx_n].pos; |
| 11337 | total_area += ImTriangleArea(triangle[0], triangle[1], triangle[2]); |
| 11338 | } |
| 11339 | |
| 11340 | // Display vertex information summary. Hover to get all triangles drawn in wire-frame |
nothing calls this directly
no test coverage detected