ImDrawList::AddImageRounded: removed PrimDistributeUV declaration, fixed coding style, restored argument order from original PR. (#845)

This commit is contained in:
omar
2017-11-20 13:31:40 +01:00
parent 3c5e64db78
commit 31683cfe34
2 changed files with 8 additions and 20 deletions

View File

@ -1124,7 +1124,6 @@ void ImDrawList::AddImage(ImTextureID user_texture_id, const ImVec2& a, const Im
if ((col & IM_COL32_A_MASK) == 0)
return;
// FIXME-OPT: This is wasting draw calls.
const bool push_texture_id = _TextureIdStack.empty() || user_texture_id != _TextureIdStack.back();
if (push_texture_id)
PushTextureID(user_texture_id);
@ -1152,36 +1151,26 @@ void ImDrawList::AddImageQuad(ImTextureID user_texture_id, const ImVec2& a, cons
PopTextureID();
}
void ImDrawList::AddImageRounded(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, float rounding, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col, int rounding_corners)
void ImDrawList::AddImageRounded(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col, float rounding, int rounding_corners)
{
if ((col & IM_COL32_A_MASK) == 0)
return;
if (rounding <= 0.0f)
if (rounding <= 0.0f || (rounding_corners & ImGuiCorner_All) == 0)
{
AddImage(user_texture_id, a, b, uv_a, uv_b, col);
return;
}
// FIXME-OPT: This is wasting draw calls.
const bool push_texture_id = _TextureIdStack.empty() || user_texture_id != _TextureIdStack.back();
if (push_texture_id)
PushTextureID(user_texture_id);
if (rounding > 0.0f && rounding_corners != 0)
{
size_t startIndex = VtxBuffer.size();
PathRect(a, b, rounding, rounding_corners);
PathFillConvex(col);
size_t endIndex = VtxBuffer.size();
ImGui::ShadeVertsLinearUV(VtxBuffer.Data + startIndex, VtxBuffer.Data + endIndex, a, b, uv_a, uv_b, true);
}
else
{
PrimReserve(6, 4);
PrimRectUV(a, b, uv_a, uv_b, col);
}
int vert_start_idx = VtxBuffer.Size;
PathRect(a, b, rounding, rounding_corners);
PathFillConvex(col);
int vert_end_idx = VtxBuffer.Size;
ImGui::ShadeVertsLinearUV(VtxBuffer.Data + vert_start_idx, VtxBuffer.Data + vert_end_idx, a, b, uv_a, uv_b, true);
if (push_texture_id)
PopTextureID();