From 3ec48b10300e3fdd56851e80f830423123a106d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Tue, 12 May 2015 16:16:16 +0200 Subject: [PATCH 1/2] allow passing --debug to view tile boundaries in mbgl-render --- bin/render.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bin/render.cpp b/bin/render.cpp index 4902d0930..33e216f52 100644 --- a/bin/render.cpp +++ b/bin/render.cpp @@ -39,6 +39,7 @@ int main(int argc, char *argv[]) { std::string cache_file = "cache.sqlite"; std::vector classes; std::string token; + bool debug = false; po::options_description desc("Allowed options"); desc.add_options() @@ -51,6 +52,7 @@ int main(int argc, char *argv[]) { ("height,h", po::value(&height)->value_name("pixels")->default_value(height), "Image height") ("class,c", po::value(&classes)->value_name("name"), "Class name") ("token,t", po::value(&token)->value_name("key")->default_value(token), "Mapbox access token") + ("debug", po::bool_switch(&debug)->default_value(debug), "Debug mode") ("output,o", po::value(&output)->value_name("file")->default_value(output), "Output file name") ("cache,d", po::value(&cache_file)->value_name("file")->default_value(cache_file), "Cache database file name") ; @@ -94,6 +96,10 @@ int main(int argc, char *argv[]) { map.setLatLngZoom({ lat, lon }, zoom); map.setBearing(bearing); + if (debug) { + map.setDebug(debug); + } + uv_async_t *async = new uv_async_t; uv_async_init(uv_default_loop(), async, [](uv_async_t *as, int) { std::unique_ptr image(reinterpret_cast(as->data)); From e2749597534d351d81cb8c2a2bc9b9886fef8028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Tue, 12 May 2015 17:30:40 +0200 Subject: [PATCH 2/2] abort rendering early when we don't need to when rendering still images, we don't need to render until everything is completely loaded --- src/mbgl/map/map_context.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mbgl/map/map_context.cpp b/src/mbgl/map/map_context.cpp index b239eb18a..087b9ae9b 100644 --- a/src/mbgl/map/map_context.cpp +++ b/src/mbgl/map/map_context.cpp @@ -216,6 +216,11 @@ void MapContext::render() { // Cleanup OpenGL objects that we abandoned since the last render call. env.performCleanup(); + if (data.mode == MapMode::Still && (!callback || !data.getFullyLoaded())) { + // We are either not waiting for a map to be rendered, or we don't have all resources yet. + return; + } + assert(style); if (!painter) { @@ -226,7 +231,7 @@ void MapContext::render() { painter->setDebug(data.getDebug()); painter->render(*style, transformState, data.getAnimationTime()); - if (data.mode == MapMode::Still && callback && style->isLoaded() && resourceLoader->getSprite()->isLoaded()) { + if (data.mode == MapMode::Still) { callback(view.readStillImage()); callback = nullptr; }