Skip to content

Commit

Permalink
Use 8bpp glyph atlases. (flutter#96)
Browse files Browse the repository at this point in the history
Also remove the debugging goop as that's only relevant if you can
visualize the background.
  • Loading branch information
chinmaygarde authored and dnfield committed Apr 27, 2022
1 parent a6b0939 commit 47e9b08
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 25 deletions.
2 changes: 1 addition & 1 deletion impeller/entity/shaders/glyph_atlas.frag
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ void main() {
frag_color = texture(
glyph_atlas_sampler,
v_unit_vertex * scale_perspective + offset
) * v_text_color;
).rrrr * v_text_color;
}
26 changes: 2 additions & 24 deletions impeller/typographer/backends/skia/text_render_context_skia.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static std::optional<SkBitmap> CreateAtlasBitmap(const GlyphAtlas& atlas,
size_t atlas_size) {
TRACE_EVENT0("impeller", __FUNCTION__);
SkBitmap bitmap;
auto image_info = SkImageInfo::MakeN32Premul(atlas_size, atlas_size);
auto image_info = SkImageInfo::MakeA8(atlas_size, atlas_size);
if (!bitmap.tryAllocPixels(image_info)) {
return std::nullopt;
}
Expand All @@ -131,28 +131,6 @@ static std::optional<SkBitmap> CreateAtlasBitmap(const GlyphAtlas& atlas,

auto glyph_color = SK_ColorWHITE;

#if 0
{
glyph_color = SkColorSetARGB(255, //
std::rand() % 255, //
std::rand() % 255, //
std::rand() % 255 //
);
SkPaint debug_paint;
debug_paint.setARGB(255 / 4, //
std::rand() % 255, //
std::rand() % 255, //
std::rand() % 255 //
);
canvas->drawRect(SkRect::MakeXYWH(location.origin.x, //
location.origin.y, //
location.size.width, //
location.size.height //
),
debug_paint);
}
#endif

SkPaint glyph_paint;
glyph_paint.setColor(glyph_color);
canvas->drawGlyphs(1u, // count
Expand Down Expand Up @@ -181,7 +159,7 @@ static std::shared_ptr<Texture> UploadGlyphTextureAtlas(
const auto& pixmap = bitmap.pixmap();

TextureDescriptor texture_descriptor;
texture_descriptor.format = PixelFormat::kR8G8B8A8UNormInt;
texture_descriptor.format = PixelFormat::kR8UNormInt;
texture_descriptor.size = ISize::MakeWH(atlas_size, atlas_size);

if (pixmap.rowBytes() * pixmap.height() !=
Expand Down

0 comments on commit 47e9b08

Please sign in to comment.