Core: Remove ImageWrite and get rid of -Wmissing-declarations warnings

This commit is contained in:
Léo Lam
2020-12-16 15:34:50 +01:00
parent eafe005672
commit 0ad2f3da45
10 changed files with 57 additions and 103 deletions

View File

@ -5,10 +5,10 @@
#include <algorithm>
#include "Common/Assert.h"
#include "Common/Image.h"
#include "Common/MsgHandler.h"
#include "VideoCommon/AbstractStagingTexture.h"
#include "VideoCommon/AbstractTexture.h"
#include "VideoCommon/ImageWrite.h"
#include "VideoCommon/RenderBase.h"
AbstractTexture::AbstractTexture(const TextureConfig& c) : m_config(c)
@ -48,9 +48,10 @@ bool AbstractTexture::Save(const std::string& filename, unsigned int level)
if (!readback_texture->Map())
return false;
return TextureToPng(reinterpret_cast<const u8*>(readback_texture->GetMappedPointer()),
static_cast<int>(readback_texture->GetMappedStride()), filename, level_width,
level_height);
return Common::SavePNG(filename,
reinterpret_cast<const u8*>(readback_texture->GetMappedPointer()),
Common::ImageByteFormat::RGBA, level_width, level_height,
static_cast<int>(readback_texture->GetMappedStride()));
}
bool AbstractTexture::IsCompressedFormat(AbstractTextureFormat format)

View File

@ -42,8 +42,6 @@ add_library(videocommon
HiresTextures.cpp
HiresTextures.h
HiresTextures_DDSLoader.cpp
ImageWrite.cpp
ImageWrite.h
IndexGenerator.cpp
IndexGenerator.h
LightingShaderGen.cpp

View File

@ -1,57 +0,0 @@
// Copyright 2008 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <list>
#include <string>
#include <vector>
#include "Common/CommonTypes.h"
#include "Common/File.h"
#include "Common/FileUtil.h"
#include "Common/Image.h"
bool SaveData(const std::string& filename, const std::string& data)
{
std::ofstream f;
File::OpenFStream(f, filename, std::ios::binary);
f << data;
return true;
}
/*
TextureToPng
Inputs:
data : This is an array of RGBA with 8 bits per channel. 4 bytes for each pixel.
row_stride: Determines the amount of bytes per row of pixels.
*/
bool TextureToPng(const u8* data, int row_stride, const std::string& filename, int width,
int height, bool save_alpha)
{
if (!data)
return false;
if (save_alpha)
{
return Common::SavePNG(filename, data, Common::ImageByteFormat::RGBA, width, height,
row_stride);
}
std::vector<u8> buffer;
buffer.reserve(width * height * 3);
for (int y = 0; y < height; ++y)
{
const u8* pos = data + y * row_stride;
for (int x = 0; x < width; ++x)
{
buffer.push_back(pos[x * 4]);
buffer.push_back(pos[x * 4 + 1]);
buffer.push_back(pos[x * 4 + 2]);
}
}
return Common::SavePNG(filename, buffer.data(), Common::ImageByteFormat::RGB, width, height);
}

View File

@ -1,12 +0,0 @@
// Copyright 2008 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <string>
#include "Common/CommonTypes.h"
bool SaveData(const std::string& filename, const std::string& data);
bool TextureToPng(const u8* data, int row_stride, const std::string& filename, int width,
int height, bool save_alpha = true);

View File

@ -29,9 +29,9 @@
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"
#include "Common/Config/Config.h"
#include "Common/Event.h"
#include "Common/FileUtil.h"
#include "Common/Flag.h"
#include "Common/Image.h"
#include "Common/Logging/Log.h"
#include "Common/MsgHandler.h"
#include "Common/Profiler.h"
@ -64,7 +64,6 @@
#include "VideoCommon/FramebufferManager.h"
#include "VideoCommon/FramebufferShaderGen.h"
#include "VideoCommon/FreeLookCamera.h"
#include "VideoCommon/ImageWrite.h"
#include "VideoCommon/NetPlayChatUI.h"
#include "VideoCommon/NetPlayGolfUI.h"
#include "VideoCommon/OnScreenDisplay.h"
@ -92,6 +91,12 @@ static float AspectToWidescreen(float aspect)
return aspect * ((16.0f / 9.0f) / (4.0f / 3.0f));
}
static bool DumpFrameToPNG(const FrameDump::FrameData& frame, const std::string& file_name)
{
return Common::ConvertRGBAToRGBAndSavePNG(file_name, frame.data, frame.width, frame.height,
frame.stride);
}
Renderer::Renderer(int backbuffer_width, int backbuffer_height, float backbuffer_scale,
AbstractTextureFormat backbuffer_format)
: m_backbuffer_width(backbuffer_width), m_backbuffer_height(backbuffer_height),
@ -1572,8 +1577,7 @@ void Renderer::FrameDumpThreadFunc()
{
std::lock_guard<std::mutex> lk(m_screenshot_lock);
if (TextureToPng(frame.data, frame.stride, m_screenshot_name, frame.width, frame.height,
false))
if (DumpFrameToPNG(frame, m_screenshot_name))
OSD::AddMessage("Screenshot saved to " + m_screenshot_name);
// Reset settings
@ -1681,8 +1685,7 @@ bool Renderer::StartFrameDumpToImage(const FrameDump::FrameData&)
void Renderer::DumpFrameToImage(const FrameDump::FrameData& frame)
{
std::string filename = GetFrameDumpNextImageFileName();
TextureToPng(frame.data, frame.stride, filename, frame.width, frame.height, false);
DumpFrameToPNG(frame, GetFrameDumpNextImageFileName());
m_frame_dump_image_counter++;
}

View File

@ -48,7 +48,6 @@
<ClCompile Include="FreeLookCamera.cpp" />
<ClCompile Include="HiresTextures.cpp" />
<ClCompile Include="HiresTextures_DDSLoader.cpp" />
<ClCompile Include="ImageWrite.cpp" />
<ClCompile Include="IndexGenerator.cpp" />
<ClCompile Include="NetPlayChatUI.cpp" />
<ClCompile Include="NetPlayGolfUI.cpp" />
@ -132,7 +131,6 @@
<ClInclude Include="UberShaderCommon.h" />
<ClInclude Include="UberShaderPixel.h" />
<ClInclude Include="HiresTextures.h" />
<ClInclude Include="ImageWrite.h" />
<ClInclude Include="IndexGenerator.h" />
<ClInclude Include="LightingShaderGen.h" />
<ClInclude Include="LookUpTables.h" />
@ -201,4 +199,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -95,9 +95,6 @@
<ClCompile Include="HiresTextures.cpp">
<Filter>Util</Filter>
</ClCompile>
<ClCompile Include="ImageWrite.cpp">
<Filter>Util</Filter>
</ClCompile>
<ClCompile Include="IndexGenerator.cpp">
<Filter>Util</Filter>
</ClCompile>
@ -290,9 +287,6 @@
<ClInclude Include="HiresTextures.h">
<Filter>Util</Filter>
</ClInclude>
<ClInclude Include="ImageWrite.h">
<Filter>Util</Filter>
</ClInclude>
<ClInclude Include="IndexGenerator.h">
<Filter>Util</Filter>
</ClInclude>
@ -411,4 +405,4 @@
<ItemGroup>
<Text Include="CMakeLists.txt" />
</ItemGroup>
</Project>
</Project>