Beispiel #1
0
        public void Constructors()
        {
            MPSImageHistogramInfo info = new MPSImageHistogramInfo();

            info.NumberOfHistogramEntries = 256;
            using (var obj = new MPSImageHistogram(MTLDevice.SystemDefault, ref info)) {
                var rv = obj.HistogramInfo;
                Asserts.AreEqual(info, rv, "HistogramForAlpha");

                Assert.IsTrue(obj.ZeroHistogram, "ZeroHistogram");
                if (TestRuntime.CheckXcodeVersion(8, 0))
                {
                    // HistogramSizeForSourceFormat was introduced in iOS 9, but no matter which MTLPixelFormat value I pass in,
                    // the native histogramSizeForSourceFormat: function rudely aborts the entire process with an abrupt:
                    // > /BuildRoot/Library/Caches/com.apple.xbs/Sources/MetalImage/MetalImage-39.3/MetalImage/Filters/MIHistogram.mm:103: failed assertion `[MPSImageHistogram histogramSizeForSourceFormat:] unsupported texture format: 114'
                    // I made sure the MTLPixelFormat values I tested with were also added in iOS 9, so that's not the problem.
                    // Conclusion: just avoid executing HistogramSizeForSourceFormat on anything below iOS 10.rm
                    Assert.AreEqual(3072, obj.GetHistogramSize(MTLPixelFormat.RGBA16Sint), "HistogramSizeForSourceFormat");
                }
                var crs = obj.ClipRectSource;
                Assert.AreEqual(0, crs.Origin.X, "ClipRectSource.Origin.X");
                Assert.AreEqual(0, crs.Origin.Y, "ClipRectSource.Origin.Y");
                Assert.AreEqual(0, crs.Origin.Z, "ClipRectSource.Origin.Z");
                Assert.AreEqual(-1, crs.Size.Depth, "ClipRectSource.Size.Depth");
                Assert.AreEqual(-1, crs.Size.Height, "ClipRectSource.Size.Height");
                Assert.AreEqual(-1, crs.Size.Width, "ClipRectSource.Size.Width");
            }
        }
Beispiel #2
0
 public static void AreEqual(MPSImageHistogramInfo expected, MPSImageHistogramInfo actual, string message)
 {
     Assert.AreEqual(expected.HistogramForAlpha, actual.HistogramForAlpha, message + " HistogramForAlpha");
     Asserts.AreEqual(expected.MaxPixelValue, actual.MaxPixelValue, message + " MaxPixelValue");
     Asserts.AreEqual(expected.MinPixelValue, actual.MinPixelValue, message + " MinPixelValue");
     Assert.AreEqual(expected.NumberOfHistogramEntries, actual.NumberOfHistogramEntries, message + " NumberOfHistogramEntries");
 }
Beispiel #3
0
 public static void AreEqual(MPSImageHistogramInfo expected, MPSImageHistogramInfo actual, string message)
 {
     Assert.AreEqual(expected.HistogramForAlpha, actual.HistogramForAlpha, $"{message} HistogramForAlpha expected: {expected} actual: {actual}");
     Asserts.AreEqual(expected.MaxPixelValue, actual.MaxPixelValue, $"{message} MaxPixelValue expected: {expected} actual: {actual}");
     Asserts.AreEqual(expected.MinPixelValue, actual.MinPixelValue, $"{message} MinPixelValue expected: {expected} actual: {actual}");
     Assert.AreEqual(expected.NumberOfHistogramEntries, actual.NumberOfHistogramEntries, $"{message} NumberOfHistogramEntries expected: {expected} actual: {actual}");
 }
        public void Constructors()
        {
            MPSImageHistogramInfo info = new MPSImageHistogramInfo();

            info.NumberOfHistogramEntries = 256;
            using (var obj = new MPSImageHistogramSpecification(MTLDevice.SystemDefault, ref info)) {
                var rv = obj.HistogramInfo;
                Asserts.AreEqual(info, rv, "HistogramForAlpha");
            }
        }
Beispiel #5
0
        public void Constructors()
        {
            TestRuntime.AssertDevice();
            TestRuntime.AssertXcodeVersion(7, 0);

            MPSImageHistogramInfo info = new MPSImageHistogramInfo();

            info.NumberOfHistogramEntries = 256;
            using (var obj = new MPSImageHistogramEqualization(MTLDevice.SystemDefault, ref info)) {
                var rv = obj.HistogramInfo;
                Asserts.AreEqual(info, rv, "HistogramForAlpha");
            }
        }
Beispiel #6
0
        public void Constructors()
        {
            var info = new MPSImageHistogramInfo {
                NumberOfHistogramEntries = 256
            };

#if !__MACOS__
            var obj = new MPSImageNormalizedHistogram(MTLDevice.SystemDefault, ref info);
#else
            MPSImageNormalizedHistogram obj = null;
            try {
                obj = new MPSImageNormalizedHistogram(MTLDevice.SystemDefault, ref info);
            }
            catch (Exception ex) {
                // This test fails on 10.13 bots but not on a local computer with 10.13. Must work on 10.14+.
                // there is no a good way to tell if MPSImageNormalizedHistogram will work or not...
                if (TestRuntime.CheckSystemVersion(PlatformName.MacOSX, 10, 14))
                {
                    Assert.Fail(ex.Message);
                }
                Assert.Inconclusive("In 10.13 this can fail in some hardware.");
            }
#endif
            Assert.NotNull(obj, "MPSImageNormalizedHistogram obj");
            var rv = obj.HistogramInfo;
            Asserts.AreEqual(info, rv, "HistogramInfo");

            Assert.IsTrue(obj.ZeroHistogram, "ZeroHistogram");
            Assert.AreEqual(3072, obj.GetHistogramSize(MTLPixelFormat.RGBA16Sint), "HistogramSizeForSourceFormat");

            var crs = obj.ClipRectSource;
            Assert.AreEqual(0, crs.Origin.X, "ClipRectSource.Origin.X");
            Assert.AreEqual(0, crs.Origin.Y, "ClipRectSource.Origin.Y");
            Assert.AreEqual(0, crs.Origin.Z, "ClipRectSource.Origin.Z");
            Assert.AreEqual(nuint.MaxValue, (nuint)crs.Size.Depth, "ClipRectSource.Size.Depth");
            Assert.AreEqual(nuint.MaxValue, (nuint)crs.Size.Height, "ClipRectSource.Size.Height");
            Assert.AreEqual(nuint.MaxValue, (nuint)crs.Size.Width, "ClipRectSource.Size.Width");
        }
        public void Constructors()
        {
            TestRuntime.AssertDevice();
            TestRuntime.AssertXcodeVersion(7, 0);

            MPSImageHistogramInfo info = new MPSImageHistogramInfo();

            info.NumberOfHistogramEntries = 256;
            using (var obj = new MPSImageHistogram(MTLDevice.SystemDefault, ref info)) {
                var rv = obj.HistogramInfo;
                Asserts.AreEqual(info, rv, "HistogramForAlpha");

                Assert.IsTrue(obj.ZeroHistogram, "ZeroHistogram");
                Assert.AreEqual(3072, obj.HistogramSizeForSourceFormat(MTLPixelFormat.RGBA16Sint), "HistogramSizeForSourceFormat");
                var crs = obj.ClipRectSource;
                Assert.AreEqual(0, crs.Origin.X, "ClipRectSource.Origin.X");
                Assert.AreEqual(0, crs.Origin.Y, "ClipRectSource.Origin.Y");
                Assert.AreEqual(0, crs.Origin.Z, "ClipRectSource.Origin.Z");
                Assert.AreEqual(-1, crs.Size.Depth, "ClipRectSource.Size.Depth");
                Assert.AreEqual(-1, crs.Size.Height, "ClipRectSource.Size.Height");
                Assert.AreEqual(-1, crs.Size.Width, "ClipRectSource.Size.Width");
            }
        }