Exemplo 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);
        }
Exemplo n.º 2
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)
                    {
                        if (rect.IsEmpty)
                        {
                            break;
                        }
                        rect.Inflate(SelectionBorderStep, SelectionBorderStep);
                        SelectionMesh.AddRect(rect, FrameSelection.Color);
                    }
                }
            }

            SelectionMesh.Update(canvas.RenderDevice);
            canvas.Draw(SelectionMesh);
        }
Exemplo n.º 3
0
 private void Row_ExpandChanged(ThreadRow row)
 {
     //Task.Run(()=>
     //{
     row.BuildMesh(surface, Scroll);
     UpdateRowsAsync();
     //});
 }
Exemplo 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);
        }
Exemplo 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 FocusFrameEventArgs(GlobalEvents.FocusFrameEvent, focusFrame, null));
        }
Exemplo n.º 6
0
        public void Highlight(EventFrame frame, IDurable focus)
        {
            Group = frame.Group;
            ThreadRow row = null;

            id2row.TryGetValue(frame.Header.ThreadIndex, out row);
            Highlight(new ThreadViewControl.Selection[] { new ThreadViewControl.Selection()
                                                          {
                                                              Frame = frame, Focus = focus, Row = row
                                                          } });
        }
Exemplo n.º 7
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();
        }
Exemplo n.º 8
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();
        }
Exemplo n.º 9
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();
            }
        }
Exemplo n.º 10
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();
            }
        }
Exemplo n.º 11
0
 private void Row_EventNodeHover(Point mousePos, Rect rect, ThreadRow row, EventNode node)
 {
     ThreadViewControl.ToolTipPanel = node != null ? new ThreadViewControl.TooltipInfo {
         Text = String.Format("{0}   {1:0.000}ms", node.Name, node.Duration), Rect = rect
     } : null;
 }
Exemplo n.º 12
0
 private void Row_VisibilityChanged(ThreadRow row)
 {
     //throw new NotImplementedException();
 }
 private void Row_EventNodeHover(Point mousePos, Rect rect, ThreadRow row, EventNode node)
 {
     ThreadViewControl.ToolTipPanel = node != null ? new ThreadViewControl.TooltipInfo {
         Text = String.Format("{0}   {1:0.#} ({2:0.#}%)", node.Description.FullName, node.Duration, 100.0 * node.Duration / Frame.Root.Duration), Rect = rect
     } : null;
 }