public override void run() { try { while (!inShutdown) { RendererJob rendererJob = this.jobQueue.Get(NUMBER_OF_THREADS); if (!this.tileCache.ContainsKey(rendererJob) || rendererJob.labelsOnly) { if (!inShutdown) { workers.execute(new MapWorker(this, rendererJob)); } else { jobQueue.Remove(rendererJob); } } } } catch (InterruptedException e) { LOGGER.Fatal("MapWorkerPool interrupted", e); // should get restarted by the ExecutorService } }
public override bool Equals(object obj) { if (this == obj) { return(true); } else if (!base.Equals(obj)) { return(false); } else if (!(obj is RendererJob)) { return(false); } RendererJob other = (RendererJob)obj; if (!this.mapDataStore.Equals(other.mapDataStore)) { return(false); } else if (BitConverter.ToInt32(BitConverter.GetBytes(this.textScale), 0) != BitConverter.ToInt32(BitConverter.GetBytes(other.textScale), 0)) { return(false); } else if (this.renderThemeFuture == null && other.renderThemeFuture != null) { return(false); } else if (this.renderThemeFuture != null && !this.renderThemeFuture.Equals(other.renderThemeFuture)) { return(false); } else if (this.labelsOnly != other.labelsOnly) { return(false); } else if (!this.displayModel.Equals(other.displayModel)) { return(false); } return(true); }
/// <summary> /// Called when a job needs to be executed. /// </summary> /// <param name="rendererJob"> /// the job that should be executed. </param> public virtual SKImage ExecuteJob(RendererJob rendererJob) { RenderTheme renderTheme; try { // Wait until RenderTheme is ready renderTheme = rendererJob.renderThemeFuture.Result; } catch (Exception e) { LOGGER.Fatal("Error to retrieve render theme from future", e); return(null); } RenderContext renderContext = null; try { renderContext = new RenderContext(renderTheme, rendererJob, new CanvasRasterer(graphicFactory)); renderContext.canvasRasterer.Canvas = graphicFactory.CreateCanvas(renderContext.rendererJob.tile.TileSize, renderContext.rendererJob.tile.TileSize); if (RenderBitmap(renderContext)) { if (this.mapDatabase != null) { MapReadResult mapReadResult = this.mapDatabase.ReadMapData(rendererJob.tile); ProcessReadMapData(renderContext, mapReadResult); } if (!rendererJob.labelsOnly) { //bitmap = this.graphicFactory.CreateTileBitmap(renderContext.rendererJob.tile.TileSize, renderContext.rendererJob.hasAlpha); //bitmap.Timestamp = rendererJob.mapDataStore.GetDataTimestamp(renderContext.rendererJob.tile); //renderContext.canvasRasterer.CanvasBitmap = bitmap; if (!rendererJob.hasAlpha && rendererJob.displayModel.BackgroundColor != renderContext.renderTheme.MapBackground) { renderContext.canvasRasterer.Fill(renderContext.renderTheme.MapBackground); } renderContext.canvasRasterer.DrawWays(renderContext); } if (renderLabels) { ISet <MapElementContainer> labelsToDraw = ProcessLabels(renderContext); // now draw the ways and the labels renderContext.canvasRasterer.DrawMapElements(labelsToDraw, renderContext.rendererJob.tile); } else { // store elements for this tile in the label cache this.labelStore.StoreMapItems(renderContext.rendererJob.tile, renderContext.labels); } //if (!rendererJob.labelsOnly && renderContext.renderTheme.HasMapBackgroundOutside()) //{ // // blank out all areas outside of map // Rectangle insideArea = this.mapDatabase.BoundingBox.GetPositionRelativeToTile(renderContext.rendererJob.tile); // if (!rendererJob.hasAlpha) // { // //renderContext.canvasRasterer.FillOutsideAreas(renderContext.renderTheme.MapBackgroundOutside, insideArea); // } // else // { // //renderContext.canvasRasterer.FillOutsideAreas(Color.Transparent, insideArea); // } //} return(((SkiaCanvas)renderContext.canvasRasterer.Canvas).Image); } // Draws a bitmap just with outside colour, used for bitmaps outside of map area. if (!renderContext.rendererJob.hasAlpha) { //renderContext.canvasRasterer.Fill(renderContext.renderTheme.MapBackgroundOutside); } return(((SkiaCanvas)renderContext.canvasRasterer.Canvas).Image); } finally { if (renderContext != null) { renderContext.Destroy(); } } }
internal MapWorker(MapWorkerPool outerInstance, RendererJob rendererJob) { this.outerInstance = outerInstance; this.rendererJob = rendererJob; this.rendererJob.renderThemeFuture.IncrementRefCount(); }