Workarounded performance issues in Bubbles-Effect

This commit is contained in:
DarthAffe committed 2016-06-12 11:54:04 +02:00
1 parent c61d0ddac3
commit 25a873b5fa
6 files changed
+17 -18

No files matched your search

+2 -2
View File
@@ -266,10 +266,10 @@
<value>True</value> <value>True</value>
</setting> </setting>
<setting name="BubbleSize" serializeAs="String"> <setting name="BubbleSize" serializeAs="String">
<value>100</value> <value>25</value>
</setting> </setting>
<setting name="MoveSpeed" serializeAs="String"> <setting name="MoveSpeed" serializeAs="String">
<value>16</value> <value>4</value>
</setting> </setting>
<setting name="ShiftColorSpeed" serializeAs="String"> <setting name="ShiftColorSpeed" serializeAs="String">
<value>12</value> <value>12</value>
+2 -2
View File
@@ -61,7 +61,7 @@ namespace Artemis.Modules.Effects.Bubbles {
[global::System.Configuration.UserScopedSettingAttribute()] [global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("100")] [global::System.Configuration.DefaultSettingValueAttribute("25")]
public int BubbleSize { public int BubbleSize {
get { get {
return ((int)(this["BubbleSize"])); return ((int)(this["BubbleSize"]));
@@ -73,7 +73,7 @@ namespace Artemis.Modules.Effects.Bubbles {
[global::System.Configuration.UserScopedSettingAttribute()] [global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("16")] [global::System.Configuration.DefaultSettingValueAttribute("4")]
public int MoveSpeed { public int MoveSpeed {
get { get {
return ((int)(this["MoveSpeed"])); return ((int)(this["MoveSpeed"]));
@@ -12,10 +12,10 @@
<Value Profile="(Default)">True</Value> <Value Profile="(Default)">True</Value>
</Setting> </Setting>
<Setting Name="BubbleSize" Type="System.Int32" Scope="User"> <Setting Name="BubbleSize" Type="System.Int32" Scope="User">
<Value Profile="(Default)">100</Value> <Value Profile="(Default)">25</Value>
</Setting> </Setting>
<Setting Name="MoveSpeed" Type="System.Int32" Scope="User"> <Setting Name="MoveSpeed" Type="System.Int32" Scope="User">
<Value Profile="(Default)">16</Value> <Value Profile="(Default)">4</Value>
</Setting> </Setting>
<Setting Name="ShiftColorSpeed" Type="System.Int32" Scope="User"> <Setting Name="ShiftColorSpeed" Type="System.Int32" Scope="User">
<Value Profile="(Default)">12</Value> <Value Profile="(Default)">12</Value>
@@ -2,7 +2,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Linq.Dynamic;
using System.Windows; using System.Windows;
using Artemis.Managers; using Artemis.Managers;
using Artemis.Models; using Artemis.Models;
@@ -18,9 +17,10 @@ namespace Artemis.Modules.Effects.Bubbles
private static readonly Random _random = new Random(); private static readonly Random _random = new Random();
private const int SCALE = 100; private const int SCALE = 25;
private readonly List<Bubble> _bubbles = new List<Bubble>(); private readonly List<Bubble> _bubbles = new List<Bubble>();
private Bitmap _bitmap;
public BubblesSettings Settings { get; } public BubblesSettings Settings { get; }
@@ -43,6 +43,7 @@ namespace Artemis.Modules.Effects.Bubbles
public override void Enable() public override void Enable()
{ {
Rect rect = MainManager.DeviceManager.ActiveKeyboard.KeyboardRectangle(SCALE); Rect rect = MainManager.DeviceManager.ActiveKeyboard.KeyboardRectangle(SCALE);
_bitmap = MainManager.DeviceManager.ActiveKeyboard.KeyboardBitmap(SCALE);
for (int i = 0; i < Settings.BubbleCount; i++) for (int i = 0; i < Settings.BubbleCount; i++)
{ {
@@ -61,6 +62,7 @@ namespace Artemis.Modules.Effects.Bubbles
public override void Dispose() public override void Dispose()
{ {
_bitmap?.Dispose();
_bubbles.Clear(); _bubbles.Clear();
Initialized = false; Initialized = false;
} }
@@ -80,17 +82,14 @@ namespace Artemis.Modules.Effects.Bubbles
public override void Render(out Bitmap keyboard, out Brush mouse, out Brush headset, bool renderMice, bool renderHeadsets) public override void Render(out Bitmap keyboard, out Brush mouse, out Brush headset, bool renderMice, bool renderHeadsets)
{ {
keyboard = null; keyboard = _bitmap;
mouse = null; mouse = null;
headset = null; headset = null;
if (!_bubbles.Any()) return;
keyboard = MainManager.DeviceManager.ActiveKeyboard.KeyboardBitmap(SCALE);
using (Graphics g = Graphics.FromImage(keyboard)) using (Graphics g = Graphics.FromImage(keyboard))
{ {
g.Clear(Color.Transparent); g.Clear(Color.Transparent);
g.SmoothingMode = SmoothingMode.HighQuality; g.SmoothingMode = SmoothingMode.None;
foreach (Bubble bubble in _bubbles) foreach (Bubble bubble in _bubbles)
bubble.Draw(g); bubble.Draw(g);
@@ -47,8 +47,8 @@ namespace Artemis.Modules.Effects.Bubbles
IsRandomColors = true; IsRandomColors = true;
BubbleColor = Color.FromArgb(255, 255, 0, 0); BubbleColor = Color.FromArgb(255, 255, 0, 0);
IsShiftColors = true; IsShiftColors = true;
ShiftColorSpeed = 12; ShiftColorSpeed = 4;
BubbleSize = 100; BubbleSize = 25;
MoveSpeed = 16; MoveSpeed = 16;
BubbleCount = 14; BubbleCount = 14;
} }
@@ -107,7 +107,7 @@
</TextBlock> </TextBlock>
<Slider x:Name="Size" Grid.Row="7" Grid.Column="1" VerticalAlignment="Center" <Slider x:Name="Size" Grid.Row="7" Grid.Column="1" VerticalAlignment="Center"
HorizontalAlignment="Right" Width="110" TickPlacement="None" TickFrequency="1" HorizontalAlignment="Right" Width="110" TickPlacement="None" TickFrequency="1"
Value="{Binding Path=EffectSettings.BubbleSize, Mode=TwoWay}" Minimum="40" Maximum="180" Value="{Binding Path=EffectSettings.BubbleSize, Mode=TwoWay}" Minimum="10" Maximum="50"
SmallChange="10" IsSnapToTickEnabled="True" /> SmallChange="10" IsSnapToTickEnabled="True" />
<!-- speed --> <!-- speed -->
@@ -117,7 +117,7 @@
</TextBlock> </TextBlock>
<Slider x:Name="MoveSpeed" Grid.Row="8" Grid.Column="1" VerticalAlignment="Center" <Slider x:Name="MoveSpeed" Grid.Row="8" Grid.Column="1" VerticalAlignment="Center"
HorizontalAlignment="Right" Width="110" TickPlacement="None" TickFrequency="1" HorizontalAlignment="Right" Width="110" TickPlacement="None" TickFrequency="1"
Value="{Binding Path=EffectSettings.MoveSpeed, Mode=TwoWay}" Minimum="1" Maximum="50" Value="{Binding Path=EffectSettings.MoveSpeed, Mode=TwoWay}" Minimum="1" Maximum="15"
SmallChange="10" IsSnapToTickEnabled="True" /> SmallChange="10" IsSnapToTickEnabled="True" />
<!-- Buttons --> <!-- Buttons -->