Пример #1
0
        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);
            }
        }
Пример #2
0
        public override void BuildMesh(DirectXCanvas canvas, ThreadScroll scroll)
        {
            if (Timestamps.Count < 2)
            {
                return;
            }

            DirectX.ComplexDynamicMesh builder = new ComplexDynamicMesh(canvas, DIPSpltCount);

            List <Color[]> entryColors = new List <Color[]>();

            foreach (Entry entry in Entries)
            {
                Color color     = entry.Fill;
                Color gradColor = DirectX.Utils.MultiplyColor(color, GradientColorShade);
                //entryColors.Add(new Color[] { leftColor, rightColor, rightColor, leftColor });
                entryColors.Add(new Color[] { color, color, gradColor, gradColor });
            }

            double left = scroll.TimeToUnit(Timestamps[0]);

            for (int i = 0; i < Timestamps.Count - 1; ++i)
            {
                double right = scroll.TimeToUnit(Timestamps[i + 1]);

                double bottom = 0.0;
                for (int entryIndex = 0; entryIndex < Entries.Count; ++entryIndex)
                {
                    double val    = Entries[entryIndex].Values[i];
                    double height = val / MaxValue;

                    if (height > 0.0)
                    {
                        builder.AddRect(new Rect(left, 1.0 - bottom - height, right - left, height), entryColors[entryIndex]);
                        bottom += height;
                    }
                }

                left = right;
            }

            ChartMeshes = builder.Freeze(canvas.RenderDevice);
        }
Пример #3
0
        public override void BuildMesh(DirectX.DirectXCanvas canvas, ThreadScroll scroll)
        {
            DirectX.DynamicMesh builder = canvas.CreateMesh();
            builder.Geometry = DirectX.Mesh.GeometryType.Lines;

            double headerHeight = 1.0;            //(Height - RenderParams.BaseMargin) / scroll.Height;

            // Adding Tickers
            if (EnableTickers)
            {
                for (double tick = Math.Ceiling(scroll.TimeSlice.StartMS); tick < Math.Ceiling(scroll.TimeSlice.FinishMS); tick += 1.0)
                {
                    double longX = scroll.TimeToUnit(new Tick {
                        Start = Durable.MsToTick(tick)
                    });
                    builder.AddLine(new Point(longX, headerHeight * 3.0 / 6.0), new Point(longX, headerHeight), TickColor);

                    double medX = scroll.TimeToUnit(new Tick {
                        Start = Durable.MsToTick(tick + 0.5)
                    });
                    builder.AddLine(new Point(medX, headerHeight * 4.0 / 6.0), new Point(medX, headerHeight), TickColor);


                    for (double miniTick = 0.1; miniTick < 1.0; miniTick += 0.1)
                    {
                        double miniX = scroll.TimeToUnit(new Tick {
                            Start = Durable.MsToTick(tick + miniTick)
                        });
                        builder.AddLine(new Point(miniX, headerHeight * 5.0 / 6.0), new Point(miniX, headerHeight), TickColor);
                    }
                }
            }
            BackgroundMeshLines = builder.Freeze(canvas.RenderDevice);

            DirectX.DynamicMesh builderHeader = canvas.CreateMesh();
            builderHeader.AddRect(new Rect(0.0, 0.0, 1.0, headerHeight), new Color[] { GradientTop, GradientTop, GradientBottom, GradientBottom });
            BackgroundMeshTris = builderHeader.Freeze(canvas.RenderDevice);
        }
Пример #4
0
        public override void BuildMesh(DirectX.DirectXCanvas canvas, ThreadScroll scroll)
        {
            DirectX.DynamicMesh builder = canvas.CreateMesh();
            builder.Geometry = DirectX.Mesh.GeometryType.Lines;

            foreach (EventFrame frame in Group.MainThread.Events)
            {
                double x = scroll.TimeToUnit(frame.Header).Left;
                builder.AddLine(new Point(x, 0.0), new Point(x, 1.0), SplitLines);
            }
            BackgroundMeshLines = builder.Freeze(canvas.RenderDevice);

            DirectX.DynamicMesh builderHeader = canvas.CreateMesh();
            builderHeader.AddRect(new Rect(0.0, 0.0, 1.0, (Height - RenderParams.BaseMargin) / scroll.Height), new Color[] { GradientTop, GradientTop, GradientBottom, GradientBottom });
            BackgroundMeshTris = builderHeader.Freeze(canvas.RenderDevice);
        }
Пример #5
0
        void BuildMeshNode(DirectX.DynamicMesh builder, ThreadScroll scroll, EventNode node, int level)
        {
            if (level == MaxDepth)
            {
                return;
            }

            Interval interval = scroll.TimeToUnit(node.Entry);

            double y = (double)level / MaxDepth;
            double h = 1.0 / MaxDepth;

            builder.AddRect(new Rect(interval.Left, y, interval.Width, h), node.Description.Color);

            foreach (EventNode child in node.Children)
            {
                BuildMeshNode(builder, scroll, child, level + 1);
            }
        }
Пример #6
0
        public void FocusOn(EventFrame frame, EventNode node)
        {
            Group = frame.Group;
            SelectionList.Clear();
            SelectionList.Add(new Selection()
            {
                Frame = frame, Node = node
            });

            Interval interval = scroll.TimeToUnit(node != null ? (IDurable)node.Entry : (IDurable)frame);

            if (!scroll.ViewUnit.Intersect(interval))
            {
                scroll.ViewUnit.Width = interval.Width * DefaultFrameZoom;
                scroll.ViewUnit.Left  = interval.Left - (scroll.ViewUnit.Width - interval.Width) * 0.5;
                scroll.ViewUnit.Normalize();
                UpdateBar();
            }

            UpdateSurface();
        }
Пример #7
0
        void BuildMeshNode(DirectX.ComplexDynamicMesh builder, ThreadScroll scroll, EventNode node, int level)
        {
            if (level == MaxDepth)
            {
                return;
            }

            Interval interval = scroll.TimeToUnit(node.Entry);

            double y = (double)level / MaxDepth;
            double h = 1.0 / MaxDepth;

            Color nodeColor     = node.Description.ForceColor;
            Color nodeGradColor = DirectX.Utils.MultiplyColor(nodeColor, NodeGradientShade);

            builder.AddRect(new Rect(interval.Left, y, interval.Width, h), new Color[] { nodeColor, nodeGradColor, nodeGradColor, nodeColor });

            foreach (EventNode child in node.Children)
            {
                BuildMeshNode(builder, scroll, child, level + 1);
            }
        }
Пример #8
0
        public override void BuildMesh(DirectX.DirectXCanvas canvas, ThreadScroll scroll)
        {
            SetBusy(true);
            UpdateDepth();

            // Build Mesh
            DirectX.ComplexDynamicMesh builder         = new ComplexDynamicMesh(canvas, DIPSplitCount);
            DirectX.ComplexDynamicMesh syncBuilder     = new ComplexDynamicMesh(canvas, DIPSplitCount);
            DirectX.ComplexDynamicMesh syncWorkBuilder = new ComplexDynamicMesh(canvas, DIPSplitCount);

            if (EventData.Sync != null && EventData.Sync != null)
            {
                SyncReason stallReason    = SyncReason.SyncReasonCount;
                long       stallFrom      = 0;
                int        frameSyncIndex = 0;

                for (int i = 0; i < EventData.Sync.Count; i++)
                {
                    SyncInterval sync = EventData.Sync[i];

                    Interval workInterval = scroll.TimeToUnit(sync);

                    //draw work
                    int coreColorIndex = (int)sync.Core;
                    coreColorIndex = coreColorIndex % WorkColors.Length;
                    Color WorkColor = WorkColors[coreColorIndex];
                    syncWorkBuilder.AddRect(new Rect(workInterval.Left, 0, workInterval.Right - workInterval.Left, SyncLineHeight / Height), WorkColor);

                    if (i == 0)
                    {
                        stallReason = sync.Reason;
                        stallFrom   = sync.Finish;
                        continue;
                    }

                    long workStart  = sync.Start;
                    long workFinish = sync.Finish;

                    while (frameSyncIndex < EventData.Events.Count && EventData.Events[frameSyncIndex].Finish < stallFrom)
                    {
                        ++frameSyncIndex;
                    }

                    //Ignoring all the waiting outside marked work to simplify the view
                    if (frameSyncIndex < EventData.Events.Count && EventData.Events[frameSyncIndex].Start <= workStart)
                    {
                        Durable  syncDurable  = new Durable(stallFrom, workStart);
                        Interval syncInterval = scroll.TimeToUnit(syncDurable);

                        double syncWidth = syncInterval.Right - syncInterval.Left;
                        if (syncWidth > 0)
                        {
                            // draw sleep
                            Color waitColor = IsUserInitiatedSync(stallReason) ? SynchronizationColorUser : SynchronizationColor;
                            syncBuilder.AddRect(new Rect(syncInterval.Left, 0, syncWidth, SyncLineHeight / Height), waitColor);
                        }
                    }

                    stallFrom   = workFinish;
                    stallReason = sync.Reason;
                }
            }

            foreach (EventFrame frame in EventData.Events)
            {
                Durable   interval = Group.Board.TimeSlice;
                EventTree tree     = GetTree(frame);
                foreach (EventNode node in tree.Children)
                {
                    BuildMeshNode(builder, scroll, node, 0);
                }
            }

            Blocks       = builder.Freeze(canvas.RenderDevice);
            SyncMesh     = syncBuilder.Freeze(canvas.RenderDevice);
            SyncWorkMesh = syncWorkBuilder.Freeze(canvas.RenderDevice);

            CallstackMeshPolys            = canvas.CreateMesh();
            CallstackMeshPolys.Projection = Mesh.ProjectionType.Pixel;

            CallstackMeshLines            = canvas.CreateMesh();
            CallstackMeshLines.Geometry   = Mesh.GeometryType.Lines;
            CallstackMeshLines.Projection = Mesh.ProjectionType.Pixel;

            SetBusy(false);
        }
Пример #9
0
        public override void Render(DirectX.DirectXCanvas canvas, ThreadScroll scroll)
        {
            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 (Mesh != null)
            {
                Mesh.World = world;
                canvas.Draw(Mesh);
            }

            if (FilterMesh != null)
            {
                FilterMesh.World = world;
                canvas.Draw(FilterMesh);
            }

            if (SyncMesh != null)
            {
                SyncMesh.World = world;
                canvas.Draw(SyncMesh);
            }

            if (CallstackMeshPolys != null && CallstackMeshLines != null && scroll.DrawCallstacks)
            {
                double unitWidth  = scroll.PixelToUnitLength(CallstackMarkerSize * 0.5);
                double unitHeight = (CallstackMarkerSize / RenderParams.BaseHeight) / MaxDepth;
                double offset     = (CallstackMarkerOffset / RenderParams.BaseHeight) / MaxDepth;

                Data.Utils.ForEachInsideInterval(EventData.Callstacks, scroll.ViewTime, callstack =>
                {
                    double center = scroll.TimeToUnit(callstack);

                    Point a = new Point(center - unitWidth, offset);
                    Point b = new Point(center, offset + unitHeight);
                    Point c = new Point(center + unitWidth, 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.DrawLater(CallstackMeshPolys);
                canvas.DrawLater(CallstackMeshLines);
            }

            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);
                });
            });
        }
Пример #10
0
        public override void BuildMesh(DirectX.DirectXCanvas canvas, ThreadScroll scroll)
        {
            // Build Mesh
            DirectX.DynamicMesh builder     = canvas.CreateMesh();
            DirectX.DynamicMesh syncBuilder = canvas.CreateMesh();

            if (EventData.Sync != null && EventData.Sync.Intervals != null)
            {
                SyncReason stallReason = SyncReason.SyncReasonCount;
                long       stallFrom   = 0;
                for (int i = 0; i < EventData.Sync.Intervals.Count; i++)
                {
                    SyncInterval sync = EventData.Sync.Intervals[i];

                    Interval workInterval = scroll.TimeToUnit(sync);

                    // draw work
                    int coreColorIndex = (int)sync.Core;
                    coreColorIndex = coreColorIndex % WorkColors.Length;
                    Color WorkColor = WorkColors[coreColorIndex];
                    syncBuilder.AddRect(new Rect(workInterval.Left, RenderParams.BaseMargin / Height, workInterval.Right - workInterval.Left, SyncLineHeight / Height), WorkColor);

                    if (i == 0)
                    {
                        stallReason = sync.Reason;
                        stallFrom   = sync.Finish;
                        continue;
                    }

                    long     workStart    = sync.Start;
                    long     workFinish   = sync.Finish;
                    Interval syncInterval = scroll.TimeToUnit(new Durable(stallFrom, workStart));

                    double syncWidth = syncInterval.Right - syncInterval.Left;
                    if (syncWidth <= 0)
                    {
                        syncWidth = 0.1;
                    }

                    // draw sleep
                    Color waitColor = IsUserInitiatedSync(stallReason) ? SynchronizationColorUser : SynchronizationColor;
                    syncBuilder.AddRect(new Rect(syncInterval.Left, RenderParams.BaseMargin / Height, syncWidth, SyncLineHeight / Height), waitColor);

                    stallFrom   = workFinish;
                    stallReason = sync.Reason;
                }
            }

            foreach (EventFrame frame in EventData.Events)
            {
                Durable interval = Group.Board.TimeSlice;

                foreach (EventNode node in frame.CategoriesTree.Children)
                {
                    BuildMeshNode(builder, scroll, node, 0);
                }
            }

            Mesh     = builder.Freeze(canvas.RenderDevice);
            SyncMesh = syncBuilder.Freeze(canvas.RenderDevice);

            CallstackMeshPolys = canvas.CreateMesh();

            CallstackMeshLines          = canvas.CreateMesh();
            CallstackMeshLines.Geometry = Mesh.GeometryType.Lines;
        }