예제 #1
0
 /// <summary>
 /// stores the textures for later use
 /// </summary>
 /// <param name="tex"></param>
 public void StoreTexture(TextureArray2D tex)
 {
     Debug.Assert(tex != null);
     if (tex.NumMipmaps == images.NumMipmaps)
     {
         // can be used for later
         textures.Push(tex);
     }
     else
     {
         // immediately discard (incompatible image)
         tex.Dispose();
     }
 }
        public TextureArray2D Run(TextureArray2D src, Size3 dstSize, ScalingModel scaling)
        {
            Debug.Assert(src.Size != dstSize);
            var genMipmaps = src.NumMipmaps > 1;
            var numMipmaps = 1;

            if (genMipmaps)
            {
                numMipmaps = dstSize.MaxMipLevels;
            }

            bool changeWidth  = dstSize.Width != src.Size.Width;
            bool changeHeight = dstSize.Height != src.Size.Height;

            if (changeWidth)
            {
                var curMips = numMipmaps;

                if (changeHeight) // only temporary texture with a single mipmap
                {
                    curMips = 1;
                }

                var tmp = new TextureArray2D(new LayerMipmapCount(src.NumLayers, curMips), new Size3(dstSize.Width, src.Size.Height), src.Format, false);
                Apply(src, tmp, 1, 0);
                src = tmp;
            }

            if (changeHeight)
            {
                var tmp = new TextureArray2D(new LayerMipmapCount(src.NumLayers, numMipmaps), dstSize, src.Format, false);

                Apply(src, tmp, 0, 1);
                if (changeWidth) // delete temporary texture created by width invocation
                {
                    src.Dispose();
                }
                src = tmp;
            }

            if (genMipmaps)
            {
                scaling.WriteMipmaps(src);
            }

            return(src);
        }
예제 #3
0
 public void Dispose()
 {
     Texture?.Dispose();
     statisticsTexture?.Dispose();
 }