[Impeller] Use separate atlases and shaders for color and alpha (flutter/engine#41780)
Creates a separate atlas context and cache for color and alpha bitmap glyphs. Removes SDF shader and uses separate shader for full color glyphs. Requires https://github.com/flutter/engine/pull/41754 Fixes https://github.com/flutter/flutter/issues/116818 Fixes https://github.com/flutter/flutter/issues/126101 This also fixes https://github.com/flutter/engine/pull/39383 but for light text on a dark background. This problem crops up when we switch to a full color atlas. In this context, the chosen glyph color is important. But with the alpha channel only atlas, its irrelevant. See diff:  Example app: ```dart // Copyright 2014 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; void main() => runApp( Container( alignment: Alignment.center, child: Text( ''' (Unicode Conference)Ø Ø§ÙØ°Ù Ø³ÙØ¹Ùد ÙÙ 10-12 آذار 1997 ب٠دÙÙØ© Ù ÙØ§ÙÙÙÙØªÙØ³Ø Ø£Ù٠اÙÙØ§. Ù Ø³ÙØ¬Ù ع اÙ٠ؤت٠ر بÙ٠خبراء Ù Ù ÙØ§ÙØ© ÙØ·Ø§Ø¹Ø§Øª Ø§ÙØµÙاعة عÙÙ Ø§ÙØ´Ø¨ÙØ© Ø§ÙØ¹Ø§ÙÙ ÙØ© Ø§ÙØªØ±ÙÙØª ÙÙÙÙÙÙÙØ¯Ø ØÙØ« Ø³ØªØªÙ Ø Ø¹ÙÙ Ø§ÙØµØ¹ÙدÙÙ Ø§ÙØ¯ÙÙÙ ÙØ§ÙÙ ØÙ٠عÙÙ ØØ¯ Ø³ÙØ§Ø¡ Ù ÙØ§Ùشة سب٠استخدا٠ÙÙÙÙÙØ¯ Ù٠اÙÙØ¸Ù اÙÙØ§Ø¦Ù Ø© ÙÙÙ٠ا ÙØ®Øµ Ø§ÙØªØ·Ø¨ÙÙØ§Øª Ø§ÙØØ§Ø³ÙØ¨ÙØ©Ø Ø§ÙØ®Ø·ÙØ·Ø ØªØµÙ Ù٠اÙÙØµÙص ÙØ§ÙØÙسبة ٠تعددة اÙÙØºØ§Øª. Ù ÙÙ ÙÙ ÙÙ ÙÙÙ ÙÙð ð ð ð ð''', textDirection: TextDirection.rtl, style: TextStyle(fontSize: 24, color: Colors.white), ), ), ); ```
This commit is contained in:
@@ -1297,8 +1297,7 @@ ORIGIN: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur_noa
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur_noalpha_nodecal.frag + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/glyph_atlas.frag + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/glyph_atlas.vert + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/glyph_atlas_sdf.frag + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/glyph_atlas_sdf.vert + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/glyph_atlas_color.frag + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/gradient_fill.vert + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/linear_gradient_fill.frag + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/linear_gradient_ssbo_fill.frag + ../../../flutter/LICENSE
|
||||
@@ -3910,8 +3909,7 @@ FILE: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur_noalp
|
||||
FILE: ../../../flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur_noalpha_nodecal.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/glyph_atlas.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/glyph_atlas.vert
|
||||
FILE: ../../../flutter/impeller/entity/shaders/glyph_atlas_sdf.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/glyph_atlas_sdf.vert
|
||||
FILE: ../../../flutter/impeller/entity/shaders/glyph_atlas_color.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/gradient_fill.vert
|
||||
FILE: ../../../flutter/impeller/entity/shaders/linear_gradient_fill.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/linear_gradient_ssbo_fill.frag
|
||||
|
||||
@@ -43,9 +43,8 @@ impeller_shaders("entity_shaders") {
|
||||
"shaders/gaussian_blur/gaussian_blur_noalpha_decal.frag",
|
||||
"shaders/gaussian_blur/gaussian_blur_noalpha_nodecal.frag",
|
||||
"shaders/glyph_atlas.frag",
|
||||
"shaders/glyph_atlas_color.frag",
|
||||
"shaders/glyph_atlas.vert",
|
||||
"shaders/glyph_atlas_sdf.frag",
|
||||
"shaders/glyph_atlas_sdf.vert",
|
||||
"shaders/gradient_fill.vert",
|
||||
"shaders/linear_to_srgb_filter.frag",
|
||||
"shaders/linear_to_srgb_filter.vert",
|
||||
|
||||
@@ -164,7 +164,8 @@ static std::unique_ptr<PipelineT> CreateDefaultPipeline(
|
||||
ContentContext::ContentContext(std::shared_ptr<Context> context)
|
||||
: context_(std::move(context)),
|
||||
tessellator_(std::make_shared<Tessellator>()),
|
||||
glyph_atlas_context_(std::make_shared<GlyphAtlasContext>()),
|
||||
alpha_glyph_atlas_context_(std::make_shared<GlyphAtlasContext>()),
|
||||
color_glyph_atlas_context_(std::make_shared<GlyphAtlasContext>()),
|
||||
scene_context_(std::make_shared<scene::SceneContext>(context_)) {
|
||||
if (!context_ || !context_->IsValid()) {
|
||||
return;
|
||||
@@ -286,6 +287,8 @@ ContentContext::ContentContext(std::shared_ptr<Context> context)
|
||||
CreateDefaultPipeline<SrgbToLinearFilterPipeline>(*context_);
|
||||
glyph_atlas_pipelines_[{}] =
|
||||
CreateDefaultPipeline<GlyphAtlasPipeline>(*context_);
|
||||
glyph_atlas_color_pipelines_[{}] =
|
||||
CreateDefaultPipeline<GlyphAtlasColorPipeline>(*context_);
|
||||
geometry_color_pipelines_[{}] =
|
||||
CreateDefaultPipeline<GeometryColorPipeline>(*context_);
|
||||
yuv_to_rgb_filter_pipelines_[{}] =
|
||||
@@ -378,9 +381,10 @@ std::shared_ptr<Tessellator> ContentContext::GetTessellator() const {
|
||||
return tessellator_;
|
||||
}
|
||||
|
||||
std::shared_ptr<GlyphAtlasContext> ContentContext::GetGlyphAtlasContext()
|
||||
const {
|
||||
return glyph_atlas_context_;
|
||||
std::shared_ptr<GlyphAtlasContext> ContentContext::GetGlyphAtlasContext(
|
||||
GlyphAtlas::Type type) const {
|
||||
return type == GlyphAtlas::Type::kAlphaBitmap ? alpha_glyph_atlas_context_
|
||||
: color_glyph_atlas_context_;
|
||||
}
|
||||
|
||||
std::shared_ptr<Context> ContentContext::GetContext() const {
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "impeller/entity/conical_gradient_fill.frag.h"
|
||||
#include "impeller/entity/glyph_atlas.frag.h"
|
||||
#include "impeller/entity/glyph_atlas.vert.h"
|
||||
#include "impeller/entity/glyph_atlas_color.frag.h"
|
||||
#include "impeller/entity/gradient_fill.vert.h"
|
||||
#include "impeller/entity/linear_gradient_fill.frag.h"
|
||||
#include "impeller/entity/linear_to_srgb_filter.frag.h"
|
||||
@@ -171,6 +172,8 @@ using SrgbToLinearFilterPipeline =
|
||||
SrgbToLinearFilterFragmentShader>;
|
||||
using GlyphAtlasPipeline =
|
||||
RenderPipelineT<GlyphAtlasVertexShader, GlyphAtlasFragmentShader>;
|
||||
using GlyphAtlasColorPipeline =
|
||||
RenderPipelineT<GlyphAtlasVertexShader, GlyphAtlasColorFragmentShader>;
|
||||
using PorterDuffBlendPipeline =
|
||||
RenderPipelineT<BlendVertexShader, PorterDuffBlendFragmentShader>;
|
||||
// Instead of requiring new shaders for clips, the solid fill stages are used
|
||||
@@ -469,6 +472,11 @@ class ContentContext {
|
||||
return GetPipeline(glyph_atlas_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetGlyphAtlasColorPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(glyph_atlas_color_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetGeometryColorPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(geometry_color_pipelines_, opts);
|
||||
@@ -654,7 +662,8 @@ class ContentContext {
|
||||
|
||||
std::shared_ptr<Context> GetContext() const;
|
||||
|
||||
std::shared_ptr<GlyphAtlasContext> GetGlyphAtlasContext() const;
|
||||
std::shared_ptr<GlyphAtlasContext> GetGlyphAtlasContext(
|
||||
GlyphAtlas::Type type) const;
|
||||
|
||||
const Capabilities& GetDeviceCapabilities() const;
|
||||
|
||||
@@ -722,6 +731,7 @@ class ContentContext {
|
||||
mutable Variants<SrgbToLinearFilterPipeline> srgb_to_linear_filter_pipelines_;
|
||||
mutable Variants<ClipPipeline> clip_pipelines_;
|
||||
mutable Variants<GlyphAtlasPipeline> glyph_atlas_pipelines_;
|
||||
mutable Variants<GlyphAtlasColorPipeline> glyph_atlas_color_pipelines_;
|
||||
mutable Variants<GeometryColorPipeline> geometry_color_pipelines_;
|
||||
mutable Variants<YUVToRGBFilterPipeline> yuv_to_rgb_filter_pipelines_;
|
||||
mutable Variants<PorterDuffBlendPipeline> porter_duff_blend_pipelines_;
|
||||
@@ -813,7 +823,8 @@ class ContentContext {
|
||||
|
||||
bool is_valid_ = false;
|
||||
std::shared_ptr<Tessellator> tessellator_;
|
||||
std::shared_ptr<GlyphAtlasContext> glyph_atlas_context_;
|
||||
std::shared_ptr<GlyphAtlasContext> alpha_glyph_atlas_context_;
|
||||
std::shared_ptr<GlyphAtlasContext> color_glyph_atlas_context_;
|
||||
std::shared_ptr<scene::SceneContext> scene_context_;
|
||||
bool wireframe_ = false;
|
||||
|
||||
|
||||
@@ -112,7 +112,6 @@ static bool CommonRender(
|
||||
frag_info.text_color = ToVector(color.Premultiply());
|
||||
FS::BindFragInfo(cmd, pass.GetTransientsBuffer().EmplaceUniform(frag_info));
|
||||
|
||||
// Common fragment uniforms for all glyphs.
|
||||
FS::BindGlyphAtlasSampler(
|
||||
cmd, // command
|
||||
atlas->GetTexture(), // texture
|
||||
@@ -198,9 +197,6 @@ static bool CommonRender(
|
||||
point * glyph_position.glyph.bounds.size);
|
||||
}
|
||||
vtx.uv = uv_origin + point * uv_size;
|
||||
vtx.has_color =
|
||||
glyph_position.glyph.type == Glyph::Type::kBitmap ? 1.0 : 0.0;
|
||||
|
||||
vertex_builder.AppendVertex(vtx);
|
||||
}
|
||||
}
|
||||
@@ -224,16 +220,9 @@ bool TextContents::Render(const ContentContext& renderer,
|
||||
return true;
|
||||
}
|
||||
|
||||
// This TextContents may be for a frame that doesn't have color, but the
|
||||
// lazy atlas for this scene already does have color.
|
||||
// Benchmarks currently show that creating two atlases per pass regresses
|
||||
// render time. This should get re-evaluated if we start caching atlases
|
||||
// between frames or get significantly faster at creating atlases, because
|
||||
// we're potentially trading memory for time here.
|
||||
auto atlas =
|
||||
ResolveAtlas(lazy_atlas_->HasColor() ? GlyphAtlas::Type::kColorBitmap
|
||||
: GlyphAtlas::Type::kAlphaBitmap,
|
||||
renderer.GetGlyphAtlasContext(), renderer.GetContext());
|
||||
auto type = frame_.GetAtlasType();
|
||||
auto atlas = ResolveAtlas(type, renderer.GetGlyphAtlasContext(type),
|
||||
renderer.GetContext());
|
||||
|
||||
if (!atlas || !atlas->IsValid()) {
|
||||
VALIDATION_LOG << "Cannot render glyphs without prepared atlas.";
|
||||
@@ -245,7 +234,11 @@ bool TextContents::Render(const ContentContext& renderer,
|
||||
cmd.label = "TextFrame";
|
||||
auto opts = OptionsFromPassAndEntity(pass, entity);
|
||||
opts.primitive_type = PrimitiveType::kTriangle;
|
||||
cmd.pipeline = renderer.GetGlyphAtlasPipeline(opts);
|
||||
if (type == GlyphAtlas::Type::kAlphaBitmap) {
|
||||
cmd.pipeline = renderer.GetGlyphAtlasPipeline(opts);
|
||||
} else {
|
||||
cmd.pipeline = renderer.GetGlyphAtlasColorPipeline(opts);
|
||||
}
|
||||
cmd.stencil_reference = entity.GetStencilDepth();
|
||||
|
||||
return CommonRender(renderer, entity, pass, color, frame_, offset_, atlas,
|
||||
|
||||
@@ -4,23 +4,18 @@
|
||||
|
||||
#include <impeller/types.glsl>
|
||||
|
||||
uniform sampler2D glyph_atlas_sampler;
|
||||
uniform f16sampler2D glyph_atlas_sampler;
|
||||
|
||||
uniform FragInfo {
|
||||
vec4 text_color;
|
||||
f16vec4 text_color;
|
||||
}
|
||||
frag_info;
|
||||
|
||||
in vec2 v_uv;
|
||||
in float v_has_color;
|
||||
|
||||
out vec4 frag_color;
|
||||
out f16vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
vec4 value = texture(glyph_atlas_sampler, v_uv);
|
||||
if (v_has_color != 1.0) {
|
||||
frag_color = value.aaaa * frag_info.text_color;
|
||||
} else {
|
||||
frag_color = value * frag_info.text_color.a;
|
||||
}
|
||||
f16vec4 value = texture(glyph_atlas_sampler, v_uv);
|
||||
frag_color = value.aaaa * frag_info.text_color;
|
||||
}
|
||||
|
||||
@@ -10,15 +10,12 @@ uniform FrameInfo {
|
||||
}
|
||||
frame_info;
|
||||
|
||||
in vec4 position;
|
||||
in highp vec4 position;
|
||||
in vec2 uv;
|
||||
in float has_color;
|
||||
|
||||
out vec2 v_uv;
|
||||
out float v_has_color;
|
||||
|
||||
void main() {
|
||||
gl_Position = frame_info.mvp * position;
|
||||
v_uv = uv;
|
||||
v_has_color = has_color;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include <impeller/types.glsl>
|
||||
|
||||
uniform f16sampler2D glyph_atlas_sampler;
|
||||
|
||||
uniform FragInfo {
|
||||
f16vec4 text_color;
|
||||
}
|
||||
frag_info;
|
||||
|
||||
in vec2 v_uv;
|
||||
|
||||
out f16vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
f16vec4 value = texture(glyph_atlas_sampler, v_uv);
|
||||
frag_color = value * frag_info.text_color.aaaa;
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include <impeller/types.glsl>
|
||||
|
||||
uniform sampler2D glyph_atlas_sampler;
|
||||
|
||||
uniform FragInfo {
|
||||
vec4 text_color;
|
||||
}
|
||||
frag_info;
|
||||
|
||||
in vec2 v_uv;
|
||||
|
||||
out vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
// Inspired by Metal by Example's SDF text rendering shader:
|
||||
// https://github.com/metal-by-example/sample-code/blob/master/objc/12-TextRendering/TextRendering/Shaders.metal
|
||||
|
||||
// Outline of glyph is the isocontour with value 50%
|
||||
float edge_distance = 0.5;
|
||||
// Sample the signed-distance field to find distance from this fragment to the
|
||||
// glyph outline
|
||||
float sample_distance = texture(glyph_atlas_sampler, v_uv).a;
|
||||
// Use local automatic gradients to find anti-aliased anisotropic edge width,
|
||||
// cf. Gustavson 2012
|
||||
float edge_width = length(vec2(dFdx(sample_distance), dFdy(sample_distance)));
|
||||
// Smooth the glyph edge by interpolating across the boundary in a band with
|
||||
// the width determined above
|
||||
float insideness = smoothstep(edge_distance - edge_width,
|
||||
edge_distance + edge_width, sample_distance);
|
||||
frag_color = frag_info.text_color * insideness;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include <impeller/types.glsl>
|
||||
|
||||
#include <impeller/transform.glsl>
|
||||
|
||||
uniform FrameInfo {
|
||||
mat4 mvp;
|
||||
}
|
||||
frame_info;
|
||||
|
||||
in vec4 position;
|
||||
in vec2 uv;
|
||||
|
||||
out vec2 v_uv;
|
||||
|
||||
void main() {
|
||||
gl_Position = frame_info.mvp * position;
|
||||
v_uv = uv;
|
||||
}
|
||||
@@ -7431,15 +7431,16 @@
|
||||
"has_stack_spilling": false,
|
||||
"performance": {
|
||||
"longest_path_bound_pipelines": [
|
||||
"varying"
|
||||
"varying",
|
||||
"texture"
|
||||
],
|
||||
"longest_path_cycles": [
|
||||
0.078125,
|
||||
0.0625,
|
||||
0.078125,
|
||||
0.03125,
|
||||
0.03125,
|
||||
0.03125,
|
||||
0.0,
|
||||
0.0,
|
||||
0.375,
|
||||
0.25,
|
||||
0.25
|
||||
],
|
||||
"pipelines": [
|
||||
@@ -7452,27 +7453,29 @@
|
||||
"texture"
|
||||
],
|
||||
"shortest_path_bound_pipelines": [
|
||||
"varying"
|
||||
"varying",
|
||||
"texture"
|
||||
],
|
||||
"shortest_path_cycles": [
|
||||
0.0625,
|
||||
0.0625,
|
||||
0.046875,
|
||||
0.03125,
|
||||
0.03125,
|
||||
0.0,
|
||||
0.0,
|
||||
0.375,
|
||||
0.0,
|
||||
0.25,
|
||||
0.25
|
||||
],
|
||||
"total_bound_pipelines": [
|
||||
"varying"
|
||||
"varying",
|
||||
"texture"
|
||||
],
|
||||
"total_cycles": [
|
||||
0.078125,
|
||||
0.0625,
|
||||
0.078125,
|
||||
0.03125,
|
||||
0.03125,
|
||||
0.03125,
|
||||
0.0,
|
||||
0.0,
|
||||
0.375,
|
||||
0.25,
|
||||
0.25
|
||||
]
|
||||
},
|
||||
@@ -7518,10 +7521,11 @@
|
||||
1.0
|
||||
],
|
||||
"total_bound_pipelines": [
|
||||
"arithmetic"
|
||||
"load_store",
|
||||
"texture"
|
||||
],
|
||||
"total_cycles": [
|
||||
1.3333333730697632,
|
||||
0.6666666865348816,
|
||||
1.0,
|
||||
1.0
|
||||
]
|
||||
@@ -7541,16 +7545,16 @@
|
||||
"type": "Vertex",
|
||||
"variants": {
|
||||
"Position": {
|
||||
"fp16_arithmetic": 88,
|
||||
"fp16_arithmetic": 0,
|
||||
"has_stack_spilling": false,
|
||||
"performance": {
|
||||
"longest_path_bound_pipelines": [
|
||||
"load_store"
|
||||
],
|
||||
"longest_path_cycles": [
|
||||
0.140625,
|
||||
0.140625,
|
||||
0.046875,
|
||||
0.265625,
|
||||
0.265625,
|
||||
0.0,
|
||||
0.0,
|
||||
2.0,
|
||||
0.0
|
||||
@@ -7567,9 +7571,9 @@
|
||||
"load_store"
|
||||
],
|
||||
"shortest_path_cycles": [
|
||||
0.140625,
|
||||
0.140625,
|
||||
0.046875,
|
||||
0.265625,
|
||||
0.265625,
|
||||
0.0,
|
||||
0.0,
|
||||
2.0,
|
||||
0.0
|
||||
@@ -7578,287 +7582,9 @@
|
||||
"load_store"
|
||||
],
|
||||
"total_cycles": [
|
||||
0.140625,
|
||||
0.140625,
|
||||
0.046875,
|
||||
0.265625,
|
||||
0.265625,
|
||||
0.0,
|
||||
2.0,
|
||||
0.0
|
||||
]
|
||||
},
|
||||
"stack_spill_bytes": 0,
|
||||
"thread_occupancy": 100,
|
||||
"uniform_registers_used": 16,
|
||||
"work_registers_used": 32
|
||||
},
|
||||
"Varying": {
|
||||
"fp16_arithmetic": null,
|
||||
"has_stack_spilling": false,
|
||||
"performance": {
|
||||
"longest_path_bound_pipelines": [
|
||||
"load_store"
|
||||
],
|
||||
"longest_path_cycles": [
|
||||
0.03125,
|
||||
0.0,
|
||||
0.03125,
|
||||
0.0,
|
||||
4.0,
|
||||
0.0
|
||||
],
|
||||
"pipelines": [
|
||||
"arith_total",
|
||||
"arith_fma",
|
||||
"arith_cvt",
|
||||
"arith_sfu",
|
||||
"load_store",
|
||||
"texture"
|
||||
],
|
||||
"shortest_path_bound_pipelines": [
|
||||
"load_store"
|
||||
],
|
||||
"shortest_path_cycles": [
|
||||
0.03125,
|
||||
0.0,
|
||||
0.03125,
|
||||
0.0,
|
||||
4.0,
|
||||
0.0
|
||||
],
|
||||
"total_bound_pipelines": [
|
||||
"load_store"
|
||||
],
|
||||
"total_cycles": [
|
||||
0.03125,
|
||||
0.0,
|
||||
0.03125,
|
||||
0.0,
|
||||
4.0,
|
||||
0.0
|
||||
]
|
||||
},
|
||||
"stack_spill_bytes": 0,
|
||||
"thread_occupancy": 100,
|
||||
"uniform_registers_used": 8,
|
||||
"work_registers_used": 9
|
||||
}
|
||||
}
|
||||
},
|
||||
"Mali-T880": {
|
||||
"core": "Mali-T880",
|
||||
"filename": "flutter/impeller/entity/gles/glyph_atlas.vert.gles",
|
||||
"has_uniform_computation": false,
|
||||
"type": "Vertex",
|
||||
"variants": {
|
||||
"Main": {
|
||||
"has_stack_spilling": false,
|
||||
"performance": {
|
||||
"longest_path_bound_pipelines": [
|
||||
"load_store"
|
||||
],
|
||||
"longest_path_cycles": [
|
||||
2.9700000286102295,
|
||||
7.0,
|
||||
0.0
|
||||
],
|
||||
"pipelines": [
|
||||
"arithmetic",
|
||||
"load_store",
|
||||
"texture"
|
||||
],
|
||||
"shortest_path_bound_pipelines": [
|
||||
"load_store"
|
||||
],
|
||||
"shortest_path_cycles": [
|
||||
2.9700000286102295,
|
||||
7.0,
|
||||
0.0
|
||||
],
|
||||
"total_bound_pipelines": [
|
||||
"load_store"
|
||||
],
|
||||
"total_cycles": [
|
||||
3.0,
|
||||
7.0,
|
||||
0.0
|
||||
]
|
||||
},
|
||||
"thread_occupancy": 100,
|
||||
"uniform_registers_used": 4,
|
||||
"work_registers_used": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"flutter/impeller/entity/gles/glyph_atlas_sdf.frag.gles": {
|
||||
"Mali-G78": {
|
||||
"core": "Mali-G78",
|
||||
"filename": "flutter/impeller/entity/gles/glyph_atlas_sdf.frag.gles",
|
||||
"has_side_effects": false,
|
||||
"has_uniform_computation": false,
|
||||
"modifies_coverage": false,
|
||||
"reads_color_buffer": false,
|
||||
"type": "Fragment",
|
||||
"uses_late_zs_test": false,
|
||||
"uses_late_zs_update": false,
|
||||
"variants": {
|
||||
"Main": {
|
||||
"fp16_arithmetic": 77,
|
||||
"has_stack_spilling": false,
|
||||
"performance": {
|
||||
"longest_path_bound_pipelines": [
|
||||
"arith_total",
|
||||
"arith_fma",
|
||||
"arith_sfu"
|
||||
],
|
||||
"longest_path_cycles": [
|
||||
0.3125,
|
||||
0.3125,
|
||||
0.046875,
|
||||
0.3125,
|
||||
0.0,
|
||||
0.25,
|
||||
0.25
|
||||
],
|
||||
"pipelines": [
|
||||
"arith_total",
|
||||
"arith_fma",
|
||||
"arith_cvt",
|
||||
"arith_sfu",
|
||||
"load_store",
|
||||
"varying",
|
||||
"texture"
|
||||
],
|
||||
"shortest_path_bound_pipelines": [
|
||||
"arith_total",
|
||||
"arith_fma",
|
||||
"arith_sfu"
|
||||
],
|
||||
"shortest_path_cycles": [
|
||||
0.3125,
|
||||
0.3125,
|
||||
0.015625,
|
||||
0.3125,
|
||||
0.0,
|
||||
0.25,
|
||||
0.25
|
||||
],
|
||||
"total_bound_pipelines": [
|
||||
"arith_total",
|
||||
"arith_fma",
|
||||
"arith_sfu"
|
||||
],
|
||||
"total_cycles": [
|
||||
0.3125,
|
||||
0.3125,
|
||||
0.046875,
|
||||
0.3125,
|
||||
0.0,
|
||||
0.25,
|
||||
0.25
|
||||
]
|
||||
},
|
||||
"stack_spill_bytes": 0,
|
||||
"thread_occupancy": 100,
|
||||
"uniform_registers_used": 8,
|
||||
"work_registers_used": 20
|
||||
}
|
||||
}
|
||||
},
|
||||
"Mali-T880": {
|
||||
"core": "Mali-T880",
|
||||
"filename": "flutter/impeller/entity/gles/glyph_atlas_sdf.frag.gles",
|
||||
"has_uniform_computation": false,
|
||||
"type": "Fragment",
|
||||
"variants": {
|
||||
"Main": {
|
||||
"has_stack_spilling": false,
|
||||
"performance": {
|
||||
"longest_path_bound_pipelines": [
|
||||
"arithmetic"
|
||||
],
|
||||
"longest_path_cycles": [
|
||||
3.299999952316284,
|
||||
1.0,
|
||||
3.0
|
||||
],
|
||||
"pipelines": [
|
||||
"arithmetic",
|
||||
"load_store",
|
||||
"texture"
|
||||
],
|
||||
"shortest_path_bound_pipelines": [
|
||||
"arithmetic"
|
||||
],
|
||||
"shortest_path_cycles": [
|
||||
3.299999952316284,
|
||||
1.0,
|
||||
3.0
|
||||
],
|
||||
"total_bound_pipelines": [
|
||||
"arithmetic"
|
||||
],
|
||||
"total_cycles": [
|
||||
3.6666667461395264,
|
||||
1.0,
|
||||
3.0
|
||||
]
|
||||
},
|
||||
"thread_occupancy": 100,
|
||||
"uniform_registers_used": 1,
|
||||
"work_registers_used": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"flutter/impeller/entity/gles/glyph_atlas_sdf.vert.gles": {
|
||||
"Mali-G78": {
|
||||
"core": "Mali-G78",
|
||||
"filename": "flutter/impeller/entity/gles/glyph_atlas_sdf.vert.gles",
|
||||
"has_uniform_computation": false,
|
||||
"type": "Vertex",
|
||||
"variants": {
|
||||
"Position": {
|
||||
"fp16_arithmetic": 88,
|
||||
"has_stack_spilling": false,
|
||||
"performance": {
|
||||
"longest_path_bound_pipelines": [
|
||||
"load_store"
|
||||
],
|
||||
"longest_path_cycles": [
|
||||
0.140625,
|
||||
0.140625,
|
||||
0.046875,
|
||||
0.0,
|
||||
2.0,
|
||||
0.0
|
||||
],
|
||||
"pipelines": [
|
||||
"arith_total",
|
||||
"arith_fma",
|
||||
"arith_cvt",
|
||||
"arith_sfu",
|
||||
"load_store",
|
||||
"texture"
|
||||
],
|
||||
"shortest_path_bound_pipelines": [
|
||||
"load_store"
|
||||
],
|
||||
"shortest_path_cycles": [
|
||||
0.140625,
|
||||
0.140625,
|
||||
0.046875,
|
||||
0.0,
|
||||
2.0,
|
||||
0.0
|
||||
],
|
||||
"total_bound_pipelines": [
|
||||
"load_store"
|
||||
],
|
||||
"total_cycles": [
|
||||
0.140625,
|
||||
0.140625,
|
||||
0.046875,
|
||||
0.0,
|
||||
2.0,
|
||||
0.0
|
||||
@@ -7924,7 +7650,7 @@
|
||||
},
|
||||
"Mali-T880": {
|
||||
"core": "Mali-T880",
|
||||
"filename": "flutter/impeller/entity/gles/glyph_atlas_sdf.vert.gles",
|
||||
"filename": "flutter/impeller/entity/gles/glyph_atlas.vert.gles",
|
||||
"has_uniform_computation": false,
|
||||
"type": "Vertex",
|
||||
"variants": {
|
||||
@@ -7968,6 +7694,129 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"flutter/impeller/entity/gles/glyph_atlas_color.frag.gles": {
|
||||
"Mali-G78": {
|
||||
"core": "Mali-G78",
|
||||
"filename": "flutter/impeller/entity/gles/glyph_atlas_color.frag.gles",
|
||||
"has_side_effects": false,
|
||||
"has_uniform_computation": false,
|
||||
"modifies_coverage": false,
|
||||
"reads_color_buffer": false,
|
||||
"type": "Fragment",
|
||||
"uses_late_zs_test": false,
|
||||
"uses_late_zs_update": false,
|
||||
"variants": {
|
||||
"Main": {
|
||||
"fp16_arithmetic": 100,
|
||||
"has_stack_spilling": false,
|
||||
"performance": {
|
||||
"longest_path_bound_pipelines": [
|
||||
"varying",
|
||||
"texture"
|
||||
],
|
||||
"longest_path_cycles": [
|
||||
0.03125,
|
||||
0.03125,
|
||||
0.03125,
|
||||
0.0,
|
||||
0.0,
|
||||
0.25,
|
||||
0.25
|
||||
],
|
||||
"pipelines": [
|
||||
"arith_total",
|
||||
"arith_fma",
|
||||
"arith_cvt",
|
||||
"arith_sfu",
|
||||
"load_store",
|
||||
"varying",
|
||||
"texture"
|
||||
],
|
||||
"shortest_path_bound_pipelines": [
|
||||
"varying",
|
||||
"texture"
|
||||
],
|
||||
"shortest_path_cycles": [
|
||||
0.03125,
|
||||
0.03125,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.25,
|
||||
0.25
|
||||
],
|
||||
"total_bound_pipelines": [
|
||||
"varying",
|
||||
"texture"
|
||||
],
|
||||
"total_cycles": [
|
||||
0.03125,
|
||||
0.03125,
|
||||
0.03125,
|
||||
0.0,
|
||||
0.0,
|
||||
0.25,
|
||||
0.25
|
||||
]
|
||||
},
|
||||
"stack_spill_bytes": 0,
|
||||
"thread_occupancy": 100,
|
||||
"uniform_registers_used": 4,
|
||||
"work_registers_used": 19
|
||||
}
|
||||
}
|
||||
},
|
||||
"Mali-T880": {
|
||||
"core": "Mali-T880",
|
||||
"filename": "flutter/impeller/entity/gles/glyph_atlas_color.frag.gles",
|
||||
"has_uniform_computation": false,
|
||||
"type": "Fragment",
|
||||
"variants": {
|
||||
"Main": {
|
||||
"has_stack_spilling": false,
|
||||
"performance": {
|
||||
"longest_path_bound_pipelines": [
|
||||
"arithmetic",
|
||||
"load_store",
|
||||
"texture"
|
||||
],
|
||||
"longest_path_cycles": [
|
||||
1.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"pipelines": [
|
||||
"arithmetic",
|
||||
"load_store",
|
||||
"texture"
|
||||
],
|
||||
"shortest_path_bound_pipelines": [
|
||||
"arithmetic",
|
||||
"load_store",
|
||||
"texture"
|
||||
],
|
||||
"shortest_path_cycles": [
|
||||
1.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"total_bound_pipelines": [
|
||||
"load_store",
|
||||
"texture"
|
||||
],
|
||||
"total_cycles": [
|
||||
0.6666666865348816,
|
||||
1.0,
|
||||
1.0
|
||||
]
|
||||
},
|
||||
"thread_occupancy": 100,
|
||||
"uniform_registers_used": 1,
|
||||
"work_registers_used": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"flutter/impeller/entity/gles/gradient_fill.vert.gles": {
|
||||
"Mali-G78": {
|
||||
"core": "Mali-G78",
|
||||
@@ -11354,15 +11203,16 @@
|
||||
"has_stack_spilling": false,
|
||||
"performance": {
|
||||
"longest_path_bound_pipelines": [
|
||||
"varying"
|
||||
"varying",
|
||||
"texture"
|
||||
],
|
||||
"longest_path_cycles": [
|
||||
0.0625,
|
||||
0.0625,
|
||||
0.046875,
|
||||
0.03125,
|
||||
0.03125,
|
||||
0.0,
|
||||
0.0,
|
||||
0.375,
|
||||
0.0,
|
||||
0.25,
|
||||
0.25
|
||||
],
|
||||
"pipelines": [
|
||||
@@ -11375,34 +11225,36 @@
|
||||
"texture"
|
||||
],
|
||||
"shortest_path_bound_pipelines": [
|
||||
"varying"
|
||||
"varying",
|
||||
"texture"
|
||||
],
|
||||
"shortest_path_cycles": [
|
||||
0.0625,
|
||||
0.0625,
|
||||
0.046875,
|
||||
0.03125,
|
||||
0.03125,
|
||||
0.0,
|
||||
0.0,
|
||||
0.375,
|
||||
0.0,
|
||||
0.25,
|
||||
0.25
|
||||
],
|
||||
"total_bound_pipelines": [
|
||||
"varying"
|
||||
"varying",
|
||||
"texture"
|
||||
],
|
||||
"total_cycles": [
|
||||
0.0625,
|
||||
0.0625,
|
||||
0.046875,
|
||||
0.03125,
|
||||
0.03125,
|
||||
0.0,
|
||||
0.0,
|
||||
0.375,
|
||||
0.0,
|
||||
0.25,
|
||||
0.25
|
||||
]
|
||||
},
|
||||
"stack_spill_bytes": 0,
|
||||
"thread_occupancy": 100,
|
||||
"uniform_registers_used": 6,
|
||||
"work_registers_used": 7
|
||||
"work_registers_used": 6
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11415,16 +11267,16 @@
|
||||
"type": "Vertex",
|
||||
"variants": {
|
||||
"Position": {
|
||||
"fp16_arithmetic": 100,
|
||||
"fp16_arithmetic": 0,
|
||||
"has_stack_spilling": false,
|
||||
"performance": {
|
||||
"longest_path_bound_pipelines": [
|
||||
"load_store"
|
||||
],
|
||||
"longest_path_cycles": [
|
||||
0.125,
|
||||
0.125,
|
||||
0.0625,
|
||||
0.25,
|
||||
0.25,
|
||||
0.0,
|
||||
0.0,
|
||||
2.0,
|
||||
0.0
|
||||
@@ -11441,9 +11293,9 @@
|
||||
"load_store"
|
||||
],
|
||||
"shortest_path_cycles": [
|
||||
0.125,
|
||||
0.125,
|
||||
0.0625,
|
||||
0.25,
|
||||
0.25,
|
||||
0.0,
|
||||
0.0,
|
||||
2.0,
|
||||
0.0
|
||||
@@ -11452,9 +11304,9 @@
|
||||
"load_store"
|
||||
],
|
||||
"total_cycles": [
|
||||
0.125,
|
||||
0.125,
|
||||
0.0625,
|
||||
0.25,
|
||||
0.25,
|
||||
0.0,
|
||||
0.0,
|
||||
2.0,
|
||||
0.0
|
||||
@@ -11462,7 +11314,7 @@
|
||||
},
|
||||
"stack_spill_bytes": 0,
|
||||
"thread_occupancy": 100,
|
||||
"uniform_registers_used": 16,
|
||||
"uniform_registers_used": 24,
|
||||
"work_registers_used": 32
|
||||
},
|
||||
"Varying": {
|
||||
@@ -11477,7 +11329,7 @@
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
4.0,
|
||||
3.0,
|
||||
0.0
|
||||
],
|
||||
"pipelines": [
|
||||
@@ -11496,7 +11348,7 @@
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
4.0,
|
||||
3.0,
|
||||
0.0
|
||||
],
|
||||
"total_bound_pipelines": [
|
||||
@@ -11507,22 +11359,22 @@
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
4.0,
|
||||
3.0,
|
||||
0.0
|
||||
]
|
||||
},
|
||||
"stack_spill_bytes": 0,
|
||||
"thread_occupancy": 100,
|
||||
"uniform_registers_used": 16,
|
||||
"work_registers_used": 7
|
||||
"uniform_registers_used": 24,
|
||||
"work_registers_used": 6
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"flutter/impeller/entity/glyph_atlas_sdf.frag.vkspv": {
|
||||
"flutter/impeller/entity/glyph_atlas_color.frag.vkspv": {
|
||||
"Mali-G78": {
|
||||
"core": "Mali-G78",
|
||||
"filename": "flutter/impeller/entity/glyph_atlas_sdf.frag.vkspv",
|
||||
"filename": "flutter/impeller/entity/glyph_atlas_color.frag.vkspv",
|
||||
"has_side_effects": false,
|
||||
"has_uniform_computation": true,
|
||||
"modifies_coverage": false,
|
||||
@@ -11532,18 +11384,18 @@
|
||||
"uses_late_zs_update": false,
|
||||
"variants": {
|
||||
"Main": {
|
||||
"fp16_arithmetic": 72,
|
||||
"fp16_arithmetic": 100,
|
||||
"has_stack_spilling": false,
|
||||
"performance": {
|
||||
"longest_path_bound_pipelines": [
|
||||
"arith_total",
|
||||
"arith_sfu"
|
||||
"varying",
|
||||
"texture"
|
||||
],
|
||||
"longest_path_cycles": [
|
||||
0.3125,
|
||||
0.25,
|
||||
0.015625,
|
||||
0.3125,
|
||||
0.03125,
|
||||
0.03125,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.25,
|
||||
0.25
|
||||
@@ -11558,27 +11410,27 @@
|
||||
"texture"
|
||||
],
|
||||
"shortest_path_bound_pipelines": [
|
||||
"arith_total",
|
||||
"arith_sfu"
|
||||
"varying",
|
||||
"texture"
|
||||
],
|
||||
"shortest_path_cycles": [
|
||||
0.3125,
|
||||
0.25,
|
||||
0.015625,
|
||||
0.3125,
|
||||
0.03125,
|
||||
0.03125,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.25,
|
||||
0.25
|
||||
],
|
||||
"total_bound_pipelines": [
|
||||
"arith_total",
|
||||
"arith_sfu"
|
||||
"varying",
|
||||
"texture"
|
||||
],
|
||||
"total_cycles": [
|
||||
0.3125,
|
||||
0.25,
|
||||
0.015625,
|
||||
0.3125,
|
||||
0.03125,
|
||||
0.03125,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.25,
|
||||
0.25
|
||||
@@ -11586,120 +11438,8 @@
|
||||
},
|
||||
"stack_spill_bytes": 0,
|
||||
"thread_occupancy": 100,
|
||||
"uniform_registers_used": 6,
|
||||
"work_registers_used": 6
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"flutter/impeller/entity/glyph_atlas_sdf.vert.vkspv": {
|
||||
"Mali-G78": {
|
||||
"core": "Mali-G78",
|
||||
"filename": "flutter/impeller/entity/glyph_atlas_sdf.vert.vkspv",
|
||||
"has_uniform_computation": true,
|
||||
"type": "Vertex",
|
||||
"variants": {
|
||||
"Position": {
|
||||
"fp16_arithmetic": 100,
|
||||
"has_stack_spilling": false,
|
||||
"performance": {
|
||||
"longest_path_bound_pipelines": [
|
||||
"load_store"
|
||||
],
|
||||
"longest_path_cycles": [
|
||||
0.125,
|
||||
0.125,
|
||||
0.0625,
|
||||
0.0,
|
||||
2.0,
|
||||
0.0
|
||||
],
|
||||
"pipelines": [
|
||||
"arith_total",
|
||||
"arith_fma",
|
||||
"arith_cvt",
|
||||
"arith_sfu",
|
||||
"load_store",
|
||||
"texture"
|
||||
],
|
||||
"shortest_path_bound_pipelines": [
|
||||
"load_store"
|
||||
],
|
||||
"shortest_path_cycles": [
|
||||
0.125,
|
||||
0.125,
|
||||
0.0625,
|
||||
0.0,
|
||||
2.0,
|
||||
0.0
|
||||
],
|
||||
"total_bound_pipelines": [
|
||||
"load_store"
|
||||
],
|
||||
"total_cycles": [
|
||||
0.125,
|
||||
0.125,
|
||||
0.0625,
|
||||
0.0,
|
||||
2.0,
|
||||
0.0
|
||||
]
|
||||
},
|
||||
"stack_spill_bytes": 0,
|
||||
"thread_occupancy": 100,
|
||||
"uniform_registers_used": 16,
|
||||
"work_registers_used": 32
|
||||
},
|
||||
"Varying": {
|
||||
"fp16_arithmetic": null,
|
||||
"has_stack_spilling": false,
|
||||
"performance": {
|
||||
"longest_path_bound_pipelines": [
|
||||
"load_store"
|
||||
],
|
||||
"longest_path_cycles": [
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
3.0,
|
||||
0.0
|
||||
],
|
||||
"pipelines": [
|
||||
"arith_total",
|
||||
"arith_fma",
|
||||
"arith_cvt",
|
||||
"arith_sfu",
|
||||
"load_store",
|
||||
"texture"
|
||||
],
|
||||
"shortest_path_bound_pipelines": [
|
||||
"load_store"
|
||||
],
|
||||
"shortest_path_cycles": [
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
3.0,
|
||||
0.0
|
||||
],
|
||||
"total_bound_pipelines": [
|
||||
"load_store"
|
||||
],
|
||||
"total_cycles": [
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
3.0,
|
||||
0.0
|
||||
]
|
||||
},
|
||||
"stack_spill_bytes": 0,
|
||||
"thread_occupancy": 100,
|
||||
"uniform_registers_used": 16,
|
||||
"work_registers_used": 6
|
||||
"uniform_registers_used": 4,
|
||||
"work_registers_used": 4
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,11 @@ LazyGlyphAtlas::~LazyGlyphAtlas() = default;
|
||||
|
||||
void LazyGlyphAtlas::AddTextFrame(const TextFrame& frame) {
|
||||
FML_DCHECK(atlas_map_.empty());
|
||||
has_color_ |= frame.HasColor();
|
||||
frames_.emplace_back(frame);
|
||||
}
|
||||
|
||||
bool LazyGlyphAtlas::HasColor() const {
|
||||
return has_color_;
|
||||
if (frame.GetAtlasType() == GlyphAtlas::Type::kAlphaBitmap) {
|
||||
alpha_frames_.emplace_back(frame);
|
||||
} else {
|
||||
color_frames_.emplace_back(frame);
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<GlyphAtlas> LazyGlyphAtlas::CreateOrGetGlyphAtlas(
|
||||
@@ -42,11 +41,13 @@ std::shared_ptr<GlyphAtlas> LazyGlyphAtlas::CreateOrGetGlyphAtlas(
|
||||
return nullptr;
|
||||
}
|
||||
size_t i = 0;
|
||||
auto frames =
|
||||
type == GlyphAtlas::Type::kAlphaBitmap ? alpha_frames_ : color_frames_;
|
||||
TextRenderContext::FrameIterator iterator = [&]() -> const TextFrame* {
|
||||
if (i >= frames_.size()) {
|
||||
if (i >= frames.size()) {
|
||||
return nullptr;
|
||||
}
|
||||
const auto& result = frames_[i];
|
||||
const auto& result = frames[i];
|
||||
i++;
|
||||
return &result;
|
||||
};
|
||||
|
||||
@@ -26,13 +26,11 @@ class LazyGlyphAtlas {
|
||||
std::shared_ptr<GlyphAtlasContext> atlas_context,
|
||||
std::shared_ptr<Context> context) const;
|
||||
|
||||
bool HasColor() const;
|
||||
|
||||
private:
|
||||
std::vector<TextFrame> frames_;
|
||||
std::vector<TextFrame> alpha_frames_;
|
||||
std::vector<TextFrame> color_frames_;
|
||||
mutable std::unordered_map<GlyphAtlas::Type, std::shared_ptr<GlyphAtlas>>
|
||||
atlas_map_;
|
||||
bool has_color_ = false;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(LazyGlyphAtlas);
|
||||
};
|
||||
|
||||
@@ -42,8 +42,9 @@ const std::vector<TextRun>& TextFrame::GetRuns() const {
|
||||
return runs_;
|
||||
}
|
||||
|
||||
bool TextFrame::HasColor() const {
|
||||
return has_color_;
|
||||
GlyphAtlas::Type TextFrame::GetAtlasType() const {
|
||||
return has_color_ ? GlyphAtlas::Type::kColorBitmap
|
||||
: GlyphAtlas::Type::kAlphaBitmap;
|
||||
}
|
||||
|
||||
bool TextFrame::MaybeHasOverlapping() const {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "impeller/typographer/glyph_atlas.h"
|
||||
#include "impeller/typographer/text_run.h"
|
||||
|
||||
namespace impeller {
|
||||
@@ -63,8 +64,8 @@ class TextFrame {
|
||||
bool MaybeHasOverlapping() const;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/// @brief Whether any run in this frame has color.
|
||||
bool HasColor() const;
|
||||
/// @brief The type of atlas this run should be emplaced in.
|
||||
GlyphAtlas::Type GetAtlasType() const;
|
||||
|
||||
private:
|
||||
std::vector<TextRun> runs_;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "impeller/typographer/backends/skia/text_frame_skia.h"
|
||||
#include "impeller/typographer/backends/skia/text_render_context_skia.h"
|
||||
#include "impeller/typographer/lazy_glyph_atlas.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkData.h"
|
||||
#include "third_party/skia/include/core/SkTextBlob.h"
|
||||
|
||||
@@ -91,22 +92,28 @@ TEST_P(TypographerTest, LazyAtlasTracksColor) {
|
||||
ASSERT_TRUE(blob);
|
||||
auto frame = TextFrameFromTextBlob(blob);
|
||||
|
||||
ASSERT_FALSE(frame.HasColor());
|
||||
ASSERT_FALSE(frame.GetAtlasType() == GlyphAtlas::Type::kColorBitmap);
|
||||
|
||||
LazyGlyphAtlas lazy_atlas;
|
||||
ASSERT_FALSE(lazy_atlas.HasColor());
|
||||
|
||||
lazy_atlas.AddTextFrame(frame);
|
||||
|
||||
ASSERT_FALSE(lazy_atlas.HasColor());
|
||||
|
||||
frame = TextFrameFromTextBlob(SkTextBlob::MakeFromString("😀 ", emoji_font));
|
||||
|
||||
ASSERT_TRUE(frame.HasColor());
|
||||
ASSERT_TRUE(frame.GetAtlasType() == GlyphAtlas::Type::kColorBitmap);
|
||||
|
||||
lazy_atlas.AddTextFrame(frame);
|
||||
|
||||
ASSERT_TRUE(lazy_atlas.HasColor());
|
||||
// Creates different atlases for color and alpha bitmap.
|
||||
auto color_context = std::make_shared<GlyphAtlasContext>();
|
||||
auto bitmap_context = std::make_shared<GlyphAtlasContext>();
|
||||
auto color_atlas = lazy_atlas.CreateOrGetGlyphAtlas(
|
||||
GlyphAtlas::Type::kColorBitmap, color_context, GetContext());
|
||||
|
||||
auto bitmap_atlas = lazy_atlas.CreateOrGetGlyphAtlas(
|
||||
GlyphAtlas::Type::kAlphaBitmap, bitmap_context, GetContext());
|
||||
|
||||
ASSERT_FALSE(color_atlas == bitmap_atlas);
|
||||
}
|
||||
|
||||
TEST_P(TypographerTest, GlyphAtlasWithOddUniqueGlyphSize) {
|
||||
|
||||
Reference in New Issue
Block a user