diff --git a/lib/src/Image.cpp b/lib/src/Image.cpp index c8e9ba4..19bbc17 100644 --- a/lib/src/Image.cpp +++ b/lib/src/Image.cpp @@ -1116,6 +1116,7 @@ Image Image::rotate(RotateAngle angle) const if (!image) { // Fallback behavior + ColorRGBAd color = {}; switch (angle) { case RotateAngle::CCW90: @@ -1129,11 +1130,10 @@ Image Image::rotate(RotateAngle angle) const const void* srcScanline = FreeImage_GetScanLine(m_impl->image, y); for (unsigned int x = 0; x < m_impl->width; ++x) { - ColorRGBAd color; getPixelImpl(color, m_impl->format, srcScanline, x); void* dstScanline = FreeImage_GetScanLine(image.m_impl->image, x); - setPixelImpl(image.m_impl->format, dstScanline, - image.m_impl->width - y - 1, color); + setPixelImpl(image.m_impl->format, dstScanline, image.m_impl->width - y - 1, + color); } } break; @@ -1150,7 +1150,6 @@ Image Image::rotate(RotateAngle angle) const m_impl->height - y - 1); for (unsigned int x = 0; x < m_impl->width; ++x) { - ColorRGBAd color; getPixelImpl(color, m_impl->format, srcScanline, x); setPixelImpl(image.m_impl->format, dstScanline, m_impl->width - x - 1, color); @@ -1168,7 +1167,6 @@ Image Image::rotate(RotateAngle angle) const const void* srcScanline = FreeImage_GetScanLine(m_impl->image, y); for (unsigned int x = 0; x < m_impl->width; ++x) { - ColorRGBAd color; getPixelImpl(color, m_impl->format, srcScanline, m_impl->width - x - 1); void* dstScanline = FreeImage_GetScanLine(image.m_impl->image, x); diff --git a/lib/test/CMakeLists.txt b/lib/test/CMakeLists.txt index 8439558..6980573 100644 --- a/lib/test/CMakeLists.txt +++ b/lib/test/CMakeLists.txt @@ -2,13 +2,15 @@ if (NOT GTEST_FOUND OR NOT CUTTLEFISH_BUILD_TESTS) return() endif() +find_package(Threads) + file(GLOB_RECURSE sources *.cpp *.h) add_executable(cuttlefish_test ${sources}) target_include_directories(cuttlefish_test PRIVATE ${GTEST_INCLUDE_DIRS}) target_link_libraries(cuttlefish_test PRIVATE cuttlefish_lib - ${GTEST_BOTH_LIBRARIES}) + ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) if (APPLE AND CUTTLEFISH_BUILD_PVRTC AND PVRTEXLIB_FOUND AND NOT CUTTLEFISH_SHARED) cfs_fixup_mac_dep(cuttlefish_test "@executable_path/../lib/libPVRTexLib.dylib" diff --git a/lib/test/ImageTest.cpp b/lib/test/ImageTest.cpp index 648c179..f47f982 100644 --- a/lib/test/ImageTest.cpp +++ b/lib/test/ImageTest.cpp @@ -141,15 +141,15 @@ TEST_P(ImageTest, Initialize) { const ImageTestInfo& imageInfo = GetParam(); Image image; - EXPECT_FALSE(image); + EXPECT_FALSE(image.isValid()); EXPECT_TRUE(image.initialize(imageInfo.format, 10, 15)); - EXPECT_TRUE(image); + EXPECT_TRUE(image.isValid()); EXPECT_EQ(imageInfo.format, image.format()); EXPECT_EQ(10U, image.width()); EXPECT_EQ(15U, image.height()); image.reset(); - EXPECT_FALSE(image); + EXPECT_FALSE(image.isValid()); } TEST_P(ImageTest, GetSetPixel) @@ -378,7 +378,7 @@ TEST_P(ImageTest, FlipHorizontal) { const ImageTestInfo& imageInfo = GetParam(); Image image; - EXPECT_FALSE(image); + EXPECT_FALSE(image.isValid()); EXPECT_TRUE(image.initialize(imageInfo.format, 10, 15)); bool divide = shouldDivide(imageInfo.format); @@ -409,7 +409,7 @@ TEST_P(ImageTest, FlipVertical) { const ImageTestInfo& imageInfo = GetParam(); Image image; - EXPECT_FALSE(image); + EXPECT_FALSE(image.isValid()); EXPECT_TRUE(image.initialize(imageInfo.format, 10, 15)); bool divide = shouldDivide(imageInfo.format); @@ -440,7 +440,7 @@ TEST_P(ImageTest, PreMultiplyAlpha) { const ImageTestInfo& imageInfo = GetParam(); Image image; - EXPECT_FALSE(image); + EXPECT_FALSE(image.isValid()); EXPECT_TRUE(image.initialize(imageInfo.format, 10, 15)); bool divide = shouldDivide(imageInfo.format); @@ -474,7 +474,7 @@ TEST_P(ImageColorTest, Grayscale) { const ImageTestInfo& imageInfo = GetParam(); Image image; - EXPECT_FALSE(image); + EXPECT_FALSE(image.isValid()); EXPECT_TRUE(image.initialize(imageInfo.format, 10, 15)); bool divide = shouldDivide(imageInfo.format); @@ -509,7 +509,7 @@ TEST_P(ImageColorTest, Swizzle) { const ImageTestInfo& imageInfo = GetParam(); Image image; - EXPECT_FALSE(image); + EXPECT_FALSE(image.isValid()); EXPECT_TRUE(image.initialize(imageInfo.format, 10, 15)); bool divide = shouldDivide(imageInfo.format); @@ -545,7 +545,7 @@ TEST_P(ImageSRGBColorTest, LinearToSRGB) { const ImageTestInfo& imageInfo = GetParam(); Image image; - EXPECT_FALSE(image); + EXPECT_FALSE(image.isValid()); EXPECT_TRUE(image.initialize(imageInfo.format, 10, 15, ColorSpace::Linear)); bool divide = shouldDivide(imageInfo.format); @@ -582,7 +582,7 @@ TEST_P(ImageSRGBColorTest, sRGBToLinear) { const ImageTestInfo& imageInfo = GetParam(); Image image; - EXPECT_FALSE(image); + EXPECT_FALSE(image.isValid()); EXPECT_TRUE(image.initialize(imageInfo.format, 10, 15, ColorSpace::sRGB)); bool divide = shouldDivide(imageInfo.format); @@ -619,7 +619,7 @@ TEST_P(ImageSRGBColorTest, Resize) { const ImageTestInfo& imageInfo = GetParam(); Image image; - EXPECT_FALSE(image); + EXPECT_FALSE(image.isValid()); EXPECT_TRUE(image.initialize(imageInfo.format, 12, 16, ColorSpace::sRGB)); bool divide = shouldDivide(imageInfo.format); @@ -662,7 +662,7 @@ TEST_P(ImageSRGBColorTest, PreMultiplyAlpha) { const ImageTestInfo& imageInfo = GetParam(); Image image; - EXPECT_FALSE(image); + EXPECT_FALSE(image.isValid()); EXPECT_TRUE(image.initialize(imageInfo.format, 12, 16, ColorSpace::sRGB)); bool divide = shouldDivide(imageInfo.format); @@ -697,7 +697,7 @@ TEST_P(ImageSRGBColorTest, Grayscale) { const ImageTestInfo& imageInfo = GetParam(); Image image; - EXPECT_FALSE(image); + EXPECT_FALSE(image.isValid()); EXPECT_TRUE(image.initialize(imageInfo.format, 12, 16, ColorSpace::sRGB)); bool divide = shouldDivide(imageInfo.format); @@ -752,7 +752,7 @@ TEST(NormalMapTest, CreateNormalMap) } Image normalMap = image.createNormalMap(true, 2.5); - EXPECT_TRUE(normalMap); + EXPECT_TRUE(normalMap.isValid()); for (unsigned int y = 0; y < image.height(); ++y) { for (unsigned int x = 0; x < image.width(); ++x) @@ -784,7 +784,7 @@ TEST(NormalMapTest, CreateNormalMap) normalMap = image.createNormalMap(false, 2.5); - EXPECT_TRUE(normalMap); + EXPECT_TRUE(normalMap.isValid()); for (unsigned int y = 0; y < image.height(); ++y) { for (unsigned int x = 0; x < image.width(); ++x) diff --git a/lib/test/TextureTest.cpp b/lib/test/TextureTest.cpp index dd40baf..996ca48 100644 --- a/lib/test/TextureTest.cpp +++ b/lib/test/TextureTest.cpp @@ -190,12 +190,12 @@ TEST(TextureTest, Generate3DMipmaps) EXPECT_EQ(1U, texture.getImage(3, 0).width()); EXPECT_EQ(1U, texture.getImage(3, 0).height()); - EXPECT_FALSE(texture.getImage(1, 2)); - EXPECT_TRUE(texture.getImage(1, 1)); - EXPECT_FALSE(texture.getImage(2, 1)); - EXPECT_TRUE(texture.getImage(2, 0)); - EXPECT_FALSE(texture.getImage(3, 1)); - EXPECT_TRUE(texture.getImage(3, 0)); + EXPECT_FALSE(texture.getImage(1, 2).isValid()); + EXPECT_TRUE(texture.getImage(1, 1).isValid()); + EXPECT_FALSE(texture.getImage(2, 1).isValid()); + EXPECT_TRUE(texture.getImage(2, 0).isValid()); + EXPECT_FALSE(texture.getImage(3, 1).isValid()); + EXPECT_TRUE(texture.getImage(3, 0).isValid()); } TEST(TextureTest, ConvertSRGB)