fix large textures being generated by Canvas gradients and crashing the game.

This commit is contained in:
nilllzz 2018-01-07 12:08:55 +01:00
parent e1ef269623
commit 79777f7bf1
1 changed files with 4 additions and 2 deletions

View File

@ -268,15 +268,17 @@
Dim gConfig As GradientConfiguration = Nothing
Dim foundConfig As Boolean = False
Dim textureWidth = Math.Min(Rectangle.Width, 2048)
Dim textureHeight = Math.Min(Rectangle.Height, 2048)
For Each g As GradientConfiguration In gradientConfigs
If g.IsConfig(Rectangle.Width, Rectangle.Height, fromColor, toColor, Horizontal, Steps) Then
If g.IsConfig(textureWidth, textureHeight, fromColor, toColor, Horizontal, Steps) Then
gConfig = g
foundConfig = True
Exit For
End If
Next
If foundConfig = False Then
gConfig = New GradientConfiguration(Rectangle.Width, Rectangle.Height, fromColor, toColor, Horizontal, Steps)
gConfig = New GradientConfiguration(textureWidth, textureHeight, fromColor, toColor, Horizontal, Steps)
gradientConfigs.Add(gConfig)
End If
gConfig.Draw(spriteBatch, Rectangle)