Ejemplo n.º 1
0
        private void UpdateScene()
        {
            Dispatcher.UIThread.VerifyAccess();
            if (_root.IsVisible)
            {
                var sceneRef = RefCountable.Create(_scene?.Item.CloneScene() ?? new Scene(_root));
                var scene    = sceneRef.Item;

                if (_dirty == null)
                {
                    _dirty = new DirtyVisuals();
                    _sceneBuilder.UpdateAll(scene);
                }
                else if (_dirty.Count > 0)
                {
                    foreach (var visual in _dirty)
                    {
                        _sceneBuilder.Update(scene, visual);
                    }
                }

                var oldScene = Interlocked.Exchange(ref _scene, sceneRef);
                oldScene?.Dispose();

                _dirty.Clear();
                (_root as IRenderRoot)?.Invalidate(new Rect(scene.Size));
            }
            else
            {
                var oldScene = Interlocked.Exchange(ref _scene, null);
                oldScene?.Dispose();
            }
        }
Ejemplo n.º 2
0
        private void UpdateScene()
        {
            Dispatcher.UIThread.VerifyAccess();

            try
            {
                var scene = _scene.Clone();

                if (_dirty == null)
                {
                    _dirty = new DirtyVisuals();
                    _sceneBuilder.UpdateAll(scene);
                }
                else if (_dirty.Count > 0)
                {
                    foreach (var visual in _dirty)
                    {
                        _sceneBuilder.Update(scene, visual);
                    }
                }

                Interlocked.Exchange(ref _scene, scene);

                _dirty.Clear();
                (_root as IRenderRoot)?.Invalidate(new Rect(scene.Size));
            }
            finally
            {
                _updateQueued = false;
            }
        }
Ejemplo n.º 3
0
        private void UpdateScene()
        {
            Dispatcher.UIThread.VerifyAccess();
            lock (_sceneLock)
            {
                if (_scene?.Item.Generation > _lastSceneId)
                {
                    return;
                }
            }
            if (_root.IsVisible)
            {
                var sceneRef = RefCountable.Create(_scene?.Item.CloneScene() ?? new Scene(_root));
                var scene    = sceneRef.Item;

                if (_dirty == null)
                {
                    _dirty = new DirtyVisuals();
                    _sceneBuilder.UpdateAll(scene);
                }
                else if (_dirty.Count > 0)
                {
                    foreach (var visual in _dirty)
                    {
                        _sceneBuilder.Update(scene, visual);
                    }
                }

                lock (_sceneLock)
                {
                    var oldScene = _scene;
                    _scene = sceneRef;
                    oldScene?.Dispose();
                }

                _dirty.Clear();
            }
            else
            {
                lock (_sceneLock)
                {
                    var oldScene = _scene;
                    _scene = null;
                    oldScene?.Dispose();
                }
            }
        }
Ejemplo n.º 4
0
        private void UpdateScene()
        {
            Dispatcher.UIThread.VerifyAccess();
            lock (_sceneLock)
            {
                if (_disposed)
                {
                    return;
                }
                if (_scene?.Item.Generation > _lastSceneId)
                {
                    return;
                }
            }
            if (_root.IsVisible)
            {
                var sceneRef = RefCountable.Create(_scene?.Item.CloneScene() ?? new Scene(_root));
                var scene    = sceneRef.Item;

                if (_dirty == null)
                {
                    _dirty = new DirtyVisuals();
                    _recalculateChildren = new HashSet <IVisual>();
                    _sceneBuilder.UpdateAll(scene);
                }
                else
                {
                    foreach (var visual in _recalculateChildren)
                    {
                        var node = scene.FindNode(visual);
                        ((VisualNode)node)?.UpdateChildren(scene);
                    }

                    _recalculateChildren.Clear();

                    foreach (var visual in _dirty)
                    {
                        _sceneBuilder.Update(scene, visual);
                    }
                }

                lock (_sceneLock)
                {
                    var oldScene = _scene;
                    _scene = sceneRef;
                    oldScene?.Dispose();
                }

                _dirty.Clear();

                if (SceneInvalidated != null)
                {
                    var rect = new Rect();

                    foreach (var layer in scene.Layers)
                    {
                        foreach (var dirty in layer.Dirty)
                        {
                            rect = rect.Union(dirty);
                        }
                    }

                    SceneInvalidated(this, new SceneInvalidatedEventArgs((IRenderRoot)_root, rect));
                }
            }
            else
            {
                lock (_sceneLock)
                {
                    var oldScene = _scene;
                    _scene = null;
                    oldScene?.Dispose();
                }
            }
        }
Ejemplo n.º 5
0
        private void UpdateScene()
        {
            Dispatcher.UIThread.VerifyAccess();
            lock (_sceneLock)
            {
                if (_disposed)
                {
                    return;
                }
                if (_scene?.Item.Generation > _lastSceneId)
                {
                    return;
                }
            }
            if (_root.IsVisible)
            {
                var sceneRef = RefCountable.Create(_scene?.Item.CloneScene() ?? new Scene(_root));
                var scene    = sceneRef.Item;

                if (_dirty == null)
                {
                    _dirty = new DirtyVisuals();
                    _sceneBuilder.UpdateAll(scene);
                }
                else if (_dirty.Count > 0)
                {
                    foreach (var visual in _dirty)
                    {
                        _sceneBuilder.Update(scene, visual);
                    }
                }

                lock (_sceneLock)
                {
                    var oldScene = _scene;
                    _scene = sceneRef;
                    oldScene?.Dispose();
                }

                _dirty.Clear();

                if (SceneInvalidated != null)
                {
                    var rect = new Rect();

                    foreach (var layer in scene.Layers)
                    {
                        foreach (var dirty in layer.Dirty)
                        {
                            rect = rect.Union(dirty);
                        }
                    }

                    System.Diagnostics.Debug.WriteLine("Invalidated " + rect);
                    SceneInvalidated(this, new SceneInvalidatedEventArgs((IRenderRoot)_root, rect));
                }
            }
            else
            {
                lock (_sceneLock)
                {
                    var oldScene = _scene;
                    _scene = null;
                    oldScene?.Dispose();
                }
            }
        }