fix: overlay scaling issue

This commit is contained in:
pa
2025-12-13 23:44:24 +09:00
committed by Natsumi
parent 728434f336
commit ae1cf134cc
5 changed files with 47 additions and 14 deletions

View File

@@ -26,7 +26,7 @@ namespace VRCX
private static readonly Logger logger = LogManager.GetCurrentClassLogger(); private static readonly Logger logger = LogManager.GetCurrentClassLogger();
public OffScreenBrowser(string address, int width, int height) public OffScreenBrowser(string address, int width, int height, IRequestContext requestContext = null)
: base(address, automaticallyCreateBrowser: false) : base(address, automaticallyCreateBrowser: false)
{ {
var windowInfo = new WindowInfo(); var windowInfo = new WindowInfo();
@@ -42,7 +42,7 @@ namespace VRCX
WindowlessFrameRate = 60 WindowlessFrameRate = 60
}; };
CreateBrowser(windowInfo, browserSettings); CreateBrowser(windowInfo, browserSettings, requestContext);
Size = new System.Drawing.Size(width, height); Size = new System.Drawing.Size(width, height);
RenderHandler = this; RenderHandler = this;

View File

@@ -24,17 +24,26 @@ namespace VRCX
private int _width; private int _width;
private int _height; private int _height;
public OffScreenBrowserLegacy(string address, int width, int height) public OffScreenBrowserLegacy(string address, int width, int height, IRequestContext requestContext = null)
: base( : base(address, automaticallyCreateBrowser: false)
address,
new BrowserSettings()
{
DefaultEncoding = "UTF-8"
}
)
{ {
_paintBufferLock = new ReaderWriterLockSlim(); _paintBufferLock = new ReaderWriterLockSlim();
var windowInfo = new WindowInfo();
windowInfo.SetAsWindowless(IntPtr.Zero);
windowInfo.WindowlessRenderingEnabled = true;
windowInfo.SharedTextureEnabled = false;
windowInfo.Width = width;
windowInfo.Height = height;
var browserSettings = new BrowserSettings()
{
DefaultEncoding = "UTF-8",
WindowlessFrameRate = 24
};
CreateBrowser(windowInfo, browserSettings, requestContext);
Size = new System.Drawing.Size(width, height); Size = new System.Drawing.Size(width, height);
RenderHandler = this; RenderHandler = this;

View File

@@ -33,6 +33,15 @@ namespace VRCX
private static readonly float[] _rotationRight = { -90f * (float)(Math.PI / 180f), -90f * (float)(Math.PI / 180f), -90f * (float)(Math.PI / 180f) }; private static readonly float[] _rotationRight = { -90f * (float)(Math.PI / 180f), -90f * (float)(Math.PI / 180f), -90f * (float)(Math.PI / 180f) };
private static OffScreenBrowser _wristOverlay; private static OffScreenBrowser _wristOverlay;
private static OffScreenBrowser _hmdOverlay; private static OffScreenBrowser _hmdOverlay;
private static readonly IRequestContext VrOverlayRequestContext = new RequestContext(
new RequestContextSettings
{
CachePath = string.Empty,
PersistSessionCookies = false,
PersistUserPreferences = false
}
);
private readonly List<string[]> _deviceList; private readonly List<string[]> _deviceList;
private readonly ReaderWriterLockSlim _deviceListLock; private readonly ReaderWriterLockSlim _deviceListLock;
private bool _active; private bool _active;
@@ -196,13 +205,15 @@ namespace VRCX
_wristOverlay = new OffScreenBrowser( _wristOverlay = new OffScreenBrowser(
Program.LaunchDebug ? "http://localhost:9000/vr.html?wrist" : "file://vrcx/vr.html?wrist", Program.LaunchDebug ? "http://localhost:9000/vr.html?wrist" : "file://vrcx/vr.html?wrist",
512, 512,
512 512,
VrOverlayRequestContext
); );
_hmdOverlay = new OffScreenBrowser( _hmdOverlay = new OffScreenBrowser(
Program.LaunchDebug ? "http://localhost:9000/vr.html?hmd" : "file://vrcx/vr.html?hmd", Program.LaunchDebug ? "http://localhost:9000/vr.html?hmd" : "file://vrcx/vr.html?hmd",
1024, 1024,
1024 1024,
VrOverlayRequestContext
); );
while (_thread != null) while (_thread != null)

View File

@@ -33,6 +33,15 @@ namespace VRCX
private static readonly float[] _rotationRight = { -90f * (float)(Math.PI / 180f), -90f * (float)(Math.PI / 180f), -90f * (float)(Math.PI / 180f) }; private static readonly float[] _rotationRight = { -90f * (float)(Math.PI / 180f), -90f * (float)(Math.PI / 180f), -90f * (float)(Math.PI / 180f) };
private static OffScreenBrowserLegacy _wristOverlay; private static OffScreenBrowserLegacy _wristOverlay;
private static OffScreenBrowserLegacy _hmdOverlay; private static OffScreenBrowserLegacy _hmdOverlay;
private static readonly IRequestContext VrOverlayRequestContext = new RequestContext(
new RequestContextSettings
{
CachePath = string.Empty,
PersistSessionCookies = false,
PersistUserPreferences = false
}
);
private readonly List<string[]> _deviceList; private readonly List<string[]> _deviceList;
private readonly ReaderWriterLockSlim _deviceListLock; private readonly ReaderWriterLockSlim _deviceListLock;
private bool _active; private bool _active;
@@ -194,13 +203,15 @@ namespace VRCX
_wristOverlay = new OffScreenBrowserLegacy( _wristOverlay = new OffScreenBrowserLegacy(
Program.LaunchDebug ? "http://localhost:9000/vr.html?wrist" : "file://vrcx/vr.html?wrist", Program.LaunchDebug ? "http://localhost:9000/vr.html?wrist" : "file://vrcx/vr.html?wrist",
512, 512,
512 512,
VrOverlayRequestContext
); );
_hmdOverlay = new OffScreenBrowserLegacy( _hmdOverlay = new OffScreenBrowserLegacy(
Program.LaunchDebug ? "http://localhost:9000/vr.html?hmd" : "file://vrcx/vr.html?hmd", Program.LaunchDebug ? "http://localhost:9000/vr.html?hmd" : "file://vrcx/vr.html?hmd",
1024, 1024,
1024 1024,
VrOverlayRequestContext
); );
while (_thread != null) while (_thread != null)

View File

@@ -435,6 +435,7 @@ function createWristOverlayWindowOffscreen() {
frame: false, frame: false,
show: false, show: false,
webPreferences: { webPreferences: {
partition: 'vrcx-vr-overlay',
offscreen: true, offscreen: true,
preload: path.join(__dirname, 'preload.js') preload: path.join(__dirname, 'preload.js')
} }
@@ -501,6 +502,7 @@ function createHmdOverlayWindowOffscreen() {
frame: false, frame: false,
show: false, show: false,
webPreferences: { webPreferences: {
partition: 'vrcx-vr-overlay',
offscreen: true, offscreen: true,
preload: path.join(__dirname, 'preload.js') preload: path.join(__dirname, 'preload.js')
} }