// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. using System; using System.Reflection; namespace SharpDX.Direct2D1 { public partial class Effect { /// /// Initializes a new instance of the class. /// /// The device context. /// The class ID of the effect to create. /// If no sufficient memory to complete the call, or if it does not have enough display memory to perform the operation, or if the specified effect is not registered by the system. /// /// The created effect does not increment the reference count for the dynamic-link library (DLL) from which the effect was created. If the application deletes an effect while that effect is loaded, the resulting behavior will be unpredictable. /// /// HRESULT ID2D1DeviceContext::CreateEffect([In] const GUID& effectId,[Out, Fast] ID2D1Effect** effect) public Effect(DeviceContext deviceContext, Guid effectId) : base(IntPtr.Zero) { deviceContext.CreateEffect(effectId, this); } /// /// Initializes a new instance of the class. /// /// The effect context. /// The class ID of the effect to create. /// No documentation. /// /// HRESULT ID2D1EffectContext::CreateEffect([In] const GUID& effectId,[Out] ID2D1Effect** effect) public Effect(EffectContext effectContext, System.Guid effectId) : base(IntPtr.Zero) { effectContext.CreateEffect(effectId, this); } /// /// Sets the input by using the output of a given effect. /// /// Index of the input /// Effect output to use as input /// To invalidate public void SetInputEffect(int index, Effect effect, bool invalidate = true) { using (var output = effect.Output) SetInput(index, output, invalidate); } } /// /// Class used to instantiate custom effects. /// /// Type of the custom effect public partial class Effect : Effect where T : CustomEffect { /// /// Initializes a new instance of a custom class. /// /// The device context. /// If no sufficient memory to complete the call, or if it does not have enough display memory to perform the operation, or if the specified effect is not registered by the system. /// /// The created effect does not increment the reference count for the dynamic-link library (DLL) from which the effect was created. If the application deletes an effect while that effect is loaded, the resulting behavior will be unpredictable. /// /// HRESULT ID2D1DeviceContext::CreateEffect([In] const GUID& effectId,[Out, Fast] ID2D1Effect** effect) public Effect(DeviceContext deviceContext) : this(deviceContext, Utilities.GetGuidFromType(typeof(T))) { } /// /// Initializes a new instance of a custom class. /// /// The device context. /// Effect ID. /// If no sufficient memory to complete the call, or if it does not have enough display memory to perform the operation, or if the specified effect is not registered by the system. /// /// The created effect does not increment the reference count for the dynamic-link library (DLL) from which the effect was created. If the application deletes an effect while that effect is loaded, the resulting behavior will be unpredictable. /// /// HRESULT ID2D1DeviceContext::CreateEffect([In] const GUID& effectId,[Out, Fast] ID2D1Effect** effect) public Effect(DeviceContext deviceContext, Guid effectId) : base(deviceContext, effectId) { } /// /// Initializes a new instance of the class. /// /// The effect context. /// No documentation. /// /// HRESULT ID2D1EffectContext::CreateEffect([In] const GUID& effectId,[Out] ID2D1Effect** effect) public Effect(EffectContext effectContext) : base(effectContext, Utilities.GetGuidFromType(typeof(T))) { } } }