diff options
author | gman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-12 00:07:55 +0000 |
---|---|---|
committer | gman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-12 00:07:55 +0000 |
commit | 5506e7813e6ab6330665ae8cc5fb3cc8275d90ff (patch) | |
tree | 4da1a84f3bfd9f6f1d651bd0a8e4f810b17868fe /o3d | |
parent | 156fa0eb10b37260f40ec70ac50a7921ad55a3dd (diff) | |
download | chromium_src-5506e7813e6ab6330665ae8cc5fb3cc8275d90ff.zip chromium_src-5506e7813e6ab6330665ae8cc5fb3cc8275d90ff.tar.gz chromium_src-5506e7813e6ab6330665ae8cc5fb3cc8275d90ff.tar.bz2 |
Fix so we don't attempt to generate mips for DXT
textures. This is a quick fix to get pulse passing
again. I'm going to make the change I suggested
before which is to always allocate enough memory
for mips.
Then I can make Bitmap::GenerateMips fail and
when it fails it won't update the number of mips
Review URL: http://codereview.chromium.org/164362
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23122 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d')
-rw-r--r-- | o3d/core/cross/image_utils.cc | 4 | ||||
-rw-r--r-- | o3d/core/cross/image_utils.h | 3 | ||||
-rw-r--r-- | o3d/core/cross/image_utils_test.cc | 11 | ||||
-rw-r--r-- | o3d/core/cross/pack.cc | 2 |
4 files changed, 19 insertions, 1 deletions
diff --git a/o3d/core/cross/image_utils.cc b/o3d/core/cross/image_utils.cc index 5570d2b..8c1eecb 100644 --- a/o3d/core/cross/image_utils.cc +++ b/o3d/core/cross/image_utils.cc @@ -141,6 +141,10 @@ unsigned int GetNumComponentsForFormat(o3d::Texture::Format format) { return 0;
}
+bool CanMakeMips(o3d::Texture::Format format) {
+ return GetNumComponentsForFormat(format) != 0;
+}
+
namespace {
static const float kEpsilon = 0.0001f;
diff --git a/o3d/core/cross/image_utils.h b/o3d/core/cross/image_utils.h index e37d8eb..cb2f761 100644 --- a/o3d/core/cross/image_utils.h +++ b/o3d/core/cross/image_utils.h @@ -66,6 +66,9 @@ inline bool CheckImageDimensions(unsigned int width, unsigned int height) { return width <= kMaxImageDimension && height <= kMaxImageDimension;
}
+// Returns whether or not we can make mips.
+bool CanMakeMips(Texture::Format format);
+
// Gets the number of mip-maps required for a full chain starting at
// width x height.
inline unsigned int ComputeMipMapCount(
diff --git a/o3d/core/cross/image_utils_test.cc b/o3d/core/cross/image_utils_test.cc index b7ca6f6..58cebdf 100644 --- a/o3d/core/cross/image_utils_test.cc +++ b/o3d/core/cross/image_utils_test.cc @@ -72,6 +72,17 @@ TEST_F(ImageTest, ComputePOTSize) { EXPECT_EQ(image::ComputePOTSize(4096), 4096u); } +TEST_F(ImageTest, CanMakeMips) { + EXPECT_TRUE(image::CanMakeMips(Texture::Format::XRGB8)); + EXPECT_TRUE(image::CanMakeMips(Texture::Format::ARGB8)); + EXPECT_TRUE(image::CanMakeMips(Texture::Format::ABGR16F)); + EXPECT_TRUE(image::CanMakeMips(Texture::Format::R32F)); + EXPECT_TRUE(image::CanMakeMips(Texture::Format::ABGR32F)); + EXPECT_FALSE(image::CanMakeMips(Texture::Format::DXT1)); + EXPECT_FALSE(image::CanMakeMips(Texture::Format::DXT3)); + EXPECT_FALSE(image::CanMakeMips(Texture::Format::DXT5)); +}; + static const uint8 kScaleUPDataNPOT[] = { // This is a 3x3 image. 0x75, 0x58, 0x7b, 0x76, diff --git a/o3d/core/cross/pack.cc b/o3d/core/cross/pack.cc index a874c02..168d700 100644 --- a/o3d/core/cross/pack.cc +++ b/o3d/core/cross/pack.cc @@ -181,7 +181,7 @@ Texture* Pack::CreateTextureFromBitmaps( O3D_ERROR(service_locator()) << "Bitmaps are not all the same dimensions"; return NULL; } - if (generate_mipmaps) { + if (generate_mipmaps && image::CanMakeMips(bitmap->format())) { unsigned total_mips = image::ComputeMipMapCount( bitmap->width(), bitmap->height()); // If we don't already have mips and we could use them then make them. |