DrawList: skip PathLineTo/PathStroke calls for common AddLine(), AddLineH(), AddLineV() functions. (#4091)
This commit is contained in:
@@ -55,6 +55,8 @@ Other Changes:
|
|||||||
- Fonts:
|
- Fonts:
|
||||||
- Added `IMGUI_DISABLE_DEFAULT_FONT_BITMAP`/`IMGUI_DISABLE_DEFAULT_FONT_VECTOR` to
|
- Added `IMGUI_DISABLE_DEFAULT_FONT_BITMAP`/`IMGUI_DISABLE_DEFAULT_FONT_VECTOR` to
|
||||||
disable embedding either fonts separately. (#9407)
|
disable embedding either fonts separately. (#9407)
|
||||||
|
- DrawList:
|
||||||
|
- Minor optimization to AddLine(), AddLineH(), AddLineV() functions. (#4091)
|
||||||
- Demo:
|
- Demo:
|
||||||
- Extract 'Widgets->Tree Nodes->Selectable Nodes' out of the 'Advanced'
|
- Extract 'Widgets->Tree Nodes->Selectable Nodes' out of the 'Advanced'
|
||||||
demo for clarity (manual reimplementation of basic selection).
|
demo for clarity (manual reimplementation of basic selection).
|
||||||
|
|||||||
+6
-9
@@ -1480,27 +1480,24 @@ void ImDrawList::AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float th
|
|||||||
{
|
{
|
||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
PathLineTo(p1 + ImVec2(0.5f, 0.5f));
|
const ImVec2 points[2] = { ImVec2(p1.x + 0.5f, p1.y + 0.5f), ImVec2(p2.x + 0.5f, p2.y + 0.5f) };
|
||||||
PathLineTo(p2 + ImVec2(0.5f, 0.5f));
|
AddPolyline(points, 2, col, thickness);
|
||||||
PathStroke(col, thickness);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::AddLineH(float min_x, float max_x, float y, ImU32 col, float thickness)
|
void ImDrawList::AddLineH(float min_x, float max_x, float y, ImU32 col, float thickness)
|
||||||
{
|
{
|
||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
PathLineTo(ImVec2(min_x + 0.5f, y + 0.5f)); // Same as AddLine() above.
|
const ImVec2 points[2] = { ImVec2(min_x + 0.5f, y + 0.5f), ImVec2(max_x + 0.5f, y + 0.5f) }; // Same as AddLine() above.
|
||||||
PathLineTo(ImVec2(max_x + 0.5f, y + 0.5f));
|
AddPolyline(points, 2, col, thickness);
|
||||||
PathStroke(col, thickness);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::AddLineV(float x, float min_y, float max_y, ImU32 col, float thickness)
|
void ImDrawList::AddLineV(float x, float min_y, float max_y, ImU32 col, float thickness)
|
||||||
{
|
{
|
||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
PathLineTo(ImVec2(x + 0.5f, min_y + 0.5f)); // Same as AddLine() above.
|
const ImVec2 points[2] = { ImVec2(x + 0.5f, min_y + 0.5f), ImVec2(x + 0.5f, max_y + 0.5f) }; // Same as AddLine() above.
|
||||||
PathLineTo(ImVec2(x + 0.5f, max_y + 0.5f));
|
AddPolyline(points, 2, col, thickness);
|
||||||
PathStroke(col, thickness);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// p_min = upper-left, p_max = lower-right
|
// p_min = upper-left, p_max = lower-right
|
||||||
|
|||||||
Reference in New Issue
Block a user