private void applyFrameTime(FrameStatistics frame)
        {
            TimeBar       timeBar = timeBars[timeBarIndex];
            TextureUpload upload  = new TextureUpload(HEIGHT * 4, textureBufferStack)
            {
                Bounds = new RectangleI(timeBarX, 0, 1, HEIGHT)
            };

            int currentHeight = HEIGHT;

            for (int i = 0; i < FrameStatistics.NUM_PERFORMANCE_COLLECTION_TYPES; i++)
            {
                currentHeight = addArea(frame, (PerformanceCollectionType)i, currentHeight, upload.Data, amount_ms_steps);
            }
            addArea(frame, null, currentHeight, upload.Data, amount_ms_steps);

            timeBar.Sprite.Texture.SetData(upload);

            timeBars[timeBarIndex].MoveToX(WIDTH - timeBarX);
            timeBars[(timeBarIndex + 1) % timeBars.Length].MoveToX(-timeBarX);
            currentX = (currentX + 1) % (timeBars.Length * WIDTH);

            foreach (Drawable e in timeBars[(timeBarIndex + 1) % timeBars.Length].Children)
            {
                if (e is Box && e.DrawPosition.X <= timeBarX)
                {
                    e.Expire();
                }
            }
        }
Esempio n. 2
0
        private void applyFrameTime(FrameStatistics frame)
        {
            TimeBar       timeBar = timeBars[TimeBarIndex];
            TextureUpload upload  = new TextureUpload(HEIGHT * 4, textureBufferStack)
            {
                Bounds = new Rectangle(TimeBarX, 0, 1, HEIGHT)
            };

            int currentHeight = HEIGHT;

            for (int i = 0; i <= (int)PerformanceCollectionType.Empty; i++)
            {
                currentHeight = addArea(frame, (PerformanceCollectionType)i, currentHeight, upload.Data, AMOUNT_MS_STEPS);
            }

            timeBar.Sprite.Texture.SetData(upload);

            timeBars[TimeBarIndex].MoveToX((WIDTH - TimeBarX));
            timeBars[(TimeBarIndex + 1) % timeBars.Length].MoveToX(-TimeBarX);
            currentX = (currentX + 1) % (timeBars.Length * WIDTH);

            foreach (Drawable e in timeBars[(TimeBarIndex + 1) % timeBars.Length].Children)
            {
                if (e is Box && e.DrawPosition.X <= TimeBarX)
                {
                    e.Expire();
                }
            }
        }
        private void applyFrameTime(FrameStatistics frame)
        {
            TimeBar       timeBar = timeBars[timeBarIndex];
            TextureUpload upload  = new TextureUpload(height * 4, textureBufferStack)
            {
                Bounds = new Rectangle(timeBarX, 0, 1, height)
            };

            int currentHeight = height;

            for (int i = 0; i <= (int)PerformanceCollectionType.Empty; i++)
            {
                currentHeight = addArea(frame, (PerformanceCollectionType)i, currentHeight, upload.Data, amount_ms_steps);
            }

            timeBar.Sprite.Texture.SetData(upload);

            timeBars[timeBarIndex].MoveToX(width - timeBarX);
            timeBars[(timeBarIndex + 1) % timeBars.Length].MoveToX(-timeBarX);
            currentX = (currentX + 1) % (timeBars.Length * width);

            foreach (Drawable e in timeBars[(timeBarIndex + 1) % timeBars.Length].Children)
            {
                if (e is Box && e.DrawPosition.X <= timeBarX)
                {
                    e.Expire();
                }
            }
        }
Esempio n. 4
0
        protected override void Update()
        {
            base.Update();

            FrameStatistics frame;

            while (monitor.PendingFrames.TryDequeue(out frame))
            {
                if (processFrames)
                {
                    foreach (int gcLevel in frame.GarbageCollections)
                    {
                        addEvent(gcLevel);
                    }

                    TimeBar       timeBar = timeBars[TimeBarIndex];
                    TextureUpload upload  = new TextureUpload(HEIGHT * 4, textureBufferStack)
                    {
                        Bounds = new Rectangle(TimeBarX, 0, 1, HEIGHT)
                    };

                    int currentHeight = HEIGHT;

                    for (int i = 0; i <= (int)PerformanceCollectionType.Empty; i++)
                    {
                        currentHeight = addArea(frame, (PerformanceCollectionType)i, currentHeight, upload.Data);
                    }

                    timeBar.Sprite.Texture.SetData(upload);

                    timeBars[TimeBarIndex].MoveToX((WIDTH - TimeBarX));
                    timeBars[(TimeBarIndex + 1) % timeBars.Length].MoveToX(-TimeBarX);
                    currentX = (currentX + 1) % (timeBars.Length * WIDTH);

                    foreach (Drawable e in timeBars[(TimeBarIndex + 1) % timeBars.Length].Children)
                    {
                        if (e is Box && e.Position.X <= TimeBarX)
                        {
                            e.Expire();
                        }
                    }
                }

                monitor.FramesHeap.FreeObject(frame);
            }
        }
Esempio n. 5
0
        private void load(OsuConfigManager config)
        {
            snakingIn  = config.GetBindable <bool>(OsuConfig.SnakingInSliders);
            snakingOut = config.GetBindable <bool>(OsuConfig.SnakingOutSliders);

            int textureWidth = (int)PathWidth * 2;

            //initialise background
            var upload = new TextureUpload(textureWidth * 4);
            var bytes  = upload.Data;

            const float aa_portion       = 0.02f;
            const float border_portion   = 0.128f;
            const float gradient_portion = 1 - border_portion;

            const float opacity_at_centre = 0.3f;
            const float opacity_at_edge   = 0.8f;

            for (int i = 0; i < textureWidth; i++)
            {
                float progress = (float)i / (textureWidth - 1);

                if (progress <= border_portion)
                {
                    bytes[i * 4]     = 255;
                    bytes[i * 4 + 1] = 255;
                    bytes[i * 4 + 2] = 255;
                    bytes[i * 4 + 3] = (byte)(Math.Min(progress / aa_portion, 1) * 255);
                }
                else
                {
                    progress -= border_portion;

                    bytes[i * 4]     = (byte)(slider.ComboColour.R * 255);
                    bytes[i * 4 + 1] = (byte)(slider.ComboColour.G * 255);
                    bytes[i * 4 + 2] = (byte)(slider.ComboColour.B * 255);
                    bytes[i * 4 + 3] = (byte)((opacity_at_edge - (opacity_at_edge - opacity_at_centre) * progress / gradient_portion) * (slider.ComboColour.A * 255));
                }
            }

            var texture = new Texture(textureWidth, 1);

            texture.SetData(upload);
            path.Texture = texture;
        }
Esempio n. 6
0
        private void reloadTexture()
        {
            var texture = new Texture(textureWidth, 1);

            //initialise background
            var upload = new TextureUpload(textureWidth * 4);
            var bytes  = upload.Data;

            const float aa_portion       = 0.02f;
            const float border_portion   = 0.128f;
            const float gradient_portion = 1 - border_portion;

            const float opacity_at_centre = 0.3f;
            const float opacity_at_edge   = 0.8f;

            for (int i = 0; i < textureWidth; i++)
            {
                float progress = (float)i / (textureWidth - 1);

                if (progress <= border_portion)
                {
                    bytes[i * 4]     = (byte)(BorderColour.R * 255);
                    bytes[i * 4 + 1] = (byte)(BorderColour.G * 255);
                    bytes[i * 4 + 2] = (byte)(BorderColour.B * 255);
                    bytes[i * 4 + 3] = (byte)(Math.Min(progress / aa_portion, 1) * (BorderColour.A * 255));
                }
                else
                {
                    progress -= border_portion;

                    bytes[i * 4]     = (byte)(AccentColour.R * 255);
                    bytes[i * 4 + 1] = (byte)(AccentColour.G * 255);
                    bytes[i * 4 + 2] = (byte)(AccentColour.B * 255);
                    bytes[i * 4 + 3] = (byte)((opacity_at_edge - (opacity_at_edge - opacity_at_centre) * progress / gradient_portion) * (AccentColour.A * 255));
                }
            }

            texture.SetData(upload);
            path.Texture = texture;

            container.ForceRedraw();
        }
Esempio n. 7
0
        private void load(OsuConfigManager config)
        {
            snakingIn = config.GetBindable<bool>(OsuConfig.SnakingInSliders);
            snakingOut = config.GetBindable<bool>(OsuConfig.SnakingOutSliders);

            int textureWidth = (int)PathWidth * 2;

            //initialise background
            var upload = new TextureUpload(textureWidth * 4);
            var bytes = upload.Data;

            const float aa_portion = 0.02f;
            const float border_portion = 0.18f;
            const float gradient_portion = 1 - border_portion;

            const float opacity_at_centre = 0.3f;
            const float opacity_at_edge = 0.8f;

            for (int i = 0; i < textureWidth; i++)
            {
                float progress = (float)i / (textureWidth - 1);

                if (progress <= border_portion)
                {
                    bytes[i * 4] = 255;
                    bytes[i * 4 + 1] = 255;
                    bytes[i * 4 + 2] = 255;
                    bytes[i * 4 + 3] = (byte)(Math.Min(progress / aa_portion, 1) * 255);
                }
                else
                {
                    progress -= border_portion;

                    bytes[i * 4] = (byte)(slider.Colour.R * 255);
                    bytes[i * 4 + 1] = (byte)(slider.Colour.G * 255);
                    bytes[i * 4 + 2] = (byte)(slider.Colour.B * 255);
                    bytes[i * 4 + 3] = (byte)((opacity_at_edge - (opacity_at_edge - opacity_at_centre) * progress / gradient_portion) * (slider.Colour.A * 255));
                }
            }

            var texture = new Texture(textureWidth, 1);
            texture.SetData(upload);
            path.Texture = texture;
        }
Esempio n. 8
0
        public override void Load()
        {
            base.Load();

            Size  = new Vector2(WIDTH, HEIGHT);
            Alpha = alpha_when_inactive;

            for (int i = 0; i < timeBars.Length; ++i)
            {
                timeBars[i] = new TimeBar();
            }

            Children = new Drawable[]
            {
                new Container
                {
                    Masking          = true,
                    RelativeSizeAxes = Axes.Both,
                    Children         = timeBars
                },
                fpsDisplay = new FpsDisplay(monitor.Clock)
                {
                    Anchor = Anchor.BottomRight,
                    Origin = Anchor.BottomRight,
                },
                overlayContainer = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Children         = new []
                    {
                        new SpriteText
                        {
                            Text     = Name,
                            Origin   = Anchor.BottomCentre,
                            Anchor   = Anchor.CentreLeft,
                            Rotation = -90
                        },
                        legendContainer = new FlowContainer
                        {
                            Anchor   = Anchor.TopRight,
                            Origin   = Anchor.TopRight,
                            Padding  = new Vector2(5, 1),
                            Children = new[]
                            {
                                new Box
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    Colour           = Color4.Black,
                                    Alpha            = 0.2f
                                }
                            }
                        },
                        new SpriteText
                        {
                            Text = $@"{visible_range}ms"
                        },
                        new SpriteText
                        {
                            Text   = @"0ms",
                            Anchor = Anchor.BottomLeft,
                            Origin = Anchor.BottomLeft
                        }
                    }
                }
            };

            foreach (PerformanceCollectionType t in Enum.GetValues(typeof(PerformanceCollectionType)))
            {
                if (t >= PerformanceCollectionType.Empty)
                {
                    continue;
                }

                legendContainer.Add(legendMapping[(int)t] = new SpriteText
                {
                    Colour = getColour(t),
                    Text   = t.ToString(),
                    Alpha  = 0
                });
            }

            overlayContainer.FadeOut(2000, EasingTypes.InExpo);

            // Initialize background
            for (int i = 0; i < WIDTH * timeBars.Length; ++i)
            {
                currentX = i;

                TextureUpload upload = new TextureUpload(HEIGHT * 4, textureBufferStack)
                {
                    Bounds = new Rectangle(TimeBarX, 0, 1, HEIGHT)
                };

                addArea(null, PerformanceCollectionType.Empty, HEIGHT, upload.Data);
                timeBars[TimeBarIndex].Sprite.Texture.SetData(upload);
            }
        }
Esempio n. 9
0
        protected override void LoadComplete()
        {
            Host.Window.Title = "FrameworkTester";
            base.LoadComplete();

            Add(new Box
            {
                Colour           = Color4.Gray,
                RelativeSizeAxes = Axes.Both,
            });
            Add(container = new BufferedContainer
            {
                CacheDrawnFrameBuffer = true,
                Child = path = new Path
                {
                    PathWidth = 50,
                    Name      = "Path1",
                    Blending  = BlendingMode.None,
                },
            });

            container.Attach(RenderbufferInternalFormat.DepthComponent16);

            populatePoints();

            int textureWidth = (int)path.PathWidth * 2;

            var texture = new Texture(textureWidth, 1);

            //initialise background
            var upload = new TextureUpload(textureWidth * 4);
            var bytes  = upload.Data;

            const float aa_portion     = .75f;
            const float border_portion = .75f;

            for (int i = 0; i < textureWidth; i++)
            {
                float progress = (float)i / (textureWidth - 1);

                if (progress <= border_portion)
                {
                    bytes[i * 4]     = (byte)(255 - 255 * progress);
                    bytes[i * 4 + 1] = (byte)(255 - 255 * progress);
                    bytes[i * 4 + 2] = (byte)(255 - 255 * progress);
                    bytes[i * 4 + 3] = (byte)(Math.Min(progress / aa_portion, 1) * 255);
                }
                else
                {
                    bytes[i * 4]     = (byte)(255 - 255 * progress);
                    bytes[i * 4 + 1] = (byte)(255 - 255 * progress);
                    bytes[i * 4 + 2] = (byte)(255 - 255 * progress);
                    bytes[i * 4 + 3] = 255;
                }
            }

            texture.SetData(upload);
            path.Texture = texture;

            newPoints();
            container.Size = path.Size;
        }
Esempio n. 10
0
        public override void Load()
        {
            base.Load();

            Container timeBarContainer;

            Children = new Drawable[] {
                new SpriteText
                {
                    Text     = Name,
                    Origin   = Anchor.BottomCentre,
                    Anchor   = Anchor.CentreLeft,
                    Rotation = -90,
                },
                new MaskingContainer
                {
                    Children = new [] {
                        timeBarContainer = new LargeContainer(),
                        legendContainer  = new FlowContainer {
                            Anchor   = Anchor.TopRight,
                            Origin   = Anchor.TopRight,
                            Padding  = new Vector2(5, 1),
                            Children = new [] {
                                new Box {
                                    SizeMode = InheritMode.XY,
                                    Colour   = Color4.Gray,
                                    Alpha    = 0.2f,
                                }
                            }
                        },
                        new SpriteText
                        {
                            Text = $@"{visible_range}ms",
                        },
                        new SpriteText
                        {
                            Text   = @"0ms",
                            Anchor = Anchor.BottomLeft,
                            Origin = Anchor.BottomLeft
                        },
                    }
                },
            };

            for (int i = 0; i < timeBars.Length; ++i)
            {
                timeBars[i] = new Sprite(new Texture(WIDTH, HEIGHT));
                timeBarContainer.Add(
                    timeBarContainers[i] = new Container
                {
                    Children = new [] { timeBars[i] },
                    Width    = WIDTH,
                    Height   = HEIGHT,
                }
                    );
            }

            foreach (PerformanceCollectionType t in Enum.GetValues(typeof(PerformanceCollectionType)))
            {
                if (t >= PerformanceCollectionType.Empty)
                {
                    continue;
                }

                legendContainer.Add(legendMapping[(int)t] = new SpriteText()
                {
                    Colour = getColour(t),
                    Text   = t.ToString(),
                    Alpha  = 0
                });

                legendContainer.FadeOut(2000, EasingTypes.InExpo);
            }

            // Initialize background
            for (int i = 0; i < WIDTH * timeBars.Length; ++i)
            {
                currentX = i;
                Sprite timeBar = timeBars[TimeBarIndex];

                TextureUpload upload = new TextureUpload(HEIGHT * 4, textureBufferStack)
                {
                    Bounds = new Rectangle(TimeBarX, 0, 1, HEIGHT)
                };

                addArea(null, PerformanceCollectionType.Empty, HEIGHT, upload.Data);
                timeBar.Texture.SetData(upload);
            }
        }