예제 #1
0
        /// <summary>
        /// Create a copy dependency between this handle, and another.
        /// </summary>
        /// <param name="other">The handle to create a copy dependency to</param>
        /// <param name="copyToOther">True if a copy should be deferred to all of the other handle's dependencies</param>
        public void CreateCopyDependency(TextureGroupHandle other, bool copyToOther = false)
        {
            // Does this dependency already exist?
            foreach (TextureDependency existing in Dependencies)
            {
                if (existing.Other.Handle == other)
                {
                    // Do not need to create it again. May need to set the dirty flag.
                    return;
                }
            }

            _group.HasCopyDependencies       = true;
            other._group.HasCopyDependencies = true;

            TextureDependency dependency      = new TextureDependency(this);
            TextureDependency otherDependency = new TextureDependency(other);

            dependency.Other      = otherDependency;
            otherDependency.Other = dependency;

            Dependencies.Add(dependency);
            other.Dependencies.Add(otherDependency);

            // Recursively create dependency:
            // All of this handle's dependencies must depend on the other.
            foreach (TextureDependency existing in Dependencies.ToArray())
            {
                if (existing != dependency && existing.Other.Handle != other)
                {
                    existing.Other.Handle.CreateCopyDependency(other);
                }
            }

            // All of the other handle's dependencies must depend on this.
            foreach (TextureDependency existing in other.Dependencies.ToArray())
            {
                if (existing != otherDependency && existing.Other.Handle != this)
                {
                    existing.Other.Handle.CreateCopyDependency(this);

                    if (copyToOther)
                    {
                        existing.Other.Handle.DeferCopy(this);
                    }
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Remove a dependency from this handle's dependency list.
 /// </summary>
 /// <param name="dependency">The dependency to remove</param>
 public void RemoveDependency(TextureDependency dependency)
 {
     Dependencies.Remove(dependency);
 }