@@ -67,7 +67,7 @@ bool TextContents::Render(const ContentContext& renderer,
6767
6868 // Information shared by all glyph draw calls.
6969 Command cmd;
70- cmd.label = " TextRun " ;
70+ cmd.label = " TextFrame " ;
7171 cmd.primitive_type = PrimitiveType::kTriangle ;
7272 cmd.pipeline =
7373 renderer.GetGlyphAtlasPipeline (OptionsFromPassAndEntity (pass, entity));
@@ -91,13 +91,11 @@ bool TextContents::Render(const ContentContext& renderer,
9191 );
9292
9393 // 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.
10199 {
102100 VertexBufferBuilder<VS::PerVertexData> vertex_builder;
103101 if (!Tessellator{}.Tessellate (
@@ -127,17 +125,9 @@ bool TextContents::Render(const ContentContext& renderer,
127125 std::vector<Point> atlas_positions;
128126 std::vector<Point> atlas_glyph_sizes;
129127
130- // Iterate through all the runs in the blob.
131128 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-
138129 auto font = run.GetFont ();
139130 auto glyph_size = ISize::Ceil (font.GetMetrics ().GetBoundingBox ().size );
140- // Draw each glyph individually. This should probably be batched.
141131 for (const auto & glyph_position : run.GetGlyphPositions ()) {
142132 FontGlyphPair font_glyph_pair{font, glyph_position.glyph };
143133 auto atlas_glyph_pos = atlas->FindFontGlyphPosition (font_glyph_pair);
@@ -154,21 +144,20 @@ bool TextContents::Render(const ContentContext& renderer,
154144 atlas_glyph_sizes.emplace_back (
155145 Point{atlas_glyph_pos->size .width , atlas_glyph_pos->size .height });
156146 }
147+ }
157148
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 ;
172161 }
173162
174163 return true ;
0 commit comments