void TerrainRenderer::Generate(const WindowProjection &map_projection, const Angle sunazimuth) { #ifdef ENABLE_OPENGL const GeoBounds &old_bounds = raster_renderer.GetBounds(); const GeoBounds &new_bounds = map_projection.GetScreenBounds(); assert(new_bounds.IsValid()); if (old_bounds.IsValid() && old_bounds.IsInside(new_bounds) && !IsLargeSizeDifference(old_bounds, new_bounds) && terrain_serial == terrain->GetSerial() && sunazimuth.CompareRoughly(last_sun_azimuth) && !raster_renderer.UpdateQuantisation()) /* no change since previous frame */ return; #else if (compare_projection.Compare(map_projection) && terrain_serial == terrain->GetSerial() && sunazimuth.CompareRoughly(last_sun_azimuth)) /* no change since previous frame */ return; compare_projection = CompareProjection(map_projection); #endif terrain_serial = terrain->GetSerial(); last_sun_azimuth = sunazimuth; const bool do_water = true; const unsigned height_scale = 4; const int interp_levels = 2; const bool is_terrain = true; const bool do_shading = is_terrain && settings.slope_shading != SlopeShading::OFF; const bool do_contour = is_terrain && settings.contours != Contours::OFF; const ColorRamp *const color_ramp = &terrain_colors[settings.ramp][0]; if (color_ramp != last_color_ramp) { raster_renderer.ColorTable(color_ramp, do_water, height_scale, interp_levels); last_color_ramp = color_ramp; } { RasterTerrain::Lease map(*terrain); raster_renderer.ScanMap(map, map_projection); } raster_renderer.GenerateImage(do_shading, height_scale, settings.contrast, settings.brightness, sunazimuth, do_contour); }
Canvas & TransparentRendererCache::Begin(Canvas &canvas, const WindowProjection &projection) { assert(canvas.IsDefined()); assert(projection.IsValid()); const PixelSize size(projection.GetScreenWidth(), projection.GetScreenHeight()); if (buffer.IsDefined()) buffer.Resize(size); else buffer.Create(canvas, size); compare_projection = CompareProjection(projection); return buffer; }
/** * Is the new projection close enough to the saved one? If not, * then the saved one is updated. */ bool CompareAndUpdate(const WindowProjection &projection) { return CompareAndUpdate(CompareProjection(projection)); }
/** * Is the new projection close enough to the saved one? */ bool Compare(const WindowProjection &projection) const { return Compare(CompareProjection(projection)); }