@@ -67,7 +67,7 @@ bool TextContents::Render(const ContentContext& renderer,
67
67
68
68
// Information shared by all glyph draw calls.
69
69
Command cmd;
70
- cmd.label = " TextRun " ;
70
+ cmd.label = " TextFrame " ;
71
71
cmd.primitive_type = PrimitiveType::kTriangle ;
72
72
cmd.pipeline =
73
73
renderer.GetGlyphAtlasPipeline (OptionsFromPassAndEntity (pass, entity));
@@ -91,13 +91,11 @@ bool TextContents::Render(const ContentContext& renderer,
91
91
);
92
92
93
93
// Common vertex information for all glyphs.
94
- // Currently, glyphs are being drawn individually. This can be batched later.
95
- // But we don't want to give each glyph unique vertex information. So all
96
- // glyphs are given the same vertex information in the form of a unit-sized
97
- // quad. The size of the glyph is specified in uniform data and the vertex
98
- // shader uses this to size the glyph correctly. The interpolated vertex
99
- // information is also used in the fragment shader to sample from the glyph
100
- // atlas.
94
+ // All glyphs are given the same vertex information in the form of a
95
+ // unit-sized quad. The size of the glyph is specified in per instance data
96
+ // and the vertex shader uses this to size the glyph correctly. The
97
+ // interpolated vertex information is also used in the fragment shader to
98
+ // sample from the glyph atlas.
101
99
{
102
100
VertexBufferBuilder<VS::PerVertexData> vertex_builder;
103
101
if (!Tessellator{}.Tessellate (
@@ -127,17 +125,9 @@ bool TextContents::Render(const ContentContext& renderer,
127
125
std::vector<Point > atlas_positions;
128
126
std::vector<Point > atlas_glyph_sizes;
129
127
130
- // Iterate through all the runs in the blob.
131
128
for (const auto & run : frame_.GetRuns ()) {
132
- instance_count = 0u ;
133
- glyph_positions.clear ();
134
- glyph_sizes.clear ();
135
- atlas_positions.clear ();
136
- atlas_glyph_sizes.clear ();
137
-
138
129
auto font = run.GetFont ();
139
130
auto glyph_size = ISize::Ceil (font.GetMetrics ().GetBoundingBox ().size );
140
- // Draw each glyph individually. This should probably be batched.
141
131
for (const auto & glyph_position : run.GetGlyphPositions ()) {
142
132
FontGlyphPair font_glyph_pair{font, glyph_position.glyph };
143
133
auto atlas_glyph_pos = atlas->FindFontGlyphPosition (font_glyph_pair);
@@ -154,21 +144,20 @@ bool TextContents::Render(const ContentContext& renderer,
154
144
atlas_glyph_sizes.emplace_back (
155
145
Point {atlas_glyph_pos->size .width , atlas_glyph_pos->size .height });
156
146
}
147
+ }
157
148
158
- cmd.instance_count = instance_count;
159
- VS::BindGlyphPositions (
160
- cmd, pass.GetTransientsBuffer ().EmplaceStorageBuffer (glyph_positions));
161
- VS::BindGlyphSizes (
162
- cmd, pass.GetTransientsBuffer ().EmplaceStorageBuffer (glyph_sizes));
163
- VS::BindAtlasPositions (
164
- cmd, pass.GetTransientsBuffer ().EmplaceStorageBuffer (atlas_positions));
165
- VS::BindAtlasGlyphSizes (
166
- cmd,
167
- pass.GetTransientsBuffer ().EmplaceStorageBuffer (atlas_glyph_sizes));
168
-
169
- if (!pass.AddCommand (cmd)) {
170
- return false ;
171
- }
149
+ cmd.instance_count = instance_count;
150
+ VS::BindGlyphPositions (
151
+ cmd, pass.GetTransientsBuffer ().EmplaceStorageBuffer (glyph_positions));
152
+ VS::BindGlyphSizes (
153
+ cmd, pass.GetTransientsBuffer ().EmplaceStorageBuffer (glyph_sizes));
154
+ VS::BindAtlasPositions (
155
+ cmd, pass.GetTransientsBuffer ().EmplaceStorageBuffer (atlas_positions));
156
+ VS::BindAtlasGlyphSizes (
157
+ cmd, pass.GetTransientsBuffer ().EmplaceStorageBuffer (atlas_glyph_sizes));
158
+
159
+ if (!pass.AddCommand (cmd)) {
160
+ return false ;
172
161
}
173
162
174
163
return true ;
0 commit comments