Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace usage of SOIL with libpng #6291

Merged
merged 4 commits into from
May 20, 2018
Merged

Conversation

JosJuice
Copy link
Member

@JosJuice JosJuice commented Jan 6, 2018

This is a rebased and improved version of PR #4575. Just like that PR, it replaces the usage of SOIL in the custom texture loading code with libpng, and then removes SOIL from Dolphin entirely. But unlike when that PR was made, we now have the ability to load DDS textures without SOIL thanks to PR #5279, so the formats that are supported after this PR are PNG and DDS. Practically every texture pack only uses those two file types, and those two file types are the only file types that Ishiiruka supports.

For reasons to stop using SOIL, see PR #2163 (including the comments) and issue 9686.

@JosJuice
Copy link
Member Author

JosJuice commented Jan 6, 2018

It seems like the Ubuntu buildbot needs an updated version of libpng before this will build correctly.

@@ -123,6 +123,7 @@
<ClInclude Include="GL\GLUtil.h" />
<ClInclude Include="Hash.h" />
<ClInclude Include="HttpRequest.h" />
<ClInclude Include="Image.h" />

This comment was marked as off-topic.

This comment was marked as off-topic.


namespace Common
{
static inline int MultiplyAlpha(int alpha, int color)

This comment was marked as off-topic.

#include <png.h>
#include <vector>

#include <Common/CommonTypes.h>

This comment was marked as off-topic.

return ((temp + (temp >> 8)) >> 8);
}

static void PremultiplyData(png_structp png, png_row_infop row_info, png_bytep data)

This comment was marked as off-topic.

This comment was marked as off-topic.


static void ReadCallback(png_structp png, png_bytep data, png_size_t size)
{
ReadProgress* progress = reinterpret_cast<ReadProgress*>(png_get_io_ptr(png));

This comment was marked as off-topic.

const size_t stride = width * 4;
data_out->resize(stride * height);

png_byte** row_pointers = reinterpret_cast<png_byte**>(malloc(height * sizeof(png_byte*)));

This comment was marked as off-topic.


#include <vector>

#include <Common/CommonTypes.h>

This comment was marked as off-topic.

// "warning C4611: interaction between '_setjmp' and C++ object destruction is non-portable"
#endif

bool LoadPNG(const std::vector<u8>& input, std::vector<u8>* data_out, u32* width_out,

This comment was marked as off-topic.

This comment was marked as off-topic.

check_lib(SOIL "(no .pc for SOIL)" SOIL SOIL/SOIL.h QUIET)
endif()
if(SOIL_FOUND)
message(STATUS "Using shared SOIL")

This comment was marked as off-topic.

This comment was marked as off-topic.

// Licensed under GPLv2+
// Refer to the license.txt file included.

#include <Common/Image.h>

This comment was marked as off-topic.

for (size_t i = 0; i < size; ++i)
{
if (progress->current >= progress->end)
png_error(png, "Read beyond end of file");

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

@JosJuice
Copy link
Member Author

I've added workarounds for the issues that we had with pre-1.5 libpng. This should now be mergeable without having to update the Ubuntu buildbot.

@@ -137,6 +138,8 @@ elseif(USE_X11)
target_link_libraries(common PUBLIC ${XRANDR_LIBRARIES})
endif()

list(APPEND LIBS png ${PNG_LIBRARIES})

This comment was marked as off-topic.

@leoetlino leoetlino merged commit 86c676a into dolphin-emu:master May 20, 2018
@JosJuice JosJuice deleted the remove-soil branch May 20, 2018 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

6 participants