Allow property functions for prerender properties, but tie them to the tile's zoom level instead of the map zoom level

fixes #253
This commit is contained in:
Konstantin Käfer
2014-06-01 17:43:12 +02:00
parent 2dc03c733c
commit 1be972eb15
9 changed files with 75 additions and 66 deletions

View File

@@ -152,18 +152,19 @@ void Painter::renderFill(FillBucket& bucket, const std::string& layer_name, cons
: defaultFillProperties;
if (!properties.enabled) return;
if (properties.prerender) {
if (pass == Translucent) {
// Buffer value around the 0..4096 extent that will be drawn into the 256x256 pixel
// texture. We later scale the texture so that the actual bounds will align with this
// tile's bounds. The reason we do this is so that the
if (!bucket.prerendered) {
bucket.prerendered = std::make_unique<PrerenderedTexture>(properties.prerenderSize);
const PrerenderProperties prerender = properties.getPrerenderProperties(id.z);
bucket.prerendered = std::make_unique<PrerenderedTexture>(prerender);
bucket.prerendered->bindFramebuffer();
preparePrerender(properties);
preparePrerender(*bucket.prerendered);
const FillProperties modifiedProperties = [&]{
FillProperties modifiedProperties = properties;
@@ -173,7 +174,7 @@ void Painter::renderFill(FillBucket& bucket, const std::string& layer_name, cons
// When drawing the fill, we want to draw a buffer around too, so we
// essentially downscale everyting, and then upscale it later when rendering.
const int buffer = 4096 * properties.prerenderBuffer;
const int buffer = prerender.buffer * 4096.0f;
const mat4 vtxMatrix = [&]{
mat4 vtxMatrix;
matrix::ortho(vtxMatrix, -buffer, 4096 + buffer, -4096 - buffer, buffer, 0, 1);
@@ -187,17 +188,16 @@ void Painter::renderFill(FillBucket& bucket, const std::string& layer_name, cons
setTranslucent();
renderFill(bucket, modifiedProperties, id, vtxMatrix);
if (properties.prerenderBlur > 0) {
bucket.prerendered->blur(*this, properties.prerenderBlur);
if (prerender.blur > 0) {
bucket.prerendered->blur(*this, prerender.blur);
}
// RESET STATE
bucket.prerendered->unbindFramebuffer();
finishPrerender(properties);
finishPrerender(*bucket.prerendered);
}
renderPrerenderedTexture(bucket, properties);
renderPrerenderedTexture(*bucket.prerendered, properties);
}
} else {
const mat4 &vtxMatrix = translatedMatrix(properties.translate, id, properties.translateAnchor);