@@ -731,58 +731,51 @@ void ImDrawList::PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, c
731
731
#define IM_POLYLINE_IDX_16_BIT 0
732
732
#else
733
733
#define IM_POLYLINE_IDX_16_BIT 1
734
- # endif
735
-
736
- // Macros that declare, load and save write pointers as local variables
737
- #if 1 // FIXME-NEWPOLYLINE: choose local or shared write pointers
738
- #define IM_POLYLINE_PRIM_VTX_WRITE vtx_write
739
- #define IM_POLYLINE_PRIM_IDX_WRITE idx_write
740
- #define IM_POLYLINE_PRIM_IDX_BASE idx_base
741
-
742
- #define IM_POLYLINE_PRIM_MAKE_LOCAL () ImDrawVert* IM_POLYLINE_PRIM_VTX_WRITE = this ->_VtxWritePtr; ImDrawIdx* IM_POLYLINE_PRIM_IDX_WRITE = this ->_IdxWritePtr; unsigned int IM_POLYLINE_PRIM_IDX_BASE = this ->_VtxCurrentIdx
743
- #define IM_POLYLINE_PRIM_LOAD_LOCAL () IM_POLYLINE_PRIM_VTX_WRITE = this ->_VtxWritePtr; IM_POLYLINE_PRIM_IDX_WRITE = this ->_IdxWritePtr; IM_POLYLINE_PRIM_IDX_BASE = this ->_VtxCurrentIdx
744
- #define IM_POLYLINE_PRIM_SAVE_LOCAL () this ->_VtxWritePtr = IM_POLYLINE_PRIM_VTX_WRITE; this ->_IdxWritePtr = IM_POLYLINE_PRIM_IDX_WRITE; this ->_VtxCurrentIdx = IM_POLYLINE_PRIM_IDX_BASE
745
- #else
746
- #define IM_POLYLINE_PRIM_VTX_WRITE this->_VtxWritePtr
747
- #define IM_POLYLINE_PRIM_IDX_WRITE this->_IdxWritePtr
748
- #define IM_POLYLINE_PRIM_IDX_BASE this->_VtxCurrentIdx
749
-
750
- #define IM_POLYLINE_PRIM_MAKE_LOCAL() (void)0
751
- #define IM_POLYLINE_PRIM_LOAD_LOCAL() (void)0
752
- #define IM_POLYLINE_PRIM_SAVE_LOCAL() (void)0
753
734
#endif
754
735
755
736
// Macros that commit, split and handle vertex offset overflow
756
- #define IM_POLYLINE_PRIM_RESERVE (IDX_COUNT, VTX_COUNT ) this ->PrimReserve ((IDX_COUNT) + IM_POLYLINE_PRIM_EXTRA_IDX_COUNT, VTX_COUNT); IM_POLYLINE_PRIM_MAKE_LOCAL()
757
- #define IM_POLYLINE_PRIM_COMMIT () \
758
- IM_POLYLINE_PRIM_SAVE_LOCAL (); \
759
- const int unused_vtx_count = (int )((this ->VtxBuffer.Data + this ->VtxBuffer.Size ) - this ->_VtxWritePtr); \
760
- const int unused_idx_count = (int )((this ->IdxBuffer.Data + this ->IdxBuffer.Size ) - this ->_IdxWritePtr); \
737
+ #define IM_POLYLINE_PRIM_RESERVE (IDX_COUNT, VTX_COUNT ) \
738
+ this ->PrimReserve ((IDX_COUNT) + IM_POLYLINE_PRIM_EXTRA_IDX_COUNT, VTX_COUNT); \
739
+ ImDrawVert* vtx_write = this ->_VtxWritePtr; \
740
+ ImDrawIdx* idx_write = this ->_IdxWritePtr; \
741
+ unsigned int idx_base = this ->_VtxCurrentIdx;
742
+
743
+ #define IM_POLYLINE_PRIM_COMMIT () \
744
+ this ->_VtxWritePtr = vtx_write; \
745
+ this ->_IdxWritePtr = idx_write; \
746
+ this ->_VtxCurrentIdx = idx_base; \
747
+ const int unused_vtx_count = (int )((this ->VtxBuffer.Data + this ->VtxBuffer.Size ) - vtx_write); \
748
+ const int unused_idx_count = (int )((this ->IdxBuffer.Data + this ->IdxBuffer.Size ) - idx_write); \
761
749
this ->PrimUnreserve (unused_idx_count, unused_vtx_count)
762
750
763
- #define IM_POLYLINE_PRIM_SPLT () IM_POLYLINE_PRIM_COMMIT(); this ->PrimReserve (unused_idx_count, unused_vtx_count); IM_POLYLINE_PRIM_LOAD_LOCAL()
751
+ #define IM_POLYLINE_PRIM_SPLIT () \
752
+ IM_POLYLINE_PRIM_COMMIT (); \
753
+ this ->PrimReserve (unused_idx_count, unused_vtx_count); \
754
+ vtx_write = this ->_VtxWritePtr; \
755
+ idx_write = this ->_IdxWritePtr; \
756
+ idx_base = this ->_VtxCurrentIdx;
764
757
765
758
#define IM_POLYLINE_VTX_COMMIT (N ) \
766
759
{ \
767
- IM_ASSERT_PARANOID ((IM_POLYLINE_PRIM_VTX_WRITE + (N)) <= (this ->VtxBuffer .Data + this ->VtxBuffer .Size ) && " IM_POLYLINE_VTX_COMMIT: VtxWritePtr moved out of bounds!" ); \
768
- IM_POLYLINE_PRIM_VTX_WRITE += N; \
769
- IM_POLYLINE_PRIM_IDX_BASE += N; \
760
+ IM_ASSERT_PARANOID ((idx_base + (N)) <= (this ->VtxBuffer .Data + this ->VtxBuffer .Size ) && " IM_POLYLINE_VTX_COMMIT: VtxWritePtr moved out of bounds!" ); \
761
+ vtx_write += N; \
762
+ idx_base += N; \
770
763
}
771
764
772
765
#if IM_POLYLINE_IDX_16_BIT
773
- #define IM_POLYLINE_PRIM_HANDLE_VTX_OFFSET_OVERFLOW (NEXT_BATCH_VTX_COUNT ) if (sizeof (ImDrawIdx) == 2 && ((IM_POLYLINE_PRIM_IDX_BASE) + (NEXT_BATCH_VTX_COUNT) >= (1 << 16 )) && (Flags & ImDrawListFlags_AllowVtxOffset)) IM_UNLIKELY { IM_POLYLINE_PRIM_SPLT (); }
766
+ #define IM_POLYLINE_PRIM_HANDLE_VTX_OFFSET_OVERFLOW (NEXT_BATCH_VTX_COUNT ) if (sizeof (ImDrawIdx) == 2 && (idx_base + (NEXT_BATCH_VTX_COUNT) >= (1 << 16 )) && (Flags & ImDrawListFlags_AllowVtxOffset)) IM_UNLIKELY { IM_POLYLINE_PRIM_SPLIT (); }
774
767
#else
775
768
#define IM_POLYLINE_PRIM_HANDLE_VTX_OFFSET_OVERFLOW (NEXT_BATCH_VTX_COUNT ) (void )0
776
769
#endif
777
770
778
771
// Macros for filling vertices
779
772
#define IM_POLYLINE_VERTEX (N, X, Y, UV, C ) \
780
773
{ \
781
- IM_ASSERT_PARANOID ((IM_POLYLINE_PRIM_VTX_WRITE + (N)) < (this ->VtxBuffer .Data + this ->VtxBuffer .Size ) && " IM_POLYLINE_VERTEX: Writing outside of allocated buffer!" ); \
782
- IM_POLYLINE_PRIM_VTX_WRITE [N].pos .x = X; \
783
- IM_POLYLINE_PRIM_VTX_WRITE [N].pos .y = Y; \
784
- IM_POLYLINE_PRIM_VTX_WRITE [N].uv = UV; \
785
- IM_POLYLINE_PRIM_VTX_WRITE [N].col = C; \
774
+ IM_ASSERT_PARANOID ((vtx_write + (N)) < (this ->VtxBuffer .Data + this ->VtxBuffer .Size ) && " IM_POLYLINE_VERTEX: Writing outside of allocated buffer!" ); \
775
+ vtx_write [N].pos .x = X; \
776
+ vtx_write [N].pos .y = Y; \
777
+ vtx_write [N].uv = UV; \
778
+ vtx_write [N].col = C; \
786
779
}
787
780
788
781
// Macros for filling indices
@@ -811,7 +804,7 @@ IM_STATIC_ASSERT(2 * sizeof(ImDrawIdx) == sizeof(ImU64)); // assumption: ImU64 m
811
804
I[(N) * 3 + 2] = (ImDrawIdx)(Z + C)
812
805
#endif
813
806
814
- #define IM_POLYLINE_TRIANGLE (N, A, B, C ) (void )(N); IM_POLYLINE_TRIANGLE_EX(IM_POLYLINE_PRIM_IDX_WRITE , N, IM_POLYLINE_PRIM_IDX_BASE , A, B, C)
807
+ #define IM_POLYLINE_TRIANGLE (N, A, B, C ) (void )(N); IM_POLYLINE_TRIANGLE_EX(idx_write , N, idx_base , A, B, C)
815
808
816
809
// Extra indices to allocate for primitives
817
810
#ifndef IM_POLYLINE_PRIM_EXTRA_IDX_COUNT
@@ -1020,17 +1013,17 @@ void ImDrawList::_PolylineThinAntiAliased(const ImDrawListPolyline& polyline)
1020
1013
const float d_x = n0.x * t; \
1021
1014
const float d_y = n0.y * t; \
1022
1015
\
1023
- IM_POLYLINE_PRIM_VTX_WRITE [0 ].pos .x -= d_y; IM_POLYLINE_PRIM_VTX_WRITE [0 ].pos .y += d_x; \
1024
- IM_POLYLINE_PRIM_VTX_WRITE [1 ].pos .x += d_y; IM_POLYLINE_PRIM_VTX_WRITE [1 ].pos .y -= d_x; \
1025
- IM_POLYLINE_PRIM_VTX_WRITE [2 ].pos .x -= d_y; IM_POLYLINE_PRIM_VTX_WRITE [2 ].pos .y += d_x; \
1016
+ vtx_write [0 ].pos .x -= d_y; vtx_write [0 ].pos .y += d_x; \
1017
+ vtx_write [1 ].pos .x += d_y; vtx_write [1 ].pos .y -= d_x; \
1018
+ vtx_write [2 ].pos .x -= d_y; vtx_write [2 ].pos .y += d_x; \
1026
1019
} \
1027
1020
else IM_UNLIKELY \
1028
1021
{ \
1029
1022
const float d_x = n0.x * half_thickness * scale; \
1030
1023
const float d_y = n0.y * half_thickness * scale; \
1031
1024
\
1032
- IM_POLYLINE_PRIM_VTX_WRITE [0 ].pos .x -= d_y; IM_POLYLINE_PRIM_VTX_WRITE [0 ].pos .y += d_x; \
1033
- IM_POLYLINE_PRIM_VTX_WRITE [2 ].pos .x -= d_y; IM_POLYLINE_PRIM_VTX_WRITE [2 ].pos .y += d_x; \
1025
+ vtx_write [0 ].pos .x -= d_y; vtx_write [0 ].pos .y += d_x; \
1026
+ vtx_write [2 ].pos .x -= d_y; vtx_write [2 ].pos .y += d_x; \
1034
1027
} \
1035
1028
\
1036
1029
IM_POLYLINE_TRIANGLE_BEGIN (3 ); \
@@ -1367,10 +1360,10 @@ void ImDrawList::_PolylineThinAntiAliased(const ImDrawListPolyline& polyline)
1367
1360
//
1368
1361
// 1 join triangles
1369
1362
//
1370
- IM_POLYLINE_PRIM_VTX_WRITE [6 ].pos .x -= n1.y * polyline.fringe_width ;
1371
- IM_POLYLINE_PRIM_VTX_WRITE [6 ].pos .y += n1.x * polyline.fringe_width ;
1372
- IM_POLYLINE_PRIM_VTX_WRITE [8 ].pos .x -= n1.y * polyline.fringe_width ;
1373
- IM_POLYLINE_PRIM_VTX_WRITE [8 ].pos .y += n1.x * polyline.fringe_width ;
1363
+ vtx_write [6 ].pos .x -= n1.y * polyline.fringe_width ;
1364
+ vtx_write [6 ].pos .y += n1.x * polyline.fringe_width ;
1365
+ vtx_write [8 ].pos .x -= n1.y * polyline.fringe_width ;
1366
+ vtx_write [8 ].pos .y += n1.x * polyline.fringe_width ;
1374
1367
1375
1368
IM_POLYLINE_TRIANGLE_BEGIN (3 );
1376
1369
IM_POLYLINE_TRIANGLE (0 , 6 , 8 , 7 );
@@ -1399,9 +1392,9 @@ void ImDrawList::_PolylineThinAntiAliased(const ImDrawListPolyline& polyline)
1399
1392
{
1400
1393
ImDrawVert* vtx_start = this ->VtxBuffer .Data + vtx_start_idx;
1401
1394
1402
- vtx_start[0 ].pos = IM_POLYLINE_PRIM_VTX_WRITE [0 ].pos ;
1403
- vtx_start[1 ].pos = IM_POLYLINE_PRIM_VTX_WRITE [1 ].pos ;
1404
- vtx_start[2 ].pos = IM_POLYLINE_PRIM_VTX_WRITE [2 ].pos ;
1395
+ vtx_start[0 ].pos = vtx_write [0 ].pos ;
1396
+ vtx_start[1 ].pos = vtx_write [1 ].pos ;
1397
+ vtx_start[2 ].pos = vtx_write [2 ].pos ;
1405
1398
}
1406
1399
else IM_UNLIKELY
1407
1400
{
@@ -1466,10 +1459,10 @@ void ImDrawList::_PolylineThickAntiAliased(const ImDrawListPolyline& polyline)
1466
1459
const float d_x = n0.x * t; \
1467
1460
const float d_y = n0.y * t; \
1468
1461
\
1469
- IM_POLYLINE_PRIM_VTX_WRITE [0 ].pos .x -= d_y; IM_POLYLINE_PRIM_VTX_WRITE [0 ].pos .y += d_x; \
1470
- IM_POLYLINE_PRIM_VTX_WRITE [1 ].pos .x += d_y; IM_POLYLINE_PRIM_VTX_WRITE [1 ].pos .y -= d_x; \
1471
- IM_POLYLINE_PRIM_VTX_WRITE [2 ].pos .x += d_y; IM_POLYLINE_PRIM_VTX_WRITE [2 ].pos .y -= d_x; \
1472
- IM_POLYLINE_PRIM_VTX_WRITE [3 ].pos .x -= d_y; IM_POLYLINE_PRIM_VTX_WRITE [3 ].pos .y += d_x; \
1462
+ vtx_write [0 ].pos .x -= d_y; vtx_write [0 ].pos .y += d_x; \
1463
+ vtx_write [1 ].pos .x += d_y; vtx_write [1 ].pos .y -= d_x; \
1464
+ vtx_write [2 ].pos .x += d_y; vtx_write [2 ].pos .y -= d_x; \
1465
+ vtx_write [3 ].pos .x -= d_y; vtx_write [3 ].pos .y += d_x; \
1473
1466
} \
1474
1467
else \
1475
1468
{ \
@@ -1478,10 +1471,10 @@ void ImDrawList::_PolylineThickAntiAliased(const ImDrawListPolyline& polyline)
1478
1471
const float d_outer_x = n0.x * half_fringe_thickness * scale; \
1479
1472
const float d_outer_y = n0.y * half_fringe_thickness * scale; \
1480
1473
\
1481
- IM_POLYLINE_PRIM_VTX_WRITE [0 ].pos .x -= d_outer_y; IM_POLYLINE_PRIM_VTX_WRITE [0 ].pos .y += d_outer_x; \
1482
- IM_POLYLINE_PRIM_VTX_WRITE [1 ].pos .x -= d_inner_y; IM_POLYLINE_PRIM_VTX_WRITE [1 ].pos .y += d_inner_x; \
1483
- IM_POLYLINE_PRIM_VTX_WRITE [2 ].pos .x -= d_inner_y; IM_POLYLINE_PRIM_VTX_WRITE [2 ].pos .y += d_inner_x; \
1484
- IM_POLYLINE_PRIM_VTX_WRITE [3 ].pos .x -= d_outer_y; IM_POLYLINE_PRIM_VTX_WRITE [3 ].pos .y += d_outer_x; \
1474
+ vtx_write [0 ].pos .x -= d_outer_y; vtx_write [0 ].pos .y += d_outer_x; \
1475
+ vtx_write [1 ].pos .x -= d_inner_y; vtx_write [1 ].pos .y += d_inner_x; \
1476
+ vtx_write [2 ].pos .x -= d_inner_y; vtx_write [2 ].pos .y += d_inner_x; \
1477
+ vtx_write [3 ].pos .x -= d_outer_y; vtx_write [3 ].pos .y += d_outer_x; \
1485
1478
} \
1486
1479
\
1487
1480
IM_POLYLINE_TRIANGLE_BEGIN (6 ); \
@@ -2085,10 +2078,10 @@ void ImDrawList::_PolylineThickAntiAliased(const ImDrawListPolyline& polyline)
2085
2078
{
2086
2079
ImDrawVert* vtx_start = this ->VtxBuffer .Data + vtx_start_idx;
2087
2080
2088
- vtx_start[0 ].pos = IM_POLYLINE_PRIM_VTX_WRITE [0 ].pos ;
2089
- vtx_start[1 ].pos = IM_POLYLINE_PRIM_VTX_WRITE [1 ].pos ;
2090
- vtx_start[2 ].pos = IM_POLYLINE_PRIM_VTX_WRITE [2 ].pos ;
2091
- vtx_start[3 ].pos = IM_POLYLINE_PRIM_VTX_WRITE [3 ].pos ;
2081
+ vtx_start[0 ].pos = vtx_write [0 ].pos ;
2082
+ vtx_start[1 ].pos = vtx_write [1 ].pos ;
2083
+ vtx_start[2 ].pos = vtx_write [2 ].pos ;
2084
+ vtx_start[3 ].pos = vtx_write [3 ].pos ;
2092
2085
}
2093
2086
else IM_UNLIKELY
2094
2087
{
@@ -2142,8 +2135,8 @@ void ImDrawList::_PolylineAliased(const ImDrawListPolyline& polyline)
2142
2135
const float d_x = n0.x * half_thickness * scale; \
2143
2136
const float d_y = n0.y * half_thickness * scale; \
2144
2137
\
2145
- IM_POLYLINE_PRIM_VTX_WRITE [0 ].pos .x -= d_y; IM_POLYLINE_PRIM_VTX_WRITE [0 ].pos .y += d_x; \
2146
- IM_POLYLINE_PRIM_VTX_WRITE [1 ].pos .x -= d_y; IM_POLYLINE_PRIM_VTX_WRITE [1 ].pos .y += d_x; \
2138
+ vtx_write [0 ].pos .x -= d_y; vtx_write [0 ].pos .y += d_x; \
2139
+ vtx_write [1 ].pos .x -= d_y; vtx_write [1 ].pos .y += d_x; \
2147
2140
} \
2148
2141
else if (polyline.cap == ImDrawFlags_CapRound) IM_UNLIKELY \
2149
2142
{ \
@@ -2555,8 +2548,8 @@ void ImDrawList::_PolylineAliased(const ImDrawListPolyline& polyline)
2555
2548
{
2556
2549
ImDrawVert* vtx_start = this ->VtxBuffer .Data + vtx_start_idx;
2557
2550
2558
- vtx_start[0 ].pos = IM_POLYLINE_PRIM_VTX_WRITE [0 ].pos ;
2559
- vtx_start[1 ].pos = IM_POLYLINE_PRIM_VTX_WRITE [1 ].pos ;
2551
+ vtx_start[0 ].pos = vtx_write [0 ].pos ;
2552
+ vtx_start[1 ].pos = vtx_write [1 ].pos ;
2560
2553
}
2561
2554
else IM_UNLIKELY
2562
2555
{
@@ -3656,7 +3649,7 @@ void ImDrawList::_RectRounded(const ImVec2& a, const ImVec2& b, ImU32 col, floa
3656
3649
uv, path_colors[j]); \
3657
3650
} \
3658
3651
\
3659
- IM_POLYLINE_PRIM_VTX_WRITE += path_count; \
3652
+ vtx_write += path_count; \
3660
3653
} \
3661
3654
\
3662
3655
path_size += arc_size; \
@@ -3668,7 +3661,7 @@ void ImDrawList::_RectRounded(const ImVec2& a, const ImVec2& b, ImU32 col, floa
3668
3661
IM_POLYLINE_VERTEX (j, X X_SIGN path_offsets[j].x , Y Y_SIGN path_offsets[j].y , uv, path_colors[j]); \
3669
3662
} \
3670
3663
\
3671
- IM_POLYLINE_PRIM_VTX_WRITE += path_count; \
3664
+ vtx_write += path_count; \
3672
3665
++path_size; \
3673
3666
}
3674
3667
@@ -3691,13 +3684,11 @@ void ImDrawList::_RectRounded(const ImVec2& a, const ImVec2& b, ImU32 col, floa
3691
3684
}
3692
3685
IM_POLYLINE_TRIANGLE_END (path_size * strip_count * 2 * 3 );
3693
3686
3694
- IM_POLYLINE_PRIM_IDX_BASE += vtx_count;
3687
+ idx_base += vtx_count;
3695
3688
3696
3689
for (int j = 0 ; j < (path_count - 1 ) * 6 ; j++)
3697
- {
3698
- if (IM_POLYLINE_PRIM_IDX_WRITE[-j - 1 ] >= IM_POLYLINE_PRIM_IDX_BASE)
3699
- IM_POLYLINE_PRIM_IDX_WRITE[-j - 1 ] -= (ImDrawIdx)vtx_count;
3700
- }
3690
+ if (idx_write[-j - 1 ] >= idx_base)
3691
+ idx_write[-j - 1 ] -= (ImDrawIdx)vtx_count;
3701
3692
3702
3693
IM_POLYLINE_PRIM_COMMIT ();
3703
3694
}
0 commit comments