From 31f58a33ac13c675ee76701f38db56c2d98b6419 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 28 Feb 2023 18:47:27 +0300 Subject: [PATCH] Use ColourInfo.Interpolate where possible --- osu.Game/Graphics/Backgrounds/TrianglesV2.cs | 16 +--------------- .../Graphics/UserInterface/SegmentedGraph.cs | 8 +------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/osu.Game/Graphics/Backgrounds/TrianglesV2.cs b/osu.Game/Graphics/Backgrounds/TrianglesV2.cs index 3bc8bb6df1..e7af6cf70d 100644 --- a/osu.Game/Graphics/Backgrounds/TrianglesV2.cs +++ b/osu.Game/Graphics/Backgrounds/TrianglesV2.cs @@ -11,7 +11,6 @@ using osu.Framework.Allocation; using System.Collections.Generic; using osu.Framework.Graphics.Rendering; using osu.Framework.Graphics.Rendering.Vertices; -using osu.Framework.Graphics.Colour; using osu.Framework.Bindables; using osu.Framework.Graphics; @@ -259,8 +258,6 @@ namespace osu.Game.Graphics.Backgrounds Vector2Extensions.Transform(triangleQuad.BottomRight * size, DrawInfo.Matrix) ); - ColourInfo colourInfo = triangleColourInfo(DrawColourInfo.Colour, triangleQuad); - RectangleF textureCoords = new RectangleF( triangleQuad.TopLeft.X - topLeft.X, triangleQuad.TopLeft.Y - topLeft.Y, @@ -268,23 +265,12 @@ namespace osu.Game.Graphics.Backgrounds triangleQuad.Height ) / relativeSize; - renderer.DrawQuad(texture, drawQuad, colourInfo, new RectangleF(0, 0, 1, 1), vertexBatch.AddAction, textureCoords: textureCoords); + renderer.DrawQuad(texture, drawQuad, DrawColourInfo.Colour.Interpolate(triangleQuad), new RectangleF(0, 0, 1, 1), vertexBatch.AddAction, textureCoords: textureCoords); } shader.Unbind(); } - private static ColourInfo triangleColourInfo(ColourInfo source, Quad quad) - { - return new ColourInfo - { - TopLeft = source.Interpolate(quad.TopLeft), - TopRight = source.Interpolate(quad.TopRight), - BottomLeft = source.Interpolate(quad.BottomLeft), - BottomRight = source.Interpolate(quad.BottomRight) - }; - } - private static Quad clampToDrawable(Vector2 topLeft, Vector2 size) { float leftClamped = Math.Clamp(topLeft.X, 0f, 1f); diff --git a/osu.Game/Graphics/UserInterface/SegmentedGraph.cs b/osu.Game/Graphics/UserInterface/SegmentedGraph.cs index e8817d5275..91971e5af9 100644 --- a/osu.Game/Graphics/UserInterface/SegmentedGraph.cs +++ b/osu.Game/Graphics/UserInterface/SegmentedGraph.cs @@ -249,13 +249,7 @@ namespace osu.Game.Graphics.UserInterface private ColourInfo getSegmentColour(SegmentInfo segment) { - var segmentColour = new ColourInfo - { - TopLeft = DrawColourInfo.Colour.Interpolate(new Vector2(segment.Start, 0f)), - TopRight = DrawColourInfo.Colour.Interpolate(new Vector2(segment.End, 0f)), - BottomLeft = DrawColourInfo.Colour.Interpolate(new Vector2(segment.Start, 1f)), - BottomRight = DrawColourInfo.Colour.Interpolate(new Vector2(segment.End, 1f)) - }; + var segmentColour = DrawColourInfo.Colour.Interpolate(new Quad(segment.Start, 0f, segment.End - segment.Start, 1f)); var tierColour = segment.Tier >= 0 ? tierColours[segment.Tier] : new Colour4(0, 0, 0, 0); segmentColour.ApplyChild(tierColour);