public override void ApplyFilter(DirectXCanvas canvas, ThreadScroll scroll, HashSet <EventDescription> descriptions) { Filter = EventFilter.Create(EventData, descriptions); if (Filter != null) { DynamicMesh builder = canvas.CreateMesh(); foreach (EventFrame frame in EventData.Events) { Interval interval = scroll.TimeToUnit(frame.Header); builder.AddRect(new Rect(interval.Left, 0.0, interval.Width, 1.0), FilterFrameColor); } foreach (Entry entry in Filter.Entries) { Interval interval = scroll.TimeToUnit(entry); builder.AddRect(new Rect(interval.Left, 0.0, interval.Width, 1.0), FilterEntryColor); } SharpDX.Utilities.Dispose(ref FilterMesh); FilterMesh = builder.Freeze(canvas.RenderDevice); //if (FilterMesh != null) // FilterMesh.UseAlpha = true; } else { SharpDX.Utilities.Dispose(ref FilterMesh); } }
private void InitBackgroundMesh() { if (BackgroundMesh != null) { BackgroundMesh.Dispose(); } DynamicMesh backgroundBuilder = surface.CreateMesh(); backgroundBuilder.Projection = Mesh.ProjectionType.Pixel; double offset = 0.0; for (int threadIndex = 0; threadIndex < rows.Count; ++threadIndex) { ThreadRow row = rows[threadIndex]; row.Offset = offset; if (threadIndex % 2 == 1) { backgroundBuilder.AddRect(new Rect(0.0, offset, scroll.Width, row.Height), BroAlternativeBackground.Color); } offset += row.Height; } BackgroundMesh = backgroundBuilder.Freeze(surface.RenderDevice); }
internal void Build(IItem root, IItem item, double offset, DynamicMesh meshBuilder, DynamicMesh lineBuilder) { double duration = (root.Finish - root.Start).TotalSeconds; Rect rect = new Rect((item.Start - root.Start).TotalSeconds / duration, offset / MaxHeight, (item.Finish - item.Start).TotalSeconds / duration, item.BaseHeight / MaxHeight); if (!String.IsNullOrEmpty(item.Name)) { TextBlocks.Add(new TextEntry() { Text = item.Name, Position = rect.TopLeft, Width = rect.Width, }); } meshBuilder.AddRect(rect, item.Color); if (item.IsStroke) { lineBuilder.AddRect(rect, Colors.Black); } offset += item.BaseHeight; if (item.Children != null) { foreach (IItem child in item.Children) { Build(root, child, offset, meshBuilder, lineBuilder); } } }
private void InitBackgroundMesh() { if (BackgroundMesh != null) { BackgroundMesh.Dispose(); } DynamicMesh backgroundBuilder = surface.CreateMesh(); backgroundBuilder.Projection = Mesh.ProjectionType.Pixel; double offset = 0.0; bool isAlternative = false; for (int threadIndex = 0; threadIndex < Rows.Count; ++threadIndex) { ThreadRow row = Rows[threadIndex]; if (!row.IsVisible) { continue; } backgroundBuilder.AddRect(new Rect(0.0, offset, Scroll.Width, row.Height), isAlternative ? OptickAlternativeBackground.Color : OptickBackground.Color); isAlternative = !isAlternative; offset += row.Height; } BackgroundMesh = backgroundBuilder.Freeze(surface.RenderDevice); }
void DrawMeasure(DirectX.DirectXCanvas canvas) { if (Input.MeasureInterval.Start != Input.MeasureInterval.Finish) { Durable activeInterval = Input.MeasureInterval.Normalize(); Interval pixelInterval = scroll.TimeToPixel(activeInterval); MeasureMesh.AddRect(new Rect(pixelInterval.Left, 0, pixelInterval.Width, scroll.Height), MeasureBackground); canvas.Text.Draw(new Point(pixelInterval.Left, scroll.Height * 0.5), activeInterval.DurationF3, Colors.White, TextAlignment.Center, pixelInterval.Width); MeasureMesh.Update(canvas.RenderDevice); canvas.Draw(MeasureMesh); } }
void DrawHover(DirectXCanvas canvas) { if (!String.IsNullOrWhiteSpace(ToolTip.Text)) { Size size = surface.Text.Measure(ToolTip.Text); Rect textArea = new Rect(Input.MousePosition.X - size.Width * 0.5 + ToolTipOffset.X, ToolTip.Rect.Top - size.Height + ToolTipOffset.Y, size.Width, size.Height); surface.Text.Draw(textArea.TopLeft, ToolTip.Text, Colors.White, TextAlignment.Left); textArea.Inflate(ToolTipMargin); HoverMesh.AddRect(textArea, HoverBackground); } if (!ToolTip.Rect.IsEmpty) { HoverLines.AddRect(ToolTip.Rect, FrameHover.Color); } HoverLines.Update(canvas.RenderDevice); canvas.Draw(HoverLines); HoverMesh.Update(canvas.RenderDevice); canvas.Draw(HoverMesh); }
void DrawSelection(DirectX.DirectXCanvas canvas) { foreach (Selection selection in SelectionList) { if (selection.Frame != null) { ThreadRow row = id2row[selection.Frame.Header.ThreadIndex]; Durable intervalTime = selection.Node == null ? (Durable)selection.Frame.Header : (Durable)selection.Node.Entry; Interval intervalPx = scroll.TimeToPixel(intervalTime); Rect rect = new Rect(intervalPx.Left, row.Offset + 2.0 * RenderParams.BaseMargin, intervalPx.Width, row.Height - 4.0 * RenderParams.BaseMargin); for (int i = 0; i < SelectionBorderCount; ++i) { rect.Inflate(SelectionBorderStep, SelectionBorderStep); SelectionMesh.AddRect(rect, FrameSelection.Color); } } } SelectionMesh.Update(canvas.RenderDevice); canvas.Draw(SelectionMesh); }
void InitThreadList(FrameGroup group) { rows.Clear(); id2row.Clear(); ThreadList.RowDefinitions.Clear(); ThreadList.Children.Clear(); if (group == null) { return; } rows.Add(new HeaderThreadRow(group) { GradientTop = Colors.LightGray, GradientBottom = Colors.Gray, SplitLines = Colors.White, TextColor = Colors.Black }); for (int i = 0; i < Math.Min(group.Board.Threads.Count, group.Threads.Count); ++i) { ThreadDescription thread = group.Board.Threads[i]; ThreadData data = group.Threads[i]; bool threadHasData = false; if ((data.Callstacks != null && data.Callstacks.Count > 3) || /*(data.Sync != null && data.Sync.Intervals.Count > 0) || */ (data.Events != null && data.Events.Count > 0)) { threadHasData = true; } if (threadHasData) { EventsThreadRow row = new EventsThreadRow(group, thread, data); rows.Add(row); id2row.Add(i, row); row.EventNodeHover += Row_EventNodeHover; row.EventNodeSelected += Row_EventNodeSelected; } } scroll.TimeSlice = group.Board.TimeSlice; scroll.Height = 0.0; scroll.Width = surface.ActualWidth * RenderSettings.dpiScaleX; rows.ForEach(row => scroll.Height += row.Height); rows.ForEach(row => row.BuildMesh(surface, scroll)); ThreadList.Margin = new Thickness(0, 0, 3, 0); if (BackgroundMesh != null) { BackgroundMesh.Dispose(); } DynamicMesh backgroundBuilder = surface.CreateMesh(); double offset = 0.0; for (int threadIndex = 0; threadIndex < rows.Count; ++threadIndex) { ThreadRow row = rows[threadIndex]; row.Offset = offset; ThreadList.RowDefinitions.Add(new RowDefinition()); Thickness margin = new Thickness(0, 0, 0, 0); Label labelName = new Label() { Content = row.Name, Margin = margin, Padding = new Thickness(), FontWeight = FontWeights.Bold, Height = row.Height / RenderSettings.dpiScaleY, VerticalContentAlignment = VerticalAlignment.Center }; Grid.SetRow(labelName, threadIndex); if (threadIndex % 2 == 1) { labelName.Background = AlternativeBackground; backgroundBuilder.AddRect(new Rect(0.0, offset / scroll.Height, 1.0, row.Height / scroll.Height), AlternativeBackground.Color); } ThreadList.Children.Add(labelName); offset += row.Height; } BackgroundMesh = backgroundBuilder.Freeze(surface.RenderDevice); }