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 1 commit
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
Prev Previous commit
Next Next commit
use specialization constant.
  • Loading branch information
jonahwilliams committed Feb 14, 2024
commit 53116aa5141649ad2bf07533cc51659a9cb9f00e
6 changes: 5 additions & 1 deletion impeller/entity/contents/content_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,11 @@ ContentContext::ContentContext(
options_trianglestrip);
srgb_to_linear_filter_pipelines_.CreateDefault(*context_,
options_trianglestrip);
glyph_atlas_pipelines_.CreateDefault(*context_, options);
glyph_atlas_pipelines_.CreateDefault(
*context_, options,
{static_cast<Scalar>(
GetContext()->GetCapabilities()->GetDefaultGlyphAtlasFormat() ==
PixelFormat::kA8UNormInt)});
glyph_atlas_color_pipelines_.CreateDefault(*context_, options);
geometry_color_pipelines_.CreateDefault(*context_, options);
yuv_to_rgb_filter_pipelines_.CreateDefault(*context_, options_trianglestrip);
Expand Down
8 changes: 7 additions & 1 deletion impeller/entity/shaders/glyph_atlas.frag
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ precision mediump float;

uniform f16sampler2D glyph_atlas_sampler;

layout(constant_id = 0) const float use_alpha_color_channel = 1.0;

in highp vec2 v_uv;

IMPELLER_MAYBE_FLAT in f16vec4 v_text_color;
Expand All @@ -16,5 +18,9 @@ out f16vec4 frag_color;

void main() {
f16vec4 value = texture(glyph_atlas_sampler, v_uv);
frag_color = vec4(max(value.r, value.a)) * v_text_color;
if (use_alpha_color_channel == 1.0) {
frag_color = value.aaaa * v_text_color;
} else {
frag_color = value.rrrr * v_text_color;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ std::shared_ptr<GlyphAtlas> TypographerContextSkia::CreateGlyphAtlas(
PixelFormat format;
switch (type) {
case GlyphAtlas::Type::kAlphaBitmap:
format = PixelFormat::kR8UNormInt;
format = context.GetCapabilities()->GetDefaultGlyphAtlasFormat();
break;
case GlyphAtlas::Type::kColorBitmap:
format = PixelFormat::kR8G8B8A8UNormInt;
Expand Down
7 changes: 4 additions & 3 deletions impeller/typographer/backends/stb/typographer_context_stb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -516,11 +516,12 @@ std::shared_ptr<GlyphAtlas> TypographerContextSTB::CreateGlyphAtlas(
PixelFormat format;
switch (type) {
case GlyphAtlas::Type::kAlphaBitmap:
format = PixelFormat::kR8UNormInt;
format = context.GetCapabilities()->GetDefaultGlyphAtlasFormat();
break;
case GlyphAtlas::Type::kColorBitmap:
format = DISABLE_COLOR_FONT_SUPPORT ? PixelFormat::kR8UNormInt
: PixelFormat::kR8G8B8A8UNormInt;
format = DISABLE_COLOR_FONT_SUPPORT
? context.GetCapabilities()->GetDefaultGlyphAtlasFormat()
: PixelFormat::kR8G8B8A8UNormInt;
break;
}
auto texture = UploadGlyphTextureAtlas(context.GetResourceAllocator(), bitmap,
Expand Down
2 changes: 1 addition & 1 deletion impeller/typographer/lazy_glyph_atlas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const std::shared_ptr<GlyphAtlas>& LazyGlyphAtlas::CreateOrGetGlyphAtlas(
}

auto& glyph_map = type == GlyphAtlas::Type::kAlphaBitmap ? alpha_glyph_map_
: color_glyph_map_;
: color_glyph_map_;
const std::shared_ptr<GlyphAtlasContext>& atlas_context =
type == GlyphAtlas::Type::kAlphaBitmap ? alpha_context_ : color_context_;
std::shared_ptr<GlyphAtlas> atlas = typographer_context_->CreateGlyphAtlas(
Expand Down