1074 Commits

Author SHA1 Message Date
ocornut
9b608ba079 DrawList: fixed warnings, added macro to facilitate visualizing rounded corner texture usage. 2026-10-07 18:53:52 +02:00
Mikko Mononen
10aa5d92e6 DrawList: Optimize AddNgon()
- test overestimate before testing more expensive details when testing if stroked ngon is actualy filled
- Note: not a common function, but the test harness is using this to draw a triangle, which makes it show up in profiling
2026-10-07 18:53:52 +02:00
Mikko Mononen
145b838818 DrawList: Optimize AddRectFilled()
- detect and draw non-rounded non-AA rect with less branches and calculations
- improves new AddRectFilled() overhead from 30% to 5-10%
2026-10-07 18:53:52 +02:00
Mikko Mononen
c5c76dcda5 DrawList: Optimize _SelectFringeTexture()
- store inverse line thickness in the spare texture uv component (same v was stord twice) to avoid division in _SelectFringeTexture
2026-10-07 18:53:52 +02:00
ocornut
d9378b71c5 DrawList: surround _GetStrokePos() in IM_MSVC_RUNTIME_CHECKS_OFF macro. 2026-10-07 18:53:52 +02:00
ocornut
230249ad58 ImFontAtlas: moved TexUv buffers and configurable defines to internals. 2026-10-07 18:53:52 +02:00
Mikko Mononen
efb5c0e1da DrawList: Added some comments and amended existing ones 2026-10-07 18:53:52 +02:00
Mikko Mononen
b181739cea DrawList: Revert texture selection to simple round() in _SelectFringeTexture
- revert texture selection to use just (inlined) round()
- the values were tuned to hide texture selection pops on small thickness
- since we're using super sampling for the problematic range, the tweaks are not necessayr anymore
2026-10-07 18:53:52 +02:00
Mikko Mononen
d24d23fb40 DrawList: No AA ends when line AA is disabled 2026-10-07 18:53:52 +02:00
Mikko Mononen
f272141a4d DrawList: merged _AddPolyline back into AddPolyline.
- AddPolyline used to call different versions of _AddPolyline, the separation is not needed anymore, one less function call in debug mode
2026-10-07 18:53:52 +02:00
Mikko Mononen
9be9c998d7 DrawList: removed vertex offset overflow (for 16-bit ImDrawIdx support) handling.
This seems unnecessary for now.
2026-10-07 18:53:52 +02:00
Mikko Mononen
478813c359 DrawList: restored non-AA rendering mode.
- the ImDrawListFlags_AntiAliasedFill and ImDrawListFlags_AntiAliasedLines flags work again
- added non-AA rendering for polyline and convex poly filled
- do not use corner textures when AA is not used
- Add missing no-AA for single line case
2026-10-07 18:53:52 +02:00
Mikko Mononen
a5d8450a0f DrawList: fixed overdraw of transparent rounded rectangles
- transition earlier to _AddRectTinyRounding() to avoid overdraw issues
2026-10-07 18:53:52 +02:00
Mikko Mononen
2edac09d9f DrawList: fixed baked corners to better match polyline corners
- added CalcArcStepAndCount() to calculate the step size consistently
- _AddRectTinyRounding: fixed stem placement with thin lines (clamping was needed for an older version of the function)
- _AddRectTinyRounding: fixed texture coordinates (uses if inner/outer were reversed)
- use polygon instead of circle when calculating baked corner rounds (the circle was more accurate but looked different size comparet to polyline)
2026-10-07 18:53:52 +02:00
Mikko Mononen
002e2a5f00 DrawList: added macro to have consistent check for rounding
- use macro to test if rounding value is worthy
- changed threshold to be a bit smaller (for smoother handling of small radius), and relative to fringe
2026-10-07 18:53:52 +02:00
Mikko Mononen
f2055fe160 DrawList: fixed reserve counts in _AddPolyline(). 2026-10-07 18:53:52 +02:00
ocornut
16860367b3 DrawList: Debug build optimizations: disable over zealous stack checks in PrimReserve, PrimUnreserve, PrimRect, PrimRectUV, PrimQuadUV, _CalculateCenterBiasedOffset, ImAlphaMultiply, _SelectFringeTexture
+ Undo inlined PrimRect() in AddRectFilled().
2026-10-07 18:53:52 +02:00
Mikko Mononen
ea638a4a11 DrawList: added vertex offset 16-bit ImDrawIdx support for _AddPolyline 2026-10-07 18:53:52 +02:00
Mikko Mononen
a5a4bed3ca DrawList: improved worst case vertex count for AddConvexPolyFilled, convex polys can have only 2 bevels verts. 2026-10-07 18:53:51 +02:00
Mikko Mononen
fc8f5e66d4 DrawList: fixed indices when AllowVtxOffset is on
- fix shape closing indices for AddPolyline and _AddRectTinyRounding
2026-10-07 18:53:51 +02:00
Mikko Mononen
130be3be42 DrawList: Optimization: added specialized 2 point polyline _AddLine(). 2026-10-07 18:53:51 +02:00
Mikko Mononen
6856b3e06b DrawList: added _InvFringeScale to use in cases of 1/_FringeScale. 2026-10-07 18:53:51 +02:00
Mikko Mononen
b484a90846 DrawList: minor render optimizations.
- Use inline array + AddPolyline/AddConvexPolyFilled for triangle and quad
- do less computation for detecting small shape rendering
- add IM_UNLIKELY for very unlikely branches
2026-10-07 18:53:51 +02:00
Mikko Mononen
7ec1bc17fd DrawList: debug build optimizations.
- changed truncated tests to use macro, and inline the computation in debug builds (~15% was spent on calling the functions)
- inlined the common rectangle cases in AddRect() for debug build speed up
2026-10-07 18:53:51 +02:00
ocornut
e8c8a10a2d DrawList: amends/review legacy stroke paths + minor tweaks. 2026-10-07 18:53:51 +02:00
ocornut
c59367efcb DrawList: renamed ImDrawFlags_StrokeCenterAligned to ImDrawFlags_StrokeCenterBiased. 2026-10-07 18:53:51 +02:00
Mikko Mononen
e9246e6ad3 DrawList: Fixed vertex count calculation in_AddRectTinyRounding() 2026-10-07 18:53:51 +02:00
ocornut
3fca7ef414 DrawList: skip PathLineTo/PathStroke calls for common AddLine() functions. (#4091)
Rough numbers
Debug x64, 100k lines: 91.5->80 ms, 87->75.5 ms (NoAAEnds), 87->76 ms (Legacy)
Release x64, 300 lines: 25.2->25 ms, 22.2->18.3 ms (NoAAEnds), 22.2->19.3 ms (Legacy)
2026-10-07 18:53:51 +02:00
Mikko Mononen
5410a04db4 DrawList: fixed out of bounds access of baked corner based on thickness 2026-10-07 18:53:51 +02:00
ocornut
68b5bf4466 DrawList: use straight floats when possible in _AddRectTinyRounding(). 2026-10-07 18:53:51 +02:00
ocornut
d453a59b9c DrawList: avoid using output references in _SelectFringeTexture() + misc tweaks, comments.
Matching coding style and more consistent for matching with other languages.
2026-10-07 18:53:51 +02:00
Mikko Mononen
ed8ed8bb71 DrawList: fixed thin lines appearing too bright.
- fixed how super sampled line textures are generated (and documented wrong assumption)
- switched to more samples and smaller thickness range
- tweaked super sampled texture selection to hide the texture changed better
2026-10-07 18:53:51 +02:00
Mikko Mononen
90e45bdde0 DrawList: extend the detailed stroke textures up stroke thickness 4. 2026-10-07 18:53:51 +02:00
ocornut
9f5bfdf83b DrawList: AddQuad() defaults to ImDrawFlags_StrokeInside. 2026-10-07 18:53:51 +02:00
Mikko Mononen
91e769fbba DrawList: fixed visual pop in stroke rendering when thickness is between 1 and 2 pixels.
- added animated thickness to demo to make it easier to evaluate thickness visual progression
- added super sampled textures in thickness range [1..3] to avoid visual pop
2026-10-07 18:53:51 +02:00
Mikko Mononen
3f7da1e184 DrawList: improved shape drawing input validation for thin shapes and small thickness. 2026-10-07 18:53:51 +02:00
Mikko Mononen
81f316a3bf DrawList: fixed and optimized _AddRectTinyRounding.
- fixed bug where fringe size was not properly applied in _AddRectTinyRounding
- optimized _AddRectTinyRounding to use less vertices
- changed _AddRectTinyRounding to use similar texturing logic as lines
- remove unused fractional line width texture
2026-10-07 18:53:51 +02:00
ocornut
4d5fcdd4ba DrawList: Textured Round Corners: use same array for fill and strokes.
Feels like a little less book-keeping.
2026-10-07 18:53:50 +02:00
ocornut
e3fb7657ba DrawList: renamed ImDrawFlags_StrokeCenterPixelAligned to ImDrawFlags_StrokeCenterAligned. 2026-10-07 18:53:50 +02:00
ocornut
d879e9781b DrawList: wired AddPolylineLegacy() to g_LEGACY_STROKES. Fixed AddLine(), AddLineV(), AddLineH() legacy path. 2026-10-07 18:53:50 +02:00
Mikko Mononen
ce3d970fc7 DrawList: optimized AA end overhead in debug builds.
- inline some code and reuse vars (ctors get function calls in debug msvc) to reduce the AA line end over in debug builds
2026-10-07 18:53:50 +02:00
Mikko Mononen
170a374f59 DrawList: added ImDrawFlags_NoAAEnds which allows to disable line end AA. 2026-10-07 18:53:50 +02:00
Mikko Mononen
c1f781d7af DrawList: manually fix cases from merge, added missing cases of ImDrawFlags_StrokeCenterPixelAligned. 2026-10-07 18:53:50 +02:00
ocornut
5d9b691248 DrawList: misc fixes, amends (replace uses of GetColorU32, macros fixes, default flags). Demo: added rotating square, added MiterOnly checkbox. 2026-10-07 18:53:50 +02:00
Mikko Mononen
5782f4e0ee DrawList: path rendering optimizations.
- added ImRsqrtPrecise() which adds Newton-Raphson iteration for more precision
- change calculation of miter_scale_factor so that it does not have a branch
- renamed IM_POLYLINE_APPEND_* macros to IM_APPEND_* and also use them in fill convex poly
- changed the convex poly miter calculation to match the polyline to make debugging and changes easier
- split the convex poly to separate loop when ImDrawFlags_MiterOnly is specified for less branches in common case

# Conflicts:
#	imgui_draw.cpp
2026-10-07 18:53:50 +02:00
Mikko Mononen
c2e029fb98 DrawList: added stroke position to path rendering.
- added generic stroke position to all path rendering
- removed stroke folding in favor of limiting the miter width (simplifies the geometry cases)
- removed fractional stroke rendering in favor of using the integer sized rendering for everything
  - the rationale is that the in-between sizes are a bit blurry anyways, and the error we get from scaling is visually acceptable
- added stroke position option for the demo
- updated the degenerate shape handling
- remove AddLine() stroke pos handling
- removed up commented out code.
2026-10-07 18:53:50 +02:00
Mikko Mononen
d1d2f5aead DrawList: use dedicated larger texture for fractional thickness lines. 2026-10-07 18:53:50 +02:00
Mikko Mononen
ea2e5c79c0 DrawList: added square cap rendering.
- Added square cap rendering to the DrawPolyline, which can be turned on by ImDrawFlags_SquareCap
- Added draw flags to AddBezierCubic() and AddBezierQuadratic()
2026-10-07 18:53:50 +02:00
Mikko Mononen
858b2b2952 DrawList: added more robust AddConvexPolyFilled(). (#2183, #7972)
- add bevel handling for sharp corners
- add limit to the miter distance to avoid inner shape spikes
- add support for ImDrawFlags_MiterOnly to keep well behaved rendering fast
2026-10-07 18:53:50 +02:00
Mikko Mononen
049f1a799a DrawList: added special case rendering for the stroked rects when the raounding radius gets really small compared to the stroke thickness. 2026-10-07 18:53:50 +02:00