void AddChild(VisualElement view, IVisualElementRenderer oldRenderer = null, RendererPool pool = null, bool sameChildren = false) { Performance.Start(out string reference); if (CompressedLayout.GetIsHeadless(view)) { var packager = new VisualElementPackager(_renderer, view); if (_childPackagers == null) { _childPackagers = new Dictionary <BindableObject, VisualElementPackager>(); } view.IsPlatformEnabled = true; packager.Load(); _childPackagers[view] = packager; } else { if (_childViews == null) { _childViews = new List <IVisualElementRenderer>(); } IVisualElementRenderer renderer = oldRenderer; if (pool != null) { renderer = pool.GetFreeRenderer(view); } if (renderer == null || (renderer.View?.Handle ?? IntPtr.Zero) == IntPtr.Zero) { Performance.Start(reference, "New renderer"); renderer = Platform.CreateRenderer(view, _renderer.View.Context); Performance.Stop(reference, "New renderer"); } if (renderer == oldRenderer) { renderer.Element?.ClearValue(Platform.RendererProperty); renderer.SetElement(view); } Performance.Start(reference, "Set renderer"); Platform.SetRenderer(view, renderer); Performance.Stop(reference, "Set renderer"); Performance.Start(reference, "Add view"); if (!sameChildren) { (_renderer.View as ViewGroup)?.AddView(renderer.View); _childViews.Add(renderer); } Performance.Stop(reference, "Add view"); } Performance.Stop(reference); }
protected void SetPackager(VisualElementPackager packager) { _packager = packager; packager.Load(); }