Пример #1
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);
                }
            }
        }
Пример #2
0
        public override void Render(DirectX.DirectXCanvas canvas, ThreadScroll scroll, DirectXCanvas.Layer layer, Rect box)
        {
            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  = CallstackMarkerRadius;
                    double height = CallstackMarkerRadius;
                    double offset = (box.Top + box.Bottom) * 0.5;

                    Data.Utils.ForEachInsideInterval(EventData.Callstacks, scroll.ViewTime, callstack =>
                    {
                        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);
                }
            }
        }