Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 private void Row_ExpandChanged(ThreadRow row)
 {
     //Task.Run(()=>
     //{
     row.BuildMesh(surface, Scroll);
     UpdateRowsAsync();
     //});
 }
Esempio n. 4
0
        void InitThreadList(FrameGroup group)
        {
            List <ThreadRow> rows = new List <ThreadRow>();

            if (group != null)
            {
                rows.Add(new HeaderThreadRow(group)
                {
                    GradientTop    = (ThreadViewControl.OptickAlternativeBackground as SolidColorBrush).Color,
                    GradientBottom = (ThreadViewControl.OptickBackground as SolidColorBrush).Color,
                    TextColor      = Colors.Gray,
                    Header         = new ThreadFilterView(),
                });

                ThreadRow cpuCoreChart = GenerateCoreChart(group);
                if (cpuCoreChart != null)
                {
                    cpuCoreChart.IsExpanded     = false;
                    cpuCoreChart.ExpandChanged += CpuCoreChart_ExpandChanged;
                    rows.Add(cpuCoreChart);
                }

                List <EventsThreadRow> threadRows = GenerateThreadRows(group);
                foreach (EventsThreadRow row in threadRows)
                {
                    if (row.Description.Origin == ThreadDescription.Source.Core)
                    {
                        row.IsVisible = false;
                        coreRows.Add(row);
                    }
                }
                rows.AddRange(threadRows);
            }

            ThreadViewControl.InitRows(rows, group != null ? group.Board.TimeSlice : null);

            List <ITick> frames = null;

            if (Group != null && Group.Frames != null && Group.Frames[FrameList.Type.CPU] != null)
            {
                FrameList list = Group.Frames[FrameList.Type.CPU];
                frames = list.Events.ConvertAll(frame => frame as ITick);
            }
            else if (Group != null)
            {
                frames = new List <ITick>();
                long step = Durable.MsToTick(1000.0);
                for (long timestamp = Group.Board.TimeSlice.Start; timestamp < Group.Board.TimeSlice.Finish; timestamp += step)
                {
                    frames.Add(new Tick()
                    {
                        Start = timestamp
                    });
                }
            }

            ThreadViewControl.InitForegroundLines(frames);
        }
Esempio n. 5
0
        private void Row_EventNodeSelected(ThreadRow row, EventFrame frame, EventNode node)
        {
            EventFrame focusFrame = frame;

            if (node != null && node.Entry.CompareTo(frame.Header) != 0)
            {
                focusFrame = new EventFrame(frame, node);
            }
            RaiseEvent(new TimeLine.FocusFrameEventArgs(TimeLine.FocusFrameEvent, focusFrame, null));
        }
Esempio n. 6
0
        public void UpdateRows()
        {
            ThreadList.Children.Clear();
            ThreadList.RowDefinitions.Clear();
            ThreadList.Margin = new Thickness(0, 0, 3, 0);
            double offset        = 0.0;
            bool   isAlternative = false;
            int    rowCount      = 0;

            for (int threadIndex = 0; threadIndex < Rows.Count; ++threadIndex)
            {
                ThreadRow row = Rows[threadIndex];
                row.Offset = offset;

                if (!row.IsVisible)
                {
                    continue;
                }

                if (ShowThreadHeaders)
                {
                    ThreadList.RowDefinitions.Add(new RowDefinition());

                    Border border = new Border()
                    {
                        Height = row.Height / RenderSettings.dpiScaleY,
                    };

                    FrameworkElement header = row.Header;
                    if (header != null && header.Parent != null && (header.Parent is Border))
                    {
                        (header.Parent as Border).Child = null;
                    }

                    border.Child      = row.Header;
                    border.Background = isAlternative ? OptickAlternativeBackground : OptickBackground;
                    Grid.SetRow(border, rowCount);

                    ThreadList.Children.Add(border);
                }
                isAlternative = !isAlternative;
                offset       += row.Height;
                rowCount     += 1;
            }

            Scroll.Height = offset;

            double controlHeight = offset / RenderSettings.dpiScaleY;

            surface.Height    = controlHeight;
            surface.MaxHeight = controlHeight;

            InitBackgroundMesh();
        }
Esempio n. 7
0
        public void Highlight(EventFrame frame, IDurable focus)
        {
            Group = frame.Group;
            ThreadRow row = null;

            id2row.TryGetValue(frame.Header.ThreadIndex, out row);
            Highlight(new ThreadView.Selection[] { new ThreadView.Selection()
                                                   {
                                                       Frame = frame, Focus = focus, Row = row
                                                   } });
        }
Esempio n. 8
0
 private void Row_EventNodeHover(Point mousePos, Rect rect, ThreadRow row, EventNode node)
 {
     if (node != null)
     {
         //HoverLines.AddRect(rect, FrameHover.Color);
         ToolTip = new TooltipInfo {
             Text = String.Format("{0}   {1:0.000}ms", node.Name, node.Duration), Rect = rect
         };
     }
     else
     {
         ToolTip = new TooltipInfo();
     }
 }
Esempio n. 9
0
        void InitThreadList(FrameGroup group)
        {
            List <ThreadRow> rows = new List <ThreadRow>();

            if (group != null)
            {
                rows.Add(new HeaderThreadRow(group)
                {
                    GradientTop    = (ThreadViewControl.OptickAlternativeBackground as SolidColorBrush).Color,
                    GradientBottom = (ThreadViewControl.OptickBackground as SolidColorBrush).Color,
                    TextColor      = Colors.Gray,
                    Header         = new ThreadFilterView(),
                });

                ThreadRow cpuCoreChart = GenerateCoreChart(group);
                if (cpuCoreChart != null)
                {
                    cpuCoreChart.IsExpanded     = false;
                    cpuCoreChart.ExpandChanged += CpuCoreChart_ExpandChanged;
                    rows.Add(cpuCoreChart);
                }

                List <EventsThreadRow> threadRows = GenerateThreadRows(group);
                foreach (EventsThreadRow row in threadRows)
                {
                    if (row.Description.Origin == ThreadDescription.Source.Core)
                    {
                        row.IsVisible = false;
                        coreRows.Add(row);
                    }
                }
                rows.AddRange(threadRows);
            }

            ThreadViewControl.InitRows(rows, group != null ? group.Board.TimeSlice : null);

            List <ITick> frames = Group?.MainThread.Events.ConvertAll(frame => frame.Header as ITick);

            ThreadViewControl.InitForegroundLines(frames);
        }
Esempio n. 10
0
        private void RenderCanvas_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            Input.MousePosition = e.Location;
            bool updateSurface = false;

            if (Input.IsDrag)
            {
                double deltaPixel = e.X - Input.DragPosition.X;

                double deltaUnit = scroll.PixelToUnitLength(deltaPixel);
                scroll.ViewUnit.Left -= deltaUnit;
                scroll.ViewUnit.Normalize();

                UpdateBar();
                updateSurface = true;

                Input.DragPosition = e.Location;
            }
            else if (Input.IsMeasure)
            {
                Input.MeasureInterval.Finish = scroll.PixelToTime(e.X).Start;
                updateSurface = true;
            }
            else
            {
                ThreadRow row = GetRow(e.Y);
                if (row != null)
                {
                    row.OnMouseMove(new Point(e.X, e.Y - row.Offset), scroll);
                }

                updateSurface = true;
            }

            if (updateSurface)
            {
                UpdateSurface();
            }
        }
Esempio n. 11
0
        private void CpuCoreChart_ExpandChanged(ThreadRow row)
        {
            if (row.IsExpanded)
            {
                if (!Group.IsCoreDataGenerated)
                {
                    bool isVisible = row.IsExpanded;
                    Task.Run(() =>
                    {
                        row.SetBusy(true);
                        Group.GenerateRealCoreThreads();
                        ThreadViewControl.ReinitRows(coreRows);
                        row.SetBusy(false);
                        Application.Current.Dispatcher.Invoke(new Action(() => coreRows.ForEach(core => core.IsVisible = isVisible)));
                    });
                    return;
                }
            }

            coreRows.ForEach(core => core.IsVisible = row.IsExpanded);
            ThreadViewControl.UpdateRows();
        }
Esempio n. 12
0
        private void RenderCanvas_MouseWheel(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (e.Delta != 0)
            {
                double delta = e.Delta * ZoomSpeed;
                double scale = delta > 0.0 ? 1 / delta : -delta;

                double ratio = (double)e.X / surface.RenderCanvas.Width;

                double prevWidth = scroll.ViewUnit.Width;
                scroll.ViewUnit.Width *= scale;
                scroll.ViewUnit.Left  += (prevWidth - scroll.ViewUnit.Width) * ratio;
                scroll.ViewUnit.Normalize();

                ThreadRow row = GetRow(e.Y);
                if (row != null)
                {
                    row.OnMouseMove(new Point(e.X, e.Y - row.Offset), scroll);
                }

                UpdateBar();
                UpdateSurface();
            }
        }
Esempio n. 13
0
        void DrawSelection(DirectX.DirectXCanvas canvas)
        {
            foreach (Selection selection in SelectionList)
            {
                if (selection.Frame != null && selection.Row != null)
                {
                    ThreadRow row = selection.Row;

                    IDurable intervalTime = selection.Focus == null ? selection.Frame.Header : selection.Focus;
                    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);
        }
Esempio n. 14
0
        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);
        }
Esempio n. 15
0
 private void Row_VisibilityChanged(ThreadRow row)
 {
     //throw new NotImplementedException();
 }
Esempio n. 16
0
 private void Row_EventNodeHover(Rect rect, ThreadRow row, EventNode node)
 {
     HoverMesh.AddRect(rect, FrameHover.Color);
 }
Esempio n. 17
0
 private void Row_EventNodeSelected(ThreadRow row, EventFrame frame, EventNode node, ITick tick)
 {
     RaiseEvent(new TimeLine.FocusFrameEventArgs(TimeLine.FocusFrameEvent, frame, node, tick));
 }
 private void Row_EventNodeHover(Point mousePos, Rect rect, ThreadRow row, EventNode node)
 {
     ThreadViewControl.ToolTipPanel = node != null ? new ThreadView.TooltipInfo {
         Text = String.Format("{0}   {1:0.#} ({2:0.#}%)", node.Description.FullName, node.Duration, 100.0 * node.Duration / Frame.Root.Duration), Rect = rect
     } : null;
 }
Esempio n. 19
0
        void InitThreadList(FrameGroup group)
        {
            rows.Clear();
            id2row.Clear();

            ThreadList.RowDefinitions.Clear();
            ThreadList.Children.Clear();

            if (group == null)
            {
                return;
            }

            rows.Add(new HeaderThreadRow(group)
            {
                GradientTop    = (BroAlternativeBackground as SolidColorBrush).Color,
                GradientBottom = (BroBackground as SolidColorBrush).Color,
                SplitLines     = (BroBackground as SolidColorBrush).Color,
                TextColor      = Colors.Gray
            });

            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);

            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 = BroAlternativeBackground;
                }

                ThreadList.Children.Add(labelName);
                offset += row.Height;
            }

            InitBackgroundMesh();
        }
Esempio n. 20
0
 private void Row_EventNodeHover(Point mousePos, Rect rect, ThreadRow row, EventNode node)
 {
     ThreadViewControl.ToolTipPanel = node != null ? new ThreadView.TooltipInfo {
         Text = String.Format("{0}   {1:0.000}ms", node.Name, node.Duration), Rect = rect
     } : null;
 }