Exemple #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);
            }
        }
Exemple #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);
        }
Exemple #3
0
 public static void Draw(DirectX.DirectXCanvas canvas, List <Mesh> meshes, Matrix world)
 {
     meshes.ForEach(mesh =>
     {
         mesh.WorldTransform = world;
         canvas.Draw(mesh);
     });
 }
Exemple #4
0
        public void Render(DirectX.DirectXCanvas canvas)
        {
            Freeze(canvas.RenderDevice);

            canvas.RenderDevice.ImmediateContext.PixelShader.SetSampler(0, canvas.TextSamplerState);
            canvas.RenderDevice.ImmediateContext.PixelShader.SetShaderResource(0, SegoeUI.TextureView);

            canvas.Draw(TextMesh);
        }
Exemple #5
0
        void DrawMeasure(DirectX.DirectXCanvas canvas)
        {
            if (IsMeasuring())
            {
                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);
            }
        }
Exemple #6
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);
        }
Exemple #7
0
        public TextManager(DirectX.DirectXCanvas canvas)
        {
            double baseFontSize    = 16.0;
            int    desiredFontSize = (int)(RenderSettings.dpiScaleY * baseFontSize);

            int fontSize = 16;

            int[] sizes = { 16, 20, 24, 28, 32 };
            for (int i = 0; i < sizes.Length; ++i)
            {
                if (desiredFontSize < sizes[i])
                {
                    break;
                }

                fontSize = sizes[i];
            }

            SegoeUI           = Font.Create(canvas.RenderDevice, String.Format("SegoeUI_{0}_Normal", fontSize));
            VertexBuffer      = new DynamicBuffer <Vertex>(canvas.RenderDevice, BindFlags.VertexBuffer);
            IndexBuffer       = new DynamicBuffer <int>(canvas.RenderDevice, BindFlags.IndexBuffer);
            TextMesh          = canvas.CreateMesh(DirectXCanvas.MeshType.Text);
            TextMesh.UseAlpha = true;
        }
Exemple #8
0
 public abstract void ApplyFilter(DirectX.DirectXCanvas canvas, ThreadScroll scroll, HashSet <EventDescription> descriptions);
Exemple #9
0
 public abstract void BuildMesh(DirectX.DirectXCanvas canvas, ThreadScroll scroll);
Exemple #10
0
 public abstract void Render(DirectX.DirectXCanvas canvas, ThreadScroll scroll, DirectXCanvas.Layer layer, Rect box);
Exemple #11
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  = Data.Utils.GetLuminance(entry.Description.ForceColor);
                        Color color = lum < Data.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 || scroll.DrawDataTags))
                {
                    double width  = CallstackMarkerRadius;
                    double height = CallstackMarkerRadius;
                    double offset = Offset + RenderParams.BaseHeight * 0.5;

                    if (scroll.DrawCallstacks != 0)
                    {
                        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);
                            }
                        });
                    }

                    if (scroll.DrawDataTags && EventData.TagsPack != null)
                    {
                        Data.Utils.ForEachInsideInterval(EventData.TagsPack.Tags, scroll.ViewTime, tag =>
                        {
                            double center  = scroll.TimeToPixel(tag);
                            Point[] points = new Point[] { new Point(center - width, Offset), new Point(center + width, Offset), new Point(center, offset) };
                            CallstackMeshPolys.AddTri(points, CallstackColor);
                            CallstackMeshLines.AddTri(points, Colors.Black);
                        });
                    }

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

                    canvas.Draw(CallstackMeshPolys);
                    canvas.Draw(CallstackMeshLines);
                }
            }
        }
Exemple #12
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);
        }