ncatlin / rgat

An instruction trace visualisation tool for dynamic program analysis
Apache License 2.0
364 stars 32 forks source link

Work out how to derive a column from a node coordinate #19

Closed ncatlin closed 7 years ago

ncatlin commented 7 years ago

Drawing text is horribly slow, there are lots of instructions -> we only want to draw the instruction labels on the screen.

To do this, rgat uses colour picking - regularly (a few times a second) drawing a sphere to the screen with 32 columns with a green gradient and 16 rows with a red gradient. It looks like this: colpickspheresmall

Before it's cleared, we check the green value of the pixel either side of the screen (and the red on top and bottom, but those values are not used yet).

This tells us the columns we need to draw text in.

Then we iterate through every node on the graph to checking if it is within those columns.

The problem with this is that my maths is horrendous. The formula to convert a node coordinate to a column looks like this [graphicsMaths.cpp]:

node column = floor(<horizontal coordinate> / (COLOUR_PICKING_MYSTERY_CONSTANTA / <horizontal edge separation>)) % 32;

The constant was found by looking at a few example row/node mappings and multiplying them. eg: coord 8a is between col 0 and 1 at h_edge_sep ~1.39. -> 1.39*8 = 11.12

(The constant that has worked best so far is 11.16).

This generally works but it gets very dubious at high graph widths and breaks entirely when the graph starts wrapping a long way around the sphere.

ncatlin commented 7 years ago

solved with deprecation of the sphere