[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

@@ -3,6 +3,7 @@
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/geo.hpp>
#include <mbgl/util/image.hpp>
#include <string>
#include <memory>
@@ -12,27 +13,18 @@ namespace mbgl {
class SpriteImage : private util::noncopyable {
public:
SpriteImage(
uint16_t width, uint16_t height, float pixelRatio, std::string&& data, bool sdf = false);
SpriteImage(PremultipliedImage&&, float pixelRatio, bool sdf = false);
// Logical dimensions of the sprite image.
const uint16_t width;
const uint16_t height;
PremultipliedImage image;
// Pixel ratio of the sprite image.
const float pixelRatio;
// Physical dimensions of the sprite image.
const uint16_t pixelWidth;
const uint16_t pixelHeight;
// A string of an RGBA8 representation of the sprite. It must have exactly
// (width * ratio) * (height * ratio) * 4 (RGBA) bytes. The scan lines may
// not have gaps between them (i.e. stride == 0).
const std::string data;
// Whether this image should be interpreted as a signed distance field icon.
const bool sdf;
float getWidth() const { return image.width / pixelRatio; }
float getHeight() const { return image.height / pixelRatio; }
};
} // namespace mbgl