Remove font renderer debug code

This commit is contained in:
Francesco Abbate 2020-06-09 16:55:26 +02:00
parent 047039a750
commit 18865fd32f
3 changed files with 0 additions and 79 deletions

View File

@ -208,9 +208,6 @@ int FontRendererBakeFontBitmap(FontRenderer *font_renderer, int font_height,
glyph_info.yoff = -pad_y;
glyph_info.xadvance = (x_next - x) / subpixel_scale;
#ifdef FONT_RENDERER_DEBUG
glyph_info.ybaseline = pixels_height - 1 - y_baseline;
#endif
if (glyph_info.x1 > glyph_info.x0) {
glyph_lut_convolution(ren_buf, lcd_lut, cover_swap_buffer, glyph_info);
}

View File

@ -11,9 +11,6 @@ extern "C" {
typedef struct {
unsigned short x0, y0, x1, y1;
float xoff, yoff, xadvance;
#ifdef FONT_RENDERER_DEBUG
int ybaseline;
#endif
} GlyphBitmapInfo;
struct FontRendererImpl;

View File

@ -126,51 +126,6 @@ void ren_free_coverage(RenCoverageImage *coverage) {
free(coverage);
}
#ifdef FONT_RENDERER_DEBUG
void debug_bitmap_draw_rect(RenImage *image, GlyphBitmapInfo *glyph) {
const int subpixel = 3;
const int x0 = glyph->x0, x1 = glyph->x1;
const int y0 = glyph->y0, y1 = glyph->y1;
const int w = image->width;
RenColor *c = image->pixels + y0 * w;
for (int x = x0 * subpixel; x < x1 * subpixel; x++) {
c[x].g = c[x].g >> 1;
c[x].b = c[x].b >> 1;
}
c = image->pixels + x1 * subpixel;
for (int y = y0; y < y1; y++) {
c[y * w].g = c[y * w].g >> 1;
c[y * w].b = c[y * w].b >> 1;
}
c = image->pixels + y1 * w;
for (int x = x0 * subpixel; x < x1 * subpixel; x++) {
c[x].g = c[x].g >> 1;
c[x].b = c[x].b >> 1;
}
c = image->pixels + x0 * subpixel;
for (int y = y0 + 1; y < y1; y++) {
c[y * w].g = c[y * w].g >> 1;
c[y * w].b = c[y * w].b >> 1;
}
c = image->pixels + glyph->ybaseline * w;
for (int x = x0 * subpixel; x < x1 * subpixel; x++) {
c[x].g = c[x].g >> 1;
c[x].r = c[x].r >> 1;
}
const int x_or = x0 - glyph->xoff, y_or = y0 - glyph->yoff;
c = image->pixels + y_or * w;
for (int x = x_or * subpixel; x < x1 * subpixel; x++) {
c[x].b = c[x].b >> 1;
c[x].r = c[x].r >> 1;
}
c = image->pixels + x_or * subpixel;
for (int y = y_or; y < y1; y++) {
c[y * w].b = c[y * w].b >> 1;
c[y * w].r = c[y * w].r >> 1;
}
}
#endif
static GlyphSet* load_glyphset(RenFont *font, int idx) {
GlyphSet *set = check_alloc(calloc(1, sizeof(GlyphSet)));
@ -194,34 +149,6 @@ retry:
goto retry;
}
#ifdef FONT_RENDERER_DEBUG
static int debug_image_index = 1;
if (idx == 0) {
RenImage *debug_cov_image = ren_new_image(width * subpixel_scale, height);
for (int h = 0; h < height; h++) {
RenColor *d = debug_cov_image->pixels + h * width * subpixel_scale;
uint8_t *s = set->coverage->pixels + h * subpixel_scale * width;
for (int w = 0; w < width * subpixel_scale; w++) {
uint8_t cover = s[w];
d[w] = (RenColor) {.b = 0xff - cover, .g = 0xff - cover, .r = 0xff - cover, .a = 0xff};
}
}
for (int i = 0; i < 256; i++) {
debug_bitmap_draw_rect(debug_cov_image, &set->glyphs[i]);
}
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
debug_cov_image->pixels,
width * subpixel_scale, height, 32, width * subpixel_scale * 4,
SDL_PIXELFORMAT_RGBA32);
char img_filename[64];
sprintf(img_filename, "agg-glyphset-%03d.bmp", debug_image_index);
SDL_SaveBMP(surface, img_filename);
SDL_FreeSurface(surface);
ren_free_image(debug_cov_image);
debug_image_index++;
}
#endif
/* adjust glyph's xadvance */
for (int i = 0; i < 256; i++) {
set->glyphs[i].xadvance = floor(set->glyphs[i].xadvance + 0.5);