[core][ios][osx][android] make SpriteImage accept PremultipliedImage

the SpriteImage constructor signature changes from

SpriteImage(
        uint16_t width, uint16_t height, float pixelRatio,
        std::string&& data, bool sdf = false);

to

SpriteImage(PremultipliedImage&&, float pixelRatio, bool sdf = false)
This commit is contained in:
Ansis Brammanis
2016-01-15 17:39:08 -08:00
parent 26faa6a5ad
commit d34f8eb674
20 changed files with 160 additions and 168 deletions

View File

@@ -6,23 +6,17 @@
namespace mbgl {
SpriteImage::SpriteImage(const uint16_t pixelWidth_,
const uint16_t pixelHeight_,
SpriteImage::SpriteImage(PremultipliedImage&& image_,
const float pixelRatio_,
std::string&& data_,
bool sdf_)
: width(std::ceil(pixelWidth_ / pixelRatio_)),
height(std::ceil(pixelHeight_ / pixelRatio_)),
: image(std::move(image_)),
pixelRatio(pixelRatio_),
pixelWidth(pixelWidth_),
pixelHeight(pixelHeight_),
data(std::move(data_)),
sdf(sdf_) {
const size_t size = pixelWidth * pixelHeight * 4;
if (size == 0) {
if (image.size() == 0) {
throw util::SpriteImageException("Sprite image dimensions may not be zero");
} else if (size != data.size()) {
throw util::SpriteImageException("Sprite image pixel count mismatch");
} else if (pixelRatio <= 0) {
throw util::SpriteImageException("Sprite pixelRatio may not be <= 0");
}
}