Skip to content

Add support for ICanvasFactoryNative.RegisterEffectFactory in PixelShaderEffect<T> - #512

Merged
Sergio0694 merged 7 commits into
mainfrom
dev/canvas-effect-factory
Apr 23, 2023
Merged

Sergio0694 merged 7 commits into
mainfrom
dev/canvas-effect-factory

Conversation

@Sergio0694

Copy link
Copy Markdown
Owner

Closes #502

Description

This PR adds support for registering effect factories for PixelShaderEffect<T> objects. This allows creating a new RCW from an orphaned D2D effect that was previously retrieved from a PixelShaderEffect<T>, which as since been unrealized/changed.

@Sergio0694 Sergio0694 added the enhancement ✨ An improvement to existing APIs label Apr 22, 2023
@Sergio0694

Copy link
Copy Markdown
Owner Author

Currently seems to crash with .NET Native, investigating:

@Sergio0694

Sergio0694 commented Apr 22, 2023 •

Copy link
Copy Markdown
Owner Author

Minimal repro:

Source code (click to expand):
public sealed partial class MainPage : Page
{
    public MainPage()
    {
        this.InitializeComponent();

        Test();
    }

    void Test()
    {
        var myClass = new MyClass();

        IntPtr myClassUnknown = Marshal.GetIUnknownForObject(myClass);
        Guid myClassGuid = typeof(IMyInterface).GUID;

        int hresult = Marshal.QueryInterface(myClassUnknown, ref myClassGuid, out _);

        Marshal.ThrowExceptionForHR(hresult);
    }
}

[Guid("E042D1F7-F9AD-4479-A713-67627EA31863")]
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMyInterface
{
    [PreserveSig]
    int Foo();
}

public sealed class MyClass : IMyInterface
{
    unsafe int IMyInterface.Foo()
    {
        return 0;
    }
}

@Sergio0694
Sergio0694 merged commit d61b37a into main Apr 23, 2023
@Sergio0694
Sergio0694 deleted the dev/canvas-effect-factory branch April 23, 2023 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement ✨ An improvement to existing APIs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Win2D ResourceManager cache

1 participant