diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-07-21 16:36:31 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-07-26 09:50:38 -0700 |
commit | 32bd1d54fa777035920b58e653905e4592ef187c (patch) | |
tree | 3f6fa84d6c9369bdd312ba630538a0c7504fce3a /bin | |
parent | 11933f6ab81248a884db3b1f69be714a60b6a86c (diff) | |
download | qtlocation-mapboxgl-32bd1d54fa777035920b58e653905e4592ef187c.tar.gz |
[node, tests] Consolidate headless rendering logic in HeadlessFrontend
Diffstat (limited to 'bin')
-rw-r--r-- | bin/render.cpp | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/bin/render.cpp b/bin/render.cpp index 0214d3310c..444921ff2b 100644 --- a/bin/render.cpp +++ b/bin/render.cpp @@ -2,14 +2,10 @@ #include <mbgl/util/image.hpp> #include <mbgl/util/run_loop.hpp> -#include <mbgl/gl/headless_backend.hpp> -#include <mbgl/gl/offscreen_view.hpp> +#include <mbgl/gl/headless_frontend.hpp> #include <mbgl/util/default_thread_pool.hpp> #include <mbgl/storage/default_file_source.hpp> #include <mbgl/style/style.hpp> -#include <mbgl/renderer/renderer.hpp> -#include <mbgl/renderer/backend_scope.hpp> -#include <mbgl/renderer/async_renderer_frontend.hpp> #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunknown-pragmas" @@ -85,13 +81,9 @@ int main(int argc, char *argv[]) { fileSource.setAccessToken(std::string(token)); } - HeadlessBackend backend; - BackendScope scope { backend }; - OffscreenView view(backend.getContext(), { static_cast<uint32_t>(width * pixelRatio), - static_cast<uint32_t>(height * pixelRatio) }); ThreadPool threadPool(4); - AsyncRendererFrontend rendererFrontend(std::make_unique<Renderer>(backend, pixelRatio, fileSource, threadPool), backend, view); - Map map(rendererFrontend, MapObserver::nullObserver(), mbgl::Size { width, height }, pixelRatio, fileSource, threadPool, MapMode::Still); + HeadlessFrontend frontend({ width, height }, pixelRatio, fileSource, threadPool); + Map map(frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, fileSource, threadPool, MapMode::Still); if (style_path.find("://") == std::string::npos) { style_path = std::string("file://") + style_path; @@ -106,23 +98,14 @@ int main(int argc, char *argv[]) { map.setDebug(debug ? mbgl::MapDebugOptions::TileBorders | mbgl::MapDebugOptions::ParseStatus : mbgl::MapDebugOptions::NoDebug); } - map.renderStill([&](std::exception_ptr error) { - try { - if (error) { - std::rethrow_exception(error); - } - } catch(std::exception& e) { - std::cout << "Error: " << e.what() << std::endl; - exit(1); - } - + try { std::ofstream out(output, std::ios::binary); - out << encodePNG(view.readStillImage()); + out << encodePNG(frontend.render(map)); out.close(); - loop.stop(); - }); - - loop.run(); + } catch(std::exception& e) { + std::cout << "Error: " << e.what() << std::endl; + exit(1); + } return 0; } |