-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #709 from cairoshell/invert-tray-icons
- Loading branch information
Showing
10 changed files
with
126 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using ManagedShell.Common.Logging; | ||
using System; | ||
using System.Windows.Media.Effects; | ||
using System.Windows; | ||
using System.Windows.Media; | ||
|
||
namespace CairoDesktop.Common | ||
{ | ||
// Courtesy of https://stackoverflow.com/a/45096471 | ||
public class InvertEffect : ShaderEffect | ||
{ | ||
private static readonly PixelShader _shader = | ||
new PixelShader { UriSource = new Uri("pack://application:,,,/CairoDesktop.Common;component/Resources/InvertShader/shader_invert.ps") }; | ||
|
||
public InvertEffect() | ||
{ | ||
PixelShader = _shader; | ||
PixelShader.InvalidPixelShaderEncountered += PixelShader_InvalidPixelShaderEncountered; | ||
UpdateShaderValue(InputProperty); | ||
} | ||
|
||
private void PixelShader_InvalidPixelShaderEncountered(object sender, EventArgs e) | ||
{ | ||
ShellLogger.Error("InvertEffect: The given pixel shader is not valid."); | ||
} | ||
|
||
public Brush Input | ||
{ | ||
get { return (Brush)GetValue(InputProperty); } | ||
set { SetValue(InputProperty, value); } | ||
} | ||
|
||
public static readonly DependencyProperty InputProperty = | ||
RegisterPixelShaderSamplerProperty("Input", typeof(InvertEffect), 0); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
Cairo Desktop/CairoDesktop.Common/Resources/InvertShader/shader_compile.bat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\fxc.exe" /T ps_3_0 /E main /Foshader_invert.ps shader_invert.hlsl |
18 changes: 18 additions & 0 deletions
18
Cairo Desktop/CairoDesktop.Common/Resources/InvertShader/shader_invert.hlsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
sampler2D input : register(s0); | ||
|
||
float4 main(float2 uv : TEXCOORD) : COLOR | ||
{ | ||
float4 color = tex2D(input, uv); | ||
float alpha = color.a; | ||
|
||
if (!(color.r == color.g && color.g == color.b)) | ||
{ | ||
return color; | ||
} | ||
|
||
color.rgb /= alpha; | ||
color.rgb = 1 - color.rgb; | ||
color.rgb *= alpha; | ||
|
||
return color; | ||
} |
Binary file added
BIN
+336 Bytes
Cairo Desktop/CairoDesktop.Common/Resources/InvertShader/shader_invert.ps
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters