/// <summary>
 /// Constructs a JsonConfig from a DisplayConfig
 /// </summary>
 /// <param name="config">A DisplayConfig whose members will be cloned</param>
 public JsonConfig(DisplayConfig config)
 {
     ResolutionScale            = config.ResolutionScale;
     ActCoefficientsX           = config.ActCoefficients.x.ToArray();
     ActCoefficientsY           = config.ActCoefficients.y.ToArray();
     DotPitchInMm               = new[] { config.DotPitchInMm.x, config.DotPitchInMm.y };
     PanelResolution            = new[] { config.PanelResolution.x, config.PanelResolution.y };
     NumViews                   = new[] { config.NumViews.x, config.NumViews.y };
     AlignmentOffset            = new[] { config.AlignmentOffset.x, config.AlignmentOffset.y };
     ViewResolution             = new[] { config.ViewResolution.x, config.ViewResolution.y };
     DisplaySizeInMm            = new[] { 0, 0 };
     SystemDisparityPercent     = config.SystemDisparityPercent;
     SystemDisparityPixels      = config.SystemDisparityPixels;
     UserOrientationIsLandscape = config.UserOrientationIsLandscape;
     UserDotPitchInMM           = config.UserDotPitchInMM == null ? new[] { 0f, 0f } : new[] { config.UserDotPitchInMM.x, config.UserDotPitchInMM.y };
     UserPanelResolution        = new[] { config.UserPanelResolution.x, config.UserPanelResolution.y };
     UserNumViews               = new[] { config.UserNumViews.x, config.UserNumViews.y };
     UserAlignmentOffset        = config.UserAlignmentOffset == null ? new[] { 0f, 0f } : new[] { config.UserAlignmentOffset.x, config.UserAlignmentOffset.y };
     UserActCoefficients        = new float[config.UserActCoefficients.x.Count + config.UserActCoefficients.y.Count];
     UserViewResolution         = new[] { config.UserViewResolution.x, config.UserViewResolution.y };
     UserDisplaySizeInMm        = config.UserDisplaySizeInMm == null ? new[] { 0, 0 } : new[] { config.UserDisplaySizeInMm.x, config.UserDisplaySizeInMm.y };
     UserAspectRatio            = config.UserAspectRatio;
     RenderModes                = config.RenderModes.ToArray();
     InterlacingMatrix          = config.InterlacingMatrix == null ? new[] { 0f, 0f } : config.InterlacingMatrix;
     InterlacingVector          = config.InterlacingVector == null ? new[] { 0f, 0f } : config.InterlacingVector;
     Gamma     = config.Gamma;
     Slant     = config.Slant;
     Beta      = config.Beta;
     isSquare  = config.isSquare;
     isSlanted = config.isSlanted;
 }
        public virtual DisplayConfig GetDisplayConfig()
        {
            // This DisplayConfig contains params that used to need to be non-null when DisplayConfig :: set_UserOrientationIsLandscape was called.
            // This stub DC is acquired
            //		in Unity Editor at runtime,
            //      in limited cases at edit time
            // in builds at start time; after a *LeiaDeviceBehaviour runs Start / RegisterDevice, this stub DC will be overwritten with data
            // from firmware.

            // since DisplayConfig now has a constructor, this code is ready to be transitioned to abstract
            _displayConfig = new DisplayConfig
            {
                isSquare               = true,
                ResolutionScale        = 1,
                AlignmentOffset        = new XyPair <float>(0, 0),
                DisplaySizeInMm        = new XyPair <int>(0, 0),
                DotPitchInMm           = new XyPair <float>(0, 0),
                NumViews               = new XyPair <int>(4, 4),
                PanelResolution        = new XyPair <int>(1440, 2560),
                SystemDisparityPercent = 0.0125f,
                SystemDisparityPixels  = 8f,
                ViewResolution         = new XyPair <int>(360, 640),
                ActCoefficients        = new XyPair <List <float> >(new List <float> {
                    .06f, .025f
                }, new List <float> {
                    .04f, .02f
                })
            };

            return(_displayConfig);
        }
 protected virtual void ApplyDisplayConfigUpdate(DisplayConfig target, params DisplayConfigJson.JsonConfigParameterUpdatePermission[] permissions)
 {
     if (DisplayConfigJson.JsonFileExists())
     {
         DisplayConfigJson.JsonConfig updater = new DisplayConfigJson.JsonConfig(DisplayConfigJson.JsonPath);
         updater.UpdatePermittedAttributesOn(_displayConfig, permissions);
     }
 }
        public virtual DisplayConfig GetDisplayConfig(bool forceReload)
        {
            if (forceReload)
            {
                _displayConfig = null;
            }

            // calls most specific type's GetDisplayConfig
            return(GetDisplayConfig());
        }
        public static void WriteJson(DisplayConfig config)
        {
            JsonConfig updated = new JsonConfig(config);

            if (!JsonFileExists())
            {
                File.Create(JsonPath).Dispose();
            }
            File.WriteAllText(JsonPath, updated.ToString());
        }
 /// <summary>
 /// Defines a method for any LeiaDevice to update its _displayConfig with sparsely defined data from json on the device
 /// </summary>
 /// <param name="permissions">Permission level(s)</param>
 protected virtual void ApplyDisplayConfigUpdate(params DisplayConfigJson.JsonConfigParameterUpdatePermission[] permissions)
 {
     if (_displayConfig == null)
     {
         LogUtil.Log(LogLevel.Error, "Called ApplyDisplayConfigUpdate but AbstractLeiaDevice :: _displayConfig is null");
         // Catch case of uninitialized DisplayConfig; throw error, but do not return. Need to run in broad span of cases to see fail cases
         _displayConfig = new DisplayConfig();
     }
     if (DisplayConfigJson.JsonFileExists())
     {
         DisplayConfigJson.JsonConfig updater = new DisplayConfigJson.JsonConfig(DisplayConfigJson.JsonPath);
         updater.UpdatePermittedAttributesOn(_displayConfig, permissions);
     }
 }
        void ConstructUI()
        {
            config         = LeiaDisplay.Instance.GetDisplayConfig();
            isSlantedState = config.isSlanted;
            // slant polarity
            slantLabel.text = config.Slant ? "Right" : "Left";

            AttachPrimitiveSliderCallbacks();
            AttachActSliderCallbacks();
            AttachFormattedTextCallbacks();

            // on opening config UI, retrieve values from DisplayConfig and assign them to sliders
            // callbacks in OnValueChanged are not triggered when callback attachment occurs in same code execution as callback trigger
            gammaSlider.value     = config.Gamma;
            disparitySlider.value = config.SystemDisparityPixels;
            betaSlider.value      = config.Beta;
            offsetSlider.value    = config.AlignmentOffset.x;
            resScaleSlider.value  = config.ResolutionScale;

            if (isSlantedState)
            {
                actcTitle.text   = "ACT Y[2]";
                actdTitle.text   = "ACT Y[3]";
                actaSlider.value = config.ActCoefficients.y[0];
                actbSlider.value = config.ActCoefficients.y[1];
                actcSlider.value = config.ActCoefficients.y[2];
                actdSlider.value = config.ActCoefficients.y[3];
            }
            else
            {
                actcTitle.text   = "ACT X[0]";
                actdTitle.text   = "ACT X[1]";
                actaSlider.value = config.ActCoefficients.y[0];
                actbSlider.value = config.ActCoefficients.y[1];
                actcSlider.value = config.ActCoefficients.x[0];
                actdSlider.value = config.ActCoefficients.x[1];
            }
            slantPage.SetActive(isSlantedState);
            betaSlider.gameObject.SetActive(isSlantedState);
            gammaSlider.GetComponent <RectTransform>().anchoredPosition = new Vector2(isSlantedState ? -200 : 0, gammaSlider.GetComponent <RectTransform>().anchoredPosition.y);
            string stateUpdateFilename   = string.Format("DisplayConfigUpdate{0}.json", isSlantedState ? "Slanted" : "Square");
            bool   loadedStateUpdateFile = StringAssetUtil.TryGetJsonObjectFromDeviceAwareFilename <JsonParamCollection>(stateUpdateFilename, out sparseUpdates);

            if (!loadedStateUpdateFile)
            {
                sparseUpdates = new JsonParamCollection();
            }
        }
예제 #8
0
        public void SetDisplayConfig(DisplayConfig displayConfig)
        {
            if (_displayConfig != null && _displayConfig.Equals(displayConfig))
            {
                return;
            }

            this.Debug("SetProfile");

            _displayConfig = displayConfig;
            _displayConfig.RenderModes.ToList().ForEach(m => _availableStateIds.Add(m));

            _builder2D = new TwoDimLeiaStateBuilder(_displayConfig);



            _builder3D = new SquareLeiaStateBuilder(_displayConfig);
        }
예제 #9
0
        public CameraCalculatedParams(LeiaCamera properties, DisplayConfig displayConfig)
        {
            ScreenHalfHeight = properties.ConvergenceDistance * Mathf.Tan(properties.FieldOfView * Mathf.PI / 360.0f);
            ScreenHalfWidth  = displayConfig.UserAspectRatio * ScreenHalfHeight;
            float f = (displayConfig.ViewResolution.y / displayConfig.ResolutionScale) / 2f / Mathf.Tan(properties.FieldOfView * Mathf.PI / 360f);

            EmissionRescalingFactor = displayConfig.SystemDisparityPixels * properties.BaselineScaling * properties.ConvergenceDistance / f;

            /*Debug.Log ("CameraCalculatedParams"
             + " UserPanel.x: " + displayConfig.UserPanelResolution.x
             + " UserPanel.y: " + displayConfig.UserPanelResolution.y
             + " UserView.x: " + displayConfig.UserViewResolution.x
             + " UserView.y: " + displayConfig.UserViewResolution.y
             + " Screen.width: " + Screen.width
             + " Screen.height: " + Screen.height
             + " properties.FieldOfView: " + properties.FieldOfView
             + " ScreenHalfWidth: " + ScreenHalfWidth
             + " ScreenHalfHeight: " + ScreenHalfHeight
             + " baseline: " + EmissionRescalingFactor);*/
        }
예제 #10
0
        public override DisplayConfig GetDisplayConfig()
        {
            if (_displayConfig != null)
            {
                return(_displayConfig);
            }

            // call DisplayConfig's constructor. default is a DisplayConfig with square = true, slanted = false
            _displayConfig = new DisplayConfig();

            // in Unity editor, read in displayConfig data from JsonParamCollection
            // this _displayConfig will have its isSquare + isSlanted flags set in this step.
            // consider setting in-editor game view resolution as well at this step
            // also consider setting build target to platform which the profile is built for
#if UNITY_EDITOR
            base.ApplyDisplayConfigUpdate(EmulatedDisplayConfigFilename);
#endif

            // then overpopulate _displayConfig from json with developer-tuned values
            base.ApplyDisplayConfigUpdate(DisplayConfigModifyPermission.Level.DeveloperTuned);

            return(_displayConfig);
        }
예제 #11
0
        /// <summary>
        /// Render in Play mode, check isDirty flag and (re)Set leiaState
        /// </summary>
        private void Update()
        {
            _screenAspectRatio = Screen.currentResolution.width * 1.0f / Screen.currentResolution.height;
            if (_prevScreenAspectRatio != _screenAspectRatio)
            {
                _prevScreenAspectRatio = _screenAspectRatio;
                _isDirty = true;
            }

#if UNITY_ANDROID && !UNITY_EDITOR
            ProcessParallaxRotation();
#else
#endif

            if (_isDirty)
            {
                _isDirty = false;
                this.Debug("IsDirty detected");
                DisplayConfig displayConfig = GetDisplayConfig();
                // inside GetDisplayConfig, calculate UserOrientationIsLandscape
                _stateFactory.SetDisplayConfig(displayConfig);
                RequestLeiaStateUpdate();
            }
        }
예제 #12
0
        public static LeiaBoundsData ComputeLeiaBounds(Camera camera, LeiaCameraData leiaCamera, float convergenceDistance, Vector2 cameraShift, DisplayConfig displayConfig)
        {
            LeiaBoundsData leiaBounds         = new LeiaBoundsData();
            var            localToWorldMatrix = camera.transform.localToWorldMatrix;

            localToWorldMatrix.SetColumn(0, localToWorldMatrix.GetColumn(0).normalized);
            localToWorldMatrix.SetColumn(1, localToWorldMatrix.GetColumn(1).normalized);
            localToWorldMatrix.SetColumn(2, localToWorldMatrix.GetColumn(2).normalized);

            if (camera.orthographic)
            {
                // assumes baseline = (baseline scaling) * (width of view in world units) * (system disparity in pixels) * (convergence distance) / (view width in pixels)

                float halfSizeY = camera.orthographicSize;
                float halfSizeX = halfSizeY * camera.aspect;


                Vector3 screenTopLeft     = localToWorldMatrix.MultiplyPoint(new Vector3(-halfSizeX, halfSizeY, convergenceDistance));
                Vector3 screenTopRight    = localToWorldMatrix.MultiplyPoint(new Vector3(halfSizeX, halfSizeY, convergenceDistance));
                Vector3 screenBottomLeft  = localToWorldMatrix.MultiplyPoint(new Vector3(-halfSizeX, -halfSizeY, convergenceDistance));
                Vector3 screenBottomRight = localToWorldMatrix.MultiplyPoint(new Vector3(halfSizeX, -halfSizeY, convergenceDistance));


                float negativeSystemDisparityZ = convergenceDistance - 1.0f / leiaCamera.baselineScaling;

                Vector3 nearTopLeft     = localToWorldMatrix.MultiplyPoint(new Vector3(-halfSizeX, halfSizeY, negativeSystemDisparityZ));
                Vector3 nearTopRight    = localToWorldMatrix.MultiplyPoint(new Vector3(halfSizeX, halfSizeY, negativeSystemDisparityZ));
                Vector3 nearBottomLeft  = localToWorldMatrix.MultiplyPoint(new Vector3(-halfSizeX, -halfSizeY, negativeSystemDisparityZ));
                Vector3 nearBottomRight = localToWorldMatrix.MultiplyPoint(new Vector3(halfSizeX, -halfSizeY, negativeSystemDisparityZ));


                float positiveSystemDisparityZ = convergenceDistance + 1.0f / leiaCamera.baselineScaling;

                Vector3 farTopLeft     = localToWorldMatrix.MultiplyPoint(new Vector3(-halfSizeX, halfSizeY, positiveSystemDisparityZ));
                Vector3 farTopRight    = localToWorldMatrix.MultiplyPoint(new Vector3(halfSizeX, halfSizeY, positiveSystemDisparityZ));
                Vector3 farBottomLeft  = localToWorldMatrix.MultiplyPoint(new Vector3(-halfSizeX, -halfSizeY, positiveSystemDisparityZ));
                Vector3 farBottomRight = localToWorldMatrix.MultiplyPoint(new Vector3(halfSizeX, -halfSizeY, positiveSystemDisparityZ));


                leiaBounds.screen = new [] { screenTopLeft, screenTopRight, screenBottomRight, screenBottomLeft };
                leiaBounds.south  = new [] { nearTopLeft, nearTopRight, nearBottomRight, nearBottomLeft };
                leiaBounds.north  = new [] { farTopLeft, farTopRight, farBottomRight, farBottomLeft };
                leiaBounds.top    = new [] { nearTopLeft, nearTopRight, farTopRight, farTopLeft };
                leiaBounds.bottom = new [] { nearBottomLeft, nearBottomRight, farBottomRight, farBottomLeft };
                leiaBounds.east   = new [] { nearTopRight, nearBottomRight, farBottomRight, farTopRight };
                leiaBounds.west   = new [] { nearTopLeft, nearBottomLeft, farBottomLeft, farTopLeft };
            }

            else
            {
                cameraShift = leiaCamera.baseline * cameraShift;

                Vector3 screenTopLeft     = localToWorldMatrix.MultiplyPoint(new Vector3(-leiaCamera.screenHalfWidth, leiaCamera.screenHalfHeight, convergenceDistance));
                Vector3 screenTopRight    = localToWorldMatrix.MultiplyPoint(new Vector3(leiaCamera.screenHalfWidth, leiaCamera.screenHalfHeight, convergenceDistance));
                Vector3 screenBottomLeft  = localToWorldMatrix.MultiplyPoint(new Vector3(-leiaCamera.screenHalfWidth, -leiaCamera.screenHalfHeight, convergenceDistance));
                Vector3 screenBottomRight = localToWorldMatrix.MultiplyPoint(new Vector3(leiaCamera.screenHalfWidth, -leiaCamera.screenHalfHeight, convergenceDistance));

                float nearPlaneZ     = (leiaCamera.baselineScaling * convergenceDistance) / (leiaCamera.baselineScaling + 1f);
                float nearRatio      = nearPlaneZ / convergenceDistance;
                float nearShiftRatio = 1f - nearRatio;

                Bounds localNearPlaneBounds = new Bounds(
                    new Vector3(nearShiftRatio * cameraShift.x, nearShiftRatio * cameraShift.y, nearPlaneZ),
                    new Vector3(leiaCamera.screenHalfWidth * nearRatio * 2, leiaCamera.screenHalfHeight * nearRatio * 2, 0));

                Vector3 nearTopLeft     = localToWorldMatrix.MultiplyPoint(new Vector3(localNearPlaneBounds.min.x, localNearPlaneBounds.max.y, localNearPlaneBounds.center.z));
                Vector3 nearTopRight    = localToWorldMatrix.MultiplyPoint(new Vector3(localNearPlaneBounds.max.x, localNearPlaneBounds.max.y, localNearPlaneBounds.center.z));
                Vector3 nearBottomLeft  = localToWorldMatrix.MultiplyPoint(new Vector3(localNearPlaneBounds.min.x, localNearPlaneBounds.min.y, localNearPlaneBounds.center.z));
                Vector3 nearBottomRight = localToWorldMatrix.MultiplyPoint(new Vector3(localNearPlaneBounds.max.x, localNearPlaneBounds.min.y, localNearPlaneBounds.center.z));

                float farPlaneZ = (leiaCamera.baselineScaling * convergenceDistance) / (leiaCamera.baselineScaling - 1f);
                farPlaneZ = 1f / Mathf.Max(1f / farPlaneZ, 1e-5f);

                float farRatio      = farPlaneZ / convergenceDistance;
                float farShiftRatio = 1f - farRatio;

                Bounds localFarPlaneBounds = new Bounds(
                    new Vector3(farShiftRatio * cameraShift.x, farShiftRatio * cameraShift.y, farPlaneZ),
                    new Vector3(leiaCamera.screenHalfWidth * farRatio * 2, leiaCamera.screenHalfHeight * farRatio * 2, 0));

                Vector3 farTopLeft     = localToWorldMatrix.MultiplyPoint(new Vector3(localFarPlaneBounds.min.x, localFarPlaneBounds.max.y, localFarPlaneBounds.center.z));
                Vector3 farTopRight    = localToWorldMatrix.MultiplyPoint(new Vector3(localFarPlaneBounds.max.x, localFarPlaneBounds.max.y, localFarPlaneBounds.center.z));
                Vector3 farBottomLeft  = localToWorldMatrix.MultiplyPoint(new Vector3(localFarPlaneBounds.min.x, localFarPlaneBounds.min.y, localFarPlaneBounds.center.z));
                Vector3 farBottomRight = localToWorldMatrix.MultiplyPoint(new Vector3(localFarPlaneBounds.max.x, localFarPlaneBounds.min.y, localFarPlaneBounds.center.z));

                leiaBounds.screen = new [] { screenTopLeft, screenTopRight, screenBottomRight, screenBottomLeft };
                leiaBounds.south  = new [] { nearTopLeft, nearTopRight, nearBottomRight, nearBottomLeft };
                leiaBounds.north  = new [] { farTopLeft, farTopRight, farBottomRight, farBottomLeft };
                leiaBounds.top    = new [] { nearTopLeft, nearTopRight, farTopRight, farTopLeft };
                leiaBounds.bottom = new [] { nearBottomLeft, nearBottomRight, farBottomRight, farBottomLeft };
                leiaBounds.east   = new [] { nearTopRight, nearBottomRight, farBottomRight, farTopRight };
                leiaBounds.west   = new [] { nearTopLeft, nearBottomLeft, farBottomLeft, farTopLeft };
            }

            return(leiaBounds);
        }
예제 #13
0
        public static LeiaCameraData ComputeLeiaCamera(Camera camera, float convergenceDistance, float baselineScaling, DisplayConfig displayConfig)
        {
            LeiaCameraData leiaCameraData = new LeiaCameraData();

            displayConfig.UserOrientationIsLandscape = camera.pixelWidth > camera.pixelHeight;

            float f = displayConfig.UserViewResolution.y / 2f / Mathf.Tan(camera.fieldOfView * Mathf.PI / 360f);

            leiaCameraData.baseline         = displayConfig.SystemDisparityPixels * baselineScaling * convergenceDistance / f;
            leiaCameraData.screenHalfHeight = convergenceDistance * Mathf.Tan(camera.fieldOfView * Mathf.PI / 360.0f);
            leiaCameraData.screenHalfWidth  = camera.aspect * leiaCameraData.screenHalfHeight;
            leiaCameraData.baselineScaling  = baselineScaling;

            return(leiaCameraData);
        }
 public AbstractLeiaStateTemplate(DisplayConfig displayConfig)
 {
     _displayConfig = displayConfig;
 }
예제 #15
0
 public TwoDimLeiaStateTemplate(DisplayConfig displayConfig) : base(displayConfig)
 {
     // this method was left blank intentionally
 }
예제 #16
0
        public override DisplayConfig GetDisplayConfig()
        {
            if (_displayConfig != null)
            {
                return(_displayConfig);
            }

            _displayConfig = new DisplayConfig();
            try
            {
                AndroidJavaObject displayConfig = _leiaBacklightInstance.Call <AndroidJavaObject> ("getDisplayConfig");
                _displayConfig = new DisplayConfig();

                // TODO hardcoded for now; replace with firmware retrieval calls later
                _displayConfig.Gamma    = 2.2f;
                _displayConfig.Beta     = 1.4f;
                _displayConfig.isSquare = true;

                // The following params
                // DotPitchInMm, PanelResolution, NumViews, AlignmentOffset, DisplaySizeInMm, and ViewResolution
                // are reported as
                // (value for device's shorter dimension, value for device's longer dimension) rather than
                // (value for device's wide side, value for device's long side) as we would expect.
                // See DisplayConfig :: UserOrientationIsLandscape

                AndroidJavaObject dotPitchInMM = displayConfig.Call <AndroidJavaObject>("getDotPitchInMm");
                _displayConfig.DotPitchInMm = new XyPair <float>(dotPitchInMM.Get <AndroidJavaObject>("x").Call <float>("floatValue"),
                                                                 dotPitchInMM.Get <AndroidJavaObject>("y").Call <float>("floatValue"));

                AndroidJavaObject panelResolution = displayConfig.Call <AndroidJavaObject>("getPanelResolution");
                _displayConfig.PanelResolution = new XyPair <int>(panelResolution.Get <AndroidJavaObject>("x").Call <int>("intValue"),
                                                                  panelResolution.Get <AndroidJavaObject>("y").Call <int>("intValue"));

                AndroidJavaObject numViews = displayConfig.Call <AndroidJavaObject>("getNumViews");
                _displayConfig.NumViews = new XyPair <int>(numViews.Get <AndroidJavaObject>("x").Call <int>("intValue"),
                                                           numViews.Get <AndroidJavaObject>("y").Call <int>("intValue"));

                AndroidJavaObject alignmentOffset = displayConfig.Call <AndroidJavaObject>("getAlignmentOffset");
                _displayConfig.AlignmentOffset = new XyPair <float>(alignmentOffset.Get <AndroidJavaObject>("x").Call <float>("floatValue"),
                                                                    alignmentOffset.Get <AndroidJavaObject>("y").Call <float>("floatValue"));

                AndroidJavaObject displaySizeInMm = displayConfig.Call <AndroidJavaObject>("getDisplaySizeInMm");
                _displayConfig.DisplaySizeInMm = new XyPair <int>(displaySizeInMm.Get <AndroidJavaObject>("x").Call <int>("intValue"),
                                                                  displaySizeInMm.Get <AndroidJavaObject>("y").Call <int>("intValue"));

                AndroidJavaObject viewResolution = displayConfig.Call <AndroidJavaObject>("getViewResolution");
                _displayConfig.ViewResolution = new XyPair <int>(viewResolution.Get <AndroidJavaObject>("x").Call <int>("intValue"),
                                                                 viewResolution.Get <AndroidJavaObject>("y").Call <int>("intValue"));

                AndroidJavaObject actCoefficients = displayConfig.Call <AndroidJavaObject>("getViewSharpeningCoefficients");

                float xA = actCoefficients.Get <AndroidJavaObject>("x").Call <AndroidJavaObject>("get", 0).Call <float>("floatValue");
                float xB = actCoefficients.Get <AndroidJavaObject>("x").Call <AndroidJavaObject>("get", 1).Call <float>("floatValue");
                float yA = actCoefficients.Get <AndroidJavaObject>("y").Call <AndroidJavaObject>("get", 0).Call <float>("floatValue");
                float yB = actCoefficients.Get <AndroidJavaObject>("y").Call <AndroidJavaObject>("get", 1).Call <float>("floatValue");
                this.Debug("coefs: " + xA + " " + xB + " " + yA + " " + yB);
                _displayConfig.ActCoefficients = new XyPair <List <float> >(new List <float>(), new List <float>());

                _displayConfig.ActCoefficients.x = new List <float>();
                _displayConfig.ActCoefficients.x.Add(xA);
                _displayConfig.ActCoefficients.x.Add(xB);

                _displayConfig.ActCoefficients.y = new List <float>();
                _displayConfig.ActCoefficients.y.Add(yA);
                _displayConfig.ActCoefficients.y.Add(yB);

                _displayConfig.SystemDisparityPercent = _leiaBacklightInstance.Call <float>("getSystemDisparityPercent");
                _displayConfig.SystemDisparityPixels  = _leiaBacklightInstance.Call <float>("getSystemDisparityPixels");
            }
            catch (System.Exception e)
            {
                LogUtil.Log(LogLevel.Error, "While loading data from Android DisplayConfig from firmware, encountered error {0}", e);
            }

            // populate _displayConfig from FW with developer-tuned values
            base.ApplyDisplayConfigUpdate(DisplayConfigModifyPermission.Level.DeveloperTuned);

            return(_displayConfig);
        }
예제 #17
0
            /// <summary>
            /// Overwrite accessible properties on a DisplayConfig.
            /// </summary>
            /// <param name="dc">A DisplayConfig to overwrite some properties on</param>
            /// <param name="permissions">Update permissions to adhere to when converting JsonConfig params to DisplayConfig params</param>
            public void UpdatePermittedAttributesOn(DisplayConfig dc, params JsonConfigParameterUpdatePermission[] permissions)
            {
                HashSet <JsonConfigParameterUpdatePermission> hashPermissions = new HashSet <JsonConfigParameterUpdatePermission>(permissions);

                // Permission level determines which params will be checked in sparse JsonConfig definition
                // Note: permissions levels are unordered and one permission level is not necessarily a subset of another permission level

                // updateParamProtocol defines what Action (defined by delegate     () => {}     ) to perform when a variable is set
                Dictionary <string, Action> updateParamProtocol = new Dictionary <string, Action>();

                updateParamProtocol["ResolutionScale"]        = () => { dc.ResolutionScale = ResolutionScale; };
                updateParamProtocol["Gamma"]                  = () => { dc.Gamma = Gamma; };
                updateParamProtocol["Beta"]                   = () => { dc.Beta = Beta; };
                updateParamProtocol["Slant"]                  = () => { dc.Slant = Slant; };
                updateParamProtocol["isSquare"]               = () => { dc.isSquare = isSquare; };
                updateParamProtocol["isSlanted"]              = () => { dc.isSlanted = isSlanted; };
                updateParamProtocol["AlignmentOffset"]        = () => { dc.AlignmentOffset = new XyPair <float>(AlignmentOffset[0], AlignmentOffset[1]); };
                updateParamProtocol["SystemDisparityPercent"] = () => { dc.SystemDisparityPercent = SystemDisparityPercent; };
                updateParamProtocol["SystemDisparityPixels"]  = () => { dc.SystemDisparityPixels = SystemDisparityPixels; };
                updateParamProtocol["ActCoefficientsX"]       = () =>
                {
                    if (dc.ActCoefficients == null)
                    {
                        dc.ActCoefficients = new XyPair <List <float> >(null, null);
                    }
                    dc.ActCoefficients.x = new List <float>(ActCoefficientsX);
                };
                updateParamProtocol["ActCoefficientsY"] = () =>
                {
                    if (dc.ActCoefficients == null)
                    {
                        dc.ActCoefficients = new XyPair <List <float> >(null, null);
                    }
                    dc.ActCoefficients.y = new List <float>(ActCoefficientsY);
                };
                updateParamProtocol["InterlacingVector"] = () => { dc.InterlacingVector = InterlacingVector; };
                updateParamProtocol["InterlacingMatrix"] = () => { dc.InterlacingMatrix = InterlacingMatrix; };
                updateParamProtocol["DotPitchInMm"]      = () => { dc.DotPitchInMm = new XyPair <float>(DotPitchInMm[0], DotPitchInMm[1]); };
                updateParamProtocol["PanelResolution"]   = () => { dc.PanelResolution = new XyPair <int>(PanelResolution[0], PanelResolution[1]); };
                updateParamProtocol["NumViews"]          = () => { dc.NumViews = new XyPair <int>(NumViews[0], NumViews[1]); };
                updateParamProtocol["DisplaySizeInMm"]   = () => { dc.DisplaySizeInMm = new XyPair <int>(DisplaySizeInMm[0], DisplaySizeInMm[1]); };
                updateParamProtocol["ViewResolution"]    = () => { dc.ViewResolution = new XyPair <int>(ViewResolution[0], ViewResolution[1]); };

                // UpdatePermissions define what keys to search for, which define which protocols get run

                // Run update protocol for PerApplicationAct permission level
                if (hashPermissions.Contains(JsonConfigParameterUpdatePermission.PerApplicationACT))
                {
                    foreach (string permittedTag in new[] { "Gamma", "Beta", "Slant", "AlignmentOffset", "SystemDisparityPercent", "SystemDisparityPixels", "ActCoefficientsX", "ActCoefficientsY", "ResolutionScale" })
                    {
                        if (updateTags.Contains(permittedTag) && updateParamProtocol.ContainsKey(permittedTag))
                        {
                            updateParamProtocol[permittedTag]();
                            updateParamProtocol.Remove(permittedTag);
                        }
                    }
                }

                // Run update protocol for Unrestricted permission level
                if (hashPermissions.Contains(JsonConfigParameterUpdatePermission.Unrestricted))
                {
                    foreach (string permittedTag in new[] { "Gamma", "Beta", "Slant", "isSquare", "isSlanted", "AlignmentOffset", "SystemDisparityPercent", "SystemDisparityPixels", "ActCoefficientsX", "ActCoefficientsY",
                                                            "InterlacingVector", "InterlacingMatrix", "DotPitchInMm", "PanelResolution", "NumViews", "AlignmentOffset", "DisplaySizeInMm",
                                                            "ViewResolution", "ResolutionScale" })
                    {
                        if (updateTags.Contains(permittedTag) && updateParamProtocol.ContainsKey(permittedTag))
                        {
                            updateParamProtocol[permittedTag]();
                            updateParamProtocol.Remove(permittedTag);
                        }
                    }
                }
            }