[all] Rationalize style::Image

A style has a collection of images, just as it has collections of sources and layers.

* Name things appropriately
* Use std::unique_ptr
This commit is contained in:
John Firebaugh
2017-04-21 14:52:19 -07:00
parent 6f708ac545
commit 5dd98df50b
34 changed files with 312 additions and 389 deletions

View File

@@ -25,7 +25,7 @@
#include <mbgl/util/logging.hpp>
#include <mbgl/util/platform.hpp>
#include <mbgl/util/projection.hpp>
#include <mbgl/sprite/sprite_image.hpp>
#include <mbgl/style/image.hpp>
#include <mbgl/style/filter.hpp>
// Java -> C++ conversion
@@ -735,12 +735,12 @@ void NativeMapView::addAnnotationIcon(JNIEnv& env, jni::String symbol, jint w, j
}
jni::GetArrayRegion(env, *jpixels, 0, size, reinterpret_cast<jbyte*>(premultipliedImage.data.get()));
auto iconImage = std::make_shared<mbgl::SpriteImage>(std::move(premultipliedImage), float(scale));
map->addAnnotationIcon(symbolName, iconImage);
map->addAnnotationImage(symbolName,
std::make_unique<mbgl::style::Image>(std::move(premultipliedImage), float(scale)));
}
jdouble NativeMapView::getTopOffsetPixelsForAnnotationSymbol(JNIEnv& env, jni::String symbolName) {
return map->getTopOffsetPixelsForAnnotationIcon(jni::Make<std::string>(env, symbolName));
return map->getTopOffsetPixelsForAnnotationImage(jni::Make<std::string>(env, symbolName));
}
jlong NativeMapView::getTransitionDuration(JNIEnv&) {
@@ -1036,9 +1036,9 @@ void NativeMapView::addImage(JNIEnv& env, jni::String name, jni::jint w, jni::ji
}
jni::GetArrayRegion(env, *pixels, 0, size, reinterpret_cast<jbyte*>(premultipliedImage.data.get()));
auto spriteImage = std::make_unique<mbgl::SpriteImage>(std::move(premultipliedImage), float(scale));
map->addImage(jni::Make<std::string>(env, name), std::move(spriteImage));
map->addImage(jni::Make<std::string>(env, name),
std::make_unique<mbgl::style::Image>(std::move(premultipliedImage), float(scale)));
}
void NativeMapView::removeImage(JNIEnv& env, jni::String name) {