コード例 #1
0
        private ulong?GetHash()
        {
            if (ReferenceData is null)
            {
                return(null);
            }

            var format    = Reference.Format.IsCompressed() ? SurfaceFormat.Color : Reference.Format;
            int rawStride = format.SizeBytes(Reference.Width);
            int rawOffset = (rawStride * Bounds.Top) + format.SizeBytes(Bounds.Left);

            bool blendEnabled = BlendState.AlphaSourceBlend != Blend.One;
            bool isWater      = TextureType == TextureType.Sprite && SpriteOverrides.IsWater(Bounds, Reference);
            bool isFont       = !isWater && TextureType == TextureType.Sprite && SpriteOverrides.IsFont(Reference, Bounds.Extent, Reference.Extent());
            var  dataHash     = GetDataHash(ReferenceData, Reference, Bounds, rawOffset, rawStride);

            if (dataHash is null)
            {
                return(null);
            }

            var result = HashUtility.Combine(
                dataHash,
                Bounds.Extent.GetLongHashCode(),
                blendEnabled.GetLongHashCode(),
                ExpectedScale.GetLongHashCode(),
                isWater.GetLongHashCode(),
                isFont.GetLongHashCode(),
                Reference.Format.GetLongHashCode(),
                Scaler.GetLongHashCode(),
                ScalerGradient.GetLongHashCode()
                );

            return(result);
        }
コード例 #2
0
    internal static ulong GetHash(SpriteInfo input, TextureType textureType)
    {
        // Need to make Hashing.CombineHash work better.
        var hash = input.Hash;

        if (Config.Resample.EnableDynamicScale)
        {
            hash = HashUtility.Combine(hash, HashUtility.Rehash(input.ExpectedScale));
        }

        if (textureType == TextureType.Sprite)
        {
            hash = HashUtility.Combine(hash, input.Bounds.Extent.GetLongHashCode());
        }
        return(hash);
    }
コード例 #3
0
    private static ulong HashClass(Type type)
    {
        ulong hash = default;

        foreach (var field in type.GetFields(StaticFlags))
        {
            hash = HashUtility.Combine(hash, field.GetValue(null).GetLongHashCode());
        }

        foreach (var child in type.GetNestedTypes(StaticFlags))
        {
            hash = HashUtility.Combine(hash, HashClass(child));
        }

        return(hash);
    }
コード例 #4
0
 internal static ulong From(int hashCode) => HashUtility.Combine((ulong)hashCode, (ulong)(~hashCode) << 32);