diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2016-10-10 17:16:37 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2016-10-25 13:52:36 -0700 |
commit | a4d259c33f9bb890bba97fd89552720e3e0ec09b (patch) | |
tree | 342ecc27a6993c48f3a2e1d739fce890350bc44d /bin | |
parent | 5cc390d694fc7510d445310d8eb9e32429a5e67b (diff) | |
download | qtlocation-mapboxgl-a4d259c33f9bb890bba97fd89552720e3e0ec09b.tar.gz |
[core] move gl::Context to Backend and refactor View
Diffstat (limited to 'bin')
-rw-r--r-- | bin/glfw.cpp | 5 | ||||
-rw-r--r-- | bin/render.cpp | 11 |
2 files changed, 9 insertions, 7 deletions
diff --git a/bin/glfw.cpp b/bin/glfw.cpp index 44713d7532..b51846b4e8 100644 --- a/bin/glfw.cpp +++ b/bin/glfw.cpp @@ -13,6 +13,7 @@ #include <sstream> #include <cstdlib> #include <cstdio> +#include <array> namespace { @@ -119,7 +120,9 @@ int main(int argc, char *argv[]) { mbgl::ThreadPool threadPool(4); - mbgl::Map map(backend, backend, backend.getPixelRatio(), fileSource, threadPool); + mbgl::Map map(backend, view->getSize(), view->getPixelRatio(), fileSource, threadPool); + + backend.setMap(&map); // Load settings mbgl::Settings_JSON settings; diff --git a/bin/render.cpp b/bin/render.cpp index f9574d0523..ad29d91993 100644 --- a/bin/render.cpp +++ b/bin/render.cpp @@ -4,7 +4,7 @@ #include <mbgl/util/run_loop.hpp> #include <mbgl/platform/default/headless_backend.hpp> -#include <mbgl/platform/default/headless_view.hpp> +#include <mbgl/platform/default/offscreen_view.hpp> #include <mbgl/platform/default/thread_pool.hpp> #include <mbgl/storage/default_file_source.hpp> @@ -29,7 +29,6 @@ int main(int argc, char *argv[]) { int width = 512; int height = 512; - double pixelRatio = 1.0; static std::string output = "out.png"; std::string cache_file = "cache.sqlite"; std::string asset_root = "."; @@ -85,9 +84,9 @@ int main(int argc, char *argv[]) { } HeadlessBackend backend; - HeadlessView view(pixelRatio, width, height); + OffscreenView view(backend.getContext(), {{ static_cast<uint16_t>(width), static_cast<uint16_t>(height) }}); ThreadPool threadPool(4); - Map map(backend, view, view.getPixelRatio(), fileSource, threadPool, MapMode::Still); + Map map(backend, view.getSize(), 1, fileSource, threadPool, MapMode::Still); map.setStyleJSON(style); map.setClasses(classes); @@ -100,7 +99,7 @@ int main(int argc, char *argv[]) { map.setDebug(debug ? mbgl::MapDebugOptions::TileBorders | mbgl::MapDebugOptions::ParseStatus : mbgl::MapDebugOptions::NoDebug); } - map.renderStill([&](std::exception_ptr error, PremultipliedImage&& image) { + map.renderStill(view, [&](std::exception_ptr error) { try { if (error) { std::rethrow_exception(error); @@ -110,7 +109,7 @@ int main(int argc, char *argv[]) { exit(1); } - util::write_file(output, encodePNG(image)); + util::write_file(output, encodePNG(view.readStillImage())); loop.stop(); }); |