diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2015-11-24 10:07:18 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2015-11-25 15:57:36 -0800 |
commit | 0c1e378bc9555f6cf826bb38b1a36fa742f8ce9b (patch) | |
tree | 9aec8e4f475ff715645072503b3e0ec78f0573af /platform/node | |
parent | 2de0a351a0635192bd05116cebdf0103c2638d05 (diff) | |
download | qtlocation-mapboxgl-0c1e378bc9555f6cf826bb38b1a36fa742f8ce9b.tar.gz |
[core] Rewrite image handling
* Consolidate Image and StillImage
* Typecheck unassociated vs premultiplied images
* Rewrite default platform image decoding implementation
Diffstat (limited to 'platform/node')
-rw-r--r-- | platform/node/src/node_map.cpp | 24 | ||||
-rw-r--r-- | platform/node/src/node_map.hpp | 2 |
2 files changed, 12 insertions, 14 deletions
diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp index eb92205487..0ce7d9398b 100644 --- a/platform/node/src/node_map.cpp +++ b/platform/node/src/node_map.cpp @@ -3,7 +3,6 @@ #include "node_mapbox_gl_native.hpp" #include <mbgl/platform/default/headless_display.hpp> -#include <mbgl/map/still_image.hpp> #include <mbgl/util/exception.hpp> #include <mbgl/util/work_request.hpp> @@ -281,7 +280,7 @@ NAN_METHOD(NodeMap::Render) { auto options = ParseOptions(info[0]->ToObject()); assert(!nodeMap->callback); - assert(!nodeMap->image); + assert(!nodeMap->image.data); nodeMap->callback = std::make_unique<Nan::Callback>(info[1].As<v8::Function>()); try { @@ -301,12 +300,12 @@ void NodeMap::startRender(std::unique_ptr<NodeMap::RenderOptions> options) { map->setBearing(options->bearing); map->setPitch(options->pitch); - map->renderStill([this](const std::exception_ptr eptr, std::unique_ptr<const mbgl::StillImage> result) { + map->renderStill([this](const std::exception_ptr eptr, mbgl::UnassociatedImage&& result) { if (eptr) { error = std::move(eptr); uv_async_send(async); } else { - assert(!image); + assert(!image.data); image = std::move(result); uv_async_send(async); } @@ -338,7 +337,7 @@ void NodeMap::renderFinished() { // These have to be empty to be prepared for the next render call. assert(!callback); - assert(!image); + assert(!image.data); if (error) { std::string errorMessage; @@ -358,17 +357,16 @@ void NodeMap::renderFinished() { assert(!error); cb->Call(1, argv); - } else if (img) { + } else if (img.data) { v8::Local<v8::Object> pixels = Nan::NewBuffer( - reinterpret_cast<char *>(img->pixels.get()), img->width * img->height * 4, - - // Retain the StillImage object until the buffer is deleted. - [](char *, void *hint) { - delete reinterpret_cast<const mbgl::StillImage *>(hint); + reinterpret_cast<char *>(img.data.get()), img.size(), + // Retain the data until the buffer is deleted. + [](char *, void * hint) { + delete [] reinterpret_cast<uint8_t*>(hint); }, - const_cast<mbgl::StillImage *>(img.get()) + img.data.get() ).ToLocalChecked(); - img.release(); + img.data.release(); v8::Local<v8::Value> argv[] = { Nan::Null(), diff --git a/platform/node/src/node_map.hpp b/platform/node/src/node_map.hpp index f610408d3f..455d38e957 100644 --- a/platform/node/src/node_map.hpp +++ b/platform/node/src/node_map.hpp @@ -49,7 +49,7 @@ public: std::unique_ptr<mbgl::Map> map; std::exception_ptr error; - std::unique_ptr<const mbgl::StillImage> image; + mbgl::UnassociatedImage image; std::unique_ptr<Nan::Callback> callback; // Async for delivering the notifications of render completion. |