Files
MapLibreParticleLab/include/llmr/util/raster.hpp
Konstantin Käfer 0bfd7b0f43 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
2014-05-09 18:10:28 +02:00

74 lines
1.3 KiB
C++

#ifndef LLMR_UTIL_RASTER
#define LLMR_UTIL_RASTER
#include <llmr/util/transition.hpp>
#include <llmr/util/texturepool.hpp>
#include <string>
#include <mutex>
#include <memory>
typedef struct uv_loop_s uv_loop_t;
namespace llmr {
class Raster : public std::enable_shared_from_this<Raster> {
public:
Raster(Texturepool &texturepool);
~Raster();
// load image data
bool load(const std::string &img);
// bind current texture
void bind(bool linear = false);
// loaded status
bool isLoaded() const;
// transitions
void beginFadeInTransition();
bool needsTransition() const;
void updateTransitions(time now);
public:
// loaded image dimensions
uint32_t width = 0, height = 0;
// has been uploaded to texture
bool textured = false;
// the uploaded texture
uint32_t texture = 0;
// texture opacity
double opacity = 0;
private:
// load raw pixels
void loadImage(const std::string& data);
private:
mutable std::mutex mtx;
// raw pixels have been loaded
bool loaded = false;
// shared texture pool
Texturepool &texturepool;
// min/mag filter
uint32_t filter = 0;
// the raw pixels
char *img = nullptr;
// fade in transition
std::shared_ptr<util::transition> fade_transition = nullptr;
};
}
#endif