Ejemplo n.º 1
0
        public void CreateSurface(RenderingSurfaceInfo surfaceInfo)
        {
            if (_surfaceInfo != null)
            {
                return;
            }

            _surfaceInfo = surfaceInfo;

            Debug.Assert(_surfaceInfo.ColorFormat == Services.SurfaceFlinger.ColorFormat.A8B8G8R8);

            // Use the whole area of the image to draw, even the alignment, otherwise it may shear the final
            // image if the pitch is different.
            uint totalWidth  = _surfaceInfo.Pitch / 4;
            uint totalHeight = _surfaceInfo.Size / _surfaceInfo.Pitch;

            Debug.Assert(_surfaceInfo.Width <= totalWidth);
            Debug.Assert(_surfaceInfo.Height <= totalHeight);
            Debug.Assert(_surfaceInfo.Pitch * _surfaceInfo.Height <= _surfaceInfo.Size);

            _surface = new Image <Argb32>((int)totalWidth, (int)totalHeight);

            ComputeConstants();
            DrawImmutableElements();
        }
Ejemplo n.º 2
0
        public bool DrawTo(RenderingSurfaceInfo surfaceInfo, IVirtualMemoryManager destination, ulong position)
        {
            _npads?.Update();

            _keyboardRenderer?.SetSurfaceInfo(surfaceInfo);

            return(_keyboardRenderer?.DrawTo(destination, position) ?? false);
        }
Ejemplo n.º 3
0
        public void SetSurfaceInfo(RenderingSurfaceInfo surfaceInfo)
        {
            lock (_stateLock)
            {
                _state.SurfaceInfo = surfaceInfo;

                // Tell the render thread there is something new to render.
                Monitor.PulseAll(_stateLock);
            }
        }
Ejemplo n.º 4
0
        internal bool DrawTo(RenderingSurfaceInfo surfaceInfo, IVirtualMemoryManager destination, ulong position)
        {
            lock (_renderLock)
            {
                if (!_surfaceInfo.Equals(surfaceInfo))
                {
                    _surfaceInfo = surfaceInfo;
                    RecreateSurface();
                    RecomputeConstants();
                }

                Redraw();

                return(TryCopyTo(destination, position));
            }
        }
        // GetIndirectLayerImageMap(s64 width, s64 height, u64 handle, nn::applet::AppletResourceUserId, pid) -> (s64, s64, buffer<bytes, 0x46>)
        public ResultCode GetIndirectLayerImageMap(ServiceCtx context)
        {
            // The size of the layer buffer should be an aligned multiple of width * height
            // because it was created using GetIndirectLayerImageRequiredMemoryInfo as a guide.

            long  layerWidth        = context.RequestData.ReadInt64();
            long  layerHeight       = context.RequestData.ReadInt64();
            long  layerHandle       = context.RequestData.ReadInt64();
            ulong layerBuffPosition = context.Request.ReceiveBuff[0].Position;
            ulong layerBuffSize     = context.Request.ReceiveBuff[0].Size;

            // Get the pitch of the layer that is necessary to render correctly.
            ulong size = GetA8B8G8R8LayerSize((int)layerWidth, (int)layerHeight, out int pitch, out _);

            Debug.Assert(layerBuffSize == size);

            RenderingSurfaceInfo surfaceInfo = new RenderingSurfaceInfo(ColorFormat.A8B8G8R8, (uint)layerWidth, (uint)layerHeight, (uint)pitch, (uint)layerBuffSize);

            // Get the applet associated with the handle.
            object appletObject = context.Device.System.AppletState.IndirectLayerHandles.GetData((int)layerHandle);

            if (appletObject == null)
            {
                Logger.Error?.Print(LogClass.ServiceVi, $"Indirect layer handle {layerHandle} does not match any applet");

                return(ResultCode.Success);
            }

            Debug.Assert(appletObject is IApplet);

            IApplet applet = appletObject as IApplet;

            if (!applet.DrawTo(surfaceInfo, context.Memory, layerBuffPosition))
            {
                Logger.Warning?.Print(LogClass.ServiceVi, $"Applet did not draw on indirect layer handle {layerHandle}");

                return(ResultCode.Success);
            }

            context.ResponseData.Write(layerWidth);
            context.ResponseData.Write(layerHeight);

            return(ResultCode.Success);
        }
Ejemplo n.º 6
0
        public SoftwareKeyboardRenderer(IHostUiTheme uiTheme)
        {
            _surfaceInfo = new RenderingSurfaceInfo(0, 0, 0, 0, 0);

            string ryujinxLogoPath = "Ryujinx.Ui.Resources.Logo_Ryujinx.png";
            int    ryujinxLogoSize = 32;

            _ryujinxLogo = LoadResource(Assembly.GetEntryAssembly(), ryujinxLogoPath, ryujinxLogoSize, ryujinxLogoSize);

            string padAcceptIconPath = "Ryujinx.HLE.HOS.Applets.SoftwareKeyboard.Resources.Icon_BtnA.png";
            string padCancelIconPath = "Ryujinx.HLE.HOS.Applets.SoftwareKeyboard.Resources.Icon_BtnB.png";
            string keyModeIconPath   = "Ryujinx.HLE.HOS.Applets.SoftwareKeyboard.Resources.Icon_KeyF6.png";

            _padAcceptIcon = LoadResource(Assembly.GetExecutingAssembly(), padAcceptIconPath, 0, 0);
            _padCancelIcon = LoadResource(Assembly.GetExecutingAssembly(), padCancelIconPath, 0, 0);
            _keyModeIcon   = LoadResource(Assembly.GetExecutingAssembly(), keyModeIconPath, 0, 0);

            Color panelColor               = ToColor(uiTheme.DefaultBackgroundColor, 255);
            Color panelTransparentColor    = ToColor(uiTheme.DefaultBackgroundColor, 150);
            Color normalTextColor          = ToColor(uiTheme.DefaultForegroundColor);
            Color invertedTextColor        = ToColor(uiTheme.DefaultForegroundColor, null, true);
            Color selectedTextColor        = ToColor(uiTheme.SelectionForegroundColor);
            Color borderColor              = ToColor(uiTheme.DefaultBorderColor);
            Color selectionBackgroundColor = ToColor(uiTheme.SelectionBackgroundColor);
            Color gridSeparatorColor       = Color.FromArgb(180, 255, 255, 255);

            float cursorWidth = 2;

            _textBoxOutlineWidth = 2;
            _padPressedPenWidth  = 2;

            _panelBrush          = new SolidBrush(panelColor);
            _disabledBrush       = new SolidBrush(panelTransparentColor);
            _textNormalBrush     = new SolidBrush(normalTextColor);
            _textSelectedBrush   = new SolidBrush(selectedTextColor);
            _textOverCursorBrush = new SolidBrush(invertedTextColor);
            _cursorBrush         = new SolidBrush(normalTextColor);
            _selectionBoxBrush   = new SolidBrush(selectionBackgroundColor);
            _keyCapBrush         = Brushes.White;
            _keyProgressBrush    = new SolidBrush(borderColor);

            _gridSeparatorPen  = new Pen(gridSeparatorColor, 2);
            _textBoxOutlinePen = new Pen(borderColor, _textBoxOutlineWidth);
            _cursorPen         = new Pen(normalTextColor, cursorWidth);
            _selectionBoxPen   = new Pen(selectionBackgroundColor, cursorWidth);
            _padPressedPen     = new Pen(borderColor, _padPressedPenWidth);

            _inputTextFontSize = 20;
            _padButtonFontSize = 24;

            string font = uiTheme.FontFamily;

            _messageFont    = new Font(font, 26, FontStyle.Regular, GraphicsUnit.Pixel);
            _inputTextFont  = new Font(font, _inputTextFontSize, FontStyle.Regular, GraphicsUnit.Pixel);
            _labelsTextFont = new Font(font, 24, FontStyle.Regular, GraphicsUnit.Pixel);
            _padSymbolFont  = new Font(font, _padButtonFontSize, FontStyle.Regular, GraphicsUnit.Pixel);
            _keyCapFont     = new Font(font, 15, FontStyle.Regular, GraphicsUnit.Pixel);

            // System.Drawing has serious problems measuring strings, so it requires a per-pixel calibration
            // to ensure we are rendering text inside the proper region
            _inputTextCalibrationHeight = CalibrateTextHeight(_inputTextFont);

            StartTextBoxBlinker(_textBoxBlinkTimedAction, _textBoxBlinkCounter);
        }