[Impeller] Share LazyGlyphAtlas across EntityPass (flutter/engine#38244)
[Impeller] Share LazyGlyphAtlas across EntityPass
This commit is contained in:
@@ -48,6 +48,7 @@ void Canvas::Initialize() {
|
||||
base_pass_ = std::make_unique<EntityPass>();
|
||||
current_pass_ = base_pass_.get();
|
||||
xformation_stack_.emplace_back(CanvasStackEntry{});
|
||||
lazy_glyph_atlas_ = std::make_shared<LazyGlyphAtlas>();
|
||||
FML_DCHECK(GetSaveCount() == 1u);
|
||||
FML_DCHECK(base_pass_->GetSubpassesDepth() == 1u);
|
||||
}
|
||||
@@ -56,6 +57,7 @@ void Canvas::Reset() {
|
||||
base_pass_ = nullptr;
|
||||
current_pass_ = nullptr;
|
||||
xformation_stack_ = {};
|
||||
lazy_glyph_atlas_ = nullptr;
|
||||
}
|
||||
|
||||
void Canvas::Save() {
|
||||
@@ -376,13 +378,11 @@ void Canvas::SaveLayer(
|
||||
void Canvas::DrawTextFrame(const TextFrame& text_frame,
|
||||
Point position,
|
||||
const Paint& paint) {
|
||||
auto lazy_glyph_atlas = GetCurrentPass().GetLazyGlyphAtlas();
|
||||
|
||||
lazy_glyph_atlas->AddTextFrame(text_frame);
|
||||
lazy_glyph_atlas_->AddTextFrame(text_frame);
|
||||
|
||||
auto text_contents = std::make_shared<TextContents>();
|
||||
text_contents->SetTextFrame(text_frame);
|
||||
text_contents->SetGlyphAtlas(std::move(lazy_glyph_atlas));
|
||||
text_contents->SetGlyphAtlas(lazy_glyph_atlas_);
|
||||
text_contents->SetColor(paint.color);
|
||||
|
||||
Entity entity;
|
||||
|
||||
@@ -116,6 +116,7 @@ class Canvas {
|
||||
std::unique_ptr<EntityPass> base_pass_;
|
||||
EntityPass* current_pass_ = nullptr;
|
||||
std::deque<CanvasStackEntry> xformation_stack_;
|
||||
std::shared_ptr<LazyGlyphAtlas> lazy_glyph_atlas_;
|
||||
|
||||
void Initialize();
|
||||
|
||||
|
||||
@@ -61,6 +61,24 @@ TEST_P(DisplayListTest, CanDrawTextBlob) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
||||
}
|
||||
|
||||
TEST_P(DisplayListTest, CanDrawTextWithSaveLayer) {
|
||||
flutter::DisplayListBuilder builder;
|
||||
builder.setColor(SK_ColorRED);
|
||||
builder.drawTextBlob(SkTextBlob::MakeFromString("Hello", CreateTestFont()),
|
||||
100, 100);
|
||||
|
||||
flutter::DlPaint save_paint;
|
||||
float alpha = 0.5;
|
||||
save_paint.setAlpha(static_cast<uint8_t>(255 * alpha));
|
||||
builder.SaveLayer(nullptr, &save_paint);
|
||||
builder.setColor(SK_ColorRED);
|
||||
builder.drawTextBlob(SkTextBlob::MakeFromString("Hello with half alpha",
|
||||
CreateTestFontOfSize(100)),
|
||||
100, 300);
|
||||
builder.restore();
|
||||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
||||
}
|
||||
|
||||
TEST_P(DisplayListTest, CanDrawImage) {
|
||||
auto texture = CreateTextureForFixture("embarcadero.jpg");
|
||||
flutter::DisplayListBuilder builder;
|
||||
|
||||
@@ -68,10 +68,6 @@ size_t EntityPass::GetSubpassesDepth() const {
|
||||
return max_subpass_depth + 1u;
|
||||
}
|
||||
|
||||
const std::shared_ptr<LazyGlyphAtlas>& EntityPass::GetLazyGlyphAtlas() const {
|
||||
return lazy_glyph_atlas_;
|
||||
}
|
||||
|
||||
std::optional<Rect> EntityPass::GetElementsCoverage(
|
||||
std::optional<Rect> coverage_crop) const {
|
||||
std::optional<Rect> result;
|
||||
|
||||
@@ -43,8 +43,6 @@ class EntityPass {
|
||||
|
||||
void SetElements(std::vector<Element> elements);
|
||||
|
||||
const std::shared_ptr<LazyGlyphAtlas>& GetLazyGlyphAtlas() const;
|
||||
|
||||
EntityPass* AddSubpass(std::unique_ptr<EntityPass> pass);
|
||||
|
||||
EntityPass* GetSuperpass() const;
|
||||
@@ -130,8 +128,6 @@ class EntityPass {
|
||||
|
||||
std::unique_ptr<EntityPassDelegate> delegate_ =
|
||||
EntityPassDelegate::MakeDefault();
|
||||
std::shared_ptr<LazyGlyphAtlas> lazy_glyph_atlas_ =
|
||||
std::make_shared<LazyGlyphAtlas>();
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(EntityPass);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user