Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/wolfpld/tracy.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon van Bernem <simon.vanbernem@yahoo.de>2020-08-07 11:24:13 +0300
committerSimon van Bernem <simon.vanbernem@yahoo.de>2020-08-07 11:24:13 +0300
commit3dd80c5288692fc11d89abf1b9e53079d516284e (patch)
treeaf74e16b507c3ff1377190fd35e14ca3f81c6ec1 /server/TracyImGui.hpp
parent550e05d14902a110c57e31186eca745dcb9a886a (diff)
DrawStripedRect can now draw screen-space stripes
Added two parameters to DrawStripedRect: fix_stripes_in_screen_space aligns the stripes to screen space. This leads to the stripes of any stripe rect being drawn aligning. Also added inverted, which flips the empty and filled part of the striped rect. This is used to make statRange and findZone stripes interleave, when they overlap.
Diffstat (limited to 'server/TracyImGui.hpp')
-rw-r--r--server/TracyImGui.hpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/server/TracyImGui.hpp b/server/TracyImGui.hpp
index 09d248eb..21b236ac 100644
--- a/server/TracyImGui.hpp
+++ b/server/TracyImGui.hpp
@@ -164,7 +164,7 @@ namespace tracy
return res;
}
- static void DrawStripedRect( ImDrawList* draw, double x0, double y0, double x1, double y1, double sw, uint32_t color )
+ static void DrawStripedRect( ImDrawList* draw, double x0, double y0, double x1, double y1, double sw, uint32_t color, bool fix_stripes_in_screen_space, bool inverted )
{
assert( x1 >= x0 );
assert( y1 >= y0 );
@@ -183,8 +183,23 @@ namespace tracy
const auto rw = x1 - x0;
const auto rh = y1 - y0;
- const auto v0 = ImVec2( x0, y0 - rw );
- const auto cnt = int( ( rh + rw + sw*2 ) / ( sw*2 ) );
+ auto v0 = ImVec2( x0, y0 - rw);
+
+ if (fix_stripes_in_screen_space)
+ {
+ const auto window_width = double(ImGui::GetWindowHeight());
+ const auto flipped_v0y = window_width - v0.y; //we transform into a y-is-up coordinate space to achieve upper-left to lower-right stripes. If we didn't, we would calculate values for lower-left to upper-right
+
+ const auto manhatten_distance = x0 + flipped_v0y;
+ const auto in_multiples_of_2_times_sw = int(manhatten_distance / (sw * 2));
+
+ const auto floored_manhatten_distance = double(in_multiples_of_2_times_sw * sw * 2); //floor in terms of 2 * stripe width
+
+ const auto corrected_flipped_v0y = (floored_manhatten_distance - x0); //we transform back into y-is-down imgui space
+ v0.y = window_width - corrected_flipped_v0y - double(inverted * sw);
+ }
+
+ const auto cnt = int( ( rh + rw + 2*sw*2 ) / ( sw*2 ) );
for( int i=0; i<cnt; i++ )
{
draw->PathLineTo( v0 + ImVec2( 0, i*sw*2 ) );