RasterRenderer::RasterRenderer() { // scale quantisation_pixels so resolution is not too high on old hardware // with large displays if (IsAncientHardware()) quantisation_pixels = Layout::FastScale(quantisation_pixels); }
static void DrawShape(Canvas &canvas, AbstractAirspace::Shape shape, const RasterPoint pt, unsigned radius, const std::vector<RasterPoint> &pts) { if (shape == AbstractAirspace::Shape::CIRCLE) canvas.DrawCircle(pt.x, pt.y, radius); else if (IsAncientHardware()) canvas.Rectangle(pt.x - radius, pt.y - radius, pt.x + radius, pt.y + radius); else canvas.DrawPolygon(&pts[0], (unsigned)pts.size()); }
void MapWindow::OnCreate() { DoubleBufferWindow::OnCreate(); #ifndef ENABLE_OPENGL WindowCanvas canvas(*this); buffer_canvas.set(canvas); if (!IsAncientHardware()) stencil_canvas.set(canvas); #endif }
RasterRenderer::RasterRenderer() :quantisation_pixels(2), #ifdef ENABLE_OPENGL last_quantisation_pixels(-1), bounds(GeoBounds::Invalid()), #endif image(NULL) { // scale quantisation_pixels so resolution is not too high on old hardware // with large displays if (IsAncientHardware()) quantisation_pixels = Layout::FastScale(quantisation_pixels); }
void TargetMapWindow::on_create() { BufferWindow::on_create(); drag_mode = DRAG_NONE; #ifndef ENABLE_OPENGL WindowCanvas canvas(*this); buffer_canvas.set(canvas); if (!IsAncientHardware()) stencil_canvas.set(canvas); #endif }
void TargetMapWindow::on_resize(UPixelScalar width, UPixelScalar height) { BufferWindow::on_resize(width, height); #ifndef ENABLE_OPENGL buffer_canvas.grow(width, height); if (!IsAncientHardware()) stencil_canvas.grow(width, height); #endif projection.SetScreenSize(width, height); projection.SetScreenOrigin(width / 2, height / 2); projection.UpdateScreenBounds(); }
void TargetMapWindow::OnResize(PixelSize new_size) { BufferWindow::OnResize(new_size); #ifndef ENABLE_OPENGL buffer_canvas.Grow(new_size); if (!IsAncientHardware()) stencil_canvas.Grow(new_size); #endif projection.SetScreenSize(new_size); projection.SetScreenOrigin(new_size.cx / 2, new_size.cy / 2); projection.UpdateScreenBounds(); }
void TargetMapWindow::on_destroy() { SetTerrain(NULL); SetTopograpgy(NULL); SetAirspaces(NULL); SetWaypoints(NULL); #ifndef ENABLE_OPENGL buffer_canvas.reset(); if (!IsAncientHardware()) stencil_canvas.reset(); #endif BufferWindow::on_destroy(); }
AirspaceVisitorMap(MapDrawHelper &_helper, const AirspaceWarningCopy &_warnings, const AirspaceRendererSettings &_settings, const AirspaceLook &_airspace_look) :MapDrawHelper(_helper), look(_airspace_look), warnings(_warnings) { switch (settings.fill_mode) { case AirspaceRendererSettings::FillMode::DEFAULT: case AirspaceRendererSettings::FillMode::PADDING: use_stencil = !IsAncientHardware(); break; case AirspaceRendererSettings::FillMode::ALL: use_stencil = false; break; } }
void OZPreviewRenderer::Draw(Canvas &canvas, const ObservationZonePoint &oz, const RasterPoint pt, unsigned radius, const TaskLook &look, const AirspaceRendererSettings &airspace_settings, const AirspaceLook &airspace_look) { fixed scale; GeoPoint center; if (IsAncientHardware()) { scale = fixed(radius) / ((const CylinderZone &)oz).GetRadius(); center = oz.GetReference(); } else { OZBoundary boundary = oz.GetBoundary(); auto it = boundary.begin(); GeoBounds bounds(*it); for (auto it_end = boundary.end(); it != it_end; ++it) bounds.Extend(*it); center = bounds.GetCenter(); fixed geo_heigth = GeoPoint(center.longitude, bounds.north).Distance( GeoPoint(center.longitude, bounds.south)); fixed geo_width = GeoPoint(bounds.west, center.latitude).Distance( GeoPoint(bounds.east, center.latitude)); scale = fixed(radius * 2) / std::max(geo_heigth, geo_width); } WindowProjection projection; projection.SetScreenSize(radius * 2, radius * 2); projection.SetScreenOrigin(pt.x, pt.y); projection.SetGeoLocation(center); projection.SetScale(scale); projection.SetScreenAngle(Angle::Zero()); projection.UpdateScreenBounds(); OZRenderer ozv(look, airspace_look, airspace_settings); ozv.Draw(canvas, OZRenderer::LAYER_SHADE, projection, oz, 1); ozv.Draw(canvas, OZRenderer::LAYER_INACTIVE, projection, oz, 1); ozv.Draw(canvas, OZRenderer::LAYER_ACTIVE, projection, oz, 1); }
void MapWindow::OnDestroy() { SetMarks(NULL); airspace_renderer.Clear(); SetWaypoints(NULL); SetTopography(NULL); SetTerrain(NULL); SetWeather(NULL); #ifndef ENABLE_OPENGL buffer_canvas.reset(); if (!IsAncientHardware()) stencil_canvas.reset(); #endif DoubleBufferWindow::OnDestroy(); }
void MapWindow::OnResize(UPixelScalar width, UPixelScalar height) { DoubleBufferWindow::OnResize(width, height); #ifndef ENABLE_OPENGL ++ui_generation; // We only grow() the buffer here because resizing it everytime has // a huge negative effect on the heap fragmentation buffer_canvas.grow(width, height); if (!IsAncientHardware()) stencil_canvas.grow(width, height); #endif visible_projection.SetScreenSize(width, height); visible_projection.UpdateScreenBounds(); }
void OZPreviewRenderer::Draw(Canvas &canvas, const ObservationZonePoint &oz, const PixelPoint pt, unsigned radius, const TaskLook &look, const AirspaceRendererSettings &airspace_settings, const AirspaceLook &airspace_look) { double scale; GeoPoint center; if (IsAncientHardware()) { scale = double(radius) / ((const CylinderZone &)oz).GetRadius(); center = oz.GetReference(); } else { OZBoundary boundary = oz.GetBoundary(); GeoBounds bounds = GeoBounds::Invalid(); for (auto i = boundary.begin(), end = boundary.end(); i != end; ++i) bounds.Extend(*i); center = bounds.GetCenter(); auto geo_width = bounds.GetGeoWidth(); auto geo_heigth = bounds.GetGeoHeight(); scale = double(radius * 2) / std::max(geo_heigth, geo_width); } WindowProjection projection; projection.SetScreenSize({radius * 2, radius * 2}); projection.SetScreenOrigin(pt.x, pt.y); projection.SetGeoLocation(center); projection.SetScale(scale); projection.SetScreenAngle(Angle::Zero()); projection.UpdateScreenBounds(); OZRenderer ozv(look, airspace_look, airspace_settings); ozv.Draw(canvas, OZRenderer::LAYER_SHADE, projection, oz, 1); ozv.Draw(canvas, OZRenderer::LAYER_INACTIVE, projection, oz, 1); ozv.Draw(canvas, OZRenderer::LAYER_ACTIVE, projection, oz, 1); }
AirspaceVisitorMap(MapDrawHelper &_helper, const AirspaceWarningCopy& warnings, const AirspaceRendererSettings &_settings, const AirspaceLook &_airspace_look) :MapDrawHelper(_helper), airspace_look(_airspace_look), m_warnings(warnings) { switch (settings.fill_mode) { case AirspaceRendererSettings::AS_FILL_DEFAULT: m_use_stencil = !IsAncientHardware(); break; case AirspaceRendererSettings::AS_FILL_ALL: m_use_stencil = false; break; case AirspaceRendererSettings::AS_FILL_PADDING: m_use_stencil = true; break; } }
void AirspacePreviewRenderer::Draw(Canvas &canvas, const AbstractAirspace &airspace, const RasterPoint pt, unsigned radius, const AirspaceRendererSettings &settings, const AirspaceLook &look) { AbstractAirspace::Shape shape = airspace.GetShape(); AirspaceClass type = airspace.GetType(); // Container for storing the points of a polygon airspace std::vector<RasterPoint> pts; if (shape == AbstractAirspace::Shape::POLYGON && !IsAncientHardware()) GetPolygonPoints(pts, (const AirspacePolygon &)airspace, pt, radius); if (PrepareFill(canvas, type, look, settings)) { DrawShape(canvas, shape, pt, radius, pts); UnprepareFill(canvas); } if (PrepareOutline(canvas, type, look, settings)) DrawShape(canvas, shape, pt, radius, pts); }
static void DrawPolygon(Canvas &canvas, const AirspacePolygon &airspace, const RasterPoint pt, unsigned radius) { if (IsAncientHardware()) { canvas.Rectangle(pt.x - radius, pt.y - radius, pt.x + radius, pt.y + radius); return; } GeoBounds bounds = airspace.GetGeoBounds(); GeoPoint center = bounds.GetCenter(); fixed geo_heigth = GeoPoint(center.longitude, bounds.north).Distance( GeoPoint(center.longitude, bounds.south)); fixed geo_width = GeoPoint(bounds.west, center.latitude).Distance( GeoPoint(bounds.east, center.latitude)); fixed geo_size = std::max(geo_heigth, geo_width); WindowProjection projection; projection.SetScreenSize(radius * 2, radius * 2); projection.SetScreenOrigin(pt.x, pt.y); projection.SetGeoLocation(center); projection.SetScale(fixed(radius * 2) / geo_size); projection.SetScreenAngle(Angle::Zero()); projection.UpdateScreenBounds(); const SearchPointVector &border = airspace.GetPoints(); std::vector<RasterPoint> pts; pts.reserve(border.size()); for (auto it = border.begin(), it_end = border.end(); it != it_end; ++it) pts.push_back(projection.GeoToScreen(it->get_location())); canvas.polygon(&pts[0], (unsigned)pts.size()); }
/** * Does this device have little main memory? On those, some expensive * features are disabled. */ constexpr static inline bool HasLittleMemory() { return IsAncientHardware() || IsAltair(); }
*/ #include "TraceComputer.hpp" #include "ComputerSettings.hpp" #include "NMEA/MoreData.hpp" #include "NMEA/Derived.hpp" #include "Asset.hpp" static constexpr unsigned full_trace_size = HasLittleMemory() ? 512 : 1024; static constexpr unsigned contest_trace_size = HasLittleMemory() ? 256 : 512; static constexpr unsigned sprint_trace_size = IsAncientHardware() ? 96 : 128; static constexpr unsigned full_trace_no_thin_time = HasLittleMemory() ? 60 : 120; TraceComputer::TraceComputer() :full(full_trace_no_thin_time, Trace::null_time, full_trace_size), contest(0, Trace::null_time, contest_trace_size), sprint(0, 9000, sprint_trace_size) { } void TraceComputer::Reset() { mutex.Lock();