[core] Rewrite image handling
* Consolidate Image and StillImage * Typecheck unassociated vs premultiplied images * Rewrite default platform image decoding implementation
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
#include <mbgl/map/map.hpp>
|
||||
#include <mbgl/map/still_image.hpp>
|
||||
#include <mbgl/util/image.hpp>
|
||||
#include <mbgl/util/io.hpp>
|
||||
|
||||
@@ -105,16 +104,14 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
uv_async_t *async = new uv_async_t;
|
||||
uv_async_init(uv_default_loop(), async, [](UV_ASYNC_PARAMS(as)) {
|
||||
std::unique_ptr<const StillImage> image(reinterpret_cast<const StillImage *>(as->data));
|
||||
std::unique_ptr<UnassociatedImage> image(reinterpret_cast<UnassociatedImage*>(as->data));
|
||||
uv_close(reinterpret_cast<uv_handle_t *>(as), [](uv_handle_t *handle) {
|
||||
delete reinterpret_cast<uv_async_t *>(handle);
|
||||
});
|
||||
|
||||
const std::string png = util::compress_png(image->width, image->height, image->pixels.get());
|
||||
util::write_file(output, png);
|
||||
util::write_file(output, encodePNG(*image));
|
||||
});
|
||||
|
||||
map.renderStill([async](std::exception_ptr error, std::unique_ptr<const StillImage> image) {
|
||||
map.renderStill([async](std::exception_ptr error, UnassociatedImage&& image) {
|
||||
try {
|
||||
if (error) {
|
||||
std::rethrow_exception(error);
|
||||
@@ -124,7 +121,7 @@ int main(int argc, char *argv[]) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
async->data = const_cast<StillImage *>(image.release());
|
||||
async->data = new UnassociatedImage(std::move(image));
|
||||
uv_async_send(async);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user