- removed assize from the back-end api - moved image to paint in renderTriangles callshared-context
@@ -166,6 +166,8 @@ void drawDropDown(struct NVGcontext* vg, const char* text, float x, float y, flo | |||||
void drawLabel(struct NVGcontext* vg, const char* text, float x, float y, float w, float h) | void drawLabel(struct NVGcontext* vg, const char* text, float x, float y, float w, float h) | ||||
{ | { | ||||
NVG_NOTUSED(w); | |||||
nvgFontSize(vg, 18.0f); | nvgFontSize(vg, 18.0f); | ||||
nvgFontFace(vg, "sans"); | nvgFontFace(vg, "sans"); | ||||
nvgFillColor(vg, nvgRGBA(255,255,255,128)); | nvgFillColor(vg, nvgRGBA(255,255,255,128)); | ||||
@@ -228,6 +230,7 @@ void drawCheckBox(struct NVGcontext* vg, const char* text, float x, float y, flo | |||||
{ | { | ||||
struct NVGpaint bg; | struct NVGpaint bg; | ||||
char icon[8]; | char icon[8]; | ||||
NVG_NOTUSED(w); | |||||
nvgFontSize(vg, 18.0f); | nvgFontSize(vg, 18.0f); | ||||
nvgFontFace(vg, "sans"); | nvgFontFace(vg, "sans"); | ||||
@@ -1511,7 +1511,7 @@ void nvgFill(struct NVGcontext* ctx) | |||||
else | else | ||||
nvg__expandStrokeAndFill(ctx, NVG_FILL, 0.0f); | nvg__expandStrokeAndFill(ctx, NVG_FILL, 0.0f); | ||||
ctx->params.renderFill(ctx->params.userPtr, &state->fill, &state->scissor, 1.0f, | |||||
ctx->params.renderFill(ctx->params.userPtr, &state->fill, &state->scissor, | |||||
ctx->cache->bounds, ctx->cache->paths, ctx->cache->npaths); | ctx->cache->bounds, ctx->cache->paths, ctx->cache->npaths); | ||||
// Count triangles | // Count triangles | ||||
@@ -1537,7 +1537,7 @@ void nvgStroke(struct NVGcontext* ctx) | |||||
else | else | ||||
nvg__expandStrokeAndFill(ctx, NVG_STROKE|NVG_CAPS, strokeWidth*0.5f); | nvg__expandStrokeAndFill(ctx, NVG_STROKE|NVG_CAPS, strokeWidth*0.5f); | ||||
ctx->params.renderStroke(ctx->params.userPtr, &state->stroke, &state->scissor, 1.0f, | |||||
ctx->params.renderStroke(ctx->params.userPtr, &state->stroke, &state->scissor, | |||||
strokeWidth, ctx->cache->paths, ctx->cache->npaths); | strokeWidth, ctx->cache->paths, ctx->cache->npaths); | ||||
// Count triangles | // Count triangles | ||||
@@ -1615,6 +1615,7 @@ static float nvg__getFontScale(struct NVGstate* state) | |||||
float nvgText(struct NVGcontext* ctx, float x, float y, const char* string, const char* end) | float nvgText(struct NVGcontext* ctx, float x, float y, const char* string, const char* end) | ||||
{ | { | ||||
struct NVGstate* state = nvg__getState(ctx); | struct NVGstate* state = nvg__getState(ctx); | ||||
struct NVGpaint paint; | |||||
struct FONStextIter iter; | struct FONStextIter iter; | ||||
struct FONSquad q; | struct FONSquad q; | ||||
struct NVGvertex* verts; | struct NVGvertex* verts; | ||||
@@ -1672,7 +1673,9 @@ float nvgText(struct NVGcontext* ctx, float x, float y, const char* string, cons | |||||
} | } | ||||
// Render triangles. | // Render triangles. | ||||
ctx->params.renderTriangles(ctx->params.userPtr, &state->fill, &state->scissor, ctx->fontImage, verts, nverts); | |||||
paint = state->fill; | |||||
paint.image = ctx->fontImage; | |||||
ctx->params.renderTriangles(ctx->params.userPtr, &paint, &state->scissor, verts, nverts); | |||||
ctx->drawCallCount++; | ctx->drawCallCount++; | ||||
ctx->textTriCount += nverts/3; | ctx->textTriCount += nverts/3; | ||||
@@ -415,9 +415,9 @@ struct NVGparams { | |||||
int (*renderGetTextureSize)(void* uptr, int image, int* w, int* h); | int (*renderGetTextureSize)(void* uptr, int image, int* w, int* h); | ||||
void (*renderViewport)(void* uptr, int width, int height); | void (*renderViewport)(void* uptr, int width, int height); | ||||
void (*renderFlush)(void* uptr); | void (*renderFlush)(void* uptr); | ||||
void (*renderFill)(void* uptr, struct NVGpaint* paint, struct NVGscissor* scissor, float aasize, const float* bounds, const struct NVGpath* paths, int npaths); | |||||
void (*renderStroke)(void* uptr, struct NVGpaint* paint, struct NVGscissor* scissor, float aasize, float strokeWidth, const struct NVGpath* paths, int npaths); | |||||
void (*renderTriangles)(void* uptr, struct NVGpaint* paint, struct NVGscissor* scissor, int image, const struct NVGvertex* verts, int nverts); | |||||
void (*renderFill)(void* uptr, struct NVGpaint* paint, struct NVGscissor* scissor, const float* bounds, const struct NVGpath* paths, int npaths); | |||||
void (*renderStroke)(void* uptr, struct NVGpaint* paint, struct NVGscissor* scissor, float strokeWidth, const struct NVGpath* paths, int npaths); | |||||
void (*renderTriangles)(void* uptr, struct NVGpaint* paint, struct NVGscissor* scissor, const struct NVGvertex* verts, int nverts); | |||||
void (*renderDelete)(void* uptr); | void (*renderDelete)(void* uptr); | ||||
}; | }; | ||||
@@ -560,8 +560,7 @@ static void glnvg__xformToMat3x3(float* m3, float* t) | |||||
m3[8] = 1.0f; | m3[8] = 1.0f; | ||||
} | } | ||||
static int glnvg__setupPaint(struct GLNVGcontext* gl, struct NVGpaint* paint, struct NVGscissor* scissor, | |||||
float width, float aasize) | |||||
static int glnvg__setupPaint(struct GLNVGcontext* gl, struct NVGpaint* paint, struct NVGscissor* scissor, float width) | |||||
{ | { | ||||
float innerCol[4]; | float innerCol[4]; | ||||
float outerCol[4]; | float outerCol[4]; | ||||
@@ -601,7 +600,7 @@ static int glnvg__setupPaint(struct GLNVGcontext* gl, struct NVGpaint* paint, st | |||||
glUniform2f(gl->shader.loc[GLNVG_LOC_SCISSORSCALE], scissorsx, scissorsy); | glUniform2f(gl->shader.loc[GLNVG_LOC_SCISSORSCALE], scissorsx, scissorsy); | ||||
glUniformMatrix3fv(gl->shader.loc[GLNVG_LOC_PAINTMAT], 1, GL_FALSE, paintMat); | glUniformMatrix3fv(gl->shader.loc[GLNVG_LOC_PAINTMAT], 1, GL_FALSE, paintMat); | ||||
glUniform2f(gl->shader.loc[GLNVG_LOC_EXTENT], paint->extent[0], paint->extent[1]); | glUniform2f(gl->shader.loc[GLNVG_LOC_EXTENT], paint->extent[0], paint->extent[1]); | ||||
glUniform1f(gl->shader.loc[GLNVG_LOC_STROKEMULT], width*0.5f + aasize*0.5f); | |||||
glUniform1f(gl->shader.loc[GLNVG_LOC_STROKEMULT], width*0.5f + 0.5f); | |||||
glUniform1i(gl->shader.loc[GLNVG_LOC_TEX], 0); | glUniform1i(gl->shader.loc[GLNVG_LOC_TEX], 0); | ||||
glUniform1i(gl->shader.loc[GLNVG_LOC_TEXTYPE], tex->type == NVG_TEXTURE_RGBA ? 0 : 1); | glUniform1i(gl->shader.loc[GLNVG_LOC_TEXTYPE], tex->type == NVG_TEXTURE_RGBA ? 0 : 1); | ||||
glnvg__checkError("tex paint loc"); | glnvg__checkError("tex paint loc"); | ||||
@@ -620,7 +619,7 @@ static int glnvg__setupPaint(struct GLNVGcontext* gl, struct NVGpaint* paint, st | |||||
glUniform1f(gl->shader.loc[GLNVG_LOC_FEATHER], paint->feather); | glUniform1f(gl->shader.loc[GLNVG_LOC_FEATHER], paint->feather); | ||||
glUniform4fv(gl->shader.loc[GLNVG_LOC_INNERCOL], 1, innerCol); | glUniform4fv(gl->shader.loc[GLNVG_LOC_INNERCOL], 1, innerCol); | ||||
glUniform4fv(gl->shader.loc[GLNVG_LOC_OUTERCOL], 1, outerCol); | glUniform4fv(gl->shader.loc[GLNVG_LOC_OUTERCOL], 1, outerCol); | ||||
glUniform1f(gl->shader.loc[GLNVG_LOC_STROKEMULT], width*0.5f + aasize*0.5f); | |||||
glUniform1f(gl->shader.loc[GLNVG_LOC_STROKEMULT], width*0.5f + 0.5f); | |||||
glnvg__checkError("grad paint loc"); | glnvg__checkError("grad paint loc"); | ||||
} | } | ||||
return 1; | return 1; | ||||
@@ -666,7 +665,7 @@ static void glnvg__uploadPaths(const struct NVGpath* paths, int npaths) | |||||
} | } | ||||
} | } | ||||
static void glnvg__renderFill(void* uptr, struct NVGpaint* paint, struct NVGscissor* scissor, float aasize, | |||||
static void glnvg__renderFill(void* uptr, struct NVGpaint* paint, struct NVGscissor* scissor, | |||||
const float* bounds, const struct NVGpath* paths, int npaths) | const float* bounds, const struct NVGpath* paths, int npaths) | ||||
{ | { | ||||
struct GLNVGcontext* gl = (struct GLNVGcontext*)uptr; | struct GLNVGcontext* gl = (struct GLNVGcontext*)uptr; | ||||
@@ -687,7 +686,7 @@ static void glnvg__renderFill(void* uptr, struct NVGpaint* paint, struct NVGscis | |||||
glEnableVertexAttribArray(0); | glEnableVertexAttribArray(0); | ||||
glEnableVertexAttribArray(1); | glEnableVertexAttribArray(1); | ||||
glnvg__setupPaint(gl, paint, scissor, 1.0001f, aasize); | |||||
glnvg__setupPaint(gl, paint, scissor, 1.0001f); | |||||
glDisable(GL_CULL_FACE); | glDisable(GL_CULL_FACE); | ||||
n = 0; | n = 0; | ||||
@@ -758,7 +757,7 @@ static void glnvg__renderFill(void* uptr, struct NVGpaint* paint, struct NVGscis | |||||
glEnable(GL_BLEND); | glEnable(GL_BLEND); | ||||
glEnableVertexAttribArray(1); | glEnableVertexAttribArray(1); | ||||
glnvg__setupPaint(gl, paint, scissor, 1.0001f, aasize); | |||||
glnvg__setupPaint(gl, paint, scissor, 1.0001f); | |||||
if (gl->edgeAntiAlias) { | if (gl->edgeAntiAlias) { | ||||
glStencilFunc(GL_EQUAL, 0x00, 0xff); | glStencilFunc(GL_EQUAL, 0x00, 0xff); | ||||
@@ -799,7 +798,7 @@ static void glnvg__renderFill(void* uptr, struct NVGpaint* paint, struct NVGscis | |||||
} | } | ||||
} | } | ||||
static void glnvg__renderStroke(void* uptr, struct NVGpaint* paint, struct NVGscissor* scissor, float aasize, | |||||
static void glnvg__renderStroke(void* uptr, struct NVGpaint* paint, struct NVGscissor* scissor, | |||||
float width, const struct NVGpath* paths, int npaths) | float width, const struct NVGpath* paths, int npaths) | ||||
{ | { | ||||
struct GLNVGcontext* gl = (struct GLNVGcontext*)uptr; | struct GLNVGcontext* gl = (struct GLNVGcontext*)uptr; | ||||
@@ -809,7 +808,7 @@ static void glnvg__renderStroke(void* uptr, struct NVGpaint* paint, struct NVGsc | |||||
if (gl->shader.prog == 0) | if (gl->shader.prog == 0) | ||||
return; | return; | ||||
glnvg__setupPaint(gl, paint, scissor, width, aasize); | |||||
glnvg__setupPaint(gl, paint, scissor, width); | |||||
glEnable(GL_CULL_FACE); | glEnable(GL_CULL_FACE); | ||||
@@ -838,11 +837,11 @@ static void glnvg__renderStroke(void* uptr, struct NVGpaint* paint, struct NVGsc | |||||
glUseProgram(0); | glUseProgram(0); | ||||
} | } | ||||
static void glnvg__renderTriangles(void* uptr, struct NVGpaint* paint, struct NVGscissor* scissor, int image, | |||||
static void glnvg__renderTriangles(void* uptr, struct NVGpaint* paint, struct NVGscissor* scissor, | |||||
const struct NVGvertex* verts, int nverts) | const struct NVGvertex* verts, int nverts) | ||||
{ | { | ||||
struct GLNVGcontext* gl = (struct GLNVGcontext*)uptr; | struct GLNVGcontext* gl = (struct GLNVGcontext*)uptr; | ||||
struct GLNVGtexture* tex = glnvg__findTexture(gl, image); | |||||
struct GLNVGtexture* tex = glnvg__findTexture(gl, paint->image); | |||||
float color[4]; | float color[4]; | ||||
NVG_NOTUSED(scissor); | NVG_NOTUSED(scissor); | ||||
@@ -566,8 +566,7 @@ static void glnvg__xformToMat3x3(float* m3, float* t) | |||||
m3[8] = 1.0f; | m3[8] = 1.0f; | ||||
} | } | ||||
static int glnvg__setupPaint(struct GLNVGcontext* gl, struct NVGpaint* paint, struct NVGscissor* scissor, | |||||
float width, float aasize) | |||||
static int glnvg__setupPaint(struct GLNVGcontext* gl, struct NVGpaint* paint, struct NVGscissor* scissor, float width) | |||||
{ | { | ||||
float innerCol[4]; | float innerCol[4]; | ||||
float outerCol[4]; | float outerCol[4]; | ||||
@@ -607,7 +606,7 @@ static int glnvg__setupPaint(struct GLNVGcontext* gl, struct NVGpaint* paint, st | |||||
glUniform2f(gl->shader.loc[GLNVG_LOC_SCISSORSCALE], scissorsx, scissorsy); | glUniform2f(gl->shader.loc[GLNVG_LOC_SCISSORSCALE], scissorsx, scissorsy); | ||||
glUniformMatrix3fv(gl->shader.loc[GLNVG_LOC_PAINTMAT], 1, GL_FALSE, paintMat); | glUniformMatrix3fv(gl->shader.loc[GLNVG_LOC_PAINTMAT], 1, GL_FALSE, paintMat); | ||||
glUniform2f(gl->shader.loc[GLNVG_LOC_EXTENT], paint->extent[0], paint->extent[1]); | glUniform2f(gl->shader.loc[GLNVG_LOC_EXTENT], paint->extent[0], paint->extent[1]); | ||||
glUniform1f(gl->shader.loc[GLNVG_LOC_STROKEMULT], width*0.5f + aasize*0.5f); | |||||
glUniform1f(gl->shader.loc[GLNVG_LOC_STROKEMULT], width*0.5f + 0.5f); | |||||
glUniform1i(gl->shader.loc[GLNVG_LOC_TEX], 0); | glUniform1i(gl->shader.loc[GLNVG_LOC_TEX], 0); | ||||
glUniform1i(gl->shader.loc[GLNVG_LOC_TEXTYPE], tex->type == NVG_TEXTURE_RGBA ? 0 : 1); | glUniform1i(gl->shader.loc[GLNVG_LOC_TEXTYPE], tex->type == NVG_TEXTURE_RGBA ? 0 : 1); | ||||
glnvg__checkError("tex paint loc"); | glnvg__checkError("tex paint loc"); | ||||
@@ -626,7 +625,7 @@ static int glnvg__setupPaint(struct GLNVGcontext* gl, struct NVGpaint* paint, st | |||||
glUniform1f(gl->shader.loc[GLNVG_LOC_FEATHER], paint->feather); | glUniform1f(gl->shader.loc[GLNVG_LOC_FEATHER], paint->feather); | ||||
glUniform4fv(gl->shader.loc[GLNVG_LOC_INNERCOL], 1, innerCol); | glUniform4fv(gl->shader.loc[GLNVG_LOC_INNERCOL], 1, innerCol); | ||||
glUniform4fv(gl->shader.loc[GLNVG_LOC_OUTERCOL], 1, outerCol); | glUniform4fv(gl->shader.loc[GLNVG_LOC_OUTERCOL], 1, outerCol); | ||||
glUniform1f(gl->shader.loc[GLNVG_LOC_STROKEMULT], width*0.5f + aasize*0.5f); | |||||
glUniform1f(gl->shader.loc[GLNVG_LOC_STROKEMULT], width*0.5f + 0.5f); | |||||
glnvg__checkError("grad paint loc"); | glnvg__checkError("grad paint loc"); | ||||
} | } | ||||
return 1; | return 1; | ||||
@@ -672,7 +671,7 @@ static void glnvg__uploadPaths(const struct NVGpath* paths, int npaths) | |||||
} | } | ||||
} | } | ||||
static void glnvg__renderFill(void* uptr, struct NVGpaint* paint, struct NVGscissor* scissor, float aasize, | |||||
static void glnvg__renderFill(void* uptr, struct NVGpaint* paint, struct NVGscissor* scissor, | |||||
const float* bounds, const struct NVGpath* paths, int npaths) | const float* bounds, const struct NVGpath* paths, int npaths) | ||||
{ | { | ||||
struct GLNVGcontext* gl = (struct GLNVGcontext*)uptr; | struct GLNVGcontext* gl = (struct GLNVGcontext*)uptr; | ||||
@@ -694,7 +693,7 @@ static void glnvg__renderFill(void* uptr, struct NVGpaint* paint, struct NVGscis | |||||
glEnableVertexAttribArray(0); | glEnableVertexAttribArray(0); | ||||
glEnableVertexAttribArray(1); | glEnableVertexAttribArray(1); | ||||
glnvg__setupPaint(gl, paint, scissor, 1.0001f, aasize); | |||||
glnvg__setupPaint(gl, paint, scissor, 1.0001f); | |||||
glDisable(GL_CULL_FACE); | glDisable(GL_CULL_FACE); | ||||
n = 0; | n = 0; | ||||
@@ -766,7 +765,7 @@ static void glnvg__renderFill(void* uptr, struct NVGpaint* paint, struct NVGscis | |||||
glEnable(GL_BLEND); | glEnable(GL_BLEND); | ||||
glEnableVertexAttribArray(1); | glEnableVertexAttribArray(1); | ||||
glnvg__setupPaint(gl, paint, scissor, 1.0001f, aasize); | |||||
glnvg__setupPaint(gl, paint, scissor, 1.0001f); | |||||
if (gl->edgeAntiAlias) { | if (gl->edgeAntiAlias) { | ||||
glStencilFunc(GL_EQUAL, 0x00, 0xff); | glStencilFunc(GL_EQUAL, 0x00, 0xff); | ||||
@@ -807,7 +806,7 @@ static void glnvg__renderFill(void* uptr, struct NVGpaint* paint, struct NVGscis | |||||
} | } | ||||
} | } | ||||
static void glnvg__renderStroke(void* uptr, struct NVGpaint* paint, struct NVGscissor* scissor, float aasize, | |||||
static void glnvg__renderStroke(void* uptr, struct NVGpaint* paint, struct NVGscissor* scissor, | |||||
float width, const struct NVGpath* paths, int npaths) | float width, const struct NVGpath* paths, int npaths) | ||||
{ | { | ||||
struct GLNVGcontext* gl = (struct GLNVGcontext*)uptr; | struct GLNVGcontext* gl = (struct GLNVGcontext*)uptr; | ||||
@@ -817,7 +816,7 @@ static void glnvg__renderStroke(void* uptr, struct NVGpaint* paint, struct NVGsc | |||||
if (gl->shader.prog == 0) | if (gl->shader.prog == 0) | ||||
return; | return; | ||||
glnvg__setupPaint(gl, paint, scissor, width, aasize); | |||||
glnvg__setupPaint(gl, paint, scissor, width); | |||||
glEnable(GL_CULL_FACE); | glEnable(GL_CULL_FACE); | ||||
@@ -847,11 +846,11 @@ static void glnvg__renderStroke(void* uptr, struct NVGpaint* paint, struct NVGsc | |||||
glUseProgram(0); | glUseProgram(0); | ||||
} | } | ||||
static void glnvg__renderTriangles(void* uptr, struct NVGpaint* paint, struct NVGscissor* scissor, int image, | |||||
static void glnvg__renderTriangles(void* uptr, struct NVGpaint* paint, struct NVGscissor* scissor, | |||||
const struct NVGvertex* verts, int nverts) | const struct NVGvertex* verts, int nverts) | ||||
{ | { | ||||
struct GLNVGcontext* gl = (struct GLNVGcontext*)uptr; | struct GLNVGcontext* gl = (struct GLNVGcontext*)uptr; | ||||
struct GLNVGtexture* tex = glnvg__findTexture(gl, image); | |||||
struct GLNVGtexture* tex = glnvg__findTexture(gl, paint->image); | |||||
float color[4]; | float color[4]; | ||||
NVG_NOTUSED(scissor); | NVG_NOTUSED(scissor); | ||||