summaryrefslogtreecommitdiffstats
path: root/o3d/core
diff options
context:
space:
mode:
Diffstat (limited to 'o3d/core')
-rw-r--r--o3d/core/cross/bitmap.cc4
-rw-r--r--o3d/core/cross/image_utils_test.cc34
-rw-r--r--o3d/core/cross/texture.cc10
3 files changed, 27 insertions, 21 deletions
diff --git a/o3d/core/cross/bitmap.cc b/o3d/core/cross/bitmap.cc
index f2c96a0..1672a4e 100644
--- a/o3d/core/cross/bitmap.cc
+++ b/o3d/core/cross/bitmap.cc
@@ -344,11 +344,11 @@ void Bitmap::DrawImage(const Bitmap& src_img,
DCHECK(src_img.image_data());
DCHECK(image_data());
- if (dst_level < 0 || dst_level >= num_mipmaps()) {
+ if (dst_level < 0 || dst_level >= static_cast<int>(num_mipmaps())) {
O3D_ERROR(service_locator()) << "Destination Mip out of range";
}
- if (src_level < 0 || src_level >= src_img.num_mipmaps()) {
+ if (src_level < 0 || src_level >= static_cast<int>(src_img.num_mipmaps())) {
O3D_ERROR(service_locator()) << "Source Mip out of range";
}
diff --git a/o3d/core/cross/image_utils_test.cc b/o3d/core/cross/image_utils_test.cc
index a2a237c..2944302 100644
--- a/o3d/core/cross/image_utils_test.cc
+++ b/o3d/core/cross/image_utils_test.cc
@@ -53,14 +53,14 @@ class ImageTest : public testing::Test {
};
TEST_F(ImageTest, GetNumComponentsForFormat) {
- EXPECT_EQ(4, image::GetNumComponentsForFormat(Texture::XRGB8));
- EXPECT_EQ(4, image::GetNumComponentsForFormat(Texture::ARGB8));
- EXPECT_EQ(4, image::GetNumComponentsForFormat(Texture::ABGR16F));
- EXPECT_EQ(4, image::GetNumComponentsForFormat(Texture::ABGR32F));
- EXPECT_EQ(1, image::GetNumComponentsForFormat(Texture::R32F));
- EXPECT_EQ(0, image::GetNumComponentsForFormat(Texture::DXT1));
- EXPECT_EQ(0, image::GetNumComponentsForFormat(Texture::DXT3));
- EXPECT_EQ(0, image::GetNumComponentsForFormat(Texture::DXT5));
+ EXPECT_EQ(4u, image::GetNumComponentsForFormat(Texture::XRGB8));
+ EXPECT_EQ(4u, image::GetNumComponentsForFormat(Texture::ARGB8));
+ EXPECT_EQ(4u, image::GetNumComponentsForFormat(Texture::ABGR16F));
+ EXPECT_EQ(4u, image::GetNumComponentsForFormat(Texture::ABGR32F));
+ EXPECT_EQ(1u, image::GetNumComponentsForFormat(Texture::R32F));
+ EXPECT_EQ(0u, image::GetNumComponentsForFormat(Texture::DXT1));
+ EXPECT_EQ(0u, image::GetNumComponentsForFormat(Texture::DXT3));
+ EXPECT_EQ(0u, image::GetNumComponentsForFormat(Texture::DXT5));
}
TEST_F(ImageTest, IsPOT) {
@@ -69,14 +69,14 @@ TEST_F(ImageTest, IsPOT) {
EXPECT_FALSE(image::IsPOT(2, 3));
}
-TEST_F(ImageTest, CheckImageDimensions) {
- EXPECT_TRUE(image::CheckImageDimensions(1u, 1u));
- EXPECT_TRUE(image::CheckImageDimensions(image::kMaxImageDimension,
- image::kMaxImageDimension));
- EXPECT_FALSE(image::CheckImageDimensions(0u, image::kMaxImageDimension + 1));
- EXPECT_FALSE(image::CheckImageDimensions(image::kMaxImageDimension + 1, 0u));
-}
-
+TEST_F(ImageTest, CheckImageDimensions) {
+ EXPECT_TRUE(image::CheckImageDimensions(1u, 1u));
+ EXPECT_TRUE(image::CheckImageDimensions(image::kMaxImageDimension,
+ image::kMaxImageDimension));
+ EXPECT_FALSE(image::CheckImageDimensions(0u, image::kMaxImageDimension + 1));
+ EXPECT_FALSE(image::CheckImageDimensions(image::kMaxImageDimension + 1, 0u));
+}
+
TEST_F(ImageTest, ComputeMipMapCount) {
EXPECT_EQ(image::ComputeMipMapCount(1, 1), 1u);
EXPECT_EQ(image::ComputeMipMapCount(2, 2), 2u);
@@ -563,4 +563,4 @@ TEST_F(ImageTest, AdjustForSetRect) {
} // namespace
-
+
diff --git a/o3d/core/cross/texture.cc b/o3d/core/cross/texture.cc
index 560eb6c..4ef14fc 100644
--- a/o3d/core/cross/texture.cc
+++ b/o3d/core/cross/texture.cc
@@ -102,7 +102,7 @@ void Texture2D::DrawImage(const Bitmap& src_img,
O3D_ERROR(service_locator()) << "Mip out of range";
}
- if (src_mip < 0 || src_mip >= src_img.num_mipmaps()) {
+ if (src_mip < 0 || src_mip >= static_cast<int>(src_img.num_mipmaps())) {
O3D_ERROR(service_locator()) << "Source Mip out of range";
}
@@ -213,7 +213,11 @@ void Texture2D::DrawImage(const Canvas& src_img,
}
unsigned int mip_width = image::ComputeMipDimension(dst_mip, width());
+ DCHECK(mip_width > 0);
+
unsigned int mip_height = image::ComputeMipDimension(dst_mip, height());
+ DCHECK(mip_height > 0);
+
unsigned int components = image::GetNumComponentsForFormat(format());
DCHECK(components > 0);
@@ -387,7 +391,7 @@ void TextureCUBE::DrawImage(const Bitmap& src_img, int src_mip,
O3D_ERROR(service_locator()) << "Destination Mip out of range";
}
- if (src_mip < 0 || src_mip >= src_img.num_mipmaps()) {
+ if (src_mip < 0 || src_mip >= static_cast<int>(src_img.num_mipmaps())) {
O3D_ERROR(service_locator()) << "Source Mip out of range";
}
@@ -501,6 +505,8 @@ void TextureCUBE::DrawImage(const Canvas& src_img,
}
unsigned int mip_length = image::ComputeMipDimension(dest_mip, edge_length());
+ DCHECK(mip_length > 0u);
+
unsigned int components = image::GetNumComponentsForFormat(format());
DCHECK(components > 0);