mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 10:35:43 -05:00
Updated NanoVG.
This commit is contained in:
parent
b09bb61548
commit
46822b242a
5 changed files with 32 additions and 41 deletions
|
@ -532,7 +532,7 @@ struct Imgui
|
|||
fs_imgui_image = bgfx::makeRef(fs_imgui_image_dx11, sizeof(fs_imgui_image_dx11) );
|
||||
fs_imgui_image_swizz = bgfx::makeRef(fs_imgui_image_swizz_dx11, sizeof(fs_imgui_image_swizz_dx11) );
|
||||
break;
|
||||
|
||||
|
||||
case bgfx::RendererType::Metal:
|
||||
vs_imgui_color = bgfx::makeRef(vs_imgui_color_mtl, sizeof(vs_imgui_color_mtl) );
|
||||
fs_imgui_color = bgfx::makeRef(fs_imgui_color_mtl, sizeof(fs_imgui_color_mtl) );
|
||||
|
@ -838,7 +838,7 @@ struct Imgui
|
|||
const int32_t my = int32_t(float(_my)*yscale);
|
||||
|
||||
IMGUI_beginFrame(mx, my, _button, _scroll, _width, _height, _inputChar, _view);
|
||||
nvgBeginFrameScaled(m_nvg, m_viewWidth, m_viewHeight, m_surfaceWidth, m_surfaceHeight, 1.0f);
|
||||
nvgBeginFrame(m_nvg, m_viewWidth, m_viewHeight, 1.0f);
|
||||
nvgViewId(m_nvg, _view);
|
||||
|
||||
bgfx::setViewName(_view, "IMGUI");
|
||||
|
|
|
@ -41,9 +41,9 @@ enum FONSalign {
|
|||
enum FONSerrorCode {
|
||||
// Font atlas is full.
|
||||
FONS_ATLAS_FULL = 1,
|
||||
// Scratch memory used to render glyphs is full, requested size reported in 'val', you may need to bump up FONS_SCRATCH_BUF_SIZE.
|
||||
// Scratch memory used to render glyphs is full, requested size reported in 'val', you may need to bump up FONS_SCRATCH_BUF_SIZE.
|
||||
FONS_SCRATCH_FULL = 2,
|
||||
// Calls to fonsPushState has craeted too large stack, if you need deep state stack bump up FONS_MAX_STATES.
|
||||
// Calls to fonsPushState has created too large stack, if you need deep state stack bump up FONS_MAX_STATES.
|
||||
FONS_STATES_OVERFLOW = 3,
|
||||
// Trying to pop too many states fonsPopState().
|
||||
FONS_STATES_UNDERFLOW = 4,
|
||||
|
@ -594,7 +594,7 @@ static int fons__atlasAddSkylineLevel(FONSatlas* atlas, int idx, int x, int y, i
|
|||
if (fons__atlasInsertNode(atlas, idx, x, y+h, w) == 0)
|
||||
return 0;
|
||||
|
||||
// Delete skyline segments that fall under the shaodw of the new segment.
|
||||
// Delete skyline segments that fall under the shadow of the new segment.
|
||||
for (i = idx+1; i < atlas->nnodes; i++) {
|
||||
if (atlas->nodes[i].x < atlas->nodes[i-1].x + atlas->nodes[i-1].width) {
|
||||
int shrink = atlas->nodes[i-1].x + atlas->nodes[i-1].width - atlas->nodes[i].x;
|
||||
|
@ -1131,7 +1131,7 @@ static void fons__getQuad(FONScontext* stash, FONSfont* font,
|
|||
|
||||
// Each glyph has 2px border to allow good interpolation,
|
||||
// one pixel to prevent leaking, and one to allow good interpolation for rendering.
|
||||
// Inset the texture region by one pixel for corret interpolation.
|
||||
// Inset the texture region by one pixel for correct interpolation.
|
||||
xoff = (short)(glyph->xoff+1);
|
||||
yoff = (short)(glyph->yoff+1);
|
||||
x0 = (float)(glyph->x0+1);
|
||||
|
@ -1630,7 +1630,7 @@ int fonsExpandAtlas(FONScontext* stash, int width, int height)
|
|||
// Increase atlas size
|
||||
fons__atlasExpand(stash->atlas, width, height);
|
||||
|
||||
// Add axisting data as dirty.
|
||||
// Add existing data as dirty.
|
||||
for (i = 0; i < stash->atlas->nnodes; i++)
|
||||
maxy = fons__maxi(maxy, stash->atlas->nodes[i].y);
|
||||
stash->dirtyRect[0] = 0;
|
||||
|
|
|
@ -59,7 +59,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
|||
#define NVG_INIT_VERTS_SIZE 256
|
||||
#define NVG_MAX_STATES 32
|
||||
|
||||
#define NVG_KAPPA90 0.5522847493f // Lenght proportional to radius of a cubic bezier handle for 90deg arcs.
|
||||
#define NVG_KAPPA90 0.5522847493f // Length proportional to radius of a cubic bezier handle for 90deg arcs.
|
||||
|
||||
#define NVG_COUNTOF(arr) (sizeof(arr) / sizeof(0[arr]))
|
||||
|
||||
|
@ -298,7 +298,7 @@ void nvgDeleteInternal(NVGcontext* ctx)
|
|||
free(ctx);
|
||||
}
|
||||
|
||||
void nvgBeginFrameScaled(NVGcontext* ctx, int windowWidth, int windowHeight, int surfaceWidth, int surfaceHeight, float devicePixelRatio)
|
||||
void nvgBeginFrame(NVGcontext* ctx, int windowWidth, int windowHeight, float devicePixelRatio)
|
||||
{
|
||||
/* printf("Tris: draws:%d fill:%d stroke:%d text:%d TOT:%d\n",
|
||||
ctx->drawCallCount, ctx->fillTriCount, ctx->strokeTriCount, ctx->textTriCount,
|
||||
|
@ -310,7 +310,7 @@ void nvgBeginFrameScaled(NVGcontext* ctx, int windowWidth, int windowHeight, int
|
|||
|
||||
nvg__setDevicePixelRatio(ctx, devicePixelRatio);
|
||||
|
||||
ctx->params.renderViewport(ctx->params.userPtr, windowWidth, windowHeight, surfaceWidth, surfaceHeight);
|
||||
ctx->params.renderViewport(ctx->params.userPtr, windowWidth, windowHeight);
|
||||
|
||||
ctx->drawCallCount = 0;
|
||||
ctx->fillTriCount = 0;
|
||||
|
@ -318,11 +318,6 @@ void nvgBeginFrameScaled(NVGcontext* ctx, int windowWidth, int windowHeight, int
|
|||
ctx->textTriCount = 0;
|
||||
}
|
||||
|
||||
void nvgBeginFrame(NVGcontext* ctx, int windowWidth, int windowHeight, float devicePixelRatio)
|
||||
{
|
||||
nvgBeginFrameScaled(ctx, windowWidth, windowHeight, windowWidth, windowHeight, devicePixelRatio);
|
||||
}
|
||||
|
||||
void nvgCancelFrame(NVGcontext* ctx)
|
||||
{
|
||||
ctx->params.renderCancel(ctx->params.userPtr);
|
||||
|
@ -1642,7 +1637,7 @@ static int nvg__expandStroke(NVGcontext* ctx, float w, int lineCap, int lineJoin
|
|||
for (i = 0; i < cache->npaths; i++) {
|
||||
NVGpath* path = &cache->paths[i];
|
||||
int loop = (path->closed == 0) ? 0 : 1;
|
||||
if (lineCap == NVG_ROUND)
|
||||
if (lineJoin == NVG_ROUND)
|
||||
cverts += (path->count + path->nbevel*(ncap+2) + 1) * 2; // plus one for loop
|
||||
else
|
||||
cverts += (path->count + path->nbevel*5 + 1) * 2; // plus one for loop
|
||||
|
@ -2350,7 +2345,7 @@ float nvgText(NVGcontext* ctx, float x, float y, const char* string, const char*
|
|||
break;
|
||||
}
|
||||
prevIter = iter;
|
||||
// Trasnform corners.
|
||||
// Transform corners.
|
||||
nvgTransformPoint(&c[0],&c[1], state->xform, q.x0*invscale, q.y0*invscale);
|
||||
nvgTransformPoint(&c[2],&c[3], state->xform, q.x1*invscale, q.y0*invscale);
|
||||
nvgTransformPoint(&c[4],&c[5], state->xform, q.x1*invscale, q.y1*invscale);
|
||||
|
@ -2610,7 +2605,7 @@ int nvgTextBreakLines(NVGcontext* ctx, const char* string, const char* end, floa
|
|||
wordStartX = iter.x;
|
||||
wordMinX = q.x0 - rowStartX;
|
||||
} else {
|
||||
// Break the line from the end of the last word, and start new line from the begining of the new.
|
||||
// Break the line from the end of the last word, and start new line from the beginning of the new.
|
||||
rows[nrows].start = rowStart;
|
||||
rows[nrows].end = breakEnd;
|
||||
rows[nrows].width = breakWidth * invscale;
|
||||
|
@ -2640,7 +2635,7 @@ int nvgTextBreakLines(NVGcontext* ctx, const char* string, const char* end, floa
|
|||
ptype = type;
|
||||
}
|
||||
|
||||
// Break the line from the end of the last word, and start new line from the begining of the new.
|
||||
// Break the line from the end of the last word, and start new line from the beginning of the new.
|
||||
if (rowStart != NULL) {
|
||||
rows[nrows].start = rowStart;
|
||||
rows[nrows].end = rowEnd;
|
||||
|
|
|
@ -116,7 +116,6 @@ enum NVGimageFlags {
|
|||
// frame buffer size. In that case you would set windowWidth/Height to the window size
|
||||
// devicePixelRatio to: frameBufferWidth / windowWidth.
|
||||
void nvgBeginFrame(NVGcontext* ctx, int windowWidth, int windowHeight, float devicePixelRatio);
|
||||
void nvgBeginFrameScaled(NVGcontext* ctx, int windowWidth, int windowHeight, int surfaceWidth, int surfaceHeight, float devicePixelRatio);
|
||||
|
||||
// Cancels drawing the current frame.
|
||||
void nvgCancelFrame(NVGcontext* ctx);
|
||||
|
@ -143,7 +142,7 @@ NVGcolor nvgRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned cha
|
|||
NVGcolor nvgRGBAf(float r, float g, float b, float a);
|
||||
|
||||
|
||||
// Linearly interpoaltes from color c0 to c1, and returns resulting color value.
|
||||
// Linearly interpolates from color c0 to c1, and returns resulting color value.
|
||||
NVGcolor nvgLerpRGBA(NVGcolor c0, NVGcolor c1, float u);
|
||||
|
||||
// Sets transparency of a color value.
|
||||
|
@ -192,7 +191,7 @@ void nvgStrokeColor(NVGcontext* ctx, NVGcolor color);
|
|||
// Sets current stroke style to a paint, which can be a one of the gradients or a pattern.
|
||||
void nvgStrokePaint(NVGcontext* ctx, NVGpaint paint);
|
||||
|
||||
// Sets current fill cstyle to a solid color.
|
||||
// Sets current fill style to a solid color.
|
||||
void nvgFillColor(NVGcontext* ctx, NVGcolor color);
|
||||
|
||||
// Sets current fill style to a paint, which can be a one of the gradients or a pattern.
|
||||
|
@ -202,7 +201,7 @@ void nvgFillPaint(NVGcontext* ctx, NVGpaint paint);
|
|||
// Miter limit controls when a sharp corner is beveled.
|
||||
void nvgMiterLimit(NVGcontext* ctx, float limit);
|
||||
|
||||
// Sets the stroke witdth of the stroke style.
|
||||
// Sets the stroke width of the stroke style.
|
||||
void nvgStrokeWidth(NVGcontext* ctx, float size);
|
||||
|
||||
// Sets how the end of the line (cap) is drawn,
|
||||
|
@ -247,16 +246,16 @@ void nvgTransform(NVGcontext* ctx, float a, float b, float c, float d, float e,
|
|||
// Translates current coordinate system.
|
||||
void nvgTranslate(NVGcontext* ctx, float x, float y);
|
||||
|
||||
// Rotates current coordinate system. Angle is specifid in radians.
|
||||
// Rotates current coordinate system. Angle is specified in radians.
|
||||
void nvgRotate(NVGcontext* ctx, float angle);
|
||||
|
||||
// Skews the current coordinate system along X axis. Angle is specifid in radians.
|
||||
// Skews the current coordinate system along X axis. Angle is specified in radians.
|
||||
void nvgSkewX(NVGcontext* ctx, float angle);
|
||||
|
||||
// Skews the current coordinate system along Y axis. Angle is specifid in radians.
|
||||
// Skews the current coordinate system along Y axis. Angle is specified in radians.
|
||||
void nvgSkewY(NVGcontext* ctx, float angle);
|
||||
|
||||
// Scales the current coordinat system.
|
||||
// Scales the current coordinate system.
|
||||
void nvgScale(NVGcontext* ctx, float x, float y);
|
||||
|
||||
// Stores the top part (a-f) of the current transformation matrix in to the specified buffer.
|
||||
|
@ -268,7 +267,7 @@ void nvgCurrentTransform(NVGcontext* ctx, float* xform);
|
|||
|
||||
|
||||
// The following functions can be used to make calculations on 2x3 transformation matrices.
|
||||
// A 2x3 matrix is representated as float[6].
|
||||
// A 2x3 matrix is represented as float[6].
|
||||
|
||||
// Sets the transform to identity matrix.
|
||||
void nvgTransformIdentity(float* dst);
|
||||
|
@ -279,13 +278,13 @@ void nvgTransformTranslate(float* dst, float tx, float ty);
|
|||
// Sets the transform to scale matrix.
|
||||
void nvgTransformScale(float* dst, float sx, float sy);
|
||||
|
||||
// Sets the transform to rotate matrix. Angle is specifid in radians.
|
||||
// Sets the transform to rotate matrix. Angle is specified in radians.
|
||||
void nvgTransformRotate(float* dst, float a);
|
||||
|
||||
// Sets the transform to skew-x matrix. Angle is specifid in radians.
|
||||
// Sets the transform to skew-x matrix. Angle is specified in radians.
|
||||
void nvgTransformSkewX(float* dst, float a);
|
||||
|
||||
// Sets the transform to skew-y matrix. Angle is specifid in radians.
|
||||
// Sets the transform to skew-y matrix. Angle is specified in radians.
|
||||
void nvgTransformSkewY(float* dst, float a);
|
||||
|
||||
// Sets the transform to the result of multiplication of two transforms, of A = A*B.
|
||||
|
@ -301,7 +300,7 @@ int nvgTransformInverse(float* dst, const float* src);
|
|||
// Transform a point by given transform.
|
||||
void nvgTransformPoint(float* dstx, float* dsty, const float* xform, float srcx, float srcy);
|
||||
|
||||
// Converts degress to radians and vice versa.
|
||||
// Converts degrees to radians and vice versa.
|
||||
float nvgDegToRad(float deg);
|
||||
float nvgRadToDeg(float rad);
|
||||
|
||||
|
@ -327,7 +326,7 @@ int nvgCreateImageRGBA(NVGcontext* ctx, int w, int h, int imageFlags, const unsi
|
|||
// Updates image data specified by image handle.
|
||||
void nvgUpdateImage(NVGcontext* ctx, int image, const unsigned char* data);
|
||||
|
||||
// Returns the domensions of a created image.
|
||||
// Returns the dimensions of a created image.
|
||||
void nvgImageSize(NVGcontext* ctx, int image, int* w, int* h);
|
||||
|
||||
// Deletes created image.
|
||||
|
@ -507,7 +506,7 @@ void nvgTextLetterSpacing(NVGcontext* ctx, float spacing);
|
|||
// Sets the proportional line height of current text style. The line height is specified as multiple of font size.
|
||||
void nvgTextLineHeight(NVGcontext* ctx, float lineHeight);
|
||||
|
||||
// Sets the text align of current text style, see NVGaling for options.
|
||||
// Sets the text align of current text style, see NVGalign for options.
|
||||
void nvgTextAlign(NVGcontext* ctx, int align);
|
||||
|
||||
// Sets the font face based on specified id of current text style.
|
||||
|
@ -589,7 +588,7 @@ struct NVGparams {
|
|||
int (*renderDeleteTexture)(void* uptr, int image);
|
||||
int (*renderUpdateTexture)(void* uptr, int image, int x, int y, int w, int h, const unsigned char* data);
|
||||
int (*renderGetTextureSize)(void* uptr, int image, int* w, int* h);
|
||||
void (*renderViewport)(void* uptr, int width, int height, int surfaceWidth, int surfaceHeight);
|
||||
void (*renderViewport)(void* uptr, int width, int height);
|
||||
void (*renderCancel)(void* uptr);
|
||||
void (*renderFlush)(void* uptr);
|
||||
void (*renderFill)(void* uptr, NVGpaint* paint, NVGscissor* scissor, float fringe, const float* bounds, const NVGpath* paths, int npaths);
|
||||
|
@ -603,7 +602,7 @@ NVGcontext* nvgCreate(int edgeaa, unsigned char viewid);
|
|||
void nvgViewId(struct NVGcontext* ctx, unsigned char viewid);
|
||||
void nvgDelete(struct NVGcontext* ctx);
|
||||
|
||||
// Contructor and destructor, called by the render back-end.
|
||||
// Constructor and destructor, called by the render back-end.
|
||||
NVGcontext* nvgCreateInternal(NVGparams* params);
|
||||
void nvgDeleteInternal(NVGcontext* ctx);
|
||||
|
||||
|
|
|
@ -134,7 +134,6 @@ namespace
|
|||
|
||||
struct GLNVGtexture* textures;
|
||||
float view[2];
|
||||
float surface[2];
|
||||
int ntextures;
|
||||
int ctextures;
|
||||
int textureId;
|
||||
|
@ -523,13 +522,11 @@ namespace
|
|||
gl->th = handle;
|
||||
}
|
||||
|
||||
static void nvgRenderViewport(void* _userPtr, int width, int height, int surfaceWidth, int surfaceHeight)
|
||||
static void nvgRenderViewport(void* _userPtr, int width, int height)
|
||||
{
|
||||
struct GLNVGcontext* gl = (struct GLNVGcontext*)_userPtr;
|
||||
gl->view[0] = (float)width;
|
||||
gl->view[1] = (float)height;
|
||||
gl->surface[0] = (float)surfaceWidth;
|
||||
gl->surface[1] = (float)surfaceHeight;
|
||||
bgfx::setViewRect(gl->viewid, 0, 0, width, height);
|
||||
}
|
||||
|
||||
|
@ -721,7 +718,7 @@ namespace
|
|||
);
|
||||
}
|
||||
|
||||
bgfx::setUniform(gl->u_viewSize, gl->surface);
|
||||
bgfx::setUniform(gl->u_viewSize, gl->view);
|
||||
|
||||
for (uint32_t ii = 0, num = gl->ncalls; ii < num; ++ii)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue