summaryrefslogtreecommitdiff
path: root/src/mbgl/geometry
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-07-06 13:13:22 +0200
committerKonstantin Käfer <mail@kkaefer.com>2015-07-08 19:46:02 +0200
commit32699333e64c8b26011ce311aa8a759f1b8dcfaa (patch)
tree615df915f39b8e82a4908dcfa83c985520c10b0f /src/mbgl/geometry
parentd08ec53a0e21f0dd5acb35b691a8f2b15e413a61 (diff)
downloadqtlocation-mapboxgl-32699333e64c8b26011ce311aa8a759f1b8dcfaa.tar.gz
add image to odd pixelRatio atlas
Diffstat (limited to 'src/mbgl/geometry')
-rw-r--r--src/mbgl/geometry/sprite_atlas.cpp11
-rw-r--r--src/mbgl/geometry/sprite_atlas.hpp3
2 files changed, 3 insertions, 11 deletions
diff --git a/src/mbgl/geometry/sprite_atlas.cpp b/src/mbgl/geometry/sprite_atlas.cpp
index 825c02658a..743848d5f2 100644
--- a/src/mbgl/geometry/sprite_atlas.cpp
+++ b/src/mbgl/geometry/sprite_atlas.cpp
@@ -27,7 +27,9 @@ SpriteAtlas::SpriteAtlas(dimension width_, dimension height_, float pixelRatio_,
pixelRatio(pixelRatio_),
store(store_),
bin(width_, height_),
+ data(std::make_unique<uint32_t[]>(pixelWidth * pixelHeight)),
dirty(true) {
+ std::fill(data.get(), data.get() + pixelWidth * pixelHeight, 0);
}
Rect<SpriteAtlas::dimension> SpriteAtlas::allocateImage(const size_t pixel_width, const size_t pixel_height) {
@@ -103,13 +105,6 @@ SpriteAtlasPosition SpriteAtlas::getPosition(const std::string& name, bool repea
};
}
-void SpriteAtlas::allocate() {
- if (!data) {
- data = std::make_unique<uint32_t[]>(pixelWidth * pixelHeight);
- std::fill(data.get(), data.get() + pixelWidth * pixelHeight, 0);
- }
-}
-
void SpriteAtlas::copy(const Holder& holder, const bool wrap) {
const uint32_t *srcData = reinterpret_cast<const uint32_t *>(holder.texture->data.data());
if (!srcData) return;
@@ -119,7 +114,6 @@ void SpriteAtlas::copy(const Holder& holder, const bool wrap) {
const int offset = 1;
- allocate();
uint32_t *const dstData = data.get();
const vec2<uint32_t> dstSize{ pixelWidth, pixelHeight };
const Rect<uint32_t> dstPos{ static_cast<uint32_t>((offset + dst.x) * pixelRatio),
@@ -222,7 +216,6 @@ void SpriteAtlas::bind(bool linear) {
if (dirty) {
std::lock_guard<std::recursive_mutex> lock(mtx);
- allocate();
if (fullUploadRequired) {
MBGL_CHECK_ERROR(glTexImage2D(
diff --git a/src/mbgl/geometry/sprite_atlas.hpp b/src/mbgl/geometry/sprite_atlas.hpp
index 6642e04bf8..bfe4f843da 100644
--- a/src/mbgl/geometry/sprite_atlas.hpp
+++ b/src/mbgl/geometry/sprite_atlas.hpp
@@ -82,7 +82,6 @@ private:
using Key = std::pair<std::string, bool>;
- void allocate();
Rect<SpriteAtlas::dimension> allocateImage(size_t width, size_t height);
void copy(const Holder& holder, const bool wrap);
@@ -91,7 +90,7 @@ private:
BinPack<dimension> bin;
std::map<Key, Holder> images;
std::set<std::string> uninitialized;
- std::unique_ptr<uint32_t[]> data;
+ const std::unique_ptr<uint32_t[]> data;
std::atomic<bool> dirty;
bool fullUploadRequired = true;
uint32_t texture = 0;