fix linejoin drawing on retina
This commit is contained in:
@@ -101,7 +101,7 @@ void Painter::depthMask(bool value) {
|
||||
|
||||
void Painter::changeMatrix() {
|
||||
// Initialize projection matrix
|
||||
matrix::ortho(projMatrix, 0, transform.width, transform.height, 0, 0, 1);
|
||||
matrix::ortho(projMatrix, 0, transform.getWidth(), transform.getHeight(), 0, 0, 1);
|
||||
|
||||
// The extrusion matrix.
|
||||
matrix::identity(extrudeMatrix);
|
||||
@@ -270,7 +270,10 @@ void Painter::renderFill(FillBucket& bucket, const std::string& layer_name, cons
|
||||
outlineShader->setColor(stroke_color);
|
||||
|
||||
// Draw the entire line
|
||||
outlineShader->setWorld({{ transform.fb_width, transform.fb_height }});
|
||||
outlineShader->setWorld({{
|
||||
static_cast<float>(transform.getFramebufferWidth()),
|
||||
static_cast<float>(transform.getFramebufferHeight())
|
||||
}});
|
||||
glDepthRange(strata, 1.0f);
|
||||
bucket.drawVertices(*outlineShader);
|
||||
} else if (fringeline) {
|
||||
@@ -350,10 +353,9 @@ void Painter::renderFill(FillBucket& bucket, const std::string& layer_name, cons
|
||||
|
||||
// Draw the entire line
|
||||
outlineShader->setWorld({{
|
||||
transform.fb_width,
|
||||
transform.fb_height
|
||||
}
|
||||
});
|
||||
static_cast<float>(transform.getFramebufferWidth()),
|
||||
static_cast<float>(transform.getFramebufferHeight())
|
||||
}});
|
||||
|
||||
glDepthRange(strata + strata_epsilon, 1.0f);
|
||||
bucket.drawVertices(*outlineShader);
|
||||
@@ -391,17 +393,17 @@ void Painter::renderLine(LineBucket& bucket, const std::string& layer_name, cons
|
||||
linejoinShader->setMatrix(matrix);
|
||||
linejoinShader->setColor(color);
|
||||
linejoinShader->setWorld({{
|
||||
transform.fb_width * 0.5f,
|
||||
transform.fb_height * 0.5f
|
||||
transform.getFramebufferWidth() * 0.5f,
|
||||
transform.getFramebufferHeight() * 0.5f
|
||||
}
|
||||
});
|
||||
linejoinShader->setLineWidth({{
|
||||
((outset - 0.25f) * transform.pixelRatio),
|
||||
((inset - 0.25f) * transform.pixelRatio)
|
||||
((outset - 0.25f) * transform.getPixelRatio()),
|
||||
((inset - 0.25f) * transform.getPixelRatio())
|
||||
}
|
||||
});
|
||||
|
||||
float pointSize = ceil(transform.pixelRatio * outset * 2.0);
|
||||
float pointSize = ceil(transform.getPixelRatio() * outset * 2.0);
|
||||
#if defined(GL_ES_VERSION_2_0)
|
||||
linejoinShader->setSize(pointSize);
|
||||
#else
|
||||
@@ -467,7 +469,7 @@ void Painter::renderPoint(PointBucket& bucket, const std::string& layer_name, co
|
||||
pointShader->setMatrix(matrix);
|
||||
pointShader->setImage(0);
|
||||
pointShader->setColor(color);
|
||||
const float pointSize = properties.size * 1.4142135623730951 * transform.pixelRatio;
|
||||
const float pointSize = properties.size * 1.4142135623730951 * transform.getPixelRatio();
|
||||
#if defined(GL_ES_VERSION_2_0)
|
||||
pointShader->setSize(pointSize);
|
||||
#else
|
||||
@@ -513,7 +515,7 @@ void Painter::renderText(TextBucket& bucket, const std::string& layer_name, cons
|
||||
glyphAtlas.bind();
|
||||
textShader->setTextureSize({{ static_cast<float>(glyphAtlas.width), static_cast<float>(glyphAtlas.height) }});
|
||||
|
||||
textShader->setGamma(2.5f / fontSize / transform.pixelRatio);
|
||||
textShader->setGamma(2.5f / fontSize / transform.getPixelRatio());
|
||||
|
||||
// Convert the -pi..pi to an int8 range.
|
||||
float angle = round((transform.getAngle() + rotate) / M_PI * 128);
|
||||
@@ -595,16 +597,16 @@ void Painter::renderDebug(const TileData::Ptr& tile_data) {
|
||||
// draw tile outline
|
||||
tileBorderArray.bind(*plainShader, tileBorderBuffer, BUFFER_OFFSET(0));
|
||||
plainShader->setColor(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
lineWidth(4.0f * transform.pixelRatio);
|
||||
lineWidth(4.0f * transform.getPixelRatio());
|
||||
glDrawArrays(GL_LINE_STRIP, 0, (GLsizei)tileBorderBuffer.index());
|
||||
|
||||
// draw debug info
|
||||
tile_data->debugFontArray.bind(*plainShader, tile_data->debugFontBuffer, BUFFER_OFFSET(0));
|
||||
plainShader->setColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
lineWidth(4.0f * transform.pixelRatio);
|
||||
lineWidth(4.0f * transform.getPixelRatio());
|
||||
glDrawArrays(GL_LINES, 0, (GLsizei)tile_data->debugFontBuffer.index());
|
||||
plainShader->setColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
lineWidth(2.0f * transform.pixelRatio);
|
||||
lineWidth(2.0f * transform.getPixelRatio());
|
||||
glDrawArrays(GL_LINES, 0, (GLsizei)tile_data->debugFontBuffer.index());
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
Reference in New Issue
Block a user