21 enum class Type { TRIANGLE, LINE, LINE0, LINE_BUTT, GLYPH,
CIRCLE, ARC, ARC0, N_TYPES };
22 static_assert(
static_cast<int>(Type::N_TYPES) <= 8);
23 const std::map<int, vector_pair<Triangle, TriangleInfo>> &triangles;
30 unsigned int hash()
const
32 return (
static_cast<unsigned int>(type) & 0x7) | (highlight << 3) | (stencil << 4);
35 static BatchKey unhash(
unsigned int h)
37 return BatchKey{
static_cast<Type
>(h & 0x7), !!(h & (1 << 3)), !!(h & (1 << 4))};
40 static constexpr unsigned int hash_max = 0x7 | (1 << 3) | (1 << 4);
41 static_assert(hash_max == 0b11'111);
46 return std::tie(type, highlight, stencil);
50 bool operator<(
const BatchKey &other)
const
52 return tie() < other.tie();
54 bool operator==(
const BatchKey &other)
const
56 return tie() == other.tie();
65 std::map<int, std::map<BatchKey, Span>> layer_offsets;
70 GLuint program_line_butt;
71 GLuint program_triangle;
72 GLuint program_circle;
82 enum class HighlightMode { SKIP, ONLY };
83 void render_layer(
int layer, HighlightMode highlight_mode,
bool ignore_flip =
false);
84 using Batch = std::vector<
decltype(layer_offsets)::mapped_type::value_type>;
85 void render_layer_batch(
int layer, HighlightMode highlight_mode,
bool ignore_flip,
const Batch &batch,
86 bool use_stencil,
bool stencil_mode);
87 void render_annotations(
bool top);
88 std::array<float, 4> apply_highlight(
const class Color &color, HighlightMode mode,
int layer)
const;
91 std::array<std::vector<unsigned int>, BatchKey::hash_max + 1> type_indices;