|
|
@@ -432,7 +432,7 @@ void nvgCancelFrame(NVGcontext* ctx)
|
|
|
void nvgEndFrame(NVGcontext* ctx)
|
|
|
{
|
|
|
NVGstate* state = nvg__getState(ctx);
|
|
|
- ctx->params.renderFlush(ctx->params.userPtr, state->compositeOperation);
|
|
|
+ ctx->params.renderFlush(ctx->params.userPtr);
|
|
|
if (ctx->fontImageIdx != 0) {
|
|
|
int fontImage = ctx->fontImages[ctx->fontImageIdx];
|
|
|
int i, j, iw, ih;
|
|
|
@@ -2166,22 +2166,31 @@ void nvgRect(NVGcontext* ctx, float x, float y, float w, float h)
|
|
|
|
|
|
void nvgRoundedRect(NVGcontext* ctx, float x, float y, float w, float h, float r)
|
|
|
{
|
|
|
- if (r < 0.1f) {
|
|
|
- nvgRect(ctx, x,y,w,h);
|
|
|
+ nvgRoundedRectVarying(ctx, x, y, w, h, r, r, r, r);
|
|
|
+}
|
|
|
+
|
|
|
+void nvgRoundedRectVarying(NVGcontext* ctx, float x, float y, float w, float h, float radTopLeft, float radTopRight, float radBottomRight, float radBottomLeft)
|
|
|
+{
|
|
|
+ if(radTopLeft < 0.1f && radTopRight < 0.1f && radBottomRight < 0.1f && radBottomLeft < 0.1f) {
|
|
|
+ nvgRect(ctx, x, y, w, h);
|
|
|
return;
|
|
|
- }
|
|
|
- else {
|
|
|
- float rx = nvg__minf(r, nvg__absf(w)*0.5f) * nvg__signf(w), ry = nvg__minf(r, nvg__absf(h)*0.5f) * nvg__signf(h);
|
|
|
+ } else {
|
|
|
+ float halfw = nvg__absf(w)*0.5f;
|
|
|
+ float halfh = nvg__absf(h)*0.5f;
|
|
|
+ float rxBL = nvg__minf(radBottomLeft, halfw) * nvg__signf(w), ryBL = nvg__minf(radBottomLeft, halfh) * nvg__signf(h);
|
|
|
+ float rxBR = nvg__minf(radBottomRight, halfw) * nvg__signf(w), ryBR = nvg__minf(radBottomRight, halfh) * nvg__signf(h);
|
|
|
+ float rxTR = nvg__minf(radTopRight, halfw) * nvg__signf(w), ryTR = nvg__minf(radTopRight, halfh) * nvg__signf(h);
|
|
|
+ float rxTL = nvg__minf(radTopLeft, halfw) * nvg__signf(w), ryTL = nvg__minf(radTopLeft, halfh) * nvg__signf(h);
|
|
|
float vals[] = {
|
|
|
- NVG_MOVETO, x, y+ry,
|
|
|
- NVG_LINETO, x, y+h-ry,
|
|
|
- NVG_BEZIERTO, x, y+h-ry*(1-NVG_KAPPA90), x+rx*(1-NVG_KAPPA90), y+h, x+rx, y+h,
|
|
|
- NVG_LINETO, x+w-rx, y+h,
|
|
|
- NVG_BEZIERTO, x+w-rx*(1-NVG_KAPPA90), y+h, x+w, y+h-ry*(1-NVG_KAPPA90), x+w, y+h-ry,
|
|
|
- NVG_LINETO, x+w, y+ry,
|
|
|
- NVG_BEZIERTO, x+w, y+ry*(1-NVG_KAPPA90), x+w-rx*(1-NVG_KAPPA90), y, x+w-rx, y,
|
|
|
- NVG_LINETO, x+rx, y,
|
|
|
- NVG_BEZIERTO, x+rx*(1-NVG_KAPPA90), y, x, y+ry*(1-NVG_KAPPA90), x, y+ry,
|
|
|
+ NVG_MOVETO, x, y + ryTL,
|
|
|
+ NVG_LINETO, x, y + h - ryBL,
|
|
|
+ NVG_BEZIERTO, x, y + h - ryBL*(1 - NVG_KAPPA90), x + rxBL*(1 - NVG_KAPPA90), y + h, x + rxBL, y + h,
|
|
|
+ NVG_LINETO, x + w - rxBR, y + h,
|
|
|
+ NVG_BEZIERTO, x + w - rxBR*(1 - NVG_KAPPA90), y + h, x + w, y + h - ryBR*(1 - NVG_KAPPA90), x + w, y + h - ryBR,
|
|
|
+ NVG_LINETO, x + w, y + ryTR,
|
|
|
+ NVG_BEZIERTO, x + w, y + ryTR*(1 - NVG_KAPPA90), x + w - rxTR*(1 - NVG_KAPPA90), y, x + w - rxTR, y,
|
|
|
+ NVG_LINETO, x + rxTL, y,
|
|
|
+ NVG_BEZIERTO, x + rxTL*(1 - NVG_KAPPA90), y, x, y + ryTL*(1 - NVG_KAPPA90), x, y + ryTL,
|
|
|
NVG_CLOSE
|
|
|
};
|
|
|
nvg__appendCommands(ctx, vals, NVG_COUNTOF(vals));
|
|
|
@@ -2245,7 +2254,7 @@ void nvgFill(NVGcontext* ctx)
|
|
|
fillPaint.innerColor.a *= state->alpha;
|
|
|
fillPaint.outerColor.a *= state->alpha;
|
|
|
|
|
|
- ctx->params.renderFill(ctx->params.userPtr, &fillPaint, &state->scissor, ctx->fringeWidth,
|
|
|
+ ctx->params.renderFill(ctx->params.userPtr, &fillPaint, state->compositeOperation, &state->scissor, ctx->fringeWidth,
|
|
|
ctx->cache->bounds, ctx->cache->paths, ctx->cache->npaths);
|
|
|
|
|
|
// Count triangles
|
|
|
@@ -2286,7 +2295,7 @@ void nvgStroke(NVGcontext* ctx)
|
|
|
else
|
|
|
nvg__expandStroke(ctx, strokeWidth*0.5f, state->lineCap, state->lineJoin, state->miterLimit);
|
|
|
|
|
|
- ctx->params.renderStroke(ctx->params.userPtr, &strokePaint, &state->scissor, ctx->fringeWidth,
|
|
|
+ ctx->params.renderStroke(ctx->params.userPtr, &strokePaint, state->compositeOperation, &state->scissor, ctx->fringeWidth,
|
|
|
strokeWidth, ctx->cache->paths, ctx->cache->npaths);
|
|
|
|
|
|
// Count triangles
|
|
|
@@ -2434,7 +2443,7 @@ static void nvg__renderText(NVGcontext* ctx, NVGvertex* verts, int nverts)
|
|
|
paint.innerColor.a *= state->alpha;
|
|
|
paint.outerColor.a *= state->alpha;
|
|
|
|
|
|
- ctx->params.renderTriangles(ctx->params.userPtr, &paint, &state->scissor, verts, nverts);
|
|
|
+ ctx->params.renderTriangles(ctx->params.userPtr, &paint, state->compositeOperation, &state->scissor, verts, nverts);
|
|
|
|
|
|
ctx->drawCallCount++;
|
|
|
ctx->textTriCount += nverts/3;
|