AA branch: further use of ImVector<> Data/Size

This commit is contained in:
ocornut 2015-07-07 12:58:36 -06:00
parent c3ced1bd71
commit bfa7d86070
2 changed files with 17 additions and 17 deletions

View File

@ -9353,7 +9353,7 @@ void ImDrawList::PathArcToFast(const ImVec2& centre, float radius, int amin, int
}
else
{
path.reserve(path.size() + (amax - amin + 1));
path.reserve(path.Size + (amax - amin + 1));
for (int a = amin; a <= amax; a++)
{
const ImVec2& c = circle_vtx[a % circle_vtx_count];
@ -9366,7 +9366,7 @@ void ImDrawList::PathArcTo(const ImVec2& centre, float radius, float amin, float
{
if (radius == 0.0f)
path.push_back(centre);
path.reserve(path.size() + (num_segments + 1));
path.reserve(path.Size + (num_segments + 1));
for (int i = 0; i <= num_segments; i++)
{
const float a = amin + ((float)i / (float)num_segments) * (amax - amin);
@ -9495,14 +9495,14 @@ void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos,
// give back unused vertices
// FIXME-OPT
vtx_buffer.resize((int)(vtx_write - &vtx_buffer.front()));
idx_buffer.resize((int)(idx_write - &idx_buffer.front()));
vtx_buffer.resize((int)(vtx_write - vtx_buffer.Data));
idx_buffer.resize((int)(idx_write - idx_buffer.Data));
int vtx_unused = vtx_count_max - (vtx_buffer.Size - vtx_begin);
int idx_unused = idx_count_max - (idx_buffer.Size - idx_begin);
cmd_buffer.back().elem_count -= idx_unused;
vtx_write -= vtx_unused;
idx_write -= idx_unused;
vtx_current_idx = (ImDrawIdx)vtx_buffer.size();
vtx_current_idx = (ImDrawIdx)vtx_buffer.Size;
}
void ImDrawList::AddImage(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv0, const ImVec2& uv1, ImU32 col)
@ -9536,12 +9536,12 @@ void ImDrawData::DeIndexAllBuffers()
ImDrawList* cmd_list = cmd_lists[i];
if (cmd_list->idx_buffer.empty())
continue;
new_vtx_buffer.resize(cmd_list->idx_buffer.size());
for (int i = 0; i < cmd_list->idx_buffer.size(); i++)
new_vtx_buffer.resize(cmd_list->idx_buffer.Size);
for (int i = 0; i < cmd_list->idx_buffer.Size; i++)
new_vtx_buffer[i] = cmd_list->vtx_buffer[cmd_list->idx_buffer[i]];
cmd_list->vtx_buffer.swap(new_vtx_buffer);
cmd_list->idx_buffer.resize(0);
total_vtx_count += (int)cmd_list->vtx_buffer.size();
total_vtx_count += cmd_list->vtx_buffer.Size;
}
}
@ -11551,7 +11551,7 @@ void ImGui::ShowTestWindow(bool* opened)
ImGui::PlotLines("Frame Times", arr, IM_ARRAYSIZE(arr));
static bool pause;
static ImVector<float> values; if (values.empty()) { values.resize(90); memset(&values.front(), 0, values.Size*sizeof(float)); }
static ImVector<float> values; if (values.empty()) { values.resize(90); memset(values.Data, 0, values.Size*sizeof(float)); }
static int values_offset = 0;
if (!pause)
{
@ -11564,7 +11564,7 @@ void ImGui::ShowTestWindow(bool* opened)
phase += 0.10f*values_offset;
}
}
ImGui::PlotLines("##Graph", &values.front(), (int)values.Size, values_offset, "avg 0.0", -1.0f, 1.0f, ImVec2(0,80));
ImGui::PlotLines("##Graph", values.Data, values.Size, values_offset, "avg 0.0", -1.0f, 1.0f, ImVec2(0,80));
ImGui::SameLine(0, (int)ImGui::GetStyle().ItemInnerSpacing.x);
ImGui::BeginGroup();
ImGui::Text("Graph");

14
imgui.h
View File

@ -851,7 +851,7 @@ struct ImGuiTextBuffer
ImGuiTextBuffer() { Buf.push_back(0); }
const char* begin() const { return &Buf.front(); }
const char* end() const { return &Buf.back(); } // Buf is zero-terminated, so end() will point on the zero-terminator
int size() const { return Buf.size()-1; }
int size() const { return Buf.Size-1; }
bool empty() { return size() >= 1; }
void clear() { Buf.clear(); Buf.push_back(0); }
IMGUI_API void append(const char* fmt, ...);
@ -1034,7 +1034,7 @@ struct ImDrawList
// [Internal to ImGui]
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()
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<ImVec4> clip_rect_stack; // [Internal]
ImVector<ImTextureID> texture_id_stack; // [Internal]
@ -1067,8 +1067,8 @@ struct ImDrawList
IMGUI_API void PathArcToFast(const ImVec2& centre, float radius, int a_min, int a_max);
IMGUI_API void PathArcTo(const ImVec2& centre, float radius, float a_min, float a_max, int num_segments = 12);
IMGUI_API void PathRect(const ImVec2& a, const ImVec2& b, float rounding = 0.0f, int rounding_corners = 0x0F);
inline void PathFill(ImU32 col) { AddConvexPolyFilled(&path[0], (int)path.size(), col, true); PathClear(); }
inline void PathStroke(ImU32 col, float thickness, bool closed) { AddPolyline(&path[0], (int)path.size(), col, thickness, closed, true); PathClear(); }
inline void PathFill(ImU32 col) { AddConvexPolyFilled(path.Data, path.Size, col, true); PathClear(); }
inline void PathStroke(ImU32 col, float thickness, bool closed) { AddPolyline(path.Data, path.Size, col, thickness, closed, true); PathClear(); }
// Advanced
IMGUI_API void AddCallback(ImDrawCallback callback, void* callback_data); // Your rendering function must check for 'user_callback' in ImDrawCmd and call the function instead of rendering triangles.
@ -1087,8 +1087,8 @@ struct ImDrawData
{
ImDrawList** cmd_lists;
int cmd_lists_count;
int total_vtx_count; // For convenience, sum of all cmd_lists vtx_buffer.size()
int total_idx_count; // For convenience, sum of all cmd_lists idx_buffer.size()
int total_vtx_count; // For convenience, sum of all cmd_lists vtx_buffer.Size
int total_idx_count; // For convenience, sum of all cmd_lists idx_buffer.Size
// Functions
void DeIndexAllBuffers(); // For backward compatibility: convert all buffers from indexed to de-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
@ -1182,7 +1182,7 @@ struct ImFont
IMGUI_API ~ImFont();
IMGUI_API void Clear();
IMGUI_API void BuildLookupTable();
IMGUI_API float GetCharAdvance(unsigned short c) const { return ((int)c < IndexXAdvance.size()) ? IndexXAdvance[(int)c] : FallbackXAdvance; }
IMGUI_API float GetCharAdvance(unsigned short c) const { return ((int)c < IndexXAdvance.Size) ? IndexXAdvance[(int)c] : FallbackXAdvance; }
IMGUI_API const Glyph* FindGlyph(unsigned short c) const;
IMGUI_API void SetFallbackChar(ImWchar c);
IMGUI_API bool IsLoaded() const { return ContainerAtlas != NULL; }