Move rendering buffers pointers computations inside FontRendererBlendGammaSubpixel

The logic is to disentangle the code between renderer.c and FontRenderer
so that this latter has a simple, logical interface.
This commit is contained in:
Francesco Abbate
2020-06-11 17:33:57 +02:00
parent 18865fd32f
commit ce664f85b1
3 changed files with 82 additions and 74 deletions
+20 -6
View File
@@ -7,12 +7,19 @@
extern "C" {
#endif
// Mirrors stbtt_bakedchar.
typedef struct {
unsigned short x0, y0, x1, y1;
float xoff, yoff, xadvance;
} GlyphBitmapInfo;
// Important: when a subpixel scale is used the width below will be the width in logical pixel.
// As each logical pixel contains 3 subpixels it means that the 'pixels' pointer
// will hold enough space for '3 * width' uint8_t values.
typedef struct {
uint8_t *pixels;
int width, height;
} FontRendererBitmap;
struct FontRendererImpl;
typedef struct FontRendererImpl FontRenderer;
@@ -26,6 +33,10 @@ typedef struct {
uint8_t r, g, b;
} FontRendererColor;
typedef struct {
int left, top, right, bottom;
} FontRendererClipArea;
FontRenderer * FontRendererNew(unsigned int flags, float gamma);
void FontRendererFree(FontRenderer *);
@@ -39,17 +50,20 @@ int FontRendererBakeFontBitmap(FontRenderer *, int font_height,
int first_char, int num_chars, GlyphBitmapInfo *glyph_info,
int subpixel_scale);
#if 0
// FIXME: this function needs to be updated to match BlendGammaSubpixel.
void FontRendererBlendGamma(FontRenderer *,
uint8_t *dst, int dst_stride,
uint8_t *src, int src_stride,
int region_width, int region_height,
FontRendererColor color);
#endif
void FontRendererBlendGammaSubpixel(FontRenderer *,
uint8_t *dst, int dst_stride,
uint8_t *src, int src_stride,
int region_width, int region_height,
FontRendererColor color);
void FontRendererBlendGammaSubpixel(FontRenderer *font_renderer,
FontRendererClipArea *clip, int x, int y,
uint8_t *dst, int dst_width,
const FontRendererBitmap *glyphs_bitmap,
const GlyphBitmapInfo *glyph, FontRendererColor color);
#ifdef __cplusplus
}