A game framework written with osu! in mind.

Revert agnostic based approach and base on wrap mode instead

+11 -13
+11 -13
osu.Framework/Graphics/OpenGL/Textures/TextureGLAtlas.cs
··· 49 49 50 50 var data = upload.Data; 51 51 52 - uploadCornerPadding(data, middleBounds, actualPadding); 53 - uploadHorizontalPadding(data, middleBounds, actualPadding); 54 - uploadVerticalPadding(data, middleBounds, actualPadding); 52 + uploadCornerPadding(data, middleBounds, actualPadding, wrapModeS != WrapMode.None && wrapModeT != WrapMode.None); 53 + uploadHorizontalPadding(data, middleBounds, actualPadding, wrapModeS != WrapMode.None); 54 + uploadVerticalPadding(data, middleBounds, actualPadding, wrapModeT != WrapMode.None); 55 55 56 56 // Upload the middle part of the texture 57 57 // For a texture atlas, we don't care about opacity, so we avoid ··· 59 59 base.SetData(upload, wrapModeS, wrapModeT, Opacity.Mixed); 60 60 } 61 61 62 - private void uploadVerticalPadding(ReadOnlySpan<Rgba32> upload, RectangleI middleBounds, int actualPadding) 62 + private void uploadVerticalPadding(ReadOnlySpan<Rgba32> upload, RectangleI middleBounds, int actualPadding, bool fillOpaque) 63 63 { 64 64 RectangleI[] sideBoundsArray = 65 65 { ··· 92 92 Rgba32 pixel = upload[index + x]; 93 93 allTransparent &= checkEdgeRGB(pixel); 94 94 95 - transferBorderPixel(ref data[y * sideBounds.Width + x], pixel); 95 + transferBorderPixel(ref data[y * sideBounds.Width + x], pixel, fillOpaque); 96 96 } 97 97 } 98 98 ··· 107 107 } 108 108 } 109 109 110 - private void uploadHorizontalPadding(ReadOnlySpan<Rgba32> upload, RectangleI middleBounds, int actualPadding) 110 + private void uploadHorizontalPadding(ReadOnlySpan<Rgba32> upload, RectangleI middleBounds, int actualPadding, bool fillOpaque) 111 111 { 112 112 RectangleI[] sideBoundsArray = 113 113 { ··· 143 143 144 144 allTransparent &= checkEdgeRGB(pixel); 145 145 146 - transferBorderPixel(ref data[y * sideBounds.Width + x], pixel); 146 + transferBorderPixel(ref data[y * sideBounds.Width + x], pixel, fillOpaque); 147 147 } 148 148 } 149 149 ··· 158 158 } 159 159 } 160 160 161 - private void uploadCornerPadding(ReadOnlySpan<Rgba32> upload, RectangleI middleBounds, int actualPadding) 161 + private void uploadCornerPadding(ReadOnlySpan<Rgba32> upload, RectangleI middleBounds, int actualPadding, bool fillOpaque) 162 162 { 163 163 RectangleI[] cornerBoundsArray = 164 164 { ··· 189 189 var data = cornerUpload.RawData; 190 190 191 191 for (int j = 0; j < nCornerPixels; ++j) 192 - transferBorderPixel(ref data[j], pixel); 192 + transferBorderPixel(ref data[j], pixel, fillOpaque); 193 193 194 194 // For a texture atlas, we don't care about opacity, so we avoid 195 195 // any computations related to it by assuming it to be mixed. ··· 199 199 } 200 200 201 201 [MethodImpl(MethodImplOptions.AggressiveInlining)] 202 - private void transferBorderPixel(ref Rgba32 dest, Rgba32 source) 202 + private void transferBorderPixel(ref Rgba32 dest, Rgba32 source, bool fillOpaque) 203 203 { 204 204 dest.R = source.R; 205 205 dest.G = source.G; 206 206 dest.B = source.B; 207 - // in the case the adjacent pixel is solid, we presume that it should interpolate to itself (creating a hard edge). 208 - // in the case of pixels with transparency it makes more sense to interpolate to nothing. 209 - dest.A = source.A < 255 ? (byte)0 : source.A; 207 + dest.A = fillOpaque ? source.A : (byte)0; 210 208 } 211 209 212 210 /// <summary>