Texture-based round corners: Fix building for stroke width 1,2,4 instead of 1,3,4.

This commit is contained in:
ocornut 2020-06-04 18:47:16 +02:00
parent e6a3a78d2a
commit 15920ed2a4
2 changed files with 8 additions and 9 deletions

10
imgui.h
View File

@ -3244,11 +3244,11 @@ struct ImFontGlyphRangesBuilder
// Data for texture-based rounded corners for a given radius
struct ImFontRoundedCornerData
{
ImVec4 TexUvFilled; // UV of filled round corner quad in the atlas (only valid when stroke width is 1)
ImVec4 TexUvStroked; // UV of stroked round corner quad in the atlas
float ParametricStrokeWidth; // Pre-calculated value for stroke width divided by the radius
int RectId; // Rect ID in the atlas, or -1 if there is no data
bool StrokedUsesAlternateUVs; // True if stroked drawing should use the alternate (i.e. other corner) UVs
ImVec4 TexUvFilled; // UV of filled round corner quad in the atlas (only valid when stroke width is 1)
ImVec4 TexUvStroked; // UV of stroked round corner quad in the atlas
float ParametricStrokeWidth; // Pre-calculated value for stroke width divided by the radius
int RectId; // Rect ID in the atlas, or -1 if there is no data
bool StrokedUsesAlternateUVs; // True if stroked drawing should use the alternate (i.e. other corner) UVs
};
// See ImFontAtlas::AddCustomRectXXX functions.

View File

@ -795,7 +795,6 @@ struct IMGUI_API ImDrawListSharedData
ImU8 CircleSegmentCounts[64]; // Precomputed segment count for given radius before we calculate it dynamically (to avoid calculation overhead)
const ImVec4* TexUvLines; // UV of anti-aliased lines in the atlas
// FIXME-ROUNDCORNERS: WIP + need to remove CircleVtx12 before PR
ImVector<ImFontRoundedCornerData>* TexRoundCornerData; // Data for texture-based rounded corners, indexed by radius
ImDrawListSharedData();
@ -3683,11 +3682,11 @@ IMGUI_API void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table
// 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 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)
const int ImFontAtlasRoundCornersMaxStrokeWidth = 4; // 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 0x0B 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 int ImFontAtlasRoundCornersStrokeWidthMask = 0xD;
const int ImFontAtlasRoundCornersStrokeWidthMask = 0x0B;
//-----------------------------------------------------------------------------
// [SECTION] Test Engine specific hooks (imgui_test_engine)