diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-03-19 18:58:50 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-03-19 18:58:50 +0100 |
commit | 4ee0cf1791f8f4b787793d2612c583bfb8b9c62f (patch) | |
tree | 19e45c0fadc108e1c27b75fdec85869cf8c799aa /src/geometry/text_buffer.cpp | |
parent | 98bb797a4adf52993835f016f577ac7de5d56dce (diff) | |
download | qtlocation-mapboxgl-4ee0cf1791f8f4b787793d2612c583bfb8b9c62f.tar.gz |
port remainder of the the placement algorithm
Diffstat (limited to 'src/geometry/text_buffer.cpp')
-rw-r--r-- | src/geometry/text_buffer.cpp | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/geometry/text_buffer.cpp b/src/geometry/text_buffer.cpp index 92580cdc32..cf130225e5 100644 --- a/src/geometry/text_buffer.cpp +++ b/src/geometry/text_buffer.cpp @@ -6,28 +6,27 @@ using namespace llmr; -const double TextVertexBuffer::angleFactor = 128 / M_PI; +const double TextVertexBuffer::angleFactor = 128.0 / M_PI; - -size_t TextVertexBuffer::add(const GlyphPosition& pos) { +size_t TextVertexBuffer::add(int16_t x, int16_t y, float ox, float oy, uint16_t tx, uint16_t ty, float angle, float minzoom, std::array<float, 2> range, float maxzoom, float labelminzoom) { size_t idx = index(); void *data = addElement(); int16_t *shorts = static_cast<int16_t *>(data); - shorts[0] = pos.x; - shorts[1] = pos.y; - shorts[2] = round(pos.ox * 64); // use 1/64 pixels for placement - shorts[3] = round(pos.oy * 64); + shorts[0] = x; + shorts[1] = y; + shorts[2] = round(ox * 64); // use 1/64 pixels for placement + shorts[3] = round(oy * 64); uint8_t *ubytes = static_cast<uint8_t *>(data); - ubytes[8] = pos.tx / 4; - ubytes[9] = pos.ty / 4; - ubytes[10] = pos.labelminzoom * 10; - ubytes[11] = pos.minzoom * 10; // 1/10 zoom levels: z16 == 160. - ubytes[12] = fmin(pos.maxzoom, 25) * 10; // 1/10 zoom levels: z16 == 160. - ubytes[13] = (int16_t)round(pos.angle * angleFactor) % 256; - ubytes[14] = util::max((int16_t)round(pos.rangefrom * angleFactor), (int16_t)0) % 256; - ubytes[15] = util::min((int16_t)round(pos.rangeto * angleFactor), (int16_t)255) % 256; + ubytes[8] = tx / 4; + ubytes[9] = ty / 4; + ubytes[10] = labelminzoom * 10; + ubytes[11] = minzoom * 10; // 1/10 zoom levels: z16 == 160. + ubytes[12] = fmin(maxzoom, 25) * 10; // 1/10 zoom levels: z16 == 160. + ubytes[13] = (int16_t)round(angle * angleFactor) % 256; + ubytes[14] = util::max((int16_t)round(range[0] * angleFactor), (int16_t)0) % 256; + ubytes[15] = util::min((int16_t)round(range[1] * angleFactor), (int16_t)255) % 256; return idx; } |