Fixes a bug when applying NVG_IMAGE_FLIPY.

This commit fixes issue #167 that `nvgImagePattern()` does not handle coordinate well if the specified image applies the `NVG_IMAGE_FLIPY` parameter.
This commit is contained in:
Olli Wang 2016-09-18 16:08:49 +08:00
parent 4f255e0daf
commit 85ac378792

View File

@ -895,10 +895,14 @@ static int glnvg__convertPaint(GLNVGcontext* gl, GLNVGfragUniforms* frag, NVGpai
tex = glnvg__findTexture(gl, paint->image); tex = glnvg__findTexture(gl, paint->image);
if (tex == NULL) return 0; if (tex == NULL) return 0;
if ((tex->flags & NVG_IMAGE_FLIPY) != 0) { if ((tex->flags & NVG_IMAGE_FLIPY) != 0) {
float flipped[6]; float m1[6], m2[6];
nvgTransformScale(flipped, 1.0f, -1.0f); nvgTransformTranslate(m1, 0.0f, frag->extent[1] * 0.5f);
nvgTransformMultiply(flipped, paint->xform); nvgTransformMultiply(m1, paint->xform);
nvgTransformInverse(invxform, flipped); nvgTransformScale(m2, 1.0f, -1.0f);
nvgTransformMultiply(m2, m1);
nvgTransformTranslate(m1, 0.0f, -frag->extent[1] * 0.5f);
nvgTransformMultiply(m1, m2);
nvgTransformInverse(invxform, m1);
} else { } else {
nvgTransformInverse(invxform, paint->xform); nvgTransformInverse(invxform, paint->xform);
} }