Exemplo n.º 1
0
        private void Rasterize()
        {
            if (!Enabled)
            {
                return;
            }

            lock (_syncLock)
            {
                if (double.IsNaN(_resolution) || _resolution <= 0)
                {
                    return;
                }
                var viewport = CreateViewport(_extent, _resolution, _renderResolutionMultiplier);

                var rasterizer = _rasterizer ?? DefaultRendererFactory.Create();

                var bitmapStream = rasterizer.RenderToBitmapStream(viewport, new[] { _layer });
                RemoveExistingFeatures();
                _cache.Features = new Features {
                    new Feature {
                        Geometry = new Raster(bitmapStream, viewport.Extent)
                    }
                };

                OnDataChanged(new DataChangedEventArgs());
            }
        }
Exemplo n.º 2
0
        private void Rasterize()
        {
            if (!Enabled)
            {
                return;
            }
            if (_busy)
            {
                return;
            }
            _busy     = true;
            _modified = false;

            lock (_syncLock)
            {
                try
                {
                    if (double.IsNaN(_resolution) || _resolution <= 0)
                    {
                        return;
                    }
                    if (_extent.Width <= 0 || _extent.Height <= 0)
                    {
                        return;
                    }
                    var viewport = CreateViewport(_extent, _resolution, _renderResolutionMultiplier, _overscan);

                    _currentViewport = viewport;

                    _rasterizer = _rasterizer ?? DefaultRendererFactory.Create();

                    var bitmapStream = _rasterizer.RenderToBitmapStream(viewport, new[] { _layer });
                    RemoveExistingFeatures();

                    if (bitmapStream != null)
                    {
                        _cache.ReplaceFeatures(new Features
                        {
                            new Feature {
                                Geometry = new Raster(bitmapStream, viewport.Extent)
                            }
                        });

                        Logger.Log(LogLevel.Debug, $"Memory after rasterizing layer {GC.GetTotalMemory(true):N0}");

                        OnDataChanged(new DataChangedEventArgs());
                    }

                    if (_modified)
                    {
                        RestartTimer();
                    }
                }
                finally
                {
                    _busy = false;
                }
            }
        }
Exemplo n.º 3
0
        private void Rasterize()
        {
            if (!Enabled)
            {
                return;
            }

            Task.Factory.StartNew(() =>
            {
                Thread.CurrentThread.Priority = ThreadPriority.Lowest;
                lock (_syncLock)
                {
                    if (double.IsNaN(_resolution) || _resolution <= 0)
                    {
                        return;
                    }
                    if (_layer.IsFetchingProperty)
                    {
                        return;
                    }

                    _drawn = true;

                    var viewport = CreateViewport(_extent, _resolution, _renderResolutionMultiplier, _overscan);

                    _currentViewport = viewport;

                    var rasterizer = _rasterizer ?? DefaultRendererFactory.Create();

                    var bitmapStream = rasterizer.RenderToBitmapStream(viewport, new[] { _layer });
                    RemoveExistingFeatures();
                    if (bitmapStream != null)
                    {
                        _cache.Features = new Features {
                            new Feature {
                                Geometry = new Raster(bitmapStream, viewport.Extent)
                            }
                        }
                    }
                    ;

                    OnDataChanged(new DataChangedEventArgs());
                }
            }, TaskCreationOptions.LongRunning);
        }