Skip to content

Commit

Permalink
performance regression fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
fabsenet committed Nov 28, 2016
1 parent 3f028ab commit 22abb7e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions adrilight/DesktopDuplicatorReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public void Run(CancellationToken token)
image.LockBits(new Rectangle(0, 0, image.Width, image.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppRgb, bitmapData);
lock (SpotSet.Lock)
{
var useLinearLighting = Settings.UseLinearLighting;

var imageRectangle = new Rectangle(0, 0, image.Width, image.Height);
Parallel.ForEach(SpotSet.Spots
, spot =>
Expand All @@ -82,7 +84,7 @@ public void Run(CancellationToken token)
var countInverse = 1f/count;
byte finalR, finalG, finalB;
ApplyColorCorrections(sumR*countInverse, sumG*countInverse, sumB*countInverse, out finalR, out finalG, out finalB);
ApplyColorCorrections(sumR*countInverse, sumG*countInverse, sumB*countInverse, out finalR, out finalG, out finalB, useLinearLighting);
spot.SetColor(finalR, finalG, finalB);
Expand All @@ -101,7 +103,7 @@ public void Run(CancellationToken token)
}
}

private void ApplyColorCorrections(float r, float g, float b, out byte finalR, out byte finalG, out byte finalB)
private void ApplyColorCorrections(float r, float g, float b, out byte finalR, out byte finalG, out byte finalB, bool useLinearLighting)
{
if (r <= Settings.SaturationTreshold && g <= Settings.SaturationTreshold && b <= Settings.SaturationTreshold)
{
Expand All @@ -110,7 +112,7 @@ private void ApplyColorCorrections(float r, float g, float b, out byte finalR, o
return;
}

if (!Settings.UseLinearLighting)
if (!useLinearLighting)
{
//apply non linear LED fading ( http://www.mikrocontroller.net/articles/LED-Fading )
r = FadeNonLinear(r);
Expand Down

0 comments on commit 22abb7e

Please sign in to comment.