Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@jonahwilliams
Copy link
Contributor

Fixes flutter/flutter#148251

Work towards flutter/flutter#138798

The rectangle packer was only filling up the top and right edge of each rectangle, making the atlas super inefficient.

ASSERT_EQ(packer->PercentFull(), 0);
}

TEST_P(TypographerTest, GlyphAtlasTextureIsRecycledWhenContentsAreRecreated) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test really depends on the exact atlas sizing and how efficient the packing is, making it unstable. I'm removing it for now.


#include <algorithm>
#include <vector>
#include "fml/logging.h"
Copy link
Member

Choose a reason for hiding this comment

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

Nit: flutter/fml/logging.h

bool AddRect(int w, int h, IPoint16* loc) final;

Scalar PercentFull() const final {
float PercentFull() const final {
Copy link
Member

Choose a reason for hiding this comment

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

Scalars are floats already.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

// 'y' with the y-location at which it fits (the x location is pulled from
// 'skylineIndex's segment.
bool rectangleFits(int skylineIndex, int width, int height, int* y) const;
bool rectangleFits(size_t skylineIndex, int width, int height, int* y) const;
Copy link
Member

Choose a reason for hiding this comment

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

Here and elsewhere, use the PascalCase per the style guide?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

for (int i = skylineIndex + 1; i < (int)skyline_.size(); ++i) {
// The new segment subsumes all or part of skyline_[i]
for (auto i = skylineIndex + 1; i < skyline_.size(); ++i) {
// The new segment subsumes all or part of fSkyline[i]
Copy link
Member

Choose a reason for hiding this comment

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

If fSkyline referring to the right ivar?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops, I had re-ported this from skia and missed some renames.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

for (auto i = 0u; i < skyline_.size(); ++i) {
int y;
if (this->rectangleFits(i, width, height, &y)) {
if (this->RectangleFits(i, width, height, &y)) {
Copy link
Member

Choose a reason for hiding this comment

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

this-> is redundant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

if (skyline_[i].y_ == skyline_[i + 1].y_) {
skyline_[i].width_ += skyline_[i + 1].width_;
skyline_.erase(std::next(skyline_.begin(), i));
skyline_.erase(skyline_.begin() + i + 1);
Copy link
Member

Choose a reason for hiding this comment

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

I always have a tough time reading the stuff that returns an iterator you must use to modify the container.

But, this is an off by one error right? That is std::next(begin(), i) + 1 would have been the same thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, looking at the diff I think this was the bug.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks. I was wondering what was different.

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label May 13, 2024
@auto-submit auto-submit bot merged commit 13a561c into flutter:main May 13, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 14, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request May 14, 2024
…148274)

flutter/engine@7dcbd93...13a561c

2024-05-13 [email protected] [Impeller] rectangle packer actually packs. (flutter/engine#52781)
2024-05-13 [email protected] Roll Skia from 75b3286ecaac to 400c6fbeace8 (6 revisions) (flutter/engine#52783)
2024-05-13 [email protected] ios_external_view_embedder to ARC (flutter/engine#52782)
2024-05-13 [email protected] Roll Dart SDK from a0a940f07d56 to 7c7767ecc3d7 (2 revisions) (flutter/engine#52777)
2024-05-13 [email protected] Remove outdated comment. (flutter/engine#52778)
2024-05-13 [email protected] [Impeller] Prepare a SkiaGPU-less iOS build. (flutter/engine#52748)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App e: impeller

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Impeller] rectangle packer struggles to pack rectangles.

3 participants