Skip to content

[Impeller] Always use RGBA8888 format in the Skia bitmap used to draw a color glyph atlas#185857

Merged
auto-submit[bot] merged 3 commits into
flutter:masterfrom
jason-simmons:bug_185602
May 4, 2026
Merged

[Impeller] Always use RGBA8888 format in the Skia bitmap used to draw a color glyph atlas#185857
auto-submit[bot] merged 3 commits into
flutter:masterfrom
jason-simmons:bug_185602

Conversation

@jason-simmons

Copy link
Copy Markdown
Member

Impeller declares color bitmap glyph atlas textures as PixelFormat::kR8G8B8A8UNormInt. But it was creating the Skia bitmap for this texture using SkImageInfo::MakeN32Premul. The Skia N32 format may be either BGRA8888 or RGBA8888 depending on what is preferred by the platform.

This PR ensures that the Skia bitmap will use RGBA8888 on all platforms.

Fixes #185602

@jason-simmons jason-simmons requested a review from gaaclarke April 30, 2026 22:28
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Apr 30, 2026
@github-actions github-actions Bot added a: text input Entering text in a text field or keyboard related problems engine flutter/engine related. See also e: labels. e: impeller Impeller rendering backend issues and features requests labels Apr 30, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a unit test for emoji rendering in Impeller and updates the Skia typographer context to explicitly use the RGBA_8888 color type for color bitmaps. A suggestion was made to use SkISize with explicit int32_t casts in the typographer context to maintain consistency with existing code and prevent implicit float-to-int conversions.

Comment on lines +95 to +96
return SkImageInfo::Make(size.width, size.height, kRGBA_8888_SkColorType,
kPremul_SkAlphaType);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the kAlpha case (lines 92-93) and to avoid implicit float-to-int conversion of the size components, consider using SkISize with explicit casts to int32_t.

      return SkImageInfo::Make(SkISize{static_cast<int32_t>(size.width),
                                       static_cast<int32_t>(size.height)},
                               kRGBA_8888_SkColorType, kPremul_SkAlphaType);
References
  1. Optimize for readability and maintain consistency in code implementation. (link)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}

TEST_P(AiksTest, TextDrawEmoji) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we have a test that already does this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, it looks like this is redundant with CanRenderEmojiTextFrame. Removed this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it also means this test isn't sufficient, right? It's hardware dependent. Maybe we can add a unit test that calls into one of those static functions directly to make sure that flag is set?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal is to render these emoji with the correct colors, and verifying that involves checking the final output.

Unfortunately the current implementation was relying on Skia behavior that varies based on the host platform. And it looks like tests such as AiksTest.CanRenderEmojiTextFrame are only generating Skia Gold images on macOS, which does not exhibit this issue.

(https://flutter-gold.skia.org/search?corpus=flutter&include_ignored=false&left_filter=name%3Dengine.impeller_Play_AiksTest_CanRenderEmojiTextFrame_OpenGLES&max_rgba=0&min_rgba=0&negative=true&not_at_head=false&positive=true&reference_image_required=false&right_filter=&sort=descending&untriaged=true)

Ideally the infrastructure would provide Skia Gold coverage of a broader range of plaforms including Linux.

Made TypographerContextSkia::GetImageInfo visible for testing and add a test that checks that it returns RGBA.

@github-actions github-actions Bot removed CICD Run CI/CD a: text input Entering text in a text field or keyboard related problems labels Apr 30, 2026
@jason-simmons jason-simmons added the CICD Run CI/CD label May 1, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label May 1, 2026

@gaaclarke gaaclarke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks jason

… a color glyph atlas

Impeller declares color bitmap glyph atlas textures as PixelFormat::kR8G8B8A8UNormInt.  But it was creating the Skia bitmap for this texture using SkImageInfo::MakeN32Premul.  The Skia N32 format may be either BGRA8888 or RGBA8888 depending on what is preferred by the platform.

This PR ensures that the Skia bitmap will use RGBA8888 on all platforms.

Fixes flutter#185602
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD e: impeller Impeller rendering backend issues and features requests engine flutter/engine related. See also e: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

emoji color is off on linux when using impeller

2 participants