Texture-based round corners: Default circle segment count to 0 + fix warnings, remove unused macro

This commit is contained in:
omar 2020-01-23 15:08:20 +01:00 committed by ocornut
parent 9a9b5cc886
commit 57e6b1e7da
2 changed files with 4 additions and 15 deletions

View File

@ -1427,8 +1427,7 @@ inline bool AddRoundCornerRect(ImDrawList* draw_list, const ImVec2& a, const ImV
// Filled rectangles have no stroke width
const int stroke_width = fill ? 1 : (int)thickness;
if ((stroke_width <= 0) || (stroke_width > ImFontAtlasRoundCornersMaxStrokeWidth))
if (stroke_width <= 0 || (int)stroke_width > ImFontAtlasRoundCornersMaxStrokeWidth)
return false; // We can't handle this
// If we have a >1 stroke width, we actually need to increase the radius appropriately as well to match how the geometry renderer does things
@ -1535,15 +1534,6 @@ inline bool AddRoundCornerRect(ImDrawList* draw_list, const ImVec2& a, const ImV
// the diagonal (as we only have 45 degrees' worth of actual valid pixel data)
// This needs to be done the opposite way around for filled vs unfilled as they
// each occupy one side of the texture
#define VTX_WRITE_LERPED(d, corner, px, py) \
draw_list->_VtxWritePtr[d].pos = ImVec2(ImLerp(i##corner.x, c##corner.x, px), ImLerp(i##corner.y, c##corner.y, py)); \
draw_list->_VtxWritePtr[d].uv = ((px < py) ^ use_alternative_uvs) ? \
ImVec2(ImLerp(corner_uv[0].x, corner_uv[b##corner ? 2 : 1].x, py), ImLerp(corner_uv[0].y, corner_uv[b##corner ? 2 : 1].y, px)) : \
ImVec2(ImLerp(corner_uv[0].x, corner_uv[b##corner ? 2 : 1].x, px), ImLerp(corner_uv[0].y, corner_uv[b##corner ? 2 : 1].y, py)); \
draw_list->_VtxWritePtr[d].col = col
// Optimized versions of the above, for the cases where either px or py is always zero
#define VTX_WRITE_LERPED_X(d, corner, px) \
draw_list->_VtxWritePtr[d].pos = ImVec2(ImLerp(i##corner.x, c##corner.x, px), i##corner.y); \
draw_list->_VtxWritePtr[d].uv = use_alternative_uvs ? \
@ -3827,7 +3817,6 @@ static void ImFontAtlasBuildRegisterRoundCornersCustomRects(ImFontAtlas* atlas)
int spare_rect_id = -1; // The last rectangle ID we generated with a spare half
for (unsigned int stroke_width_index = 0; stroke_width_index < max_thickness; stroke_width_index++)
{
//const unsigned int index = stroke_width_index + (radius_index * ImFontAtlasRoundCornersMaxStrokeWidth);
const int width = radius_index + 1 + pad * 2;
const int height = radius_index + 1 + FONT_ATLAS_ROUNDED_CORNER_TEX_CENTER_PADDING + pad * 2;

View File

@ -3681,12 +3681,12 @@ IMGUI_API void ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_ta
IMGUI_API void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256], unsigned char* pixels, int x, int y, int w, int h, int stride);
// Note that stroke width increases effective radius, so (e.g.) a max radius circle will have to use the fallback path if stroke width is > 1
const unsigned int ImFontAtlasRoundCornersMaxSize = 32; // Maximum size of rounded corner texture to generate in fonts
const unsigned int ImFontAtlasRoundCornersMaxStrokeWidth = 5; // Maximum stroke width of rounded corner texture to generate in fonts
const int ImFontAtlasRoundCornersMaxSize = 32; // Maximum size of rounded corner texture to generate in fonts
const int ImFontAtlasRoundCornersMaxStrokeWidth = 5; // Maximum stroke width of rounded corner texture to generate in fonts
// Bit mask for which stroke widths should have textures generated for them (the default of 0xD means widths 1, 2 and 4)
// Only bits up to ImFontAtlasRoundCornersMaxStrokeWidth are considered, and bit 0 (stroke width 1) must always be set
// Optimally there should be an odd number of bits set, as the texture packing packs the data in pairs, with one half of one pair being occupied by the filled texture
const unsigned int ImFontAtlasRoundCornersStrokeWidthMask = 0xD;
const int ImFontAtlasRoundCornersStrokeWidthMask = 0xD;
//-----------------------------------------------------------------------------
// [SECTION] Test Engine specific hooks (imgui_test_engine)