mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-24 00:11:14 +01:00
Add hb_gpu_draw_set_scale() API and store x/y scale in the glyph blob header (buf[1].b/a). hb_gpu_draw_glyph() sets it automatically from the font. hb_gpu_render() now reads the scale, computes ppem via fwidth, and automatically blends 4 corner samples at ±1/3 pixel when ppem < 16 to reduce moiré at small sizes. Define HB_GPU_NO_MSAA to disable. Add hb_gpu_ppem() public shader helper so clients can get ppem without touching internal functions (e.g. for hb_gpu_darken). Remove hb_gpu_render_aaa(), u_upem uniform, and set_upem plumbing from the demo — no longer needed. GLSL only for now. Assisted-by: Claude <noreply@anthropic.com>
61 lines
1.4 KiB
C
61 lines
1.4 KiB
C
/*
|
|
* Copyright 2026 Behdad Esfahbod. All Rights Reserved.
|
|
*/
|
|
|
|
#ifndef DEMO_RENDERER_H
|
|
#define DEMO_RENDERER_H
|
|
|
|
#include "demo-common.h"
|
|
#include "demo-shader.h"
|
|
|
|
typedef struct demo_atlas_t demo_atlas_t;
|
|
|
|
|
|
struct demo_renderer_t
|
|
{
|
|
virtual ~demo_renderer_t () {}
|
|
|
|
/* Atlas for glyph data upload. */
|
|
virtual demo_atlas_t *get_atlas () = 0;
|
|
|
|
/* One-time setup after atlas is populated. */
|
|
virtual void setup () = 0;
|
|
|
|
/* Rendering state. */
|
|
virtual void set_gamma (float gamma) = 0;
|
|
virtual void set_foreground (float r, float g, float b, float a) = 0;
|
|
virtual void set_background (float r, float g, float b, float a) = 0;
|
|
virtual void set_debug (bool enabled) = 0;
|
|
virtual void set_stem_darkening (bool enabled) { (void) enabled; }
|
|
|
|
/* sRGB framebuffer control; returns false if unsupported. */
|
|
virtual bool set_srgb (bool enabled) = 0;
|
|
|
|
/* Vsync toggle. */
|
|
virtual void toggle_vsync (bool &vsync) = 0;
|
|
|
|
/* Render a frame. generation changes when buffer content is rebuilt. */
|
|
virtual void display (glyph_vertex_t *vertices, unsigned int count,
|
|
unsigned generation,
|
|
int width, int height, float mat[16]) = 0;
|
|
};
|
|
|
|
|
|
#ifndef HB_GPU_NO_GLFW
|
|
demo_renderer_t *
|
|
demo_renderer_create_gl (GLFWwindow *window);
|
|
|
|
#ifdef __APPLE__
|
|
demo_renderer_t *
|
|
demo_renderer_create_metal (GLFWwindow *window);
|
|
#endif
|
|
|
|
#ifdef _WIN32
|
|
demo_renderer_t *
|
|
demo_renderer_create_d3d11 (GLFWwindow *window);
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#endif /* DEMO_RENDERER_H */
|