Skip to content

Commit

Permalink
fix Texture2D.SetData() checkedRect (#1299)
Browse files Browse the repository at this point in the history
  • Loading branch information
nkast authored Mar 9, 2024
1 parent 05e99c6 commit fc03c52
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Xna.Framework.Graphics/Graphics/Texture2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,13 @@ public void SetData<T>(int level, Rectangle? rect, T[] data, int startIndex, int
{
ValidateArrayBounds<T>(0, data, startIndex, elementCount);
Rectangle textureBounds = new Rectangle(0, 0, Math.Max(Width >> level, 1), Math.Max(Height >> level, 1));
bool rectHasValue = rect.HasValue;
if (rect == null)
rect = textureBounds;
ValidateRect<T>(level, ref textureBounds, rect.Value);
Rectangle checkedRect;
ValidateParams<T>(level, rect.Value, elementCount, ref textureBounds, out checkedRect);
if (rect.HasValue)
if (rectHasValue)
_strategyTexture2D.SetData<T>(level, 0, checkedRect, data, startIndex, elementCount);
else
_strategyTexture2D.SetData<T>(level, data, startIndex, elementCount);
Expand Down

0 comments on commit fc03c52

Please sign in to comment.