X-Git-Url: https://harrygodden.com/git/?p=vg.git;a=blobdiff_plain;f=vg_profiler.h;fp=vg_profiler.h;h=699e2a72eadfdacac40abac419c53737554c34dd;hp=d0106af5d7eef89c6ffd3503d8715853aa1faf47;hb=fce86711735b15bff37de0f70716808410fcf269;hpb=1c305409e8eca9cf8449d681df73208956ce14df diff --git a/vg_profiler.h b/vg_profiler.h index d0106af..699e2a7 100644 --- a/vg_profiler.h +++ b/vg_profiler.h @@ -59,8 +59,8 @@ static void vg_profile_end( struct vg_profile *profile ) } static void vg_profile_drawn( struct vg_profile **profiles, u32 count, - float budget, ui_rect panel, u32 colour_offset, - int dir ) + f64 budget, ui_rect panel, + int dir, i32 normalize ) { if( panel[2] == 0 ) panel[2] = 256; @@ -68,54 +68,41 @@ static void vg_profile_drawn( struct vg_profile **profiles, u32 count, if( panel[3] == 0 ) panel[3] = VG_PROFILE_SAMPLE_COUNT * 2; - f32 sh = (f32)panel[3^dir] / (f32)VG_PROFILE_SAMPLE_COUNT, + f64 sh = (f32)panel[3^dir] / (f32)VG_PROFILE_SAMPLE_COUNT, sw = (f32)panel[2^dir]; ui_fill( panel, 0xa0000000 ); assert( count <= 8 ); f64 avgs[8]; - int ptrs[8]; - - for( int i=0; ibuffer_current; -#else - ptrs[i] = 0; -#endif - avgs[i] = 0.0f; + u32 colours[8]; + for( u32 i=0; isamples[i] * rate_mul; + } - f64 sample = (f64)profiles[j]->samples[ptrs[j]] * rate_mul, - px = (total / (budget)) * sw, - wx = (sample / (budget)) * sw; + for( int j=0; jsamples[i] * rate_mul, + px = (total / budget) * sw, + wx = (sample / budget) * sw; ui_rect block; block[0^dir] = panel[0^dir] + px; block[1^dir] = panel[1^dir] + (f32)i*sh; - block[2^dir] = wx; + block[2^dir] = VG_MAX( 1, wx-1 ); block[3^dir] = ceilf(sh)-1; - - u32 colour = colours[ (j+colour_offset) % vg_list_size(colours) ]; - ui_fill( block, colour ); + ui_fill( block, colours[j] ); total += sample; avgs[j] += sample; @@ -136,11 +123,10 @@ static void vg_profile_drawn( struct vg_profile **profiles, u32 count, avgs[i] * (1.0f/(VG_PROFILE_SAMPLE_COUNT-1)), profiles[i]->name ); - ui_text( (ui_rect){ panel[0] + panel[2] + 4, - panel[1] + i * 14, 0, 0 }, - infbuf, - 1, - k_ui_align_left, 0 ); + ui_text( (ui_rect){ panel[0] + 4, + panel[1] + panel[3] + 4 + i*14, + panel[2]-8, 14 }, + infbuf, 1, k_ui_align_left, 0 ); } }