Repository navigation
Add C++ implementations of the GaussianBlurEffect class. - #398
Conversation
Effect classes are defined in Win2D, but in C# we avoid taking the Win2D dependency by implementing the class in the generated code. This change also cleans up the CompositeEffect class to be a bit clearer and more consistent with GaussianBlurEffect. And fixes a compilation error in the CX output.
| var effectVariable = "gaussianBlurEffect"; | ||
| builder.WriteLine($"ComPtr<GaussianBlurEffect> {effectVariable}(new GaussianBlurEffect());"); | ||
| if (effect.BlurAmount != null) | ||
| if (effect.BlurAmount.HasValue) |
There was a problem hiding this comment.
if (effect.BlurAmount.HasValue) [](start = 12, length = 31)
Should you keep the check for effect.BlurAmount != null? If it is null I think this will crash #ByDesign
There was a problem hiding this comment.
BlurAmount is a Nullable value type. https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/nullable-value-types
It's always safe to call .HasValue on it.
Good intuition - it's super weird that you can call a method on something where "== null" is true. I hadn't thought about that before.
In reply to: 534305992 [](ancestors = 534305992)
|
|
||
| static string GaussianBlurEffectClass => | ||
| @" | ||
| // This class is a substitute for the Microsoft::Graphics::Canvas::Effects::GuassianBlurEffect |
There was a problem hiding this comment.
u [](start = 81, length = 1)
"Gaussian" #Closed
| { | ||
| if (id != nullptr) | ||
| { | ||
| // CLSID_D2D1GaussianBlur value |
There was a problem hiding this comment.
value [](start = 41, length = 6)
Nit: period. #Closed
| } | ||
|
|
||
| // IGraphicsEffectD2D1Interop. | ||
| IFACEMETHODIMP GetSourceCount(UINT* count) override |
There was a problem hiding this comment.
[](start = 59, length = 1)
Nit: extra space. #Closed
| } | ||
|
|
||
| m_source.as<::ABI::Windows::Graphics::Effects::IGraphicsEffectSource>().copy_to(source); | ||
|
|
| { | ||
| switch (index) | ||
| { | ||
| case D2D1_GAUSSIANBLUR_PROP_BORDER_MODE: |
There was a problem hiding this comment.
[](start = 52, length = 1)
Nit: extra spaces (here and below). #Closed
| { | ||
| // set CLSID_D2D1Composite value | ||
| *id = { 0x48fc9f51, 0xf6ac, 0x48f1, { 0x8b, 0x58, 0x3b, 0x28, 0xac, 0x46, 0xf7, 0x6d } }; | ||
| // CLSID_D2D1Composite value |
There was a problem hiding this comment.
value [](start = 35, length = 5)
Nit: period. #Closed
| if (id != nullptr) | ||
| { | ||
| // CLSID_D2D1GaussianBlur. | ||
| *id = { 0x1feb6d69, 0x2fe6, 0x4ac9, { 0x8c, 0x58, 0x1d, 0x7f, 0x93, 0xe7, 0xa6, 0xa5 } }; |
Effect classes are defined in Win2D, but in C# we avoid taking the Win2D dependency by implementing the class in the generated code.
This change also cleans up the CompositeEffect class to be a bit clearer and more consistent with GaussianBlurEffect. And fixes a compilation error in the CX output.