forked from unoplatform/uno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(composition): Implement WhiteNoiseEffect + Sample + Win2D + Refa…
…ctor
- Loading branch information
Showing
38 changed files
with
2,465 additions
and
2,027 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
2,066 changes: 39 additions & 2,027 deletions
2,066
src/SamplesApp/UITests.Shared/Windows_UI_Composition/EffectBrushTests.xaml.cs
Large diffs are not rendered by default.
Oops, something went wrong.
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
69 changes: 69 additions & 0 deletions
69
src/Uno.UI.Composition/Composition/Effects/WhiteNoiseEffect.cs
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,69 @@ | ||
using System; | ||
using System.Numerics; | ||
using System.Runtime.InteropServices; | ||
using Windows.Graphics.Effects; | ||
using Windows.Graphics.Effects.Interop; | ||
|
||
namespace Windows.UI.Composition.Effects | ||
{ | ||
[Guid("6152DFC6-9FBA-4810-8CBA-B280AA27BFF6")] | ||
internal class WhiteNoiseEffect : IGraphicsEffect, IGraphicsEffectSource, IGraphicsEffectD2D1Interop | ||
{ | ||
private string _name = "WhiteNoiseEffect"; | ||
private Guid _id = new Guid("6152DFC6-9FBA-4810-8CBA-B280AA27BFF6"); | ||
|
||
public string Name | ||
{ | ||
get => _name; | ||
set => _name = value; | ||
} | ||
|
||
public Vector2 Frequency { get; set; } = new(0.01f); | ||
|
||
public Vector2 Offset { get; set; } | ||
|
||
public Guid GetEffectId() => _id; | ||
|
||
public void GetNamedPropertyMapping(string name, out uint index, out GraphicsEffectPropertyMapping mapping) | ||
{ | ||
switch (name) | ||
{ | ||
case "Frequency": | ||
{ | ||
index = 0; | ||
mapping = GraphicsEffectPropertyMapping.Direct; | ||
break; | ||
} | ||
case "Offset": | ||
{ | ||
index = 1; | ||
mapping = GraphicsEffectPropertyMapping.Direct; | ||
break; | ||
} | ||
default: | ||
{ | ||
index = 0xFF; | ||
mapping = (GraphicsEffectPropertyMapping)0xFF; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
public object GetProperty(uint index) | ||
{ | ||
switch (index) | ||
{ | ||
case 0: | ||
return Frequency; | ||
case 1: | ||
return Offset; | ||
default: | ||
return null; | ||
} | ||
} | ||
|
||
public uint GetPropertyCount() => 2; | ||
public IGraphicsEffectSource GetSource(uint index) => throw new NotSupportedException(); | ||
public uint GetSourceCount() => 0; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/Uno.UI.Composition/Win2D/Microsoft/Graphics/Canvas/CanvasComposite.cs
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,19 @@ | ||
namespace Microsoft.Graphics.Canvas | ||
{ | ||
public enum CanvasComposite | ||
{ | ||
SourceOver = 0, | ||
DestinationOver = 1, | ||
SourceIn = 2, | ||
DestinationIn = 3, | ||
SourceOut = 4, | ||
DestinationOut = 5, | ||
SourceAtop = 6, | ||
DestinationAtop = 7, | ||
Xor = 8, | ||
Add = 9, | ||
Copy = 10, | ||
BoundedCopy = 11, | ||
MaskInvert = 12 | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/Uno.UI.Composition/Win2D/Microsoft/Graphics/Canvas/CanvasEdgeBehavior.cs
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,10 @@ | ||
namespace Microsoft.Graphics.Canvas | ||
{ | ||
public enum CanvasEdgeBehavior | ||
{ | ||
Clamp = 0, | ||
Wrap = 1, | ||
Mirror = 2 | ||
} | ||
} | ||
|
34 changes: 34 additions & 0 deletions
34
src/Uno.UI.Composition/Win2D/Microsoft/Graphics/Canvas/Effects/AlphaMaskEffect.cs
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,34 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using Windows.Graphics.Effects; | ||
using Windows.Graphics.Effects.Interop; | ||
|
||
namespace Microsoft.Graphics.Canvas.Effects | ||
{ | ||
[Guid("C80ECFF0-3FD5-4F05-8328-C5D1724B4F0A")] | ||
public class AlphaMaskEffect : IGraphicsEffect, IGraphicsEffectSource, IGraphicsEffectD2D1Interop | ||
{ | ||
private string _name = "AlphaMaskEffect"; | ||
private Guid _id = new Guid("C80ECFF0-3FD5-4F05-8328-C5D1724B4F0A"); | ||
|
||
public string Name | ||
{ | ||
get => _name; | ||
set => _name = value; | ||
} | ||
|
||
public IGraphicsEffectSource AlphaMask { get; set; } | ||
|
||
public IGraphicsEffectSource Source { get; set; } | ||
|
||
public Guid GetEffectId() => _id; | ||
|
||
public void GetNamedPropertyMapping(string name, out uint index, out GraphicsEffectPropertyMapping mapping) => throw new NotSupportedException(); | ||
|
||
public object GetProperty(uint index) => throw new NotSupportedException(); | ||
|
||
public uint GetPropertyCount() => 0; | ||
public IGraphicsEffectSource GetSource(uint index) => index == 0 ? Source : AlphaMask; | ||
public uint GetSourceCount() => 2; | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
src/Uno.UI.Composition/Win2D/Microsoft/Graphics/Canvas/Effects/BlendEffect.cs
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,64 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using Windows.Graphics.Effects; | ||
using Windows.Graphics.Effects.Interop; | ||
|
||
namespace Microsoft.Graphics.Canvas.Effects | ||
{ | ||
[Guid("81C5B77B-13F8-4CDD-AD20-C890547AC65D")] | ||
public class BlendEffect : IGraphicsEffect, IGraphicsEffectSource, IGraphicsEffectD2D1Interop | ||
{ | ||
private string _name = "BlendEffect"; | ||
private Guid _id = new Guid("81C5B77B-13F8-4CDD-AD20-C890547AC65D"); | ||
|
||
public string Name | ||
{ | ||
get => _name; | ||
set => _name = value; | ||
} | ||
|
||
public BlendEffectMode Mode { get; set; } = BlendEffectMode.Multiply; | ||
|
||
public IGraphicsEffectSource Background { get; set; } | ||
|
||
public IGraphicsEffectSource Foreground { get; set; } | ||
|
||
public Guid GetEffectId() => _id; | ||
|
||
public void GetNamedPropertyMapping(string name, out uint index, out GraphicsEffectPropertyMapping mapping) | ||
{ | ||
switch (name) | ||
{ | ||
case "Mode": | ||
{ | ||
index = 0; | ||
mapping = GraphicsEffectPropertyMapping.Direct; | ||
break; | ||
} | ||
default: | ||
{ | ||
index = 0xFF; | ||
mapping = (GraphicsEffectPropertyMapping)0xFF; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
public object GetProperty(uint index) | ||
{ | ||
switch (index) | ||
{ | ||
case 0: | ||
return Mode; | ||
default: | ||
return null; | ||
} | ||
} | ||
|
||
public uint GetPropertyCount() => 1; | ||
|
||
public IGraphicsEffectSource GetSource(uint index) => index is 0 ? Background : Foreground; | ||
|
||
public uint GetSourceCount() => 2; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/Uno.UI.Composition/Win2D/Microsoft/Graphics/Canvas/Effects/BlendEffectMode.cs
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,32 @@ | ||
namespace Microsoft.Graphics.Canvas.Effects | ||
{ | ||
public enum BlendEffectMode | ||
{ | ||
Multiply = 0, | ||
Screen = 1, | ||
Darken = 2, | ||
Lighten = 3, | ||
Dissolve = 4, | ||
ColorBurn = 5, | ||
LinearBurn = 6, | ||
DarkerColor = 7, | ||
LighterColor = 8, | ||
ColorDodge = 9, | ||
LinearDodge = 10, | ||
Overlay = 11, | ||
SoftLight = 12, | ||
HardLight = 13, | ||
VividLight = 14, | ||
LinearLight = 15, | ||
PinLight = 16, | ||
HardMix = 17, | ||
Difference = 18, | ||
Exclusion = 19, | ||
Hue = 20, | ||
Saturation = 21, | ||
Color = 22, | ||
Luminosity = 23, | ||
Subtract = 24, | ||
Division = 25 | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
src/Uno.UI.Composition/Win2D/Microsoft/Graphics/Canvas/Effects/BorderEffect.cs
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,70 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using Windows.Graphics.Effects; | ||
using Windows.Graphics.Effects.Interop; | ||
|
||
namespace Microsoft.Graphics.Canvas.Effects | ||
{ | ||
[Guid("2A2D49C0-4ACF-43C7-8C6A-7C4A27874D27")] | ||
public class BorderEffect : IGraphicsEffect, IGraphicsEffectSource, IGraphicsEffectD2D1Interop | ||
{ | ||
private string _name = "BorderEffect"; | ||
private Guid _id = new Guid("2A2D49C0-4ACF-43C7-8C6A-7C4A27874D27"); | ||
|
||
public string Name | ||
{ | ||
get => _name; | ||
set => _name = value; | ||
} | ||
|
||
public CanvasEdgeBehavior ExtendX { get; set; } = CanvasEdgeBehavior.Clamp; | ||
|
||
public CanvasEdgeBehavior ExtendY { get; set; } = CanvasEdgeBehavior.Clamp; | ||
|
||
public IGraphicsEffectSource Source { get; set; } | ||
|
||
public Guid GetEffectId() => _id; | ||
|
||
public void GetNamedPropertyMapping(string name, out uint index, out GraphicsEffectPropertyMapping mapping) | ||
{ | ||
switch (name) | ||
{ | ||
case "ExtendX": | ||
{ | ||
index = 0; | ||
mapping = GraphicsEffectPropertyMapping.Direct; | ||
break; | ||
} | ||
case "ExtendY": | ||
{ | ||
index = 1; | ||
mapping = GraphicsEffectPropertyMapping.Direct; | ||
break; | ||
} | ||
default: | ||
{ | ||
index = 0xFF; | ||
mapping = (GraphicsEffectPropertyMapping)0xFF; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
public object GetProperty(uint index) | ||
{ | ||
switch (index) | ||
{ | ||
case 0: | ||
return ExtendX; | ||
case 1: | ||
return ExtendY; | ||
default: | ||
return null; | ||
} | ||
} | ||
|
||
public uint GetPropertyCount() => 2; | ||
public IGraphicsEffectSource GetSource(uint index) => Source; | ||
public uint GetSourceCount() => 1; | ||
} | ||
} |
Oops, something went wrong.