// %BANNER_BEGIN% // --------------------------------------------------------------------- // %COPYRIGHT_BEGIN% // Copyright (c) (2018-2022) Magic Leap, Inc. All Rights Reserved. // Use of this file is governed by the Software License Agreement, located here: https://www.magicleap.com/software-license-agreement-ml2 // Terms and conditions applicable to third-party materials accompanying this distribution may also be found in the top-level NOTICE file appearing herein. // %COPYRIGHT_END% // --------------------------------------------------------------------- // %BANNER_END% using System; using System.Runtime.InteropServices; using MagicLeap.Android.NDK.NativeWindow; namespace UnityEngine.XR.MagicLeap { public partial class YCbCrRenderer { public interface IFrameAvailabilityProvider { internal bool IsNewFrameAvailable(); } public interface IFrameTransformMatrixProvider { internal bool GetFrameTransformMatrix(ref Matrix4x4 frameTransformMatColMajor); } public interface IHardwareBufferProvider { public bool AcquireNextAvailableHwBuffer(out AHardwareBuffer hwBuffer); public void ReleaseHwBuffer(AHardwareBuffer hwBuffer); } public interface IYCbCrConversionSamplerProvider { /// /// Invoked by the YcbcrRenderer plugin on Unity's render thread. /// Apps wanting to override the VkSamplerYcbcrConversionCreateInfo /// for the hardware buffer rendering should implement this interface. /// /// VkAndroidHardwareBufferFormatPropertiesANDROID of the currently acquired AHardwareBuffer /// VkSamplerYcbcrConversionCreateInfo of the previous frame /// true if the input sampler values were changed public bool OverrideYCbCrConversionSampler(ref VkAndroidHardwareBufferFormatPropertiesAndroid hwBufferFormatProperties, ref VkSamplerYCbCrConversionCreateInfo sampler); } [StructLayout(LayoutKind.Sequential)] public struct VkComponentMapping { /// /// VkComponentSwizzle /// public uint r; /// /// VkComponentSwizzle /// public uint g; /// /// VkComponentSwizzle /// public uint b; /// /// VkComponentSwizzle /// public uint a; public override bool Equals(object obj) { if (obj is VkComponentMapping componentMapping) { return componentMapping.r == r && componentMapping.g == g && componentMapping.b == b && componentMapping.a == a; } return false; } public override int GetHashCode() { return HashCode.Combine(r, g, b, a); } } [StructLayout(LayoutKind.Sequential)] public struct VkAndroidHardwareBufferFormatPropertiesAndroid { /// /// VkStructureType /// public uint sType; /// /// void* /// public IntPtr pNext; /// /// VkFormat /// public uint format; /// /// uint64 /// public ulong externalFormat; /// /// VkFormatFeatureFlags /// public uint formatFeatures; /// /// VkComponentMapping /// public VkComponentMapping samplerYCbCrConversionComponents; /// /// VkSamplerYCbCrModelConversion /// public uint suggestedYCbCrModel; /// /// VkSamplerYCbCrRange /// public uint suggestedYCbCrRange; /// /// VkChromaLocation /// public uint suggestedXChromaOffset; /// /// VkChromaLocation /// public uint suggestedYChromaOffset; } [StructLayout(LayoutKind.Sequential)] public struct VkSamplerYCbCrConversionCreateInfo { /// /// VkStructureType /// public uint sType; /// /// void* /// public IntPtr pNext; /// /// VkFormat /// public uint format; /// /// VkSamplerYCbCrModelConversion /// public uint yCbCrModel; /// /// VkSamplerYCbCrRange /// public uint yCbCrRange; /// /// VkComponentMapping /// public VkComponentMapping components; /// /// VkChromaLocation /// public uint xChromaOffset; /// /// VkChromaLocation /// public uint yChromaOffset; /// /// VkFilter /// public uint chromaFilter; /// /// VkBool32 /// public uint forceExplicitReconstruction; } } }