From 6a22835f63769b0e9b6e84e7361851ba3aededd4 Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 6 Jul 2015 21:09:05 -0600 Subject: [PATCH] AA branch: ImDrawList: rename commands to cmd_buffer Not strictly necessary but while we're doing minor breakage let's do them at all once. --- .../directx11_example/imgui_impl_dx11.cpp | 4 +-- examples/directx9_example/imgui_impl_dx9.cpp | 4 +-- .../opengl3_example/imgui_impl_glfw_gl3.cpp | 4 +-- examples/opengl_example/imgui_impl_glfw.cpp | 4 +-- imgui.cpp | 32 +++++++++---------- imgui.h | 12 +++---- 6 files changed, 30 insertions(+), 30 deletions(-) diff --git a/examples/directx11_example/imgui_impl_dx11.cpp b/examples/directx11_example/imgui_impl_dx11.cpp index de02fd01..89f0ff4b 100644 --- a/examples/directx11_example/imgui_impl_dx11.cpp +++ b/examples/directx11_example/imgui_impl_dx11.cpp @@ -119,9 +119,9 @@ static void ImGui_ImplDX11_RenderDrawLists(ImDrawData* draw_data) for (int n = 0; n < draw_data->cmd_lists_count; n++) { const ImDrawList* cmd_list = draw_data->cmd_lists[n]; - for (size_t cmd_i = 0; cmd_i < cmd_list->commands.size(); cmd_i++) + for (size_t cmd_i = 0; cmd_i < cmd_list->cmd_buffer.size(); cmd_i++) { - const ImDrawCmd* pcmd = &cmd_list->commands[cmd_i]; + const ImDrawCmd* pcmd = &cmd_list->cmd_buffer[cmd_i]; if (pcmd->user_callback) { pcmd->user_callback(cmd_list, pcmd); diff --git a/examples/directx9_example/imgui_impl_dx9.cpp b/examples/directx9_example/imgui_impl_dx9.cpp index 654d767e..91e81fcc 100644 --- a/examples/directx9_example/imgui_impl_dx9.cpp +++ b/examples/directx9_example/imgui_impl_dx9.cpp @@ -97,9 +97,9 @@ static void ImGui_ImplDX9_RenderDrawLists(ImDrawData* draw_data) for (int n = 0; n < draw_data->cmd_lists_count; n++) { const ImDrawList* cmd_list = draw_data->cmd_lists[n]; - for (size_t cmd_i = 0; cmd_i < cmd_list->commands.size(); cmd_i++) + for (size_t cmd_i = 0; cmd_i < cmd_list->cmd_buffer.size(); cmd_i++) { - const ImDrawCmd* pcmd = &cmd_list->commands[cmd_i]; + const ImDrawCmd* pcmd = &cmd_list->cmd_buffer[cmd_i]; if (pcmd->user_callback) { pcmd->user_callback(cmd_list, pcmd); diff --git a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp index 84c70dfd..2b80fbb0 100644 --- a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp +++ b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp @@ -86,8 +86,8 @@ static void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawData* draw_data) const ImDrawList* cmd_list = draw_data->cmd_lists[n]; const ImDrawIdx* idx_buffer = (const unsigned short*)&cmd_list->idx_buffer.front(); - const ImDrawCmd* pcmd_end = cmd_list->commands.end(); - for (const ImDrawCmd* pcmd = cmd_list->commands.begin(); pcmd != pcmd_end; pcmd++) + const ImDrawCmd* pcmd_end = cmd_list->cmd_buffer.end(); + for (const ImDrawCmd* pcmd = cmd_list->cmd_buffer.begin(); pcmd != pcmd_end; pcmd++) { if (pcmd->user_callback) { diff --git a/examples/opengl_example/imgui_impl_glfw.cpp b/examples/opengl_example/imgui_impl_glfw.cpp index 037850a5..a60d8f00 100644 --- a/examples/opengl_example/imgui_impl_glfw.cpp +++ b/examples/opengl_example/imgui_impl_glfw.cpp @@ -62,9 +62,9 @@ static void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data) glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF(ImDrawVert, uv))); glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF(ImDrawVert, col))); - for (size_t cmd_i = 0; cmd_i < cmd_list->commands.size(); cmd_i++) + for (size_t cmd_i = 0; cmd_i < cmd_list->cmd_buffer.size(); cmd_i++) { - const ImDrawCmd* pcmd = &cmd_list->commands[cmd_i]; + const ImDrawCmd* pcmd = &cmd_list->cmd_buffer[cmd_i]; if (pcmd->user_callback) { pcmd->user_callback(cmd_list, pcmd); diff --git a/imgui.cpp b/imgui.cpp index 7e3813e8..7325a77a 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1902,10 +1902,10 @@ void ImGuiWindow::FocusItemUnregister() static inline void AddDrawListToRenderList(ImVector& out_render_list, ImDrawList* draw_list) { - if (!draw_list->commands.empty() && !draw_list->vtx_buffer.empty()) + if (!draw_list->cmd_buffer.empty() && !draw_list->vtx_buffer.empty()) { - if (draw_list->commands.back().elem_count == 0) - draw_list->commands.pop_back(); + if (draw_list->cmd_buffer.back().elem_count == 0) + draw_list->cmd_buffer.pop_back(); out_render_list.push_back(draw_list); GImGui->IO.MetricsRenderVertices += (int)draw_list->vtx_buffer.size(); GImGui->IO.MetricsRenderIndices += (int)draw_list->idx_buffer.size(); @@ -8964,7 +8964,7 @@ static ImVec4 GNullClipRect(-9999.0f,-9999.0f, +9999.0f, +9999.0f); void ImDrawList::Clear() { - commands.resize(0); + cmd_buffer.resize(0); vtx_buffer.resize(0); vtx_write = NULL; vtx_current_idx = 0; @@ -8976,7 +8976,7 @@ void ImDrawList::Clear() void ImDrawList::ClearFreeMemory() { - commands.clear(); + cmd_buffer.clear(); vtx_buffer.clear(); vtx_write = NULL; vtx_current_idx = 0; @@ -8996,16 +8996,16 @@ void ImDrawList::AddDrawCmd() draw_cmd.user_callback_data = NULL; IM_ASSERT(draw_cmd.clip_rect.x <= draw_cmd.clip_rect.z && draw_cmd.clip_rect.y <= draw_cmd.clip_rect.w); - commands.push_back(draw_cmd); + cmd_buffer.push_back(draw_cmd); } void ImDrawList::AddCallback(ImDrawCallback callback, void* callback_data) { - ImDrawCmd* current_cmd = commands.empty() ? NULL : &commands.back(); + ImDrawCmd* current_cmd = cmd_buffer.empty() ? NULL : &cmd_buffer.back(); if (!current_cmd || current_cmd->elem_count != 0 || current_cmd->user_callback != NULL) { AddDrawCmd(); - current_cmd = &commands.back(); + current_cmd = &cmd_buffer.back(); } current_cmd->user_callback = callback; current_cmd->user_callback_data = callback_data; @@ -9017,7 +9017,7 @@ void ImDrawList::AddCallback(ImDrawCallback callback, void* callback_data) void ImDrawList::UpdateClipRect() { - ImDrawCmd* current_cmd = commands.empty() ? NULL : &commands.back(); + ImDrawCmd* current_cmd = cmd_buffer.empty() ? NULL : &cmd_buffer.back(); if (!current_cmd || (current_cmd->elem_count != 0) || current_cmd->user_callback != NULL) { AddDrawCmd(); @@ -9025,8 +9025,8 @@ void ImDrawList::UpdateClipRect() else { ImVec4 current_clip_rect = clip_rect_stack.empty() ? GNullClipRect : clip_rect_stack.back(); - if (commands.size() >= 2 && ImLengthSqr(commands[commands.size()-2].clip_rect - current_clip_rect) < 0.00001f) - commands.pop_back(); + if (cmd_buffer.size() >= 2 && ImLengthSqr(cmd_buffer[cmd_buffer.size()-2].clip_rect - current_clip_rect) < 0.00001f) + cmd_buffer.pop_back(); else current_cmd->clip_rect = current_clip_rect; } @@ -9057,7 +9057,7 @@ void ImDrawList::PopClipRect() void ImDrawList::UpdateTextureID() { - ImDrawCmd* current_cmd = commands.empty() ? NULL : &commands.back(); + ImDrawCmd* current_cmd = cmd_buffer.empty() ? NULL : &cmd_buffer.back(); const ImTextureID texture_id = texture_id_stack.empty() ? NULL : texture_id_stack.back(); if (!current_cmd || (current_cmd->elem_count != 0 && current_cmd->texture_id != texture_id) || current_cmd->user_callback != NULL) { @@ -9084,7 +9084,7 @@ void ImDrawList::PopTextureID() void ImDrawList::PrimReserve(unsigned int idx_count, unsigned int vtx_count) { - ImDrawCmd& draw_cmd = commands.back(); + ImDrawCmd& draw_cmd = cmd_buffer.back(); draw_cmd.elem_count += idx_count; size_t vtx_buffer_size = vtx_buffer.size(); @@ -9504,7 +9504,7 @@ void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos, idx_buffer.resize((size_t)(idx_write - &idx_buffer.front())); unsigned int vtx_unused = vtx_count_max - (unsigned int)(vtx_buffer.size() - vtx_begin); unsigned int idx_unused = idx_count_max - (unsigned int)(idx_buffer.size() - idx_begin); - commands.back().elem_count -= idx_unused; + cmd_buffer.back().elem_count -= idx_unused; vtx_write -= vtx_unused; idx_write -= idx_unused; vtx_current_idx = (ImDrawIdx)vtx_buffer.size(); @@ -12232,7 +12232,7 @@ void ImGui::ShowMetricsWindow(bool* opened) { static void NodeDrawList(ImDrawList* draw_list, const char* label) { - bool node_opened = ImGui::TreeNode(draw_list, "%s: '%s' %d vtx, %d indices, %d cmds", label, draw_list->owner_name ? draw_list->owner_name : "", draw_list->vtx_buffer.size(), draw_list->idx_buffer.size(), draw_list->commands.size()); + bool node_opened = ImGui::TreeNode(draw_list, "%s: '%s' %d vtx, %d indices, %d cmds", label, draw_list->owner_name ? draw_list->owner_name : "", draw_list->vtx_buffer.size(), draw_list->idx_buffer.size(), draw_list->cmd_buffer.size()); if (draw_list == ImGui::GetWindowDrawList()) { ImGui::SameLine(); @@ -12242,7 +12242,7 @@ void ImGui::ShowMetricsWindow(bool* opened) return; int elem_offset = 0; - for (const ImDrawCmd* pcmd = draw_list->commands.begin(); pcmd < draw_list->commands.end(); elem_offset += pcmd->elem_count, pcmd++) + for (const ImDrawCmd* pcmd = draw_list->cmd_buffer.begin(); pcmd < draw_list->cmd_buffer.end(); elem_offset += pcmd->elem_count, pcmd++) if (pcmd->user_callback) ImGui::BulletText("Callback %p, user_data %p", pcmd->user_callback, pcmd->user_callback_data); else diff --git a/imgui.h b/imgui.h index b31e59a8..5848a9d7 100644 --- a/imgui.h +++ b/imgui.h @@ -1033,18 +1033,18 @@ IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT; struct ImDrawList { // This is what you have to render - ImVector commands; // Commands. Typically 1 command = 1 gpu draw call. - ImVector vtx_buffer; // Vertex buffer. Each command consume ImDrawCmd::vtx_count of those + ImVector cmd_buffer; // Commands. Typically 1 command = 1 gpu draw call. + ImVector vtx_buffer; // Vertex buffer. ImVector idx_buffer; // Index buffer. Each command consume ImDrawCmd::idx_count of those // [Internal to ImGui] - const char* owner_name; // Pointer to owner window's name, if any - ImVector clip_rect_stack; // [Internal] - ImVector texture_id_stack; // [Internal] - ImVector path; // [Internal] current path building + const char* owner_name; // Pointer to owner window's name (if any) for debugging ImDrawVert* vtx_write; // [Internal] point within vtx_buffer after each add command (to avoid using the ImVector<> operators too much) unsigned int vtx_current_idx; // [Internal] == vtx_buffer.size() ImDrawIdx* idx_write; // [Internal] point within idx_buffer after each add command (to avoid using the ImVector<> operators too much) + ImVector clip_rect_stack; // [Internal] + ImVector texture_id_stack; // [Internal] + ImVector path; // [Internal] current path building ImDrawList() { owner_name = NULL; Clear(); } IMGUI_API void Clear();