@@ -80,6 +80,7 @@ static bool CommonRender(
80
80
SamplerDescriptor sampler_desc;
81
81
sampler_desc.min_filter = MinMagFilter::kLinear ;
82
82
sampler_desc.mag_filter = MinMagFilter::kLinear ;
83
+ sampler_desc.mip_filter = MipFilter::kNone ;
83
84
84
85
typename FS::FragInfo frag_info;
85
86
frag_info.text_color = ToVector (color.Premultiply ());
@@ -103,9 +104,9 @@ static bool CommonRender(
103
104
// interpolated vertex information is also used in the fragment shader to
104
105
// sample from the glyph atlas.
105
106
106
- const std::vector <Point > unit_vertex_points = {
107
- { 0 , 0 }, { 1 , 0 }, {0 , 1 }, {1 , 1 }};
108
- const std::vector <uint32_t > indices = {0 , 1 , 2 , 1 , 2 , 3 };
107
+ const std::array <Point , 4 > unit_points = {Point { 0 , 0 }, Point { 1 , 0 },
108
+ Point {0 , 1 }, Point {1 , 1 }};
109
+ const std::array <uint32_t , 6 > indices = {0 , 1 , 2 , 1 , 2 , 3 };
109
110
110
111
VertexBufferBuilder<typename VS::PerVertexData> vertex_builder;
111
112
@@ -127,7 +128,7 @@ static bool CommonRender(
127
128
128
129
for (const auto & run : frame.GetRuns ()) {
129
130
auto font = run.GetFont ();
130
- auto glyph_size_ = ISize::Ceil ( font.GetMetrics ().GetBoundingBox ().size ) ;
131
+ auto glyph_size_ = font.GetMetrics ().GetBoundingBox ().size ;
131
132
auto glyph_size = Point {static_cast <Scalar>(glyph_size_.width ),
132
133
static_cast <Scalar>(glyph_size_.height )};
133
134
auto metrics_offset =
@@ -141,22 +142,20 @@ static bool CommonRender(
141
142
return false ;
142
143
}
143
144
144
- auto atlas_position =
145
- atlas_glyph_pos->origin + Point {1 / atlas_glyph_pos->size .width ,
146
- 1 / atlas_glyph_pos->size .height };
145
+ auto atlas_position = atlas_glyph_pos->origin ;
147
146
auto atlas_glyph_size =
148
147
Point {atlas_glyph_pos->size .width , atlas_glyph_pos->size .height };
149
148
auto offset_glyph_position = glyph_position.position + metrics_offset;
150
149
151
- for (const auto & point : unit_vertex_points ) {
150
+ for (const auto & point : unit_points ) {
152
151
typename VS::PerVertexData vtx;
153
- vtx.unit_vertex = point;
154
- vtx.glyph_position = offset_glyph_position;
155
- vtx.glyph_size = glyph_size;
156
- vtx.atlas_position = atlas_position;
157
- vtx.atlas_glyph_size = atlas_glyph_size;
152
+ vtx.unit_position = point;
153
+ vtx.destination_position = offset_glyph_position + Point ( 0.5 , 0.5 ) ;
154
+ vtx.destination_size = glyph_size - Point ( 1.0 , 1.0 ) ;
155
+ vtx.source_position = atlas_position + Point ( 0.5 , 0.5 ) ;
156
+ vtx.source_glyph_size = atlas_glyph_size - Point ( 1.0 , 1.0 ) ;
158
157
if constexpr (std::is_same_v<TPipeline, GlyphAtlasPipeline>) {
159
- vtx.color_glyph =
158
+ vtx.has_color =
160
159
glyph_position.glyph .type == Glyph::Type::kBitmap ? 1.0 : 0.0 ;
161
160
}
162
161
vertex_builder.AppendVertex (std::move (vtx));
0 commit comments