コード例 #1
0
        void OnDraw(DirectX.DirectXCanvas canvas, DirectXCanvas.Layer layer)
        {
            if (layer == DirectXCanvas.Layer.Background)
            {
                canvas.Draw(BackgroundMesh);
            }

            Rect box = new Rect(0, 0, Scroll.Width, Scroll.Height);

            foreach (ThreadRow row in Rows)
            {
                box.Height = row.Height;
                row.Render(canvas, Scroll, layer, box);
                box.Y = box.Y + row.Height;
            }

            if (layer == DirectXCanvas.Layer.Foreground)
            {
                if (ForegroundMesh != null)
                {
                    Matrix world = new Matrix(Scroll.Zoom, 0.0, 0.0, 1.0, -Scroll.ViewUnit.Left * Scroll.Zoom, 0.0);
                    ForegroundMesh.WorldTransform = world;
                    canvas.Draw(ForegroundMesh);
                }

                DrawSelection(canvas);
                DrawHover(canvas);
                DrawMeasure(canvas);
            }
        }
コード例 #2
0
 public static void Draw(DirectX.DirectXCanvas canvas, List <Mesh> meshes, Matrix world)
 {
     meshes.ForEach(mesh =>
     {
         mesh.WorldTransform = world;
         canvas.Draw(mesh);
     });
 }
コード例 #3
0
        public ComplexDynamicMesh(DirectXCanvas canvas, int chunkCount = 20)
        {
            double scaleX = 1.0 / chunkCount;

            for (int i = 0; i < chunkCount; ++i)
            {
                DynamicMesh mesh = canvas.CreateMesh();
                mesh.LocalTransform = new Matrix(scaleX, 0.0, 0.0, 1.0, -i / chunkCount, 0.0);
                DIPs.Add(mesh);
            }
        }
コード例 #4
0
ファイル: ThreadView.xaml.cs プロジェクト: wobbier/brofiler
        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);
            }
        }
コード例 #5
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);
        }
コード例 #6
0
        void OnDraw(DirectX.DirectXCanvas canvas)
        {
            canvas.Draw(BackgroundMesh);

            foreach (ThreadRow.RenderPriority priority in Enum.GetValues(typeof(ThreadRow.RenderPriority)))
            {
                foreach (ThreadRow row in rows)
                {
                    if (row.Priority == priority)
                    {
                        row.Render(canvas, scroll);
                    }
                }
            }

            DrawSelection(canvas);
            DrawHover(canvas);
        }
コード例 #7
0
        void OnDraw(DirectX.DirectXCanvas canvas, DirectXCanvas.Layer layer)
        {
            if (layer == DirectXCanvas.Layer.Background)
            {
                canvas.Draw(BackgroundMesh);
            }

            foreach (ThreadRow row in rows)
            {
                row.Render(canvas, scroll, layer);
            }

            if (layer == DirectXCanvas.Layer.Foreground)
            {
                DrawSelection(canvas);
                DrawHover(canvas);
                DrawMeasure(canvas);
            }
        }
コード例 #8
0
ファイル: ThreadRow.cs プロジェクト: withdrawmemory/optick
        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);
        }
コード例 #9
0
ファイル: ThreadView.xaml.cs プロジェクト: wobbier/brofiler
        void OnDraw(DirectX.DirectXCanvas canvas, DirectXCanvas.Layer layer)
        {
            if (layer == DirectXCanvas.Layer.Background)
            {
                canvas.Draw(BackgroundMesh);
            }

            Rect box = new Rect(0, 0, scroll.Width, scroll.Height);

            foreach (ThreadRow row in rows)
            {
                box.Height = row.Height;
                row.Render(canvas, scroll, layer, box);
                box.Y = box.Y + row.Height;
            }

            if (layer == DirectXCanvas.Layer.Foreground)
            {
                DrawSelection(canvas);
                DrawHover(canvas);
                DrawMeasure(canvas);
            }
        }
コード例 #10
0
ファイル: ThreadRow.cs プロジェクト: SergeyMakeev/brofiler
        public override void Render(DirectX.DirectXCanvas canvas, ThreadScroll scroll)
        {
            SharpDX.Matrix world = SharpDX.Matrix.Scaling((float)scroll.Zoom, 1.0f, 1.0f);
            world.TranslationVector = new SharpDX.Vector3(-(float)(scroll.ViewUnit.Left * scroll.Zoom), 0.0f, 0.0f);

            BackgroundMeshLines.World = world;
            BackgroundMeshTris.World  = world;

            canvas.Draw(BackgroundMeshTris);
            canvas.Draw(BackgroundMeshLines);

            Data.Utils.ForEachInsideInterval(Group.MainThread.Events, scroll.ViewTime, frame =>
            {
                Interval interval = scroll.TimeToPixel(frame.Header);

                String text = String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:0.0} ms", frame.Header.Duration);

                // 2 times to emulate "bold"
                for (int i = 0; i < 2; ++i)
                {
                    canvas.Text.Draw(new Point(interval.Left, Offset), text, TextColor, TextAlignment.Center, interval.Width);
                }
            });
        }
コード例 #11
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);
        }
コード例 #12
0
ファイル: ThreadView.xaml.cs プロジェクト: wobbier/brofiler
        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);
        }
コード例 #13
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);
        }
コード例 #14
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;
        }
コード例 #15
0
ファイル: ThreadRow.cs プロジェクト: withdrawmemory/optick
 public abstract void ApplyFilter(DirectX.DirectXCanvas canvas, ThreadScroll scroll, HashSet <EventDescription> descriptions);
コード例 #16
0
ファイル: ThreadRow.cs プロジェクト: withdrawmemory/optick
 public abstract void BuildMesh(DirectX.DirectXCanvas canvas, ThreadScroll scroll);
コード例 #17
0
ファイル: ThreadRow.cs プロジェクト: withdrawmemory/optick
 public abstract void Render(DirectX.DirectXCanvas canvas, ThreadScroll scroll, DirectXCanvas.Layer layer, Rect box);
コード例 #18
0
        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);
                }
            }
        }
コード例 #19
0
        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  = DirectX.Utils.GetLuminance(entry.Description.ForceColor);
                        Color color = lum < DirectX.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)
                {
                    double width  = CallstackMarkerRadius;
                    double height = CallstackMarkerRadius;
                    double offset = Offset + RenderParams.BaseHeight * 0.5;

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

                    CallstackMeshPolys.Update(canvas.RenderDevice);
                    CallstackMeshLines.Update(canvas.RenderDevice);

                    //CallstackMeshPolys.World = world;
                    //CallstackMeshLines.World = world;

                    canvas.Draw(CallstackMeshPolys);
                    canvas.Draw(CallstackMeshLines);
                }
            }
        }
コード例 #20
0
ファイル: ThreadRow.cs プロジェクト: SergeyMakeev/brofiler
 public abstract void Render(DirectX.DirectXCanvas canvas, ThreadScroll scroll);