summaryrefslogtreecommitdiff
path: root/include/mbgl/util
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-10-26 17:19:19 -0700
committerKonstantin Käfer <mail@kkaefer.com>2016-11-01 18:41:52 +0100
commit358701f475b2c04c4681d70435bc76370b371285 (patch)
tree7ab5d170957eb8d209716f695aec428a44d4ddf2 /include/mbgl/util
parent9e3839781fdf1b1c6a2d61a5de9b2c7ddd68e9ed (diff)
downloadqtlocation-mapboxgl-358701f475b2c04c4681d70435bc76370b371285.tar.gz
[core] add ability to upload alpha-only textures + images
Diffstat (limited to 'include/mbgl/util')
-rw-r--r--include/mbgl/util/image.hpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/include/mbgl/util/image.hpp b/include/mbgl/util/image.hpp
index 3dbab27f41..1d84d4824a 100644
--- a/include/mbgl/util/image.hpp
+++ b/include/mbgl/util/image.hpp
@@ -9,9 +9,10 @@
namespace mbgl {
-enum ImageAlphaMode {
+enum class ImageAlphaMode {
Unassociated,
- Premultiplied
+ Premultiplied,
+ Exclusive, // Alpha-channel only
};
template <ImageAlphaMode Mode>
@@ -47,15 +48,17 @@ public:
return size && data.get() != nullptr;
}
- size_t stride() const { return static_cast<size_t>(size.width) * 4; }
+ size_t stride() const { return channels * size.width; }
size_t bytes() const { return stride() * size.height; }
Size size;
+ static constexpr size_t channels = Mode == ImageAlphaMode::Exclusive ? 1 : 4;
std::unique_ptr<uint8_t[]> data;
};
using UnassociatedImage = Image<ImageAlphaMode::Unassociated>;
using PremultipliedImage = Image<ImageAlphaMode::Premultiplied>;
+using AlphaImage = Image<ImageAlphaMode::Exclusive>;
// TODO: don't use std::string for binary data.
PremultipliedImage decodeImage(const std::string&);