示例#1
0
        public static void OutputEffectCpp(Effects.Effect effect, Formatter output)
        {
            OutputDataTypes.OutputLeadingComment(output);

            bool isInputSizeFixed = !EffectHasVariableNumberOfInputs(effect);
            int  inputsCount      = isInputSizeFixed ? effect.Inputs.InputsList.Count : 0;

            output.WriteLine("#include \"pch.h\"");
            output.WriteLine("#include \"" + effect.ClassName + ".h\"");
            output.WriteLine();
            output.WriteLine("namespace ABI { namespace Microsoft { namespace Graphics { namespace Canvas { namespace Effects");
            output.WriteLine("{");
            output.Indent();
            output.WriteLine(effect.ClassName + "::" + effect.ClassName + "()");
            output.WriteIndent();
            output.WriteLine(": CanvasEffect(CLSID_D2D1"
                             + EffectGenerator.FormatClassName(effect.Properties[0].Value) + ", "
                             + (effect.Properties.Count(p => !p.IsHandCoded) - 4) + ", "
                             + inputsCount + ", "
                             + isInputSizeFixed.ToString().ToLower() + ")");
            output.WriteLine("{");
            output.Indent();
            output.WriteLine("// Set default values");

            foreach (var property in effect.Properties)
            {
                WritePropertyInitialization(output, property);
            }
            output.Unindent();
            output.WriteLine("}");
            output.WriteLine();
            foreach (var property in effect.Properties)
            {
                WritePropertyImplementation(effect, output, property);
            }

            if (EffectHasVariableNumberOfInputs(effect))
            {
                output.WriteLine("IMPLEMENT_EFFECT_SOURCES_PROPERTY(" + effect.ClassName + ")");
                output.WriteLine();
            }
            else
            {
                for (int i = 0; i < effect.Inputs.InputsList.Count; ++i)
                {
                    var input = effect.Inputs.InputsList[i];
                    output.WriteLine("IMPLEMENT_EFFECT_SOURCE_PROPERTY(" + effect.ClassName + ",");
                    output.Indent();
                    output.WriteLine(input.Name + ",");
                    output.WriteLine(i.ToString() + ")");
                    output.Unindent();
                    output.WriteLine();
                }
            }

            output.WriteLine("ActivatableClass(" + effect.ClassName + ");");

            output.Unindent();
            output.WriteLine("}}}}}");
        }
示例#2
0
        public static void OutputEffectMakers(List <Effects.Effect> effects, Formatter output)
        {
            OutputDataTypes.OutputLeadingComment(output);

            output.WriteLine("#include \"pch.h\"");
            output.WriteLine();

            var enabledEffects = from effect in effects
                                 where EffectGenerator.IsEffectEnabled(effect)
                                 select effect;

            var effectsByVersion = from effect in enabledEffects
                                   orderby effect.ClassName
                                   group effect by(effect.Overrides != null?effect.Overrides.WinVer : null) into versionGroup
                                   orderby versionGroup.Key
                                   select versionGroup;

            foreach (var versionGroup in effectsByVersion)
            {
                OutputVersionConditional(versionGroup.Key, output);

                foreach (var effect in versionGroup)
                {
                    output.WriteLine("#include \"" + effect.ClassName + ".h\"");
                }

                EndVersionConditional(versionGroup.Key, output);
                output.WriteLine();
            }

            output.WriteLine();
            output.WriteLine("std::pair<IID, CanvasEffect::MakeEffectFunction> CanvasEffect::m_effectMakers[] =");
            output.WriteLine("{");

            int longestName = enabledEffects.Select(effect => effect.ClassName.Length).Max();

            foreach (var versionGroup in effectsByVersion)
            {
                OutputVersionConditional(versionGroup.Key, output);
                output.Indent();

                foreach (var effect in versionGroup)
                {
                    string padding = new string(' ', longestName - effect.ClassName.Length);

                    output.WriteLine("{ " + effect.ClassName + "::EffectId(), " + padding + "MakeEffect<" + effect.ClassName + "> " + padding + "},");
                }

                output.Unindent();
                EndVersionConditional(versionGroup.Key, output);
                output.WriteLine();
            }

            output.Indent();
            output.WriteLine("{ GUID_NULL, nullptr }");
            output.Unindent();

            output.WriteLine("};");
        }
示例#3
0
文件: Program.cs 项目: nicecai/Win2D
        public static void GenerateEffectsCode(string inputDir, string outputDir)
        {
            EffectGenerator effectGen = new EffectGenerator();

            String inputEffectsDir = Path.Combine(inputDir, "apiref/effects");

            effectGen.OuptutEffects(inputEffectsDir, outputDir);
        }
示例#4
0
 private static string GetEffectCLSID(Effects.Effect effect)
 {
     if (effect.Overrides != null && !string.IsNullOrEmpty(effect.Overrides.CLSIDOverride))
     {
         return(effect.Overrides.CLSIDOverride);
     }
     else
     {
         return("CLSID_D2D1" + EffectGenerator.FormatClassName(effect.Properties[0].Value));
     }
 }
示例#5
0
        public static void GenerateEffectsCode(string inputDir, Dictionary <string, QualifiableType> typeDictionary, string outputDir)
        {
            String inputEffectsDir = Path.Combine(inputDir, "apiref/effects");

            EffectGenerator.OutputEffects(inputEffectsDir, typeDictionary, outputDir);
        }
示例#6
0
        public static void OutputEffectIdl(Effects.Effect effect, Formatter output)
        {
            OutputDataTypes.OutputLeadingComment(output);

            OutputVersionConditional(effect, output);

            output.WriteLine("namespace Microsoft.Graphics.Canvas.Effects");
            output.WriteLine("{");
            output.Indent();

            // Output all enums specific to this effect
            foreach (var property in effect.Properties)
            {
                if (property.Type == "enum" &&
                    property.EnumFields.Usage == Effects.EnumValues.UsageType.UsedByOneEffect &&
                    property.ShouldProject)
                {
                    OutputEnum(property, output);
                    output.WriteLine();
                }
            }

            output.WriteLine("runtimeclass " + effect.ClassName + ";");
            output.WriteLine();
            output.WriteLine("[version(VERSION), uuid(" + effect.Uuid + "), exclusiveto(" + effect.ClassName + ")]");
            output.WriteLine("interface " + effect.InterfaceName + " : IInspectable");
            output.WriteIndent();
            output.WriteLine("requires ICanvasEffect");
            output.WriteLine("{");
            output.Indent();

            foreach (var property in effect.Properties)
            {
                // Property with type string describes
                // name/author/category/description of effect but not input type
                if (property.Type == "string" || property.IsHidden)
                {
                    continue;
                }

                output.WriteLine("[propget]");
                if (property.IsArray)
                {
                    output.WriteLine("HRESULT " + property.Name + "([out] UINT32* valueCount, [out, size_is(, *valueCount), retval] " + property.TypeNameIdl + "** valueElements);");
                }
                else
                {
                    output.WriteLine("HRESULT " + property.Name + "([out, retval] " + property.TypeNameIdl + "* value);");
                }
                output.WriteLine();

                output.WriteLine("[propput]");
                if (property.IsArray)
                {
                    output.WriteLine("HRESULT " + property.Name + "([in] UINT32 valueCount, [in, size_is(valueCount)] " + property.TypeNameIdl + "* valueElements);");
                }
                else
                {
                    output.WriteLine("HRESULT " + property.Name + "([in] " + property.TypeNameIdl + " value);");
                }
                output.WriteLine();
            }

            if (EffectHasVariableNumberOfInputs(effect))
            {
                output.WriteLine("[propget]");
                output.WriteLine("HRESULT Sources([out, retval] Windows.Foundation.Collections.IVector<IGRAPHICSEFFECTSOURCE*>** value);");
                output.WriteLine();
            }
            else
            {
                for (int i = 0; i < effect.Inputs.InputsList.Count; ++i)
                {
                    var input = effect.Inputs.InputsList[i];

                    output.WriteLine("[propget]");
                    output.WriteLine("HRESULT " + input.Name + "([out, retval] IGRAPHICSEFFECTSOURCE** source);");
                    output.WriteLine();

                    output.WriteLine("[propput]");
                    output.WriteLine("HRESULT " + input.Name + "([in] IGRAPHICSEFFECTSOURCE* source);");
                    output.WriteLine();
                }
            }

            output.Unindent();
            output.WriteLine("};");
            output.WriteLine();

            string staticAttribute = "";

            if (HasStatics(effect))
            {
                string staticsInterfaceName = effect.InterfaceName + "Statics";
                string staticsUuid          = EffectGenerator.GenerateUuid(staticsInterfaceName);

                staticAttribute = ", static(" + staticsInterfaceName + ", VERSION)";

                output.WriteLine("[version(VERSION), uuid(" + staticsUuid + "), exclusiveto(" + effect.ClassName + ")]");
                output.WriteLine("interface " + staticsInterfaceName + " : IInspectable");
                output.WriteLine("{");
                output.Indent();

                foreach (var customIdl in effect.Overrides.CustomStaticMethodIdl)
                {
                    output.WriteLine(customIdl.Trim());
                }

                if (!string.IsNullOrEmpty(effect.Overrides.IsSupportedCheck))
                {
                    output.WriteLine("[propget] HRESULT IsSupported([out, retval] boolean* value);");
                }

                output.Unindent();
                output.WriteLine("}");
                output.WriteLine();
            }

            output.WriteLine("[STANDARD_ATTRIBUTES, activatable(VERSION)" + staticAttribute + "]");

            output.WriteLine("runtimeclass " + effect.ClassName);
            output.WriteLine("{");
            output.Indent();
            output.WriteLine("[default] interface " + effect.InterfaceName + ";");
            output.Unindent();
            output.WriteLine("}");
            output.Unindent();
            output.WriteLine("}");

            EndVersionConditional(effect, output);
        }