Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions tools/codegen/exe/OutputEffectType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,11 @@ public static void OutputEffectCpp(Effects.Effect effect, Formatter output)

if (effect.Overrides != null && !string.IsNullOrEmpty(effect.Overrides.IsSupportedCheck))
{
output.WriteLine("if (!SharedDeviceState::GetInstance()->Is" + effect.Overrides.IsSupportedCheck + "Supported())");
if (effect.Overrides.IsSupportedCheck == "Registered") {
output.WriteLine("if (!SharedDeviceState::GetInstance()->IsEffectRegistered(" + effect.ClassName + "::EffectId(), true))");
} else {
output.WriteLine("if (!SharedDeviceState::GetInstance()->Is" + effect.Overrides.IsSupportedCheck + "Supported())");
}
output.Indent();
output.WriteLine("ThrowHR(E_NOTIMPL, Strings::NotSupportedOnThisVersionOfWindows);");
output.Unindent();
Expand Down Expand Up @@ -474,7 +478,11 @@ public static void OutputEffectCpp(Effects.Effect effect, Formatter output)
output.WriteLine("{");
output.Indent();
output.WriteLine("CheckInPointer(result);");
output.WriteLine("*result = SharedDeviceState::GetInstance()->Is" + effect.Overrides.IsSupportedCheck + "Supported();");
if (effect.Overrides.IsSupportedCheck == "Registered") {
output.WriteLine("*result = SharedDeviceState::GetInstance()->IsEffectRegistered(" + effect.ClassName + "::EffectId(), true);");
} else {
output.WriteLine("*result = SharedDeviceState::GetInstance()->Is" + effect.Overrides.IsSupportedCheck + "Supported();");
}
output.Unindent();
output.WriteLine("});");
output.Unindent();
Expand Down
1 change: 1 addition & 0 deletions tools/codegen/exe/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public class Effect
[XmlAttributeAttribute]
public string WinVer;

//If set to "Registered", this will checck if the effect is registered using its class ID.
[XmlAttributeAttribute]
public string IsSupportedCheck;

Expand Down
6 changes: 6 additions & 0 deletions tools/codegen/exe/Settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -299,5 +299,11 @@ Licensed under the MIT License. See LICENSE.txt in the project root for license
</Effect>
<Effect Name="OpacityEffect" WinVer="_WIN32_WINNT_WIN10" IsSupportedCheck="ID2D1Factory5"/>
<Effect Name="TintEffect" WinVer="_WIN32_WINNT_WIN10" IsSupportedCheck="ID2D1Factory5"/>
<Effect Name="HDRToneMapEffect" ProjectedNameOverride="HdrToneMapEffect" CLSIDOverride="CLSID_D2D1HdrToneMap" WinVer="_WIN32_WINNT_WIN10" IsSupportedCheck="Registered"/>
<Enum Name="HDRToneMapEffectDisplayMode" ProjectedNameOverride="HdrToneMapEffectDisplayMode">
<Field Name="SDR" ProjectedNameOverride="Sdr"/>
<Field Name="HDR" ProjectedNameOverride="Hdr"/>
</Enum>
<Effect Name="WhiteLevelAdjustmentEffect" WinVer="_WIN32_WINNT_WIN10" IsSupportedCheck="Registered"/>
</Namespace>
</Settings>
4 changes: 3 additions & 1 deletion tools/codegen/exe/apiref/UpdateApiResourceFiles.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ SET FILE_LIST=^
GammaTransfer.xml ^
GaussianBlur.xml ^
Grayscale.xml ^
HDRToneMap.xml ^
HighlightsShadows.xml ^
HueRotation.xml ^
HueToRgb.xml ^
Expand Down Expand Up @@ -125,7 +126,8 @@ SET FILE_LIST=^
Tint.xml ^
Turbulence.xml ^
UnPremultiply.xml ^
Vignette.xml
Vignette.xml ^
WhiteLevelAdjustment.xml

CALL :UPDATE_FILES

Expand Down
43 changes: 43 additions & 0 deletions tools/codegen/exe/apiref/effects/HdrToneMap.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0"?>
<!--
Copyright (c) Microsoft Corporation. All rights reserved.

Licensed under the MIT License. See LICENSE.txt in the project root for license information.
-->

<Effect>
<!-- Localization -->
<_locDefinition>
<_locDefault _loc="locNone" />
<_locTag _locAttrData="displayname">Field</_locTag>
<_locTag _locAttrData="name">Input</_locTag>
<_locTag _locAttrData="value">Property</_locTag>
</_locDefinition>
<!-- System Properties -->
<Property name='DisplayName' type='string' value='HDR Tone Map'/>
<Property name='Author' type='string' value='Microsoft Corporation'/>
<Property name='Category' type='string' value='Color'/>
<Property name='Description' type='string' value='Adjusts the maximum luminance of the source image to fit within the maximum output luminance supported. Input and output luminance values are specified in nits. Note that the color space of the image is assumed to be scRGB.'/>

<!-- This effect has one input -->
<Inputs>
<Input name='Source'/>
</Inputs>

<Property name='InputMaxLuminance' type='float'>
<Property name='DisplayName' type='string' value='Input Max Luminance'/>
<Property name="Default" type="float" value="4000" />
</Property>
<Property name="OutputMaxLuminance" type="float">
<Property name="DisplayName" type="string" value="Output Max Luminance" />
<Property name="Default" type="float" value="300" />
</Property>
<Property name='DisplayMode' type='enum'>
<Property name='DisplayName' type='string' value='Display Mode'/>
<Property name="Default" type="enum" value="0" />
<Fields>
<Field name='SDR' displayname='SDR' index="0" />
<Field name='HDR' displayname='HDR' index="1" />
</Fields>
</Property>
</Effect>
36 changes: 36 additions & 0 deletions tools/codegen/exe/apiref/effects/WhiteLevelAdjustment.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0"?>
<!--
Copyright (c) Microsoft Corporation. All rights reserved.

Licensed under the MIT License. See LICENSE.txt in the project root for license information.
-->

<Effect>
<!-- Localization -->
<_locDefinition>
<_locDefault _loc="locNone" />
<_locTag _locAttrData="displayname">Field</_locTag>
<_locTag _locAttrData="name">Input</_locTag>
<_locTag _locAttrData="value">Property</_locTag>
</_locDefinition>
<!-- System Properties -->
<Property name='DisplayName' type='string' value='White Level Adjustment'/>
<Property name='Author' type='string' value='Microsoft Corporation'/>
<Property name='Category' type='string' value='Color'/>
<Property name='Description' type='string'
value='This effect adjusts the white level of the source image by multiplying the source image color by the ratio of the input and output white levels. Input and output white levels are specified in nits.'/>

<!-- This effect have one input -->
<Inputs>
<Input name='Source'/>
</Inputs>

<Property name='InputWhiteLevel' type='float'>
<Property name='DisplayName' type='string' value='Input White Level'/>
<Property name="Default" type="float" value="80" />
</Property>
<Property name="OutputWhiteLevel" type="float">
<Property name="DisplayName" type="string" value="Output White Level" />
<Property name="Default" type="float" value="80" />
</Property>
</Effect>
2 changes: 2 additions & 0 deletions tools/codegen/exe/codegen.exe.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@
<None Include="apiref\effects\CrossFade.xml" />
<None Include="apiref\effects\Opacity.xml" />
<None Include="apiref\effects\Tint.xml" />
<None Include="apiref\effects\HdrToneMap.xml" />
<None Include="apiref\effects\WhiteLevelAdjustment.xml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
2 changes: 1 addition & 1 deletion tools/codegen/test/UnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void OutputEffectsIsSync()
FileInfo[] actualGeneratedFiles = actualDirectoryInfo.GetFiles();

// Ensure the correct number of files was generated.
const int expectedEffectCount = 59;
const int expectedEffectCount = 61;
Assert.AreEqual(expectedEffectCount * 3 + 2, expectedGeneratedFiles.Length);
Assert.AreEqual(expectedGeneratedFiles.Length, actualGeneratedFiles.Length);

Expand Down
1 change: 1 addition & 0 deletions tools/docs/DocPreprocess/Tag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Tag
new Tag("Win10_10586", "This API is only available when running on Windows 10 build 10586 (released November 2015) or greater.") { PropagateTypeTagsToMembers = true },
new Tag("Win10_14393", "This API is only available when running on Windows 10 build 14393 (Anniversary Update) or greater.") { PropagateTypeTagsToMembers = true },
new Tag("Win10_15063", "This API is only available when running on Windows 10 build 15063 (Creators Update) or greater.") { PropagateTypeTagsToMembers = true },
new Tag("Win10_17763", "This API is only available when running on Windows 10 build 17763 (October 2018) or greater.") { PropagateTypeTagsToMembers = true },
new Tag("NoComposition", "Supported by Win2D but not Windows.UI.Composition."),
};

Expand Down
2 changes: 1 addition & 1 deletion winrt/docsrc/Interop.aml
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ Licensed under the MIT License. See LICENSE.txt in the project root for license
}
}
</code>
Remember to include the header &lt;unkwn.h&gt; in pch.h before any winrt headers (required in SDK 17763 and later).
Remember to include the header &lt;unknwn.h&gt; in pch.h before any winrt headers (required in SDK 17763 and later).
</content>
</section>

Expand Down
2 changes: 1 addition & 1 deletion winrt/docsrc/effects/AlphaMaskEffect.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Licensed under the MIT License. See LICENSE.txt in the project root for license

<inherittemplate name="EffectTemplate" replacement="AlphaMaskEffect" />
<inherittemplate name="ICanvasEffectTemplate" replacement="AlphaMaskEffect" />
<inherittemplate name="EffectRequires14393Template" replacement="AlphaMaskEffect" />
<inherittemplate name="EffectRequiresOSVersionTemplate" replacement="AlphaMaskEffect" />

</members>
</doc>
2 changes: 1 addition & 1 deletion winrt/docsrc/effects/CrossFadeEffect.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Licensed under the MIT License. See LICENSE.txt in the project root for license

<inherittemplate name="EffectTemplate" replacement="CrossFadeEffect" />
<inherittemplate name="ICanvasEffectTemplate" replacement="CrossFadeEffect" />
<inherittemplate name="EffectRequires14393Template" replacement="CrossFadeEffect" />
<inherittemplate name="EffectRequiresOSVersionTemplate" replacement="CrossFadeEffect" />

</members>
</doc>
10 changes: 5 additions & 5 deletions winrt/docsrc/effects/Effects.xml
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,17 @@ Licensed under the MIT License. See LICENSE.txt in the project root for license
</template>


<template name="EffectRequires14393Template">
<member name="P:Microsoft.Graphics.Canvas.Effects.EffectRequires14393Template.IsSupported" Win10_14393="false">
<summary>Checks whether EffectRequires14393Template is supported on the current operating system version.</summary>
<template name="EffectRequiresOSVersionTemplate">
<member name="P:Microsoft.Graphics.Canvas.Effects.EffectRequiresOSVersionTemplate.IsSupported" Win10_14393="false" Win10_17763="false">
<summary>Checks whether EffectRequiresOSVersionTemplate is supported on the current operating system version.</summary>
<remarks>
<p>
If the application is currently running on an operating system that doesn't
support EffectRequires14393Template then calls to create this effect will fail.
support EffectRequiresOSVersionTemplate then calls to create this effect will fail.
</p>
<p>
If you know that your application will never run on an operating system that
doesn't support EffectRequires14393Template then there is no need to perform this check.
doesn't support EffectRequiresOSVersionTemplate then there is no need to perform this check.
</p>
</remarks>
</member>
Expand Down
54 changes: 54 additions & 0 deletions winrt/docsrc/effects/HdrToneMapEffect.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0"?>
<!--
Copyright (c) Microsoft Corporation. All rights reserved.

Licensed under the MIT License. See LICENSE.txt in the project root for license information.
-->

<doc>
<assembly>
<name>Microsoft.Graphics.Canvas</name>
</assembly>
<members>

<member name="T:Microsoft.Graphics.Canvas.Effects.HdrToneMapEffect" NoComposition="true" Win10_17763="true">
<summary>
This effect adjusts the dynamic range of an image to better suit its content to the capability of the output display.
</summary>
<remarks>
<p>This Windows Runtime type corresponds to the
<a href="https://docs.microsoft.com/en-us/windows/win32/direct2d/hdr-tone-map-effect">D2D HDR tone map effect</a>.</p>
</remarks>
</member>
<member name="M:Microsoft.Graphics.Canvas.Effects.HdrToneMapEffect.#ctor">
<summary>Initializes a new instance of the HdrToneMapEffect class.</summary>
</member>
<member name="P:Microsoft.Graphics.Canvas.Effects.HdrToneMapEffect.Source">
<summary>Gets or sets the input source for the effect.</summary>
</member>
<member name="P:Microsoft.Graphics.Canvas.Effects.HdrToneMapEffect.InputMaxLuminance">
<summary>The maximum light level (or MaxCLL) of the image, in nits. Default value 4000.</summary>
</member>
<member name="P:Microsoft.Graphics.Canvas.Effects.HdrToneMapEffect.OutputMaxLuminance">
<summary>The MaxCLL supported by the output target, in nits - typically set to the MaxCLL of the display. Default value 300.</summary>
</member>
<member name="P:Microsoft.Graphics.Canvas.Effects.HdrToneMapEffect.DisplayMode">
<summary>When set to Hdr, the tone mapping curve is adjusted to better fit the fit the behavior of common HDR displays. Default value Sdr.</summary>
</member>

<member name="T:Microsoft.Graphics.Canvas.Effects.HdrToneMapEffectDisplayMode">
<summary>The display mode used for the effect.</summary>
</member>
<member name="F:Microsoft.Graphics.Canvas.Effects.HdrToneMapEffectDisplayMode.Sdr">
<summary>Specifies that the tone mapper algorithm be optimized for best appearance on a standard dynamic range (SDR) display.</summary>
</member>
<member name="F:Microsoft.Graphics.Canvas.Effects.HdrToneMapEffectDisplayMode.Hdr">
<summary>Specifies that the tone mapper algorithm be optimized for best appearance on a high dynamic range (HDR) display.</summary>
</member>

<inherittemplate name="EffectTemplate" replacement="HdrToneMapEffect" />
<inherittemplate name="ICanvasEffectTemplate" replacement="HdrToneMapEffect" />
<inherittemplate name="EffectRequiresOSVersionTemplate" replacement="HdrToneMapEffect" />

</members>
</doc>
2 changes: 1 addition & 1 deletion winrt/docsrc/effects/OpacityEffect.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Licensed under the MIT License. See LICENSE.txt in the project root for license

<inherittemplate name="EffectTemplate" replacement="OpacityEffect" />
<inherittemplate name="ICanvasEffectTemplate" replacement="OpacityEffect" />
<inherittemplate name="EffectRequires14393Template" replacement="OpacityEffect" />
<inherittemplate name="EffectRequiresOSVersionTemplate" replacement="OpacityEffect" />

</members>
</doc>
2 changes: 1 addition & 1 deletion winrt/docsrc/effects/TintEffect.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Licensed under the MIT License. See LICENSE.txt in the project root for license

<inherittemplate name="EffectTemplate" replacement="TintEffect" />
<inherittemplate name="ICanvasEffectTemplate" replacement="TintEffect" />
<inherittemplate name="EffectRequires14393Template" replacement="TintEffect" />
<inherittemplate name="EffectRequiresOSVersionTemplate" replacement="TintEffect" />

</members>
</doc>
41 changes: 41 additions & 0 deletions winrt/docsrc/effects/WhiteLevelAdjustmentEffect.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0"?>
<!--
Copyright (c) Microsoft Corporation. All rights reserved.

Licensed under the MIT License. See LICENSE.txt in the project root for license information.
-->

<doc>
<assembly>
<name>Microsoft.Graphics.Canvas</name>
</assembly>
<members>

<member name="T:Microsoft.Graphics.Canvas.Effects.WhiteLevelAdjustmentEffect" NoComposition="true" Win10_17763="true">
<summary>
This effect allows the white level of an image to be linearly scaled. This is especially helpful when you convert between display-referred luminance space and scene-referred luminance space, or vice versa.
</summary>
<remarks>
<p>This Windows Runtime type corresponds to the
<a href="https://docs.microsoft.com/en-us/windows/win32/direct2d/white-level-adjustment-effect">D2D White level adjustment effect</a>.</p>
</remarks>
</member>
<member name="M:Microsoft.Graphics.Canvas.Effects.WhiteLevelAdjustmentEffect.#ctor">
<summary>Initializes a new instance of the WhiteLevelAdjustmentEffect class.</summary>
</member>
<member name="P:Microsoft.Graphics.Canvas.Effects.WhiteLevelAdjustmentEffect.Source">
<summary>Gets or sets the input source for the effect.</summary>
</member>
<member name="P:Microsoft.Graphics.Canvas.Effects.WhiteLevelAdjustmentEffect.InputWhiteLevel">
<summary>The white level of the input image, in nits. Default value 80.</summary>
</member>
<member name="P:Microsoft.Graphics.Canvas.Effects.WhiteLevelAdjustmentEffect.OutputWhiteLevel">
<summary>The white level of the output image, in nits. Default value 80.</summary>
</member>

<inherittemplate name="EffectTemplate" replacement="WhiteLevelAdjustmentEffect" />
<inherittemplate name="ICanvasEffectTemplate" replacement="WhiteLevelAdjustmentEffect" />
<inherittemplate name="EffectRequiresOSVersionTemplate" replacement="WhiteLevelAdjustmentEffect" />

</members>
</doc>
2 changes: 2 additions & 0 deletions winrt/lib/Canvas.abi.idl
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ cpp_quote("#endif")
#include "effects\generated\GammaTransferEffect.abi.idl"
#include "effects\generated\GaussianBlurEffect.abi.idl"
#include "effects\generated\GrayscaleEffect.abi.idl"
#include "effects\generated\HdrToneMapEffect.abi.idl"
#include "effects\generated\HighlightsAndShadowsEffect.abi.idl"
#include "effects\generated\HueRotationEffect.abi.idl"
#include "effects\generated\HueToRgbEffect.abi.idl"
Expand Down Expand Up @@ -132,3 +133,4 @@ cpp_quote("#endif")
#include "effects\generated\TurbulenceEffect.abi.idl"
#include "effects\generated\UnPremultiplyEffect.abi.idl"
#include "effects\generated\VignetteEffect.abi.idl"
#include "effects\generated\WhiteLevelAdjustmentEffect.abi.idl"
18 changes: 18 additions & 0 deletions winrt/lib/drawing/CanvasDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,24 @@ namespace ABI { namespace Microsoft { namespace Graphics { namespace Canvas
return !!m_isID2D1Factory5Supported;
}

bool SharedDeviceState::IsEffectRegistered(IID const& effectId, bool cacheResult) {
{
RecursiveLock lock(m_mutex);
auto it = m_cachedRegisteredEffects.find(effectId);
if (it != m_cachedRegisteredEffects.end()) {
return it->second;
}
}
auto factory = m_adapter->CreateD2DFactory(CanvasDebugLevel::None);
ComPtr<ID2D1Properties> effectProperties;
auto hr = factory->GetEffectProperties(effectId, effectProperties.GetAddressOf());
bool result = SUCCEEDED(hr);
if (cacheResult){
RecursiveLock lock(m_mutex);
m_cachedRegisteredEffects.insert_or_assign(effectId, result);
}
return result;
}

//
// CanvasDeviceFactory
Expand Down
3 changes: 3 additions & 0 deletions winrt/lib/drawing/CanvasDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#pragma once

#include "DeviceContextPool.h"
#include "Utils/GuidUtilities.h"

namespace ABI { namespace Microsoft { namespace Graphics { namespace Canvas
{
Expand Down Expand Up @@ -469,6 +470,7 @@ namespace ABI { namespace Microsoft { namespace Graphics { namespace Canvas
CanvasDebugLevel m_currentDebugLevel;

int m_isID2D1Factory5Supported; // negative = not yet checked.
std::map<const IID, bool, GuidComparer> m_cachedRegisteredEffects;

std::recursive_mutex m_mutex;

Expand All @@ -483,6 +485,7 @@ namespace ABI { namespace Microsoft { namespace Graphics { namespace Canvas
void SetDebugLevel(CanvasDebugLevel const& value);

bool IsID2D1Factory5Supported();
bool IsEffectRegistered(IID const& effectId, bool cacheResult); //Only set cacheResult to true for built-in effects, which cannot be unregistered.

CanvasDeviceAdapter* GetAdapter() const { return m_adapter.get(); }

Expand Down
Loading