Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions impeller/aiks/aiks_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,8 @@ bool RenderTextInCanvas(const std::shared_ptr<Context>& context,
Canvas& canvas,
const std::string& text,
const std::string& font_fixture,
Scalar font_size = 50.0) {
Scalar font_size = 50.0,
Scalar alpha = 1.0) {
Scalar baseline = 200.0;
Point text_position = {100, baseline};

Expand All @@ -1147,7 +1148,7 @@ bool RenderTextInCanvas(const std::shared_ptr<Context>& context,
auto frame = TextFrameFromTextBlob(blob);

Paint text_paint;
text_paint.color = Color::Yellow();
text_paint.color = Color::Yellow().WithAlpha(alpha);
canvas.DrawTextFrame(frame, text_position, text_paint);
return true;
}
Expand Down Expand Up @@ -1180,6 +1181,18 @@ TEST_P(AiksTest, CanRenderEmojiTextFrame) {
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}

TEST_P(AiksTest, CanRenderEmojiTextFrameWithAlpha) {
Canvas canvas;
ASSERT_TRUE(RenderTextInCanvas(GetContext(), canvas,
"😀 😃 😄 😁 😆 😅 😂 🤣 🥲 😊",
#if FML_OS_MACOSX
"Apple Color Emoji.ttc", 50, 0.5));
#else
"NotoColorEmoji.ttf", 50, 0.5));
#endif
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}

TEST_P(AiksTest, CanRenderTextInSaveLayer) {
Canvas canvas;
canvas.DrawPaint({.color = Color::White()});
Expand Down
3 changes: 2 additions & 1 deletion impeller/entity/shaders/glyph_atlas.frag
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ void main() {
vec2 uv_position = v_source_position / frag_info.atlas_size;
if (v_has_color == 1.0) {
frag_color =
texture(glyph_atlas_sampler, v_unit_position * uv_size + uv_position);
texture(glyph_atlas_sampler, v_unit_position * uv_size + uv_position) *
frag_info.text_color.a;
} else {
frag_color =
texture(glyph_atlas_sampler, v_unit_position * uv_size + uv_position)
Expand Down