Merge pull request #3493 from ShiinaRinne/AddEnableHWA

Add: 设置中添加"启用硬件加速"的选项
pull/3507/head
2dust 2023-03-16 14:10:20 +08:00 committed by GitHub
commit ccc10dbae4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 47 additions and 0 deletions

View File

@ -103,6 +103,8 @@ namespace v2rayN.Mode
public bool enableSecurityProtocolTls13 { get; set; } public bool enableSecurityProtocolTls13 { get; set; }
public int trayMenuServersLimit { get; set; } = 20; public int trayMenuServersLimit { get; set; } = 20;
public bool enableHWA { get; set; } = true;
} }
[Serializable] [Serializable]

View File

@ -2509,6 +2509,15 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Enable hardware acceleration(Require restart) 的本地化字符串。
/// </summary>
public static string TbSettingsEnableHWA {
get {
return ResourceManager.GetString("TbSettingsEnableHWA", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Exception 的本地化字符串。 /// 查找类似 Exception 的本地化字符串。
/// </summary> /// </summary>

View File

@ -1066,4 +1066,7 @@
<data name="TbSettingsDefUserAgentTips" xml:space="preserve"> <data name="TbSettingsDefUserAgentTips" xml:space="preserve">
<value>This parameter is valid only for tcp/http and ws</value> <value>This parameter is valid only for tcp/http and ws</value>
</data> </data>
<data name="TbSettingsEnableHWA" xml:space="preserve">
<value>فعال‌سازی شتاب‌دهنده سخت‌افزاری (نیاز به راه‌اندازی مجدد)</value>
</data>
</root> </root>

View File

@ -1141,4 +1141,7 @@
<data name="TbSpiderX" xml:space="preserve"> <data name="TbSpiderX" xml:space="preserve">
<value>SpiderX</value> <value>SpiderX</value>
</data> </data>
<data name="TbSettingsEnableHWA" xml:space="preserve">
<value>Enable hardware acceleration(Require restart)</value>
</data>
</root> </root>

View File

@ -1108,4 +1108,7 @@
<data name="TbSettingsFontSize" xml:space="preserve"> <data name="TbSettingsFontSize" xml:space="preserve">
<value>Размер шрифта</value> <value>Размер шрифта</value>
</data> </data>
<data name="TbSettingsEnableHWA" xml:space="preserve">
<value>Включить аппаратное ускорение (требуется перезагрузка)</value>
</data>
</root> </root>

View File

@ -1141,4 +1141,7 @@
<data name="TbSpiderX" xml:space="preserve"> <data name="TbSpiderX" xml:space="preserve">
<value>SpiderX</value> <value>SpiderX</value>
</data> </data>
<data name="TbSettingsEnableHWA" xml:space="preserve">
<value>启用硬件加速(需重启)</value>
</data>
</root> </root>

View File

@ -65,6 +65,7 @@ namespace v2rayN.ViewModels
[Reactive] public string currentFontFamily { get; set; } [Reactive] public string currentFontFamily { get; set; }
[Reactive] public int SpeedTestTimeout { get; set; } [Reactive] public int SpeedTestTimeout { get; set; }
[Reactive] public string SpeedTestUrl { get; set; } [Reactive] public string SpeedTestUrl { get; set; }
[Reactive] public bool EnableHWA { get; set; }
#endregion #endregion
@ -160,6 +161,7 @@ namespace v2rayN.ViewModels
currentFontFamily = _config.uiItem.currentFontFamily; currentFontFamily = _config.uiItem.currentFontFamily;
SpeedTestTimeout = _config.speedTestItem.speedTestTimeout; SpeedTestTimeout = _config.speedTestItem.speedTestTimeout;
SpeedTestUrl = _config.speedTestItem.speedTestUrl; SpeedTestUrl = _config.speedTestItem.speedTestUrl;
EnableHWA = _config.guiItem.enableHWA;
#endregion #endregion
@ -339,6 +341,7 @@ namespace v2rayN.ViewModels
_config.uiItem.currentFontFamily = currentFontFamily; _config.uiItem.currentFontFamily = currentFontFamily;
_config.speedTestItem.speedTestTimeout = SpeedTestTimeout; _config.speedTestItem.speedTestTimeout = SpeedTestTimeout;
_config.speedTestItem.speedTestUrl = SpeedTestUrl; _config.speedTestItem.speedTestUrl = SpeedTestUrl;
_config.guiItem.enableHWA = EnableHWA;
//systemProxy //systemProxy
_config.systemProxyExceptions = systemProxyExceptions; _config.systemProxyExceptions = systemProxyExceptions;

View File

@ -197,6 +197,11 @@ namespace v2rayN.Views
{ {
WindowState = WindowState.Minimized; WindowState = WindowState.Minimized;
} }
if (!_config.guiItem.enableHWA)
{
RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
}
} }
#region Event #region Event

View File

@ -481,6 +481,7 @@
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
@ -752,6 +753,20 @@
Width="300" Width="300"
Margin="{StaticResource SettingItemMargin}" Margin="{StaticResource SettingItemMargin}"
Style="{StaticResource DefComboBox}" /> Style="{StaticResource DefComboBox}" />
<TextBlock
Grid.Row="18"
Grid.Column="0"
Margin="{StaticResource SettingItemMargin}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsEnableHWA}"/>
<ToggleButton
x:Name="togEnableHWA"
Grid.Row="18"
Grid.Column="1"
Margin="{StaticResource SettingItemMargin}"
HorizontalAlignment="Left" />
</Grid> </Grid>
</ScrollViewer> </ScrollViewer>
</TabItem> </TabItem>

View File

@ -164,6 +164,7 @@ namespace v2rayN.Views
this.Bind(ViewModel, vm => vm.currentFontFamily, v => v.cmbcurrentFontFamily.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.currentFontFamily, v => v.cmbcurrentFontFamily.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SpeedTestTimeout, v => v.cmbSpeedTestTimeout.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SpeedTestTimeout, v => v.cmbSpeedTestTimeout.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SpeedTestUrl, v => v.cmbSpeedTestUrl.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SpeedTestUrl, v => v.cmbSpeedTestUrl.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.EnableHWA, v => v.togEnableHWA.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.systemProxyAdvancedProtocol, v => v.cmbsystemProxyAdvancedProtocol.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.systemProxyAdvancedProtocol, v => v.cmbsystemProxyAdvancedProtocol.Text).DisposeWith(disposables);