Commit Graph

11938 Commits

Author SHA1 Message Date
Mikko Mononen
9cdeccc0f6 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-09-07 16:24:02 +02:00
ocornut
9ee6e16ee1 DrawList: amends/review legacy stroke paths + minor tweaks. 2026-09-07 16:24:02 +02:00
ocornut
4d0afafb7b DrawList: renamed ImDrawFlags_StrokeCenterAligned to ImDrawFlags_StrokeCenterBiased. 2026-09-07 16:24:02 +02:00
Mikko Mononen
261d1887bb DrawList: Fixed vertex count calculation in_AddRectTinyRounding() 2026-09-07 16:24:02 +02:00
ocornut
af86c8e551 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-09-07 16:24:02 +02:00
Mikko Mononen
e295d429be DrawList: fixed out of bounds access of baked corner based on thickness 2026-09-07 16:24:02 +02:00
ocornut
c20c3aa5ef Docs: update changelog. 2026-09-07 16:24:01 +02:00
ocornut
fafa147d2a DrawList: use straight floats when possible in _AddRectTinyRounding(). 2026-09-07 16:24:01 +02:00
ocornut
4b5224d2cb DrawList: avoid using output references in _SelectFringeTexture() + misc tweaks, comments.
Matching coding style and more consistent for matching with other languages.
2026-09-07 16:24:01 +02:00
Mikko Mononen
7372d6ac95 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-09-07 16:24:01 +02:00
Mikko Mononen
7fa09cf7f6 DrawList: extend the detailed stroke textures up stroke thickness 4. 2026-09-07 16:24:01 +02:00
ocornut
e6097985be DrawList: AddQuad() defaults to ImDrawFlags_StrokeInside. 2026-09-07 16:24:01 +02:00
ocornut
92c4dd8670 Demo: fixed using Miter/Square/NoAAends checkboxes interfering with stroke mode. warnings.
Demo: update "Lines" demo to help diagnose brightness change.
2026-09-07 16:24:01 +02:00
Mikko Mononen
48be9f0231 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-09-07 16:24:01 +02:00
Mikko Mononen
a94f8a4d53 DrawList: improved shape drawing input validation for thin shapes and small thickness. 2026-09-07 16:24:00 +02:00
Mikko Mononen
3096c3927a 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-09-07 16:24:00 +02:00
ocornut
deff9015ce DrawList: Textured Round Corners: use same array for fill and strokes.
Feels like a little less book-keeping.
2026-09-07 16:24:00 +02:00
ocornut
3012bb7aec DrawList: renamed ImDrawFlags_StrokeCenterPixelAligned to ImDrawFlags_StrokeCenterAligned. 2026-09-07 16:24:00 +02:00
ocornut
5b59b8ffb8 Demo: rework Custom Rendering's Primitives rendering. Fill + Stroke overlap.
Use {} style for ImVec2.
2026-09-07 16:24:00 +02:00
ocornut
d03240fecc DrawList: wired AddPolylineLegacy() to g_LEGACY_STROKES. Fixed AddLine(), AddLineV(), AddLineH() legacy path. 2026-09-07 16:24:00 +02:00
Mikko Mononen
bd8c9b65dd 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-09-07 16:24:00 +02:00
Mikko Mononen
1fdafd5f78 DrawList: added ImDrawFlags_NoAAEnds which allows to disable line end AA. 2026-09-07 16:24:00 +02:00
Mikko Mononen
76d6ba3cee DrawList: manually fix cases from merge, added missing cases of ImDrawFlags_StrokeCenterPixelAligned. 2026-09-07 16:24:00 +02:00
ocornut
f8fb97df35 DrawList: misc fixes, amends (replace uses of GetColorU32, macros fixes, default flags). Demo: added rotating square, added MiterOnly checkbox. 2026-09-07 16:23:59 +02:00
Mikko Mononen
8e9473f836 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-09-07 16:23:59 +02:00
Mikko Mononen
267948bdb2 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-09-07 16:23:59 +02:00
Mikko Mononen
1f5aca007b DrawList: use dedicated larger texture for fractional thickness lines. 2026-09-07 16:23:59 +02:00
Mikko Mononen
b3e51b527e 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-09-07 16:23:59 +02:00
Mikko Mononen
1a092dd07b 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-09-07 16:23:59 +02:00
Mikko Mononen
7ad2d0ed10 DrawList: added special case rendering for the stroked rects when the raounding radius gets really small compared to the stroke thickness.
# Conflicts:
#	imgui.h
#	imgui_draw.cpp
2026-09-07 16:23:59 +02:00
Mikko Mononen
17bda40343 DrawList: improved handling of rounded stroked rectangles, where rounding is less than stroke thickness
# Conflicts:
#	imgui.h
#	imgui_draw.cpp
2026-09-07 16:23:59 +02:00
Mikko Mononen
63af4b649e DrawList: added better handling for rendering degenerate geometry. (2183, 7972)
- Add ImDrawFlags_MiterOnly which is used to indicate that a path contains simple geometry and can be rendered using mitered corners
- Added handling of degenerated shapes for stroked rectangle, circle, ngon, and ellipse
- Render shapes filled when outline covers the whole shape
- Clamp very small circles and ngons, and use alpha fade below one pixel
- Added correct offset for ellipse
2026-09-07 16:23:58 +02:00
Mikko Mononen
fa266872e1 DrawList: added improved polyline rendering. (2183, 7972)
- added 2 variants of polyline rendering
- one handles integersized thickness using one strip of triangles along the line
- second handles any thickness using 2 strips of triangles long the line
2026-09-07 16:23:58 +02:00
ocornut
6dc64cc465 DrawList: fixed build/warnings + added pretty theorical support for _StrokeLegacy in AddLineV/AddLineH
(Squash) Various zealous warning fixes. deom draw
2026-09-07 16:23:58 +02:00
Mikko Mononen
6d25a9f451 DrawList: changed CenterPixelAligned growth to be smoother, added stroke pos to AddLine()
- changed vertical AddLine() to be consistent with AddLineV()
- changed CenterPixelAligned growth to be smoother
- added (temporary) specialized stroke pos support for AddLine()
2026-09-07 16:23:58 +02:00
ocornut
293d5a5142 DrawList: added _GetStrokePos() helper indirection, made flags=0 select default at runtime. 2026-09-07 16:23:58 +02:00
ocornut
f25e4f5e5f DrawList: fixed is_truncated checks in AddRect() and AddRectFilled(). 2026-09-07 16:23:58 +02:00
ocornut
0e16f2f685 Demo: Custom Rendering: expose Stroke Position.
Demo: Custom Rendering: amend tests (to include legacy AddLine() for vertical/horizontal lines to compare.
2026-09-07 16:23:58 +02:00
Mikko Mononen
e2356aebf7 DrawList: optimize non-AA non-rounded case of AddRect() 2026-09-07 16:23:58 +02:00
Mikko Mononen
e80f7bf802 DrawList: added ImDrawFlags_StrokeCenterPixelAligned
- added ImDrawFlags_StrokeCenterPixelAligned which center aligns stroke so that outside of the stroke is pixel aligned
- fixed AddRect() non-rounded pixel aligned case to use correnct min/max
- fixed AddRect() default case to not adjust rounding for non-rounded rects
- fixed lineV() centered offset
- renamed ImDrawFlags_StrokeCenterPixelAligned to ImDrawFlags_StrokeCenterAligned.
- reduced debug build indirections.
2026-09-07 16:23:58 +02:00
ocornut
2eed449ac8 DrawList: AddRect: avoid altering rounding on StrokeOutside when initial value if 0 + comments 2026-09-07 16:23:57 +02:00
ocornut
766fd957c3 DrawList: Textured Round Corners: use macros + rename locals. (1962)
Squashed: Rename macros to IM_APPEND_VTX(), IM_APPEND_TRI()
2026-09-07 16:23:57 +02:00
Mikko Mononen
6e48756909 DrawList: Textured Round Corners: Added flags to disable textured rounded corners (1962)
- added ImFontAtlasFlags_NoBakedRoundCorners which controls if rounded corners should be baked to texture
- added ImDrawListFlags_RoundCornersUseTex which controls if we should try to use textured roudned corners
- fixed how _FringeScaleIsInteger is calculated (we want to detect integer pixel scale)
- fixed how _FringeScale is used with textured rounded corners
2026-09-07 16:23:57 +02:00
Mikko Mononen
7298a7d0f3 DrawList: Textured Round Corners: implemented faster render path for stroked rectangles. (1962)
- added check to render simpler geometry when (stroked) rectangle has integer coords
- render non.rounded with 4 non-AA rectangles
- added textures for corners of 1-3 thickness and 1-16 rounding
- use textured corners when possible, or fallback to generic one
2026-09-07 16:23:57 +02:00
Mikko Mononen
9346710933 DrawList: Textured Round Corners: first version. (1962) 2026-09-07 16:23:57 +02:00
Mikko Mononen
b95b9db799 Fixed layout/pixel-perfect issues in various widgets (w/ g_LEGACY_STROKES toggle) 2026-09-07 16:23:57 +02:00
ocornut
574d7ad93d DrawList: added ImDrawFlags_StrokeLegacy support to AddLine(). 2026-09-07 16:23:57 +02:00
Mikko Mononen
4af2aec78b DrawList: added StrokePos flags: ImDrawFlags_StrokeInside, ImDrawFlags_StrokeOutside, ImDrawFlags_StrokeCenter, ImDrawFlags_StrokeLegacy. 2026-09-07 16:23:57 +02:00
Mikko Mononen
358a03aca5 (Breaking) DrawList: removed half pixel offset from ImDrawList::AddLine()
- removed half pixel offset from ImDrawList::AddLine()
- added ImDrawList::AddHorizontalLine() and ImDrawList::AddVerticalLine() which draw line to the side of the specified line
- Change uses of AddLine() which were obviously vertical and horizontal  to use the v and h lines
- Fixed layouting issues from above changes
- Changed primitives demo to use vline and hline
- Fixed angled header to match original
- Fixed separator line to match original
- Fixed caret to match original
- Fix separator vertical alignment
- Added stroke pos, which controls how stroke is draw relative to the shape
- Kept legacy mode which does 1/2px inset
- Added stroke pos support for Rect, Circle, Ngon, and Ellipse
- add stroke pos to hline and vline
- Added drawflag ImDrawFlags_TruncateCoords which allows to hint the renderer that the input is snapped to pixels (can disable AA in some cases)
- Implemented 9-slice renderer for rounded corners
- Remove ImDrawFlags_TruncateCoords flag in favor of detecting truncated coords.
- Renamed to AddLineH(), AddLineV()
- Removed ImDrawStrokePos, folded into ImDrawFlags
2026-09-07 16:23:57 +02:00
ocornut
7e1b65d26d Merge branch 'master' into docking
# Conflicts:
#	imgui_internal.h
2026-09-02 17:27:51 +02:00