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()); } }
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; } } }
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); }