public override void Render(DirectX.DirectXCanvas canvas, ThreadScroll scroll, DirectXCanvas.Layer layer, Rect box) { if (!IsVisible) { return; } Matrix world = GetWorldMatrix(scroll); if (layer == DirectXCanvas.Layer.Background) { Draw(canvas, Blocks, world); if (FilterMesh != null) { FilterMesh.WorldTransform = world; canvas.Draw(FilterMesh); } if (scroll.SyncDraw == ThreadScroll.SyncDrawType.Wait) { Draw(canvas, SyncMesh, world); } if (SyncWorkMesh != null && scroll.SyncDraw == ThreadScroll.SyncDrawType.Work) { Draw(canvas, SyncWorkMesh, world); } Data.Utils.ForEachInsideInterval(EventData.Events, scroll.ViewTime, frame => { GetTree(frame).ForEachChild((node, level) => { Entry entry = (node as EventNode).Entry; Interval intervalPx = scroll.TimeToPixel(entry); if (intervalPx.Width < TextDrawThreshold || intervalPx.Right < 0.0 || level >= MaxDepth) { return(false); } if (intervalPx.Left < 0.0) { intervalPx.Width += intervalPx.Left; intervalPx.Left = 0.0; } double lum = Data.Utils.GetLuminance(entry.Description.ForceColor); Color color = lum < Data.Utils.LuminanceThreshold ? Colors.White : Colors.Black; canvas.Text.Draw(new Point(intervalPx.Left + TextDrawOffset, Offset + level * RenderParams.BaseHeight), entry.Description.Name, color, TextAlignment.Left, intervalPx.Width - TextDrawOffset); return(true); }); }); } if (layer == DirectXCanvas.Layer.Foreground) { if (CallstackMeshPolys != null && CallstackMeshLines != null && (scroll.DrawCallstacks != 0 || scroll.DrawDataTags)) { double width = CallstackMarkerRadius; double height = CallstackMarkerRadius; double offset = Offset + RenderParams.BaseHeight * 0.5; if (scroll.DrawCallstacks != 0) { Data.Utils.ForEachInsideInterval(EventData.Callstacks, scroll.ViewTime, callstack => { if ((callstack.Reason & scroll.DrawCallstacks) != 0) { double center = scroll.TimeToPixel(callstack); Point[] points = new Point[] { new Point(center - width, offset), new Point(center, offset - height), new Point(center + width, offset), new Point(center, offset + height) }; Color fillColor = (callstack.Reason == CallStackReason.AutoSample) ? CallstackColor : SystemCallstackColor; Color strokeColor = Colors.Black; CallstackMeshPolys.AddRect(points, fillColor); CallstackMeshLines.AddRect(points, strokeColor); } }); } if (scroll.DrawDataTags && EventData.TagsPack != null) { Data.Utils.ForEachInsideInterval(EventData.TagsPack.Tags, scroll.ViewTime, tag => { double center = scroll.TimeToPixel(tag); Point[] points = new Point[] { new Point(center - width, Offset), new Point(center + width, Offset), new Point(center, offset) }; CallstackMeshPolys.AddTri(points, CallstackColor); CallstackMeshLines.AddTri(points, Colors.Black); }); } CallstackMeshPolys.Update(canvas.RenderDevice); CallstackMeshLines.Update(canvas.RenderDevice); canvas.Draw(CallstackMeshPolys); canvas.Draw(CallstackMeshLines); } } }
public override void Render(DirectX.DirectXCanvas canvas, ThreadScroll scroll, DirectXCanvas.Layer layer) { SharpDX.Matrix world = SharpDX.Matrix.Scaling((float)scroll.Zoom, (float)((Height - 2.0 * RenderParams.BaseMargin) / scroll.Height), 1.0f); world.TranslationVector = new SharpDX.Vector3(-(float)(scroll.ViewUnit.Left * scroll.Zoom), (float)((Offset + 1.0 * RenderParams.BaseMargin) / scroll.Height), 0.0f); if (layer == DirectXCanvas.Layer.Background) { if (Mesh != null) { Mesh.World = world; canvas.Draw(Mesh); } if (FilterMesh != null) { FilterMesh.World = world; canvas.Draw(FilterMesh); } if (SyncMesh != null && scroll.SyncDraw == ThreadScroll.SyncDrawType.Wait) { SyncMesh.World = world; canvas.Draw(SyncMesh); } if (SyncWorkMesh != null && scroll.SyncDraw == ThreadScroll.SyncDrawType.Work) { SyncWorkMesh.World = world; canvas.Draw(SyncWorkMesh); } Data.Utils.ForEachInsideInterval(EventData.Events, scroll.ViewTime, frame => { frame.CategoriesTree.ForEachChild((node, level) => { Entry entry = (node as EventNode).Entry; Interval intervalPx = scroll.TimeToPixel(entry); if (intervalPx.Width < TextDrawThreshold || intervalPx.Right < 0.0) { return(false); } if (intervalPx.Left < 0.0) { intervalPx.Width += intervalPx.Left; intervalPx.Left = 0.0; } double lum = DirectX.Utils.GetLuminance(entry.Description.Color); Color color = lum < 0.33 ? Colors.White : Colors.Black; canvas.Text.Draw(new Point(intervalPx.Left + TextDrawOffset, Offset + level * RenderParams.BaseHeight), entry.Description.Name, color, TextAlignment.Left, intervalPx.Width - TextDrawOffset); return(true); }); }); } if (layer == DirectXCanvas.Layer.Foreground) { if (CallstackMeshPolys != null && CallstackMeshLines != null && scroll.DrawCallstacks) { double width = CallstackMarkerSize * 0.5; double height = (CallstackMarkerSize / RenderParams.BaseHeight) / MaxDepth; double offset = (CallstackMarkerOffset / RenderParams.BaseHeight) / MaxDepth; Data.Utils.ForEachInsideInterval(EventData.Callstacks, scroll.ViewTime, callstack => { double center = scroll.TimeToPixel(callstack); Point a = new Point(center - width, offset); Point b = new Point(center, offset + height); Point c = new Point(center + width, offset); CallstackMeshPolys.AddTri(a, b, c, (callstack.Reason == CallStackReason.AutoSample) ? CallstackColor : SystemCallstackColor); CallstackMeshLines.AddTri(a, b, c, Colors.Black); }); CallstackMeshPolys.Update(canvas.RenderDevice); CallstackMeshLines.Update(canvas.RenderDevice); CallstackMeshPolys.World = world; CallstackMeshLines.World = world; canvas.Draw(CallstackMeshPolys); canvas.Draw(CallstackMeshLines); } } }