diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-05-09 18:10:28 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-05-09 18:10:28 +0200 |
commit | 0bfd7b0f430d51dd5661d69876ac5294616d128f (patch) | |
tree | 0a1b706049246a4152dec605b8193b223b81d170 /src/util/raster.cpp | |
parent | 70a7ba81f33d88991d21534b68600d470ad2b798 (diff) | |
download | qtlocation-mapboxgl-0bfd7b0f430d51dd5661d69876ac5294616d128f.tar.gz |
Calculate clip IDs with a huffman prefix tree
This changes the clip IDs from sequential to a huffman prefix tree, meaning that
parent tiles share the same prefix with child tiles (but are shorter). This allows
us to use the same checkerboard pattern to draw all tiles.
TODO:
- make sure we're not overflowing the 8 bit limit of the stencil buffer
- draw all checkerboard fields at the same time, with one draw call
- fix raster drawing (fading, clipping)
refs #132
Diffstat (limited to 'src/util/raster.cpp')
-rw-r--r-- | src/util/raster.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/util/raster.cpp b/src/util/raster.cpp index e7cb89e429..90268c09b0 100644 --- a/src/util/raster.cpp +++ b/src/util/raster.cpp @@ -13,11 +13,15 @@ using namespace llmr; +Raster::Raster(Texturepool &texturepool) + : texturepool(texturepool) +{} + Raster::~Raster() { if (img && !textured) { free(img); } else if (textured) { - texturepool->removeTextureID(texture); + texturepool.removeTextureID(texture); } } @@ -26,17 +30,14 @@ bool Raster::isLoaded() const { return loaded; } -void Raster::load() { +bool Raster::load(const std::string &data) { loadImage(data); - { - std::lock_guard<std::mutex> lock(mtx); - if (img) { - loaded = true; - } + std::lock_guard<std::mutex> lock(mtx); + if (img) { + loaded = true; } - - data.clear(); + return loaded; } struct Buffer { @@ -154,9 +155,6 @@ void Raster::loadImage(const std::string& data) { } } -void Raster::setTexturepool(Texturepool* new_texturepool) { - texturepool = new_texturepool; -} void Raster::bind(bool linear) { if (!width || !height) { @@ -164,8 +162,8 @@ void Raster::bind(bool linear) { return; } - if (img && !textured && texturepool) { - texture = texturepool->getTextureID(); + if (img && !textured) { + texture = texturepool.getTextureID(); glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |