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 all commits
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
2 changes: 2 additions & 0 deletions impeller/geometry/geometry_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,8 @@ TEST(GeometryTest, CanGenerateMipCounts) {
ASSERT_EQ((Size{128, 0}.MipCount()), 1u);
ASSERT_EQ((Size{128, -25}.MipCount()), 1u);
ASSERT_EQ((Size{-128, 25}.MipCount()), 1u);
ASSERT_EQ((Size{1, 1}.MipCount()), 1u);
Copy link
Contributor

Choose a reason for hiding this comment

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

Mip counts should always at least be 1. Perhaps also check Size{0, 0}?

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

ASSERT_EQ((Size{0, 0}.MipCount()), 1u);
}

TEST(GeometryTest, CanConvertTTypesExplicitly) {
Expand Down
6 changes: 4 additions & 2 deletions impeller/geometry/size.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,12 @@ struct TSize {
}

constexpr size_t MipCount() const {
constexpr size_t minimum_mip = 1u;
if (!IsPositive()) {
return 1u;
return minimum_mip;
}
return std::max(ceil(log2(width)), ceil(log2(height)));
size_t result = std::max(ceil(log2(width)), ceil(log2(height)));
return std::max(result, minimum_mip);
}
};

Expand Down