Commit aab90e1
* Initial plan
* Revert xunit maxParallelThreads to default to fix performance issue
Co-authored-by: tig <[email protected]>
* Fix 10x performance regression in RenderLineCanvas
Found via binary search of 51 commits that commit 0270183 introduced
the slowdown by calling context.AddDrawnRectangle() for every cell in
the LineCanvas (thousands of times per frame).
Fixed by reporting the entire LineCanvas.Bounds once instead of per-cell.
Test results:
- Before: 1m 33s (10x slower than v2_release)
- After: 9s (same as v2_release)
Fixes the performance issue in AllViews_Draw_Does_Not_Layout test.
Co-authored-by: tig <[email protected]>
* Add comment clarifying LineCanvas coordinate system
Addresses code review feedback about coordinate system conversion.
LineCanvas.Bounds is already in screen-relative coordinates since
cells are stored with screen positions (used with Driver.Move).
Co-authored-by: tig <[email protected]>
* Build non-rectangular Region from LineCanvas cells efficiently
Instead of reporting entire LineCanvas.Bounds (which includes empty space),
efficiently build a Region that encompasses only the actual line cells.
Algorithm groups contiguous horizontal cells into spans per row, avoiding
per-cell overhead while accurately representing the non-rectangular shape.
Performance maintained: 10s (same as v2_release)
All tests pass: 5695 drawing tests, 200 LineCanvas tests, 33 transparency tests
Co-authored-by: tig <[email protected]>
* Address code review feedback - improve robustness
- Remove redundant empty check (caller already verifies)
- Add safety check for empty row groups to prevent IndexOutOfRangeException
- Update documentation to clarify precondition
Tests still pass with 9s performance.
Co-authored-by: tig <[email protected]>
* Optimize BuildRegionFromLineCells - eliminate redundant sort
Remove redundant OrderBy since X values are already sorted from the
initial OrderBy().ThenBy() operation. Also remove unreachable empty
check since GroupBy guarantees non-empty groups.
Performance maintained at 9s.
Co-authored-by: tig <[email protected]>
* Final code review fixes - improve comments and add defensive check
- Clarify comment about sorting behavior
- Add defensive empty check for edge cases
- Performance maintained at 10s
Co-authored-by: tig <[email protected]>
* Move BuildRegionFromCells to LineCanvas class
Moved the BuildRegionFromCells method from View.Drawing.cs to LineCanvas
where it logically belongs as a public static method.
Updated View.Drawing.cs to call Drawing.LineCanvas.BuildRegionFromCells.
Performance maintained at 9s. All tests pass.
Co-authored-by: tig <[email protected]>
* Update documentation for BuildRegionFromCells
- Clarify that method handles empty cellMap gracefully
- Improve comment explaining the defensive empty check
- Performance maintained at 10s
Co-authored-by: tig <[email protected]>
* Rename BuildRegionFromCells to GetRegion
Renamed the method as requested to have a more concise name.
Performance maintained at 10s. All tests pass.
Co-authored-by: tig <[email protected]>
* Add GetCellMapWithRegion optimization for single-pass iteration
Implemented optimized method that builds both cell map and Region in a
single pass through the canvas bounds, eliminating the need for separate
GetCellMap() and GetRegion() calls.
Benefits:
- Reduces from 2 iterations to 1 (GetCellMap then GetRegion -> single pass)
- Eliminates sorting overhead (O(n log n) -> O(n))
- X values already sorted due to inner loop order
- Builds Region incrementally per row as cells are discovered
Performance maintained at 10s. All tests pass:
- AllViews_Draw_Does_Not_Layout: 10s
- 5695 drawing tests passed
- 200 LineCanvas tests passed
- 33 transparency tests passed
Co-authored-by: tig <[email protected]>
* Add comprehensive unit tests for GetRegion and GetCellMapWithRegion
Added 15 new unit tests covering:
GetRegion tests:
- Empty cell map handling
- Single cell regions
- Horizontal and vertical lines
- L-shaped regions
- Discontiguous cells creating separate spans
- Intersecting lines
GetCellMapWithRegion tests:
- Empty canvas handling
- Single horizontal/vertical lines
- Intersecting lines with proper intersection handling
- Complex shapes (boxes)
- Consistency with separate GetCellMap + GetRegion calls
- Negative coordinate handling
- Exclusion region support
All 215 LineCanvas tests pass. Performance maintained at 9s.
Co-authored-by: tig <[email protected]>
* Fix code style violations per CONTRIBUTING.md
- Replace var with explicit types (Dictionary<Point, Cell?>, LineCanvas, Region, etc.)
- Replace new TypeName() with target-typed new () where type is declared
- Fix foreach loop to use explicit IGrouping<int, Point> type
- Use StraightLine instead of var in foreach
All style violations fixed per CONTRIBUTING.md coding conventions.
Tests still pass: 215 LineCanvas tests, 9s performance maintained.
Co-authored-by: tig <[email protected]>
* Code cleanup.
* Upgrades Transparent Scenario to demonstrate LineCanvas transparency. "dotnet" is drawn using LineCanvas.
* Comment out debug assertions in View drawing logic
The debug assertions in the `View` class, which validated the relationships between `Margin`, `Border`, `Padding`, and their parent objects, as well as their `SubViewNeedsDraw` and `NeedsDraw` states, have been commented out. These assertions were conditionally executed when the current object and its `SuperView` were not of type `Adornment`.
The code has been retained as comments for potential future reference or debugging purposes, but the assertions are no longer active in the current implementation.
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: tig <[email protected]>
Co-authored-by: Tig <[email protected]>
1 parent 3ae28bb commit aab90e1
File tree
5 files changed
+658
-69
lines changed- Examples/UICatalog/Scenarios
- Terminal.Gui
- Drawing/LineCanvas
- ViewBase
- Tests/UnitTestsParallelizable
- Drawing/Lines
5 files changed
+658
-69
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
222 | 231 | | |
223 | 232 | | |
224 | 233 | | |
225 | 234 | | |
226 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
227 | 318 | | |
228 | 319 | | |
229 | 320 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
182 | | - | |
| 182 | + | |
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
| |||
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
195 | 325 | | |
196 | 326 | | |
197 | 327 | | |
| |||
227 | 357 | | |
228 | 358 | | |
229 | 359 | | |
230 | | - | |
| 360 | + | |
231 | 361 | | |
232 | 362 | | |
233 | 363 | | |
| |||
442 | 572 | | |
443 | 573 | | |
444 | 574 | | |
445 | | - | |
446 | | - | |
447 | | - | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
448 | 578 | | |
449 | 579 | | |
450 | | - | |
451 | | - | |
452 | | - | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
453 | 583 | | |
454 | 584 | | |
455 | 585 | | |
| |||
727 | 857 | | |
728 | 858 | | |
729 | 859 | | |
730 | | - | |
731 | | - | |
732 | | - | |
733 | | - | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
734 | 864 | | |
735 | 865 | | |
736 | 866 | | |
| |||
773 | 903 | | |
774 | 904 | | |
775 | 905 | | |
776 | | - | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
777 | 911 | | |
778 | 912 | | |
779 | 913 | | |
780 | 914 | | |
781 | 915 | | |
782 | | - | |
783 | | - | |
| 916 | + | |
| 917 | + | |
784 | 918 | | |
785 | 919 | | |
786 | 920 | | |
| |||
792 | 926 | | |
793 | 927 | | |
794 | 928 | | |
795 | | - | |
| 929 | + | |
796 | 930 | | |
797 | | - | |
| 931 | + | |
798 | 932 | | |
799 | 933 | | |
800 | 934 | | |
| |||
0 commit comments