Wire up effect factory registration on first realization
このコミットが含まれているのは:
1 親
6c17745c5d
コミット
051e2536ef
2ファイル変更
+24
-1
検索条件に一致するファイルはありません
@@ -90,6 +90,25 @@ internal static unsafe class ResourceManager
|
||||
canvasFactoryNative.Get()->UnregisterWrapper(resource).Assert();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers a factory of wrappers for custom effect with a given effect id.
|
||||
/// </summary>
|
||||
/// <param name="effectId">The id of the effects to register a factory for.</param>
|
||||
/// <param name="factory">The input factory to create wrappers of native effects.</param>
|
||||
public static void RegisterEffectFactory(Guid effectId, ICanvasEffectFactoryNative.Interface factory)
|
||||
{
|
||||
using ComPtr<ICanvasFactoryNative> canvasFactoryNative = default;
|
||||
|
||||
GetActivationFactory(canvasFactoryNative.GetAddressOf());
|
||||
|
||||
using ComPtr<ICanvasEffectFactoryNative> canvasEffectFactoryNative = default;
|
||||
|
||||
RcwMarshaller.GetNativeInterface(factory, canvasEffectFactoryNative.GetAddressOf()).Assert();
|
||||
|
||||
// Register the factory for the current effect from the activation factory
|
||||
canvasFactoryNative.Get()->RegisterEffectFactory(&effectId, canvasEffectFactoryNative.Get()).Assert();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ICanvasFactoryNative"/> activation factory.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using ABI.Microsoft.Graphics.Canvas;
|
||||
using ComputeSharp.D2D1.Extensions;
|
||||
using ComputeSharp.D2D1.Interop.Effects;
|
||||
#if WINDOWS_UWP
|
||||
using ComputeSharp.D2D1.Uwp.Extensions;
|
||||
using ComputeSharp.D2D1.Uwp.Helpers;
|
||||
@@ -48,13 +49,16 @@ unsafe partial class PixelShaderEffect<T>
|
||||
/// </summary>
|
||||
public static EffectFactoryManager Instance { get; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Ensures an effect factory is registered in Win2D for the current effect type, or registers one otherwise.
|
||||
/// </summary>
|
||||
public void EnsureEffectFactoryIsRegistered()
|
||||
{
|
||||
lock (this.lockObject)
|
||||
{
|
||||
if (!this.isEffectFactoryRegistered)
|
||||
{
|
||||
// TODO
|
||||
ResourceManager.RegisterEffectFactory(PixelShaderEffect.For<T>.Instance.Id, this);
|
||||
|
||||
this.isEffectFactoryRegistered = true;
|
||||
}
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする