Exemplo n.º 1
0
        /// <summary>
        /// Regenerates the <see cref="RenderTree"/> and adds the changes to the
        /// <paramref name="batchBuilder"/>.
        /// </summary>
        public void Render(Renderer renderer, RenderBatchBuilder batchBuilder)
        {
            if (_component is IHandlePropertiesChanged notifyableComponent)
            {
                notifyableComponent.OnPropertiesChanged();
            }

            // Swap the old and new tree builders
            (_renderTreeBuilderCurrent, _renderTreeBuilderPrevious) = (_renderTreeBuilderPrevious, _renderTreeBuilderCurrent);

            _renderTreeBuilderCurrent.Clear();
            _component.BuildRenderTree(_renderTreeBuilderCurrent);

            var diff = RenderTreeDiffBuilder.ComputeDiff(
                _renderer,
                batchBuilder,
                _componentId,
                _renderTreeBuilderPrevious.GetFrames(),
                _renderTreeBuilderCurrent.GetFrames());

            batchBuilder.UpdatedComponentDiffs.Append(diff);

            // Process disposal queue now in case it causes further component renders to be enqueued
            while (batchBuilder.ComponentDisposalQueue.Count > 0)
            {
                var disposeComponentId = batchBuilder.ComponentDisposalQueue.Dequeue();
                renderer.DisposeInExistingBatch(batchBuilder, disposeComponentId);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Notifies the component that it is being disposed.
        /// </summary>
        public void NotifyDisposed(RenderBatchBuilder batchBuilder)
        {
            // TODO: Handle components throwing during dispose. Shouldn't break the whole render batch.
            if (_component is IDisposable disposable)
            {
                disposable.Dispose();
            }

            RenderTreeDiffBuilder.DisposeFrames(batchBuilder, _renderTreeBuilderCurrent.GetFrames());
        }
Exemplo n.º 3
0
        private void RenderInExistingBatch(RenderBatchBuilder batchBuilder, int componentId)
        {
            GetRequiredComponentState(componentId).RenderIntoBatch(batchBuilder);

            // Process disposal queue now in case it causes further component renders to be enqueued
            while (batchBuilder.ComponentDisposalQueue.Count > 0)
            {
                var disposeComponentId = batchBuilder.ComponentDisposalQueue.Dequeue();
                GetRequiredComponentState(disposeComponentId).DisposeInBatch(batchBuilder);
                _componentStateById.Remove(disposeComponentId);
                batchBuilder.DisposedComponentIds.Append(disposeComponentId);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Regenerates the <see cref="RenderTree"/> and adds the changes to the
        /// <paramref name="batchBuilder"/>.
        /// </summary>
        public void Render(RenderBatchBuilder batchBuilder)
        {
            // Swap the old and new tree builders
            (_renderTreeBuilderCurrent, _renderTreeBuilderPrevious) = (_renderTreeBuilderPrevious, _renderTreeBuilderCurrent);

            _renderTreeBuilderCurrent.Clear();
            _component.BuildRenderTree(_renderTreeBuilderCurrent);
            _diffComputer.ApplyNewRenderTreeVersion(
                batchBuilder,
                _componentId,
                _renderTreeBuilderPrevious.GetFrames(),
                _renderTreeBuilderCurrent.GetFrames());
        }
Exemplo n.º 5
0
        public void DisposeInBatch(RenderBatchBuilder batchBuilder)
        {
            _componentWasDisposed = true;

            // TODO: Handle components throwing during dispose. Shouldn't break the whole render batch.
            if (_component is IDisposable disposable)
            {
                disposable.Dispose();
            }

            RenderTreeDiffBuilder.DisposeFrames(batchBuilder, _renderTreeBuilderCurrent.GetFrames());

            if (_cascadingParameters != null)
            {
                RemoveCascadingParameterSubscriptions();
            }
        }
Exemplo n.º 6
0
        public void RenderIntoBatch(RenderBatchBuilder batchBuilder, Action <RenderTreeBuilder> renderAction)
        {
            // Swap the old and new tree builders
            (_renderTreeBuilderCurrent, _renderTreeBuilderPrevious) = (_renderTreeBuilderPrevious, _renderTreeBuilderCurrent);

            _renderTreeBuilderCurrent.Clear();
            renderAction(_renderTreeBuilderCurrent);

            var diff = RenderTreeDiffBuilder.ComputeDiff(
                _renderer,
                batchBuilder,
                _componentId,
                _renderTreeBuilderPrevious.GetFrames(),
                _renderTreeBuilderCurrent.GetFrames());

            batchBuilder.UpdatedComponentDiffs.Append(diff);
        }
Exemplo n.º 7
0
        public void RenderIntoBatch(RenderBatchBuilder batchBuilder)
        {
            if (_component is IHandlePropertiesChanged notifyableComponent)
            {
                notifyableComponent.OnPropertiesChanged();
            }

            // Swap the old and new tree builders
            (_renderTreeBuilderCurrent, _renderTreeBuilderPrevious) = (_renderTreeBuilderPrevious, _renderTreeBuilderCurrent);

            _renderTreeBuilderCurrent.Clear();
            _component.BuildRenderTree(_renderTreeBuilderCurrent);

            var diff = RenderTreeDiffBuilder.ComputeDiff(
                _renderer,
                batchBuilder,
                _componentId,
                _renderTreeBuilderPrevious.GetFrames(),
                _renderTreeBuilderCurrent.GetFrames());

            batchBuilder.UpdatedComponentDiffs.Append(diff);
        }
Exemplo n.º 8
0
        public void RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment)
        {
            // A component might be in the render queue already before getting disposed by an
            // earlier entry in the render queue. In that case, rendering is a no-op.
            if (_componentWasDisposed)
            {
                return;
            }

            // Swap the old and new tree builders
            (_renderTreeBuilderCurrent, _renderTreeBuilderPrevious) = (_renderTreeBuilderPrevious, _renderTreeBuilderCurrent);

            _renderTreeBuilderCurrent.Clear();
            renderFragment(_renderTreeBuilderCurrent);

            var diff = RenderTreeDiffBuilder.ComputeDiff(
                _renderer,
                batchBuilder,
                _componentId,
                _renderTreeBuilderPrevious.GetFrames(),
                _renderTreeBuilderCurrent.GetFrames());

            batchBuilder.UpdatedComponentDiffs.Append(diff);
        }
Exemplo n.º 9
0
 internal void DisposeInExistingBatch(RenderBatchBuilder batchBuilder, int componentId)
 {
     GetRequiredComponentState(componentId).NotifyDisposed();
     batchBuilder.AddDisposedComponent(componentId);
 }
Exemplo n.º 10
0
 internal void RenderInExistingBatch(RenderBatchBuilder batchBuilder, int componentId)
 {
     GetRequiredComponentState(componentId).Render(batchBuilder);
 }