Remove leftover ComPtr extensions
このコミットが含まれているのは:
1 親
265de8d1ea
コミット
c7664916ad
2ファイル変更
+1
-69
検索条件に一致するファイルはありません
@@ -71,7 +71,7 @@ internal static unsafe class ICanvasDeviceExtensions
|
||||
else
|
||||
{
|
||||
// Otherwise, just use the input device context
|
||||
ComPtr.WriteTo(d2D1DeviceContext, out *d2D1DeviceContextEffective);
|
||||
*d2D1DeviceContextEffective = new ComPtr<ID2D1DeviceContext>(d2D1DeviceContext).Get();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,74 +13,6 @@ using static ComputeSharp.Win32.S;
|
||||
|
||||
namespace ComputeSharp.Win32;
|
||||
|
||||
/// <summary>
|
||||
/// Extensions for <see cref="ComPtr{T}"/> to operate on raw pointers as well.
|
||||
/// </summary>
|
||||
internal static unsafe class ComPtr
|
||||
{
|
||||
/// <summary>
|
||||
/// Disposes a target COM object, if it's not <see langword="null"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of COM objects to work with.</typeparam>
|
||||
/// <param name="other">The COM object to potentially release.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Dispose<T>(T* other)
|
||||
where T : unmanaged
|
||||
{
|
||||
if (other is not null)
|
||||
{
|
||||
_ = ((IUnknown*)other)->Release();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies a given COM object into a target destination, incrementing reference counts where needed.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of COM objects to work with.</typeparam>
|
||||
/// <param name="obj">The input COM object to copy.</param>
|
||||
/// <param name="other">The target destination for the COM object.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void CopyTo<T>(T* obj, ref T* other)
|
||||
where T : unmanaged
|
||||
{
|
||||
// We specifically need to increment the reference count on the source object before releasing the
|
||||
// target object, to avoid issues in case source and destination were pointers to the same object
|
||||
// (which can be the case even if the two pointers are not identical). To double check, a full check
|
||||
// through an IUnknown* cast would be needed, but to avoid the extra QueryInterface call on both objects,
|
||||
// we can just always do one AddRef call which avoids issues in all cases as well. The situation we need
|
||||
// to avoid is that without a temporary copy, releasing the target object might actually destroy the
|
||||
// object, causing the following AddRef call to AV.
|
||||
if (obj is not null)
|
||||
{
|
||||
_ = ((IUnknown*)obj)->AddRef();
|
||||
}
|
||||
|
||||
T* pointer = other;
|
||||
|
||||
if (pointer is not null)
|
||||
{
|
||||
_ = ((IUnknown*)pointer)->Release();
|
||||
}
|
||||
|
||||
other = obj;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a given COM object into a target (assumed uninitialized) destination, incrementing reference counts where needed.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of COM objects to work with.</typeparam>
|
||||
/// <param name="obj">The input COM object to copy.</param>
|
||||
/// <param name="other">The target destination for the COM object.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void WriteTo<T>(T* obj, out T* other)
|
||||
where T : unmanaged
|
||||
{
|
||||
_ = ((IUnknown*)obj)->AddRef();
|
||||
|
||||
other = obj;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A type that allows working with pointers to COM objects more securely.</summary>
|
||||
/// <typeparam name="T">The type to wrap in the current <see cref="ComPtr{T}"/> instance.</typeparam>
|
||||
/// <remarks>While this type is not marked as <see langword="ref"/> so that it can also be used in fields, make sure to keep the reference counts properly tracked if you do store <see cref="ComPtr{T}"/> instances on the heap.</remarks>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする