Pulp
1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
psdf_atlas.hpp
Go to the documentation of this file.
1
#pragma once
2
3
// Pseudo-Signed Distance Field (PSDF) atlas.
4
//
5
// A PSDF stores a one-channel distance field like `SdfAtlas` but uses a
6
// cheaper generator (Manhattan/Chebyshev distance rather than true
7
// Euclidean) trading a small amount of corner accuracy for faster
8
// per-glyph generation. That makes it a useful runtime choice for
9
// procedural UIs that build atlases on demand.
10
//
11
// The runtime surface matches `SdfAtlas` so the sampler shader does
12
// not change — only the atlas construction differs.
13
14
#include <
pulp/canvas/sdf_atlas.hpp
>
15
16
namespace
pulp::canvas
{
17
18
// PsdfAtlas is a thin subclass today: it inherits the packing/metrics
19
// pipeline from SdfAtlas and will override the distance-transform step
20
// once the pseudo-distance generator lands. Keeping the same type
21
// surface now lets downstream code pick the generator without an
22
// API break later.
23
class
PsdfAtlas
:
public
SdfAtlas
{
24
public
:
25
PsdfAtlas
() =
default
;
26
};
27
28
// ---------------------------------------------------------------------
29
// Vector-fallback policy
30
// ---------------------------------------------------------------------
31
//
32
// At extreme magnifications (> 8× the atlas base_size) an SDF sampler
33
// can lose high-frequency detail because the nearest-edge encoding is
34
// only as precise as the atlas resolution. Call `should_use_vector_fallback`
35
// to decide whether to bypass the SDF pipeline and draw the glyph via
36
// Skia's path rasterizer for pixel-perfect quality.
37
//
38
// threshold — zoom factor (render_px / base_size) above which to
39
// prefer vector rendering. 8.0 is a sensible default.
40
inline
bool
should_use_vector_fallback
(
float
render_px,
41
float
base_size,
42
float
threshold = 8.0f) {
43
if
(base_size <= 0.0f)
return
false
;
44
return
(render_px / base_size) > threshold;
45
}
46
47
}
// namespace pulp::canvas
pulp::canvas::PsdfAtlas::PsdfAtlas
PsdfAtlas()=default
pulp::canvas::SdfAtlas::SdfAtlas
SdfAtlas()
pulp::canvas
Definition
affine_transform.hpp:24
pulp::canvas::should_use_vector_fallback
bool should_use_vector_fallback(float render_px, float base_size, float threshold=8.0f)
Definition
psdf_atlas.hpp:40
sdf_atlas.hpp
core
canvas
include
pulp
canvas
psdf_atlas.hpp
Generated by
1.15.0