Skip to content

Commit

Permalink
GCC 4.8 build fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
akb825 committed Aug 2, 2018
1 parent 0d675ea commit c03fae6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
8 changes: 3 additions & 5 deletions lib/src/Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,7 @@ Image Image::rotate(RotateAngle angle) const
if (!image)
{
// Fallback behavior
ColorRGBAd color = {};
switch (angle)
{
case RotateAngle::CCW90:
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion lib/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
30 changes: 15 additions & 15 deletions lib/test/ImageTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions lib/test/TextureTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c03fae6

Please sign in to comment.