Example #1
0
        /// <summary>
        /// Unregisters an element from the out-of-band renderer.
        /// </summary>
        /// <param name="element">The element to unregister.</param>
        public void Unregister(UIElement element)
        {
            Contract.Require(element, nameof(element));
            Contract.EnsureNotDisposed(this, Disposed);

            foreach (var registeredElement in registeredElements)
            {
                var weakRefTarget = (UIElement)registeredElement.Target;
                if (weakRefTarget != element)
                {
                    continue;
                }

                for (UpfPool <OutOfBandRenderTarget> .PooledObject current = element.OutOfBandRenderTarget, next = null; current != null; current = next)
                {
                    next = current.Value.NextInternal;
                    current.Value.Resize(1, 1);
                    current.Value.NextInternal = null;
                    renderTargetPool.Release(current);
                }

                registeredElements.Remove(registeredElement);
                element.OutOfBandRenderTarget = null;

                registeredElement.Target = null;
                WeakReferencePool.Instance.Release(registeredElement);

                break;
            }
        }
Example #2
0
        /// <summary>
        /// Ensures that the out-of-band renderer's internal pools have been created.
        /// </summary>
        public void InitializePools()
        {
            if (renderTargetPool != null)
            {
                return;
            }

            renderTargetPool = new UpfPool <OutOfBandRenderTarget>(Ultraviolet, 8, 32, () => new OutOfBandRenderTarget(Ultraviolet));
        }