diff --git a/tools/codegen/exe/OutputEffectType.cs b/tools/codegen/exe/OutputEffectType.cs index b69876a10..3643d3c07 100644 --- a/tools/codegen/exe/OutputEffectType.cs +++ b/tools/codegen/exe/OutputEffectType.cs @@ -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(); @@ -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(); diff --git a/tools/codegen/exe/Settings.cs b/tools/codegen/exe/Settings.cs index 19cff4586..93ad82d87 100644 --- a/tools/codegen/exe/Settings.cs +++ b/tools/codegen/exe/Settings.cs @@ -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; diff --git a/tools/codegen/exe/Settings.xml b/tools/codegen/exe/Settings.xml index fc2d59887..aaba3b564 100644 --- a/tools/codegen/exe/Settings.xml +++ b/tools/codegen/exe/Settings.xml @@ -299,5 +299,11 @@ Licensed under the MIT License. See LICENSE.txt in the project root for license + + + + + + diff --git a/tools/codegen/exe/apiref/UpdateApiResourceFiles.cmd b/tools/codegen/exe/apiref/UpdateApiResourceFiles.cmd index 4bd4b5332..cafabaeb8 100644 --- a/tools/codegen/exe/apiref/UpdateApiResourceFiles.cmd +++ b/tools/codegen/exe/apiref/UpdateApiResourceFiles.cmd @@ -97,6 +97,7 @@ SET FILE_LIST=^ GammaTransfer.xml ^ GaussianBlur.xml ^ Grayscale.xml ^ + HDRToneMap.xml ^ HighlightsShadows.xml ^ HueRotation.xml ^ HueToRgb.xml ^ @@ -125,7 +126,8 @@ SET FILE_LIST=^ Tint.xml ^ Turbulence.xml ^ UnPremultiply.xml ^ - Vignette.xml + Vignette.xml ^ + WhiteLevelAdjustment.xml CALL :UPDATE_FILES diff --git a/tools/codegen/exe/apiref/effects/HdrToneMap.xml b/tools/codegen/exe/apiref/effects/HdrToneMap.xml new file mode 100644 index 000000000..d43a07bf6 --- /dev/null +++ b/tools/codegen/exe/apiref/effects/HdrToneMap.xml @@ -0,0 +1,43 @@ + + + + + + <_locDefinition> + <_locDefault _loc="locNone" /> + <_locTag _locAttrData="displayname">Field + <_locTag _locAttrData="name">Input + <_locTag _locAttrData="value">Property + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/codegen/exe/apiref/effects/WhiteLevelAdjustment.xml b/tools/codegen/exe/apiref/effects/WhiteLevelAdjustment.xml new file mode 100644 index 000000000..af6d156a9 --- /dev/null +++ b/tools/codegen/exe/apiref/effects/WhiteLevelAdjustment.xml @@ -0,0 +1,36 @@ + + + + + + <_locDefinition> + <_locDefault _loc="locNone" /> + <_locTag _locAttrData="displayname">Field + <_locTag _locAttrData="name">Input + <_locTag _locAttrData="value">Property + + + + + + + + + + + + + + + + + + + + + diff --git a/tools/codegen/exe/codegen.exe.csproj b/tools/codegen/exe/codegen.exe.csproj index a6f16431c..c53d73030 100644 --- a/tools/codegen/exe/codegen.exe.csproj +++ b/tools/codegen/exe/codegen.exe.csproj @@ -128,6 +128,8 @@ + + + + + + Microsoft.Graphics.Canvas + + + + + + This effect adjusts the dynamic range of an image to better suit its content to the capability of the output display. + + +

This Windows Runtime type corresponds to the + D2D HDR tone map effect.

+
+
+ + Initializes a new instance of the HdrToneMapEffect class. + + + Gets or sets the input source for the effect. + + + The maximum light level (or MaxCLL) of the image, in nits. Default value 4000. + + + The MaxCLL supported by the output target, in nits - typically set to the MaxCLL of the display. Default value 300. + + + When set to Hdr, the tone mapping curve is adjusted to better fit the fit the behavior of common HDR displays. Default value Sdr. + + + + The display mode used for the effect. + + + Specifies that the tone mapper algorithm be optimized for best appearance on a standard dynamic range (SDR) display. + + + Specifies that the tone mapper algorithm be optimized for best appearance on a high dynamic range (HDR) display. + + + + + + +
+
diff --git a/winrt/docsrc/effects/OpacityEffect.xml b/winrt/docsrc/effects/OpacityEffect.xml index 2d521a7ba..a7c2a5686 100644 --- a/winrt/docsrc/effects/OpacityEffect.xml +++ b/winrt/docsrc/effects/OpacityEffect.xml @@ -32,7 +32,7 @@ Licensed under the MIT License. See LICENSE.txt in the project root for license - + diff --git a/winrt/docsrc/effects/TintEffect.xml b/winrt/docsrc/effects/TintEffect.xml index d48f95d5c..2ccce468b 100644 --- a/winrt/docsrc/effects/TintEffect.xml +++ b/winrt/docsrc/effects/TintEffect.xml @@ -56,7 +56,7 @@ Licensed under the MIT License. See LICENSE.txt in the project root for license - + diff --git a/winrt/docsrc/effects/WhiteLevelAdjustmentEffect.xml b/winrt/docsrc/effects/WhiteLevelAdjustmentEffect.xml new file mode 100644 index 000000000..6677f6407 --- /dev/null +++ b/winrt/docsrc/effects/WhiteLevelAdjustmentEffect.xml @@ -0,0 +1,41 @@ + + + + + + Microsoft.Graphics.Canvas + + + + + + 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. + + +

This Windows Runtime type corresponds to the + D2D White level adjustment effect.

+
+
+ + Initializes a new instance of the WhiteLevelAdjustmentEffect class. + + + Gets or sets the input source for the effect. + + + The white level of the input image, in nits. Default value 80. + + + The white level of the output image, in nits. Default value 80. + + + + + + +
+
diff --git a/winrt/lib/Canvas.abi.idl b/winrt/lib/Canvas.abi.idl index 9dd441acf..64c92a57b 100644 --- a/winrt/lib/Canvas.abi.idl +++ b/winrt/lib/Canvas.abi.idl @@ -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" @@ -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" diff --git a/winrt/lib/drawing/CanvasDevice.cpp b/winrt/lib/drawing/CanvasDevice.cpp index f39d4d58e..92720b255 100644 --- a/winrt/lib/drawing/CanvasDevice.cpp +++ b/winrt/lib/drawing/CanvasDevice.cpp @@ -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 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 diff --git a/winrt/lib/drawing/CanvasDevice.h b/winrt/lib/drawing/CanvasDevice.h index 54c9e6b99..f9f3ddc45 100644 --- a/winrt/lib/drawing/CanvasDevice.h +++ b/winrt/lib/drawing/CanvasDevice.h @@ -5,6 +5,7 @@ #pragma once #include "DeviceContextPool.h" +#include "Utils/GuidUtilities.h" namespace ABI { namespace Microsoft { namespace Graphics { namespace Canvas { @@ -469,6 +470,7 @@ namespace ABI { namespace Microsoft { namespace Graphics { namespace Canvas CanvasDebugLevel m_currentDebugLevel; int m_isID2D1Factory5Supported; // negative = not yet checked. + std::map m_cachedRegisteredEffects; std::recursive_mutex m_mutex; @@ -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(); } diff --git a/winrt/lib/effects/generated/EffectMakers.cpp b/winrt/lib/effects/generated/EffectMakers.cpp index 6e6aa21f0..2343d33eb 100644 --- a/winrt/lib/effects/generated/EffectMakers.cpp +++ b/winrt/lib/effects/generated/EffectMakers.cpp @@ -52,6 +52,7 @@ #include "EmbossEffect.h" #include "ExposureEffect.h" #include "GrayscaleEffect.h" +#include "HdrToneMapEffect.h" #include "HighlightsAndShadowsEffect.h" #include "HueToRgbEffect.h" #include "InvertEffect.h" @@ -65,6 +66,7 @@ #include "TemperatureAndTintEffect.h" #include "TintEffect.h" #include "VignetteEffect.h" +#include "WhiteLevelAdjustmentEffect.h" std::pair CanvasEffect::m_effectMakers[] = @@ -115,6 +117,7 @@ std::pair CanvasEffect::m_effectMakers[] { EmbossEffect::EffectId(), MakeEffect }, { ExposureEffect::EffectId(), MakeEffect }, { GrayscaleEffect::EffectId(), MakeEffect }, + { HdrToneMapEffect::EffectId(), MakeEffect }, { HighlightsAndShadowsEffect::EffectId(), MakeEffect }, { HueToRgbEffect::EffectId(), MakeEffect }, { InvertEffect::EffectId(), MakeEffect }, @@ -128,6 +131,7 @@ std::pair CanvasEffect::m_effectMakers[] { TemperatureAndTintEffect::EffectId(), MakeEffect }, { TintEffect::EffectId(), MakeEffect }, { VignetteEffect::EffectId(), MakeEffect }, + { WhiteLevelAdjustmentEffect::EffectId(), MakeEffect }, { GUID_NULL, nullptr } }; diff --git a/winrt/lib/effects/generated/HdrToneMapEffect.abi.idl b/winrt/lib/effects/generated/HdrToneMapEffect.abi.idl new file mode 100644 index 000000000..9b3234563 --- /dev/null +++ b/winrt/lib/effects/generated/HdrToneMapEffect.abi.idl @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +// This file was automatically generated. Please do not edit it manually. + +#if (defined _WIN32_WINNT_WIN10) && (WINVER >= _WIN32_WINNT_WIN10) + +namespace Microsoft.Graphics.Canvas.Effects +{ + [version(VERSION)] + typedef enum HdrToneMapEffectDisplayMode + { + Sdr = 0, + Hdr = 1 + } HdrToneMapEffectDisplayMode; + + runtimeclass HdrToneMapEffect; + + [version(VERSION), uuid(2004FAAC-663E-5DF4-B4CD-A5AFBFD9341F), exclusiveto(HdrToneMapEffect)] + interface IHdrToneMapEffect : IInspectable + requires ICanvasEffect + { + [propget] + HRESULT InputMaxLuminance([out, retval] float* value); + + [propput] + HRESULT InputMaxLuminance([in] float value); + + [propget] + HRESULT OutputMaxLuminance([out, retval] float* value); + + [propput] + HRESULT OutputMaxLuminance([in] float value); + + [propget] + HRESULT DisplayMode([out, retval] HdrToneMapEffectDisplayMode* value); + + [propput] + HRESULT DisplayMode([in] HdrToneMapEffectDisplayMode value); + + [propget] + HRESULT Source([out, retval] IGRAPHICSEFFECTSOURCE** source); + + [propput] + HRESULT Source([in] IGRAPHICSEFFECTSOURCE* source); + + }; + + [version(VERSION), uuid(0181F02F-0A7E-55E1-8D2D-42AB99739B27), exclusiveto(HdrToneMapEffect)] + interface IHdrToneMapEffectStatics : IInspectable + { + [propget] HRESULT IsSupported([out, retval] boolean* value); + } + + [STANDARD_ATTRIBUTES, activatable(VERSION), static(IHdrToneMapEffectStatics, VERSION)] + runtimeclass HdrToneMapEffect + { + [default] interface IHdrToneMapEffect; + } +} + +#endif // _WIN32_WINNT_WIN10 diff --git a/winrt/lib/effects/generated/HdrToneMapEffect.cpp b/winrt/lib/effects/generated/HdrToneMapEffect.cpp new file mode 100644 index 000000000..abf02d8a4 --- /dev/null +++ b/winrt/lib/effects/generated/HdrToneMapEffect.cpp @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +// This file was automatically generated. Please do not edit it manually. + +#include "pch.h" +#include "HdrToneMapEffect.h" + +#if (defined _WIN32_WINNT_WIN10) && (WINVER >= _WIN32_WINNT_WIN10) + +namespace ABI { namespace Microsoft { namespace Graphics { namespace Canvas { namespace Effects +{ + HdrToneMapEffect::HdrToneMapEffect(ICanvasDevice* device, ID2D1Effect* effect) + : CanvasEffect(EffectId(), 3, 1, true, device, effect, static_cast(this)) + { + if (!SharedDeviceState::GetInstance()->IsEffectRegistered(HdrToneMapEffect::EffectId(), true)) + ThrowHR(E_NOTIMPL, Strings::NotSupportedOnThisVersionOfWindows); + + if (!effect) + { + // Set default values + SetBoxedProperty(D2D1_HDRTONEMAP_PROP_INPUT_MAX_LUMINANCE, 4000.0f); + SetBoxedProperty(D2D1_HDRTONEMAP_PROP_OUTPUT_MAX_LUMINANCE, 300.0f); + SetBoxedProperty(D2D1_HDRTONEMAP_PROP_DISPLAY_MODE, HdrToneMapEffectDisplayMode::Sdr); + } + } + + IMPLEMENT_EFFECT_PROPERTY(HdrToneMapEffect, + InputMaxLuminance, + float, + float, + D2D1_HDRTONEMAP_PROP_INPUT_MAX_LUMINANCE) + + IMPLEMENT_EFFECT_PROPERTY(HdrToneMapEffect, + OutputMaxLuminance, + float, + float, + D2D1_HDRTONEMAP_PROP_OUTPUT_MAX_LUMINANCE) + + IMPLEMENT_EFFECT_PROPERTY(HdrToneMapEffect, + DisplayMode, + uint32_t, + HdrToneMapEffectDisplayMode, + D2D1_HDRTONEMAP_PROP_DISPLAY_MODE) + + IMPLEMENT_EFFECT_SOURCE_PROPERTY(HdrToneMapEffect, + Source, + 0) + + IMPLEMENT_EFFECT_PROPERTY_MAPPING(HdrToneMapEffect, + { L"InputMaxLuminance", D2D1_HDRTONEMAP_PROP_INPUT_MAX_LUMINANCE, GRAPHICS_EFFECT_PROPERTY_MAPPING_DIRECT }, + { L"OutputMaxLuminance", D2D1_HDRTONEMAP_PROP_OUTPUT_MAX_LUMINANCE, GRAPHICS_EFFECT_PROPERTY_MAPPING_DIRECT }, + { L"DisplayMode", D2D1_HDRTONEMAP_PROP_DISPLAY_MODE, GRAPHICS_EFFECT_PROPERTY_MAPPING_DIRECT }) + + IFACEMETHODIMP HdrToneMapEffectFactory::ActivateInstance(IInspectable** instance) + { + return ExceptionBoundary([&] + { + auto effect = Make(); + CheckMakeResult(effect); + + ThrowIfFailed(effect.CopyTo(instance)); + }); + } + + IFACEMETHODIMP HdrToneMapEffectFactory::get_IsSupported(_Out_ boolean* result) + { + return ExceptionBoundary([&] + { + CheckInPointer(result); + *result = SharedDeviceState::GetInstance()->IsEffectRegistered(HdrToneMapEffect::EffectId(), true); + }); + } + + ActivatableClassWithFactory(HdrToneMapEffect, HdrToneMapEffectFactory); +}}}}} + +#endif // _WIN32_WINNT_WIN10 diff --git a/winrt/lib/effects/generated/HdrToneMapEffect.h b/winrt/lib/effects/generated/HdrToneMapEffect.h new file mode 100644 index 000000000..5198871fe --- /dev/null +++ b/winrt/lib/effects/generated/HdrToneMapEffect.h @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +// This file was automatically generated. Please do not edit it manually. + +#pragma once + +#if (defined _WIN32_WINNT_WIN10) && (WINVER >= _WIN32_WINNT_WIN10) + +namespace ABI { namespace Microsoft { namespace Graphics { namespace Canvas { namespace Effects +{ + using namespace ::Microsoft::WRL; + using namespace ABI::Microsoft::Graphics::Canvas; + + class HdrToneMapEffect : public RuntimeClass< + IHdrToneMapEffect, + MixIn>, + public CanvasEffect + { + InspectableClass(RuntimeClass_Microsoft_Graphics_Canvas_Effects_HdrToneMapEffect, BaseTrust); + + public: + HdrToneMapEffect(ICanvasDevice* device = nullptr, ID2D1Effect* effect = nullptr); + + static IID const& EffectId() { return CLSID_D2D1HdrToneMap; } + + EFFECT_PROPERTY(InputMaxLuminance, float); + EFFECT_PROPERTY(OutputMaxLuminance, float); + EFFECT_PROPERTY(DisplayMode, HdrToneMapEffectDisplayMode); + EFFECT_PROPERTY(Source, IGraphicsEffectSource*); + + EFFECT_PROPERTY_MAPPING(); + }; + + class HdrToneMapEffectFactory + : public AgileActivationFactory + , private LifespanTracker + { + InspectableClassStatic(RuntimeClass_Microsoft_Graphics_Canvas_Effects_HdrToneMapEffect, BaseTrust); + + public: + IFACEMETHODIMP ActivateInstance(IInspectable**) override; + IFACEMETHOD(get_IsSupported)(boolean* value) override; + }; +}}}}} + +#endif // _WIN32_WINNT_WIN10 diff --git a/winrt/lib/effects/generated/WhiteLevelAdjustmentEffect.abi.idl b/winrt/lib/effects/generated/WhiteLevelAdjustmentEffect.abi.idl new file mode 100644 index 000000000..7eca0ebef --- /dev/null +++ b/winrt/lib/effects/generated/WhiteLevelAdjustmentEffect.abi.idl @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +// This file was automatically generated. Please do not edit it manually. + +#if (defined _WIN32_WINNT_WIN10) && (WINVER >= _WIN32_WINNT_WIN10) + +namespace Microsoft.Graphics.Canvas.Effects +{ + runtimeclass WhiteLevelAdjustmentEffect; + + [version(VERSION), uuid(0B0B945C-96F7-56B4-8317-01DE629FC904), exclusiveto(WhiteLevelAdjustmentEffect)] + interface IWhiteLevelAdjustmentEffect : IInspectable + requires ICanvasEffect + { + [propget] + HRESULT InputWhiteLevel([out, retval] float* value); + + [propput] + HRESULT InputWhiteLevel([in] float value); + + [propget] + HRESULT OutputWhiteLevel([out, retval] float* value); + + [propput] + HRESULT OutputWhiteLevel([in] float value); + + [propget] + HRESULT Source([out, retval] IGRAPHICSEFFECTSOURCE** source); + + [propput] + HRESULT Source([in] IGRAPHICSEFFECTSOURCE* source); + + }; + + [version(VERSION), uuid(58DACBF8-637A-5DA7-9457-1EEEDF5A191C), exclusiveto(WhiteLevelAdjustmentEffect)] + interface IWhiteLevelAdjustmentEffectStatics : IInspectable + { + [propget] HRESULT IsSupported([out, retval] boolean* value); + } + + [STANDARD_ATTRIBUTES, activatable(VERSION), static(IWhiteLevelAdjustmentEffectStatics, VERSION)] + runtimeclass WhiteLevelAdjustmentEffect + { + [default] interface IWhiteLevelAdjustmentEffect; + } +} + +#endif // _WIN32_WINNT_WIN10 diff --git a/winrt/lib/effects/generated/WhiteLevelAdjustmentEffect.cpp b/winrt/lib/effects/generated/WhiteLevelAdjustmentEffect.cpp new file mode 100644 index 000000000..9a9b8e140 --- /dev/null +++ b/winrt/lib/effects/generated/WhiteLevelAdjustmentEffect.cpp @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +// This file was automatically generated. Please do not edit it manually. + +#include "pch.h" +#include "WhiteLevelAdjustmentEffect.h" + +#if (defined _WIN32_WINNT_WIN10) && (WINVER >= _WIN32_WINNT_WIN10) + +namespace ABI { namespace Microsoft { namespace Graphics { namespace Canvas { namespace Effects +{ + WhiteLevelAdjustmentEffect::WhiteLevelAdjustmentEffect(ICanvasDevice* device, ID2D1Effect* effect) + : CanvasEffect(EffectId(), 2, 1, true, device, effect, static_cast(this)) + { + if (!SharedDeviceState::GetInstance()->IsEffectRegistered(WhiteLevelAdjustmentEffect::EffectId(), true)) + ThrowHR(E_NOTIMPL, Strings::NotSupportedOnThisVersionOfWindows); + + if (!effect) + { + // Set default values + SetBoxedProperty(D2D1_WHITELEVELADJUSTMENT_PROP_INPUT_WHITE_LEVEL, 80.0f); + SetBoxedProperty(D2D1_WHITELEVELADJUSTMENT_PROP_OUTPUT_WHITE_LEVEL, 80.0f); + } + } + + IMPLEMENT_EFFECT_PROPERTY(WhiteLevelAdjustmentEffect, + InputWhiteLevel, + float, + float, + D2D1_WHITELEVELADJUSTMENT_PROP_INPUT_WHITE_LEVEL) + + IMPLEMENT_EFFECT_PROPERTY(WhiteLevelAdjustmentEffect, + OutputWhiteLevel, + float, + float, + D2D1_WHITELEVELADJUSTMENT_PROP_OUTPUT_WHITE_LEVEL) + + IMPLEMENT_EFFECT_SOURCE_PROPERTY(WhiteLevelAdjustmentEffect, + Source, + 0) + + IMPLEMENT_EFFECT_PROPERTY_MAPPING(WhiteLevelAdjustmentEffect, + { L"InputWhiteLevel", D2D1_WHITELEVELADJUSTMENT_PROP_INPUT_WHITE_LEVEL, GRAPHICS_EFFECT_PROPERTY_MAPPING_DIRECT }, + { L"OutputWhiteLevel", D2D1_WHITELEVELADJUSTMENT_PROP_OUTPUT_WHITE_LEVEL, GRAPHICS_EFFECT_PROPERTY_MAPPING_DIRECT }) + + IFACEMETHODIMP WhiteLevelAdjustmentEffectFactory::ActivateInstance(IInspectable** instance) + { + return ExceptionBoundary([&] + { + auto effect = Make(); + CheckMakeResult(effect); + + ThrowIfFailed(effect.CopyTo(instance)); + }); + } + + IFACEMETHODIMP WhiteLevelAdjustmentEffectFactory::get_IsSupported(_Out_ boolean* result) + { + return ExceptionBoundary([&] + { + CheckInPointer(result); + *result = SharedDeviceState::GetInstance()->IsEffectRegistered(WhiteLevelAdjustmentEffect::EffectId(), true); + }); + } + + ActivatableClassWithFactory(WhiteLevelAdjustmentEffect, WhiteLevelAdjustmentEffectFactory); +}}}}} + +#endif // _WIN32_WINNT_WIN10 diff --git a/winrt/lib/effects/generated/WhiteLevelAdjustmentEffect.h b/winrt/lib/effects/generated/WhiteLevelAdjustmentEffect.h new file mode 100644 index 000000000..579eca0cf --- /dev/null +++ b/winrt/lib/effects/generated/WhiteLevelAdjustmentEffect.h @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +// This file was automatically generated. Please do not edit it manually. + +#pragma once + +#if (defined _WIN32_WINNT_WIN10) && (WINVER >= _WIN32_WINNT_WIN10) + +namespace ABI { namespace Microsoft { namespace Graphics { namespace Canvas { namespace Effects +{ + using namespace ::Microsoft::WRL; + using namespace ABI::Microsoft::Graphics::Canvas; + + class WhiteLevelAdjustmentEffect : public RuntimeClass< + IWhiteLevelAdjustmentEffect, + MixIn>, + public CanvasEffect + { + InspectableClass(RuntimeClass_Microsoft_Graphics_Canvas_Effects_WhiteLevelAdjustmentEffect, BaseTrust); + + public: + WhiteLevelAdjustmentEffect(ICanvasDevice* device = nullptr, ID2D1Effect* effect = nullptr); + + static IID const& EffectId() { return CLSID_D2D1WhiteLevelAdjustment; } + + EFFECT_PROPERTY(InputWhiteLevel, float); + EFFECT_PROPERTY(OutputWhiteLevel, float); + EFFECT_PROPERTY(Source, IGraphicsEffectSource*); + + EFFECT_PROPERTY_MAPPING(); + }; + + class WhiteLevelAdjustmentEffectFactory + : public AgileActivationFactory + , private LifespanTracker + { + InspectableClassStatic(RuntimeClass_Microsoft_Graphics_Canvas_Effects_WhiteLevelAdjustmentEffect, BaseTrust); + + public: + IFACEMETHODIMP ActivateInstance(IInspectable**) override; + IFACEMETHOD(get_IsSupported)(boolean* value) override; + }; +}}}}} + +#endif // _WIN32_WINNT_WIN10 diff --git a/winrt/lib/utils/GuidUtilities.h b/winrt/lib/utils/GuidUtilities.h new file mode 100644 index 000000000..fdd6219e8 --- /dev/null +++ b/winrt/lib/utils/GuidUtilities.h @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +#pragma once + +namespace ABI { namespace Microsoft { namespace Graphics { namespace Canvas +{ + + struct GuidComparer { + bool operator()(GUID const& left, GUID const& right) const { + return memcmp(&left, &right, sizeof(GUID)) < 0; + } + }; + +}}}} \ No newline at end of file diff --git a/winrt/lib/winrt.lib.uap.vcxproj b/winrt/lib/winrt.lib.uap.vcxproj index ceb2b3edb..18d9cdc71 100644 --- a/winrt/lib/winrt.lib.uap.vcxproj +++ b/winrt/lib/winrt.lib.uap.vcxproj @@ -104,6 +104,7 @@ + @@ -114,6 +115,7 @@ + @@ -235,6 +237,7 @@ + @@ -263,6 +266,7 @@ + @@ -273,6 +277,7 @@ + Create @@ -450,6 +455,7 @@ + @@ -460,6 +466,7 @@ + diff --git a/winrt/lib/winrt.lib.uap.vcxproj.filters b/winrt/lib/winrt.lib.uap.vcxproj.filters index 15fe1b332..1819d3490 100644 --- a/winrt/lib/winrt.lib.uap.vcxproj.filters +++ b/winrt/lib/winrt.lib.uap.vcxproj.filters @@ -313,6 +313,9 @@ effects\generated + + effects\generated + effects\generated @@ -343,6 +346,9 @@ effects\generated + + effects\generated + xaml @@ -781,6 +787,9 @@ effects\generated + + effects\generated + effects\generated @@ -811,6 +820,9 @@ effects\generated + + effects\generated + xaml @@ -940,6 +952,9 @@ svg + + utils + @@ -1114,6 +1129,9 @@ effects\generated + + effects\generated + effects\generated @@ -1144,6 +1162,9 @@ effects\generated + + effects\generated + geometry