private static ArrayRange <RenderTreeFrame> GetRenderTree(IComponent component) { var treeBuilder = new RenderTreeBuilder(new TestRenderer()); component.BuildRenderTree(treeBuilder); return(treeBuilder.GetFrames()); }
/// <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); } }
/// <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()); }
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); }