Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
font_flight_recorder.hpp
Go to the documentation of this file.
1// font_flight_recorder.hpp
2//
3// FontFlightRecorder is the process-global sink for FallbackTraceRecord
4// events produced by FontResolver every time a typeface resolves. It's a
5// bounded ring buffer; callers (the --font-trace CLI flag, the
6// import-missing-font-advisor, a developer's debug overlay) can drain it to
7// see exactly which font cascade step produced each glyph.
8//
9// The recorder runs always-on with a reasonable default capacity
10// (1024 records) — there's no measurable overhead at typical UI
11// rates and the diagnostic value of "what fonts did the last
12// frame use" is high. Callers that need a different cap can call
13// set_capacity(); 0 disables recording entirely.
14
15#pragma once
16
17#include <cstddef>
18#include <cstdint>
19#include <memory>
20#include <string>
21#include <vector>
22
23namespace pulp::canvas {
24
29 std::string requested_family;
30 std::string selected_family;
31 std::uint8_t origin;
32 std::uint64_t generation;
33 std::uint64_t sequence;
34};
35
36class FontFlightRecorder {
37public:
38 static FontFlightRecorder& instance();
39
43
45 std::vector<FallbackTraceRecord> drain();
46
48 std::vector<FallbackTraceRecord> snapshot() const;
49
51 void clear();
52
55 void set_capacity(std::size_t capacity);
56 std::size_t capacity() const noexcept;
57
59 std::size_t size() const noexcept;
60
61private:
62 FontFlightRecorder();
63 ~FontFlightRecorder();
64 FontFlightRecorder(const FontFlightRecorder&) = delete;
65 FontFlightRecorder& operator=(const FontFlightRecorder&) = delete;
66
67 struct Impl;
68 std::unique_ptr<Impl> impl_;
69};
70
76
77} // namespace pulp::canvas
void clear()
Drop all buffered records.
void set_capacity(std::size_t capacity)
Set the ring-buffer capacity.
std::vector< FallbackTraceRecord > snapshot() const
Snapshot only (does not clear). Returns oldest-first.
static FontFlightRecorder & instance()
std::size_t capacity() const noexcept
std::size_t size() const noexcept
Number of records currently buffered.
std::vector< FallbackTraceRecord > drain()
Snapshot + clear the buffered records. Returns oldest-first.
void record_fallback(const FallbackTraceRecord &record)
Append a resolution event.
Definition affine_transform.hpp:24
std::string flight_recorder_drain_json()
Convenience: drain the global recorder and emit one JSON object per record to out.
STL namespace.
One resolution event.
Definition font_flight_recorder.hpp:28
std::string requested_family
Definition font_flight_recorder.hpp:29
std::uint8_t origin
matches FallbackOrigin enum cast to u8
Definition font_flight_recorder.hpp:31
std::string selected_family
Definition font_flight_recorder.hpp:30
std::uint64_t generation
registry generation at resolve time
Definition font_flight_recorder.hpp:32
std::uint64_t sequence
monotonic per-recorder sequence number
Definition font_flight_recorder.hpp:33