/// <summary>
        /// Processes a collection of files, each of which represents a separate layer of the surface.
        /// </summary>
        private Surface3D ProcessMultipleFiles(ContentManager manager, IContentProcessorMetadata metadata, PlatformNativeSurface input, String filename)
        {
            var mdat        = metadata.As <SDL2Surface3DProcessorMetadata>();
            var srgbEncoded = mdat.SrgbEncoded ?? manager.Ultraviolet.Properties.SrgbDefaultForSurface3D;

            var layer0     = input.CreateCopy();
            var layers     = new Dictionary <Int32, String>();
            var layerIndex = 1;

            var extension = Path.GetExtension(metadata.AssetFileName);
            var directory = (metadata.AssetPath == null) ? String.Empty : Path.GetDirectoryName(metadata.AssetPath);

            if (!String.IsNullOrEmpty(directory))
            {
                var assetsInDirectory = manager.GetAssetFilePathsInDirectory(directory);
                while (true)
                {
                    var layerAsset = assetsInDirectory.Where(x => String.Equals(Path.GetFileName(x),
                                                                                $"{filename}_{layerIndex}{extension}", StringComparison.OrdinalIgnoreCase)).SingleOrDefault();
                    if (layerAsset == null)
                    {
                        break;
                    }

                    layerAsset = ResolveDependencyAssetPath(metadata, Path.GetFileName(layerAsset));

                    layers[layerIndex] = layerAsset;
                    layerIndex++;
                }
            }

            var surfaceOpts = srgbEncoded ? SurfaceOptions.SrgbColor : SurfaceOptions.LinearColor;
            var surface     = new SDL2Surface3D(manager.Ultraviolet, layer0.Width, layer0.Height, 1 + layers.Count, layer0.BytesPerPixel, surfaceOpts);

            var surfaceLayer0 = Surface2D.Create(layer0);

            surfaceLayer0.SrgbEncoded = srgbEncoded;
            surface.SetLayer(0, surfaceLayer0, true);

            for (int i = 0; i < layers.Count; i++)
            {
                var layerAsset = layers[1 + i];
                metadata.AddAssetDependency(layerAsset);

                var layerSurface = manager.Load <Surface2D>(layerAsset, metadata.AssetDensity, false, metadata.IsLoadedFromSolution);
                layerSurface.SrgbEncoded = srgbEncoded;
                surface.SetLayer(1 + i, layerSurface, true);
            }

            return(surface);
        }
        /// <summary>
        /// Processes a single file which has all of the layers of the surface within it.
        /// </summary>
        private Surface3D ProcessSingleFile(ContentManager manager, IContentProcessorMetadata metadata, PlatformNativeSurface input)
        {
            var mdat        = metadata.As <SDL2Surface3DProcessorMetadata>();
            var srgbEncoded = mdat.SrgbEncoded ?? manager.Ultraviolet.Properties.SrgbDefaultForSurface3D;

            // Layers must be square. Validate our dimensions.
            var layerHeight = input.Height;
            var layerWidth  = layerHeight;
            var layerCount  = input.Width / layerWidth;

            if (input.Width % layerWidth != 0)
            {
                throw new InvalidDataException(SDL2Strings.SurfaceMustHaveSquareLayers);
            }

            // Create surfaces for each of our layers.
            using (var mainSurface = Surface2D.Create(input))
            {
                mainSurface.SrgbEncoded = srgbEncoded;

                var resultOpts = srgbEncoded ? SurfaceOptions.SrgbColor : SurfaceOptions.LinearColor;
                var result     = new SDL2Surface3D(manager.Ultraviolet, layerWidth, layerHeight, layerCount, mainSurface.BytesPerPixel, resultOpts);
                for (int i = 0; i < layerCount; i++)
                {
                    var layerSurface = mainSurface.CreateSurface(new Rectangle(i * layerWidth, 0, layerWidth, layerHeight));
                    result.SetLayer(i, layerSurface, true);
                }
                return(result);
            }
        }
        /// <inheritdoc/>
        public override Surface3D CreateSurface()
        {
            Contract.EnsureNotDisposed(this, Disposed);

            var resultOpts = SrgbEncoded ? SurfaceOptions.SrgbColor : SurfaceOptions.LinearColor;
            var result     = new SDL2Surface3D(Ultraviolet, Width, Height, Depth, BytesPerPixel, resultOpts);

            for (int i = 0; i < Depth; i++)
            {
                var layerCopy = this.GetLayer(i).CreateSurface();
                result.SetLayer(i, layerCopy, true);
            }
            return(result);
        }