Skip to content

Commit

Permalink
Merge pull request #863 from Sergio0694/dev/rename-canvaseffect-setpr…
Browse files Browse the repository at this point in the history
…operty

Rename 'CanvasEffect' API to 'SetPropertyAndInvalidateEffectGraph'
  • Loading branch information
Sergio0694 authored Oct 21, 2024
2 parents ce23fb4 + 38116e6 commit 9753cc9
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 15 deletions.
4 changes: 2 additions & 2 deletions samples/ComputeSharp.NativeLibrary.WinRT/HelloWorldEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public sealed partial class HelloWorldEffect : CanvasEffect
public float Time
{
get => this.time;
set => SetAndInvalidateEffectGraph(ref this.time, value);
set => SetPropertyAndInvalidateEffectGraph(ref this.time, value);
}

/// <summary>
Expand All @@ -35,7 +35,7 @@ public float Time
public Rect DispatchArea
{
get => this.dispatchArea;
set => SetAndInvalidateEffectGraph(ref this.dispatchArea, value);
set => SetPropertyAndInvalidateEffectGraph(ref this.dispatchArea, value);
}

/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal abstract partial class PixelShaderEffect : CanvasEffect
public TimeSpan ElapsedTime
{
get => this.elapsedTime;
set => SetAndInvalidateEffectGraph(ref this.elapsedTime, value);
set => SetPropertyAndInvalidateEffectGraph(ref this.elapsedTime, value);
}

/// <summary>
Expand All @@ -40,7 +40,7 @@ public TimeSpan ElapsedTime
public int ScreenWidth
{
get => this.screenWidth;
set => SetAndInvalidateEffectGraph(ref this.screenWidth, value);
set => SetPropertyAndInvalidateEffectGraph(ref this.screenWidth, value);
}

/// <summary>
Expand All @@ -49,7 +49,7 @@ public int ScreenWidth
public int ScreenHeight
{
get => this.screenHeight;
set => SetAndInvalidateEffectGraph(ref this.screenHeight, value);
set => SetPropertyAndInvalidateEffectGraph(ref this.screenHeight, value);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal abstract partial class PixelShaderEffect : CanvasEffect
public TimeSpan ElapsedTime
{
get => this.elapsedTime;
set => SetAndInvalidateEffectGraph(ref this.elapsedTime, value);
set => SetPropertyAndInvalidateEffectGraph(ref this.elapsedTime, value);
}

/// <summary>
Expand All @@ -40,7 +40,7 @@ public TimeSpan ElapsedTime
public int ScreenWidth
{
get => this.screenWidth;
set => SetAndInvalidateEffectGraph(ref this.screenWidth, value);
set => SetPropertyAndInvalidateEffectGraph(ref this.screenWidth, value);
}

/// <summary>
Expand All @@ -49,7 +49,7 @@ public int ScreenWidth
public int ScreenHeight
{
get => this.screenHeight;
set => SetAndInvalidateEffectGraph(ref this.screenHeight, value);
set => SetPropertyAndInvalidateEffectGraph(ref this.screenHeight, value);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public abstract partial class PixelShaderEffect : CanvasEffect
public TimeSpan ElapsedTime
{
get => this.elapsedTime;
set => SetAndInvalidateEffectGraph(ref this.elapsedTime, value);
set => SetPropertyAndInvalidateEffectGraph(ref this.elapsedTime, value);
}

/// <summary>
Expand All @@ -40,7 +40,7 @@ public TimeSpan ElapsedTime
public int ScreenWidth
{
get => this.screenWidth;
set => SetAndInvalidateEffectGraph(ref this.screenWidth, value);
set => SetPropertyAndInvalidateEffectGraph(ref this.screenWidth, value);
}

/// <summary>
Expand All @@ -49,7 +49,7 @@ public int ScreenWidth
public int ScreenHeight
{
get => this.screenHeight;
set => SetAndInvalidateEffectGraph(ref this.screenHeight, value);
set => SetPropertyAndInvalidateEffectGraph(ref this.screenHeight, value);
}

/// <summary>
Expand Down
11 changes: 10 additions & 1 deletion src/ComputeSharp.D2D1.UI/CanvasEffect.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Graphics.Canvas;

Expand Down Expand Up @@ -144,7 +145,7 @@ protected void InvalidateEffectGraph(CanvasEffectInvalidationType invalidationTy
/// <param name="storage">The storage for the effect property value.</param>
/// <param name="value">The new effect property value to set.</param>
/// <param name="invalidationType">The invalidation type to request.</param>
protected void SetAndInvalidateEffectGraph<T>([NotNullIfNotNull(nameof(value))] ref T storage, T value, CanvasEffectInvalidationType invalidationType = CanvasEffectInvalidationType.Update)
protected void SetPropertyAndInvalidateEffectGraph<T>([NotNullIfNotNull(nameof(value))] ref T storage, T value, CanvasEffectInvalidationType invalidationType = CanvasEffectInvalidationType.Update)
{
if (EqualityComparer<T>.Default.Equals(storage, value))
{
Expand All @@ -156,6 +157,14 @@ protected void SetAndInvalidateEffectGraph<T>([NotNullIfNotNull(nameof(value))]
InvalidateEffectGraph(invalidationType);
}

/// <inheritdoc cref="SetPropertyAndInvalidateEffectGraph"/>
[Obsolete("Use 'SetPropertyAndInvalidateEffectGraph' instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
protected void SetAndInvalidateEffectGraph<T>([NotNullIfNotNull(nameof(value))] ref T storage, T value, CanvasEffectInvalidationType invalidationType = CanvasEffectInvalidationType.Update)
{
SetPropertyAndInvalidateEffectGraph(ref storage, value, invalidationType);
}

/// <summary>
/// Disposes any disposable resources in the current instance.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,13 +390,13 @@ private sealed class EffectWithNoInputs : CanvasEffect
public int Value
{
get => this.value;
set => SetAndInvalidateEffectGraph(ref this.value, value);
set => SetPropertyAndInvalidateEffectGraph(ref this.value, value);
}

public int ValueWithReload
{
get => this.value;
set => SetAndInvalidateEffectGraph(ref this.value, value, CanvasEffectInvalidationType.Creation);
set => SetPropertyAndInvalidateEffectGraph(ref this.value, value, CanvasEffectInvalidationType.Creation);
}

public int NumberOfBuildEffectGraphCalls { get; private set; }
Expand Down
2 changes: 1 addition & 1 deletion tests/ComputeSharp.D2D1.WinUI.Tests/Tests/ShadersTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private sealed class TestCanvasEffect<T> : CanvasEffect
public T ConstantBuffer
{
get => this.constantBuffer;
set => SetAndInvalidateEffectGraph(ref this.constantBuffer, value);
set => SetPropertyAndInvalidateEffectGraph(ref this.constantBuffer, value);
}

protected override void BuildEffectGraph(CanvasEffectGraph effectGraph)
Expand Down

0 comments on commit 9753cc9

Please sign in to comment.