Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 47e9b08

Browse files
chinmaygardednfield
authored andcommitted
Use 8bpp glyph atlases. (#96)
Also remove the debugging goop as that's only relevant if you can visualize the background.
1 parent a6b0939 commit 47e9b08

File tree

2 files changed

+3
-25
lines changed

2 files changed

+3
-25
lines changed

impeller/entity/shaders/glyph_atlas.frag

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ void main() {
1919
frag_color = texture(
2020
glyph_atlas_sampler,
2121
v_unit_vertex * scale_perspective + offset
22-
) * v_text_color;
22+
).rrrr * v_text_color;
2323
}

impeller/typographer/backends/skia/text_render_context_skia.cc

+2-24
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static std::optional<SkBitmap> CreateAtlasBitmap(const GlyphAtlas& atlas,
105105
size_t atlas_size) {
106106
TRACE_EVENT0("impeller", __FUNCTION__);
107107
SkBitmap bitmap;
108-
auto image_info = SkImageInfo::MakeN32Premul(atlas_size, atlas_size);
108+
auto image_info = SkImageInfo::MakeA8(atlas_size, atlas_size);
109109
if (!bitmap.tryAllocPixels(image_info)) {
110110
return std::nullopt;
111111
}
@@ -131,28 +131,6 @@ static std::optional<SkBitmap> CreateAtlasBitmap(const GlyphAtlas& atlas,
131131

132132
auto glyph_color = SK_ColorWHITE;
133133

134-
#if 0
135-
{
136-
glyph_color = SkColorSetARGB(255, //
137-
std::rand() % 255, //
138-
std::rand() % 255, //
139-
std::rand() % 255 //
140-
);
141-
SkPaint debug_paint;
142-
debug_paint.setARGB(255 / 4, //
143-
std::rand() % 255, //
144-
std::rand() % 255, //
145-
std::rand() % 255 //
146-
);
147-
canvas->drawRect(SkRect::MakeXYWH(location.origin.x, //
148-
location.origin.y, //
149-
location.size.width, //
150-
location.size.height //
151-
),
152-
debug_paint);
153-
}
154-
#endif
155-
156134
SkPaint glyph_paint;
157135
glyph_paint.setColor(glyph_color);
158136
canvas->drawGlyphs(1u, // count
@@ -181,7 +159,7 @@ static std::shared_ptr<Texture> UploadGlyphTextureAtlas(
181159
const auto& pixmap = bitmap.pixmap();
182160

183161
TextureDescriptor texture_descriptor;
184-
texture_descriptor.format = PixelFormat::kR8G8B8A8UNormInt;
162+
texture_descriptor.format = PixelFormat::kR8UNormInt;
185163
texture_descriptor.size = ISize::MakeWH(atlas_size, atlas_size);
186164

187165
if (pixmap.rowBytes() * pixmap.height() !=

0 commit comments

Comments
 (0)