[Impeller] ensure 1x1 has mipcount of 1 (flutter/engine#39182)

* [Impeller] ensure 1x1 has mipcount of 1

* Update geometry_unittests.cc

* Update size.h
This commit is contained in:
Jonah Williams
2023-01-26 19:33:27 -08:00
committed by GitHub
parent 3bfa5c5b1d
commit 82a5c50210
2 changed files with 6 additions and 2 deletions

View File

@@ -666,6 +666,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);
ASSERT_EQ((Size{0, 0}.MipCount()), 1u);
}
TEST(GeometryTest, CanConvertTTypesExplicitly) {

View File

@@ -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);
}
};