Skip to content

Add C++ implementations of the GaussianBlurEffect class. - #398

Merged
simeoncran merged 4 commits into
masterfrom
CppBlurImpl
Dec 3, 2020
Merged

simeoncran merged 4 commits into
masterfrom
CppBlurImpl

Conversation

@simeoncran

Copy link
Copy Markdown
Contributor

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.

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.
@simeoncran
simeoncran requested a review from a team as a code owner December 2, 2020 00:21
var effectVariable = "gaussianBlurEffect";
builder.WriteLine($"ComPtr<GaussianBlurEffect> {effectVariable}(new GaussianBlurEffect());");
if (effect.BlurAmount != null)
if (effect.BlurAmount.HasValue)

@patrickeganMSFT patrickeganMSFT Dec 2, 2020 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@derobinsMSFT derobinsMSFT Dec 2, 2020 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

u [](start = 81, length = 1)

"Gaussian" #Closed

{
if (id != nullptr)
{
// CLSID_D2D1GaussianBlur value

@derobinsMSFT derobinsMSFT Dec 2, 2020 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

value [](start = 41, length = 6)

Nit: period. #Closed

}

// IGraphicsEffectD2D1Interop.
IFACEMETHODIMP GetSourceCount(UINT* count) override

@derobinsMSFT derobinsMSFT Dec 2, 2020 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[](start = 59, length = 1)

Nit: extra space. #Closed

}

m_source.as<::ABI::Windows::Graphics::Effects::IGraphicsEffectSource>().copy_to(source);

@derobinsMSFT derobinsMSFT Dec 2, 2020 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit; extra spaces. #Closed

{
switch (index)
{
case D2D1_GAUSSIANBLUR_PROP_BORDER_MODE:

@derobinsMSFT derobinsMSFT Dec 2, 2020 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[](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

@derobinsMSFT derobinsMSFT Dec 2, 2020 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 } };

@derobinsMSFT derobinsMSFT Dec 3, 2020 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation. #Closed

derobinsMSFT
derobinsMSFT previously approved these changes Dec 3, 2020

@derobinsMSFT derobinsMSFT left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@derobinsMSFT derobinsMSFT left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@simeoncran
simeoncran merged commit af3a5a6 into master Dec 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants