mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
gl_engine: correct the stroke alpha calculation
The wrong matrix scale factor value caused the stroke alpha to be zero when the matrix contains rotation.
This commit is contained in:
parent
968e438d25
commit
1a766ec00e
3 changed files with 7 additions and 2 deletions
|
@ -57,6 +57,11 @@
|
|||
} while(0)
|
||||
#endif
|
||||
|
||||
static inline float getScaleFactor(const Matrix& m)
|
||||
{
|
||||
return sqrtf(m.e11 * m.e11 + m.e21 * m.e21);
|
||||
}
|
||||
|
||||
enum class GlStencilMode {
|
||||
None,
|
||||
FillWinding,
|
||||
|
|
|
@ -162,7 +162,7 @@ void GlRenderer::drawPrimitive(GlShape& sdata, const RenderColor& c, RenderUpdat
|
|||
auto a = MULTIPLY(c.a, sdata.opacity);
|
||||
|
||||
if (flag & RenderUpdateFlag::Stroke) {
|
||||
float strokeWidth = sdata.rshape->strokeWidth() * sdata.geometry->getTransformMatrix().e11;
|
||||
float strokeWidth = sdata.rshape->strokeWidth() * getScaleFactor(sdata.geometry->getTransformMatrix());
|
||||
if (strokeWidth < MIN_GL_STROKE_WIDTH) {
|
||||
float alpha = strokeWidth / MIN_GL_STROKE_WIDTH;
|
||||
a = MULTIPLY(a, static_cast<uint8_t>(alpha * 255));
|
||||
|
|
|
@ -1534,7 +1534,7 @@ void Stroker::stroke(const RenderShape *rshape)
|
|||
mStrokeWidth = rshape->strokeWidth();
|
||||
|
||||
if (isinf(mMatrix.e11)) {
|
||||
auto strokeWidth = rshape->strokeWidth() * mMatrix.e11;
|
||||
auto strokeWidth = rshape->strokeWidth() * getScaleFactor(mMatrix);
|
||||
if (strokeWidth <= MIN_GL_STROKE_WIDTH) strokeWidth = MIN_GL_STROKE_WIDTH;
|
||||
mStrokeWidth = strokeWidth / mMatrix.e11;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue