saving current state

This commit is contained in:
Konstantin Käfer
2014-06-23 18:05:06 +02:00
parent f51fd9be58
commit ba4294ae0c
56 changed files with 3078 additions and 6223 deletions

View File

@@ -5,17 +5,12 @@
using namespace llmr;
void Painter::renderText(TextBucket& bucket, const std::string& layer_name, const Tile::ID& id) {
void Painter::renderText(TextBucket& bucket, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id) {
// Abort early.
if (pass == Opaque) return;
if (!bucket.hasData()) return;
const std::unordered_map<std::string, TextProperties> &text_properties = map.getStyle()->computed.texts;
const std::unordered_map<std::string, TextProperties>::const_iterator text_properties_it = text_properties.find(layer_name);
const TextProperties &properties = text_properties_it != text_properties.end()
? text_properties_it->second
: defaultTextProperties;
const TextProperties &properties = layer_desc->getProperties<TextProperties>();
if (!properties.enabled) return;
mat4 exMatrix;
@@ -24,16 +19,13 @@ void Painter::renderText(TextBucket& bucket, const std::string& layer_name, cons
matrix::rotate_z(exMatrix, exMatrix, map.getState().getAngle());
}
const float rotate = properties.rotate;
if (rotate != 0.0f) {
matrix::rotate_z(exMatrix, exMatrix, rotate);
}
// If layerStyle.size > bucket.info.fontSize then labels may collide
float fontSize = std::fmin(properties.size, bucket.properties.max_size);
matrix::scale(exMatrix, exMatrix, fontSize / 24.0f, fontSize / 24.0f, 1.0f);
const mat4 &vtxMatrix = translatedMatrix(properties.translate, id, properties.translateAnchor);
// TODO: figure out whether we actually need to account for this while painting; we might already have
// done this during label placement.
// const mat4 &vtxMatrix = translatedMatrix(properties.translate, id, properties.translateAnchor);
useProgram(textShader->program);
textShader->setMatrix(vtxMatrix);
@@ -45,7 +37,7 @@ void Painter::renderText(TextBucket& bucket, const std::string& layer_name, cons
static_cast<float>(glyphAtlas.height)}});
// Convert the -pi..pi to an int8 range.
float angle = std::round((map.getState().getAngle() + rotate) / M_PI * 128);
float angle = std::round((map.getState().getAngle()) / M_PI * 128);
// adjust min/max zooms for variable font sies
float zoomAdjust = log(fontSize / bucket.properties.max_size) / log(2);
@@ -98,12 +90,12 @@ void Painter::renderText(TextBucket& bucket, const std::string& layer_name, cons
// We're drawing in the translucent pass which is bottom-to-top, so we need
// to draw the halo first.
if (properties.halo[3] > 0.0f) {
if (properties.halo_color[3] > 0.0f) {
// TODO: Get rid of the 2.4 magic value. It is currently 24 / 10, with 24 being the font size
// of the SDF glyphs.
textShader->setGamma(properties.halo_blur * 2.4f / fontSize / map.getState().getPixelRatio());
textShader->setColor(properties.halo);
textShader->setBuffer(properties.halo_radius);
textShader->setColor(properties.halo_color);
textShader->setBuffer(properties.halo_width);
glDepthRange(strata, 1.0f);
bucket.drawGlyphs(*textShader);
}