コード例 #1
0
        ///<summary>
        ///    Create an instance of this technique.
        ///</summary>
        public virtual CompositorInstance CreateInstance(CompositorChain chain)
        {
            CompositorInstance mew = new CompositorInstance(parent, this, chain);

            instances.Add(mew);
            return(mew);
        }
コード例 #2
0
 public CompositorInstance(Compositor filter, CompositionTechnique technique, CompositorChain chain)
 {
     this.compositor        = filter;
     this.technique         = technique;
     this.chain             = chain;
     this.enabled           = false;
     localTextures          = new Dictionary <string, Texture>();
     renderSystemOperations = new List <QueueIDAndOperation>();
     listeners = new List <CompositorInstanceListener>();
 }
コード例 #3
0
        ///<summary>
        ///    Add a compositor to a viewport. By default, it is added to end of the chain,
        ///    after the other compositors.
        ///</summary>
        ///<param name="vp">Viewport to modify</param>
        ///<param name="compositor">The name of the compositor to apply</param>
        ///<param name="addPosition">At which position to add, defaults to the end (-1).</param>
        ///<returns>pointer to instance, or null if it failed.</returns>
        public CompositorInstance AddCompositor(Viewport vp, string compositor, int addPosition)
        {
            Compositor comp = (Compositor)GetByName(compositor);

            if (comp == null)
            {
                return(null);
            }
            CompositorChain chain = GetCompositorChain(vp);

            return(chain.AddCompositor(comp, addPosition == -1 ? CompositorChain.LastCompositor : addPosition));
        }
コード例 #4
0
        ///<summary>
        ///    Remove a compositor from a viewport
        ///</summary>
        public void RemoveCompositor(Viewport vp, string compositor)
        {
            CompositorChain chain = GetCompositorChain(vp);

            for (int i = 0; i < chain.Instances.Count; i++)
            {
                CompositorInstance instance = chain.GetCompositor(i);
                if (instance.Compositor.Name == compositor)
                {
                    chain.RemoveCompositor(i);
                    break;
                }
            }
        }
コード例 #5
0
        ///<summary>
        ///    Set the state of a compositor on a viewport to enabled or disabled.
        ///    Disabling a compositor stops it from rendering but does not free any resources.
        ///    This can be more efficient than using removeCompositor and addCompositor in cases
        ///    the filter is switched on and off a lot.
        ///</summary>
        public void SetCompositorEnabled(Viewport vp, string compositor, bool value)
        {
            CompositorChain chain = GetCompositorChain(vp);

            for (int i = 0; i < chain.Instances.Count; i++)
            {
                CompositorInstance instance = chain.GetCompositor(i);
                if (instance.Compositor.Name == compositor)
                {
                    chain.SetCompositorEnabled(i, value);
                    break;
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// another overload to remove a compositor instance from its chain
        /// </summary>
        /// <param name="remInstance"></param>
        public void RemoveCompositor(CompositorInstance remInstance)
        {
            CompositorChain chain = remInstance.Chain;

            for (int i = 0; i < chain.Instances.Count; i++)
            {
                CompositorInstance instance = chain.GetCompositor(i);
                if (instance == remInstance)
                {
                    chain.RemoveCompositor(i);
                    break;
                }
            }
        }
コード例 #7
0
        ///<summary>
        ///    Get the compositor chain for a Viewport. If there is none yet, a new
        ///    compositor chain is registered.
        ///    XXX We need a _notifyViewportRemoved to find out when this viewport disappears,
        ///    so we can destroy its chain as well.
        ///</summary>
        public CompositorChain GetCompositorChain(Viewport vp)
        {
            CompositorChain chain;

            if (chains.TryGetValue(vp, out chain))
            {
                return(chain);
            }
            else
            {
                chain      = new CompositorChain(vp);
                chains[vp] = chain;
                return(chain);
            }
        }
コード例 #8
0
 ///<summary>
 ///    Get the compositor chain for a Viewport. If there is none yet, a new
 ///    compositor chain is registered.
 ///    XXX We need a _notifyViewportRemoved to find out when this viewport disappears,
 ///    so we can destroy its chain as well.
 ///</summary>
 public CompositorChain GetCompositorChain( Viewport vp )
 {
     CompositorChain chain;
     if ( this.chains.TryGetValue( vp, out chain ) )
     {
         // Make sure we have the right viewport
         // It's possible that this chain may have outlived a viewport and another
         // viewport was created at the same physical address, meaning we find it again but the viewport is gone
         chain.Viewport = vp;
     }
     else
     {
         chain = new CompositorChain( vp );
         this.chains[ vp ] = chain;
     }
     return chain;
 }
コード例 #9
0
		public CompositorInstance( CompositionTechnique technique, CompositorChain chain )
		{
			this.compositor = technique.Parent;
			this.technique = technique;
			this.chain = chain;
			this.enabled = false;

			var logicName = technique.CompositorLogicName;
			if ( !String.IsNullOrEmpty( logicName ) )
			{
				CompositorManager.Instance.CompositorLogics[ logicName ].CompositorInstanceCreated( this );
			}

			this.localTextures = new Dictionary<string, Texture>();
			this.renderSystemOperations = new List<QueueIDAndOperation>();
		}
コード例 #10
0
 public CompositorInstance(Compositor filter, CompositionTechnique technique, CompositorChain chain)
 {
     this.compositor = filter;
     this.technique = technique;
     this.chain = chain;
     this.enabled = false;
     localTextures = new Dictionary<string, Texture>();
     renderSystemOperations = new List<QueueIDAndOperation>();
     listeners = new List<CompositorInstanceListener>();
 }
コード例 #11
0
 ///<summary>
 ///    Create an instance of this technique.
 ///</summary>
 public virtual CompositorInstance CreateInstance(CompositorChain chain)
 {
     CompositorInstance mew = new CompositorInstance(parent, this, chain);
     instances.Add(mew);
     return mew;
 }
コード例 #12
0
 ///<summary>
 ///    Get the compositor chain for a Viewport. If there is none yet, a new
 ///    compositor chain is registered.
 ///    XXX We need a _notifyViewportRemoved to find out when this viewport disappears,
 ///    so we can destroy its chain as well.
 ///</summary>
 public CompositorChain GetCompositorChain(Viewport vp)
 {
     CompositorChain chain;
     if (chains.TryGetValue(vp, out chain))
         return chain;
     else {
         chain = new CompositorChain(vp);
         chains[vp] = chain;
         return chain;
     }
 }