Implement ID2D1ResourceTextureManagerInternal

このコミットが含まれているのは:
Sergio Pedri committed 2022-08-15 15:01:15 +02:00
1 親 5221a61048
コミット aa21ceb0a6
3ファイル変更
+66 -8

検索条件に一致するファイルはありません

@@ -87,7 +87,25 @@ partial struct ResourceTextureManager
[UnmanagedCallersOnly]
public static int Initialize(ResourceTextureManager* @this, ID2D1EffectContext* effectContext)
{
return 0;
if (effectContext is null)
{
return E.E_POINTER;
}
effectContext->AddRef();
// If this is the first time the method is called, just store the context
if (@this->d2D1EffectContext is null)
{
@this->d2D1EffectContext = effectContext;
return S.S_OK;
}
// Otherwise, just do nothing and return S_FALSE. This allows an existing resource texture
// manager to be shared across effects. If the resource cannot be shared, it will just
// return an error when effect is actually set, with ID2D1DrawInfo::SetResourceTexture.
return S.S_FALSE;
}
/// <summary>
@@ -99,7 +117,50 @@ partial struct ResourceTextureManager
[UnmanagedCallersOnly]
public static int GetResourceTexture(ResourceTextureManager* @this, ID2D1ResourceTexture** resourceTexture)
{
return 0;
if (*resourceTexture is not null)
{
return E.E_POINTER;
}
// If the effect context is null, it means Initialize has not been called yet
if (@this->d2D1EffectContext is null)
{
return E.E_NOT_VALID_STATE;
}
// If the texture has already been created, just return it
if (@this->d2D1ResourceTexture is not null)
{
@this->d2D1ResourceTexture->AddRef();
*resourceTexture = @this->d2D1ResourceTexture;
}
// If the data is null at this point, it means CreateResourceTexture has not been called yet
if (@this->data is null)
{
return E.E_NOT_VALID_STATE;
}
// Create the resource now, as it hasn't been created yet
int result = @this->d2D1EffectContext->CreateResourceTexture(
resourceId: @this->resourceId,
resourceTextureProperties: &@this->resourceTextureProperties,
data: @this->data,
strides: @this->strides,
dataSize: @this->dataSize,
resourceTexture: resourceTexture);
// If creation was successful, release the buffered data
if (result == S.S_OK)
{
NativeMemory.Free(@this->resourceTextureProperties.extents);
NativeMemory.Free(@this->resourceTextureProperties.extendModes);
NativeMemory.Free(@this->data);
NativeMemory.Free(@this->strides);
}
return S.S_OK;
}
}
}
+3
ファイルの表示
@@ -7,6 +7,9 @@ namespace TerraFX.Interop.Windows
{
internal static class E
{
[NativeTypeName("#define E_NOT_VALID_STATE HRESULT_FROM_WIN32(ERROR_INVALID_STATE)")]
public const int E_NOT_VALID_STATE = -2147019873;
[NativeTypeName("#define E_NOTIMPL _HRESULT_TYPEDEF_(0x80004001L)")]
public const int E_NOTIMPL = unchecked((int)(0x80004001));
-6
ファイルの表示
@@ -12,11 +12,5 @@ namespace TerraFX.Interop.Windows
[NativeTypeName("#define S_FALSE ((HRESULT)1L)")]
public const int S_FALSE = ((int)(1));
[NativeTypeName("#define S_STORE_LAUNCHED_FOR_REMEDIATION _HRESULT_TYPEDEF_(0x00270258L)")]
public const int S_STORE_LAUNCHED_FOR_REMEDIATION = ((int)(0x00270258));
[NativeTypeName("#define S_APPLICATION_ACTIVATION_ERROR_HANDLED_BY_DIALOG _HRESULT_TYPEDEF_(0x00270259L)")]
public const int S_APPLICATION_ACTIVATION_ERROR_HANDLED_BY_DIALOG = ((int)(0x00270259));
}
}