[node] Cleanup NodeMap::Render

This commit is contained in:
Bruno de Oliveira Abinader
2017-08-08 14:42:34 +03:00
parent 3f6f236f7b
commit d43757271e
3 changed files with 15 additions and 22 deletions

View File

@@ -42,7 +42,8 @@ public:
// Register a callback that will get called (on the render thread) when all resources have
// been loaded and a complete render occurs.
using StillImageCallback = std::function<void (std::exception_ptr)>;
void renderStill(StillImageCallback callback);
void renderStill(StillImageCallback);
void renderStill(const CameraOptions&, MapDebugOptions, StillImageCallback);
// Triggers a repaint.
void triggerRepaint();

View File

@@ -357,28 +357,13 @@ void NodeMap::startRender(NodeMap::RenderOptions options) {
frontend->setSize(options.size);
map->setSize(options.size);
if (map->getZoom() != options.zoom) {
map->setZoom(options.zoom);
}
mbgl::CameraOptions camera;
camera.center = mbgl::LatLng { options.latitude, options.longitude };
camera.zoom = options.zoom;
camera.angle = -options.bearing * mbgl::util::DEG2RAD;
camera.pitch = options.pitch * mbgl::util::DEG2RAD;
mbgl::LatLng latLng(options.latitude, options.longitude);
if (map->getLatLng() != latLng) {
map->setLatLng(latLng);
}
if (map->getBearing() != options.bearing) {
map->setBearing(options.bearing);
}
if (map->getPitch() != options.pitch) {
map->setPitch(options.pitch);
}
if (map->getDebug() != options.debugOptions) {
map->setDebug(options.debugOptions);
}
map->renderStill([this](const std::exception_ptr eptr) {
map->renderStill(camera, options.debugOptions, [this](const std::exception_ptr eptr) {
if (eptr) {
error = std::move(eptr);
uv_async_send(async);

View File

@@ -169,6 +169,13 @@ void Map::renderStill(StillImageCallback callback) {
impl->onUpdate(Update::Repaint);
}
void Map::renderStill(const CameraOptions& camera, MapDebugOptions debugOptions, StillImageCallback callback) {
impl->cameraMutated = true;
impl->debugOptions = debugOptions;
impl->transform.jumpTo(camera);
renderStill(std::move(callback));
}
void Map::triggerRepaint() {
impl->onUpdate(Update::Repaint);
}