Browse Source

Increased SCRATCH_FONS_SCRATCH_BUF_SIZE to 64000

shared-context
Michael Hartmann 9 years ago
parent
commit
6245376103
4 changed files with 6099 additions and 2961 deletions
  1. +6
    -6
      src/fontstash.h
  2. +13
    -10
      src/nanovg.c
  3. +2831
    -864
      src/stb_image.h
  4. +3249
    -2081
      src/stb_truetype.h

+ 6
- 6
src/fontstash.h View File

@@ -41,7 +41,7 @@ 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 created too large stack, if you need deep state stack bump up FONS_MAX_STATES.
FONS_STATES_OVERFLOW = 3,
@@ -90,7 +90,7 @@ void fonsDeleteInternal(FONScontext* s);
void fonsSetErrorCallback(FONScontext* s, void (*callback)(void* uptr, int error, int val), void* uptr);
// Returns current atlas size.
void fonsGetAtlasSize(FONScontext* s, int* width, int* height);
// Expands the atlas size.
// Expands the atlas size.
int fonsExpandAtlas(FONScontext* s, int width, int height);
// Resets the whole stash.
int fonsResetAtlas(FONScontext* stash, int width, int height);
@@ -154,7 +154,7 @@ typedef struct FONSttFontImpl FONSttFontImpl;
static FT_Library ftLibrary;

int fons__tt_init(FONScontext *context)
{
{
FT_Error ftError;
FONS_NOTUSED(context);
ftError = FT_Init_FreeType(&ftLibrary);
@@ -304,7 +304,7 @@ int fons__tt_getGlyphKernAdvance(FONSttFontImpl *font, int glyph1, int glyph2)
#endif

#ifndef FONS_SCRATCH_BUF_SIZE
# define FONS_SCRATCH_BUF_SIZE 16000
# define FONS_SCRATCH_BUF_SIZE 64000
#endif
#ifndef FONS_HASH_LUT_SIZE
# define FONS_HASH_LUT_SIZE 256
@@ -1403,7 +1403,7 @@ void fonsDrawDebug(FONScontext* stash, float x, float y)
}

float fonsTextBounds(FONScontext* stash,
float x, float y,
float x, float y,
const char* str, const char* end,
float* bounds)
{
@@ -1591,7 +1591,7 @@ int fonsExpandAtlas(FONScontext* stash, int width, int height)
height = fons__maxi(height, stash->params.height);

if (width == stash->params.width && height == stash->params.height)
return 1;
return 1;

// Flush pending glyphs.
fons__flush(stash);


+ 13
- 10
src/nanovg.c View File

@@ -18,6 +18,9 @@

#include <stdio.h>
#include <math.h>
#include <malloc.h>
#include <memory.h>

#include "nanovg.h"
#define FONTSTASH_IMPLEMENTATION
#include "fontstash.h"
@@ -291,7 +294,7 @@ void nvgBeginFrame(NVGcontext* ctx, int windowWidth, int windowHeight, float dev
nvgReset(ctx);

nvg__setDevicePixelRatio(ctx, devicePixelRatio);
ctx->params.renderViewport(ctx->params.userPtr, windowWidth, windowHeight);

ctx->drawCallCount = 0;
@@ -391,7 +394,7 @@ NVGcolor nvgLerpRGBA(NVGcolor c0, NVGcolor c1, float u)
{
cint.rgba[i] = c0.rgba[i] * oneminu + c1.rgba[i] * u;
}
return cint;
}

@@ -913,7 +916,7 @@ void nvgIntersectScissor(NVGcontext* ctx, float x, float y, float w, float h)
}

// Transform the current scissor rect into current transform space.
// If there is difference in rotation, this will be approximation.
// If there is difference in rotation, this will be approximation.
memcpy(pxform, state->scissor.xform, sizeof(float)*6);
ex = state->scissor.extent[0];
ey = state->scissor.extent[1];
@@ -1173,7 +1176,7 @@ static void nvg__tesselateBezier(NVGcontext* ctx,
{
float x12,y12,x23,y23,x34,y34,x123,y123,x234,y234,x1234,y1234;
float dx,dy,d2,d3;
if (level > 10) return;

x12 = (x1+x2)*0.5f;
@@ -1205,8 +1208,8 @@ static void nvg__tesselateBezier(NVGcontext* ctx,
x1234 = (x123+x234)*0.5f;
y1234 = (y123+y234)*0.5f;

nvg__tesselateBezier(ctx, x1,y1, x12,y12, x123,y123, x1234,y1234, level+1, 0);
nvg__tesselateBezier(ctx, x1234,y1234, x234,y234, x34,y34, x4,y4, level+1, type);
nvg__tesselateBezier(ctx, x1,y1, x12,y12, x123,y123, x1234,y1234, level+1, 0);
nvg__tesselateBezier(ctx, x1234,y1234, x234,y234, x34,y34, x4,y4, level+1, type);
}

static void nvg__flattenPaths(NVGcontext* ctx)
@@ -1604,7 +1607,7 @@ static void nvg__calculateJoins(NVGcontext* ctx, float w, int lineJoin, float mi


static int nvg__expandStroke(NVGcontext* ctx, float w, int lineCap, int lineJoin, float miterLimit)
{
{
NVGpathCache* cache = ctx->cache;
NVGvertex* verts;
NVGvertex* dst;
@@ -1868,7 +1871,7 @@ void nvgQuadTo(NVGcontext* ctx, float cx, float cy, float x, float y)
{
float x0 = ctx->commandx;
float y0 = ctx->commandy;
float vals[] = { NVG_BEZIERTO,
float vals[] = { NVG_BEZIERTO,
x0 + 2.0f/3.0f*(cx - x0), y0 + 2.0f/3.0f*(cy - y0),
x + 2.0f/3.0f*(cx - x), y + 2.0f/3.0f*(cy - y),
x, y };
@@ -1950,7 +1953,7 @@ void nvgArc(NVGcontext* ctx, float cx, float cy, float r, float a0, float a1, in
float px = 0, py = 0, ptanx = 0, ptany = 0;
float vals[3 + 5*7 + 100];
int i, ndivs, nvals;
int move = ctx->ncommands > 0 ? NVG_LINETO : NVG_MOVETO;
int move = ctx->ncommands > 0 ? NVG_LINETO : NVG_MOVETO;

// Clamp angles
da = a1 - a0;
@@ -2343,7 +2346,7 @@ float nvgText(NVGcontext* ctx, float x, float y, const char* string, const char*
}
}

// TODO: add back-end bit to do this just once per frame.
// TODO: add back-end bit to do this just once per frame.
nvg__flushTextTexture(ctx);

nvg__renderText(ctx, verts, nverts);


+ 2831
- 864
src/stb_image.h
File diff suppressed because it is too large
View File


+ 3249
- 2081
src/stb_truetype.h
File diff suppressed because it is too large
View File


Loading…
Cancel
Save