add image interface, remove lodepng from video_core/core, address more comments, fix comments
remove unnecessary conversion
This commit is contained in:
parent
5940361b81
commit
b81c15941e
16 changed files with 208 additions and 55 deletions
|
@ -102,6 +102,7 @@ add_library(core STATIC
|
|||
frontend/emu_window.h
|
||||
frontend/framebuffer_layout.cpp
|
||||
frontend/framebuffer_layout.h
|
||||
frontend/image_interface.h
|
||||
frontend/input.h
|
||||
frontend/mic.h
|
||||
frontend/mic.cpp
|
||||
|
@ -460,7 +461,7 @@ endif()
|
|||
create_target_directory_groups(core)
|
||||
|
||||
target_link_libraries(core PUBLIC common PRIVATE audio_core network video_core)
|
||||
target_link_libraries(core PUBLIC Boost::boost PRIVATE cryptopp fmt open_source_archives lodepng)
|
||||
target_link_libraries(core PUBLIC Boost::boost PRIVATE cryptopp fmt open_source_archives)
|
||||
if (ENABLE_WEB_SERVICE)
|
||||
target_compile_definitions(core PRIVATE -DENABLE_WEB_SERVICE)
|
||||
target_link_libraries(core PRIVATE web_service)
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <lodepng.h>
|
||||
#include "audio_core/dsp_interface.h"
|
||||
#include "audio_core/hle/hle.h"
|
||||
#include "audio_core/lle/lle.h"
|
||||
|
@ -126,15 +125,14 @@ void System::PreloadCustomTextures() {
|
|||
u32 png_height;
|
||||
std::vector<u8> decoded_png;
|
||||
|
||||
u32 lodepng_ret =
|
||||
lodepng::decode(decoded_png, png_width, png_height, file.physicalName);
|
||||
if (lodepng_ret) {
|
||||
LOG_CRITICAL(Render_OpenGL, "Failed to preload custom texture: {}",
|
||||
lodepng_error_text(lodepng_ret));
|
||||
} else {
|
||||
if (registered_image_interface->DecodePNG(decoded_png, png_width, png_height,
|
||||
file.physicalName)) {
|
||||
LOG_INFO(Render_OpenGL, "Preloaded custom texture from {}", file.physicalName);
|
||||
Common::FlipRGBA8Texture(decoded_png, png_width, png_height);
|
||||
custom_tex_cache->CacheTexture(hash, decoded_png, png_width, png_height);
|
||||
} else {
|
||||
// Error should be reported by frontend
|
||||
LOG_CRITICAL(Render_OpenGL, "Failed to preload custom texture");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -404,6 +402,10 @@ void System::RegisterSoftwareKeyboard(std::shared_ptr<Frontend::SoftwareKeyboard
|
|||
registered_swkbd = std::move(swkbd);
|
||||
}
|
||||
|
||||
void System::RegisterImageInterface(std::shared_ptr<Frontend::ImageInterface> image_interface) {
|
||||
registered_image_interface = std::move(image_interface);
|
||||
}
|
||||
|
||||
void System::Shutdown() {
|
||||
// Log last frame performance stats
|
||||
const auto perf_results = GetAndResetPerfStats();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "core/custom_tex_cache.h"
|
||||
#include "core/frontend/applets/mii_selector.h"
|
||||
#include "core/frontend/applets/swkbd.h"
|
||||
#include "core/frontend/image_interface.h"
|
||||
#include "core/loader/loader.h"
|
||||
#include "core/memory.h"
|
||||
#include "core/perf_stats.h"
|
||||
|
@ -256,6 +257,14 @@ public:
|
|||
return registered_swkbd;
|
||||
}
|
||||
|
||||
/// Image interface
|
||||
|
||||
void RegisterImageInterface(std::shared_ptr<Frontend::ImageInterface> image_interface);
|
||||
|
||||
std::shared_ptr<Frontend::ImageInterface> GetImageInterface() const {
|
||||
return registered_image_interface;
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* Initialize the emulated system.
|
||||
|
@ -300,6 +309,9 @@ private:
|
|||
/// Custom texture cache system
|
||||
std::unique_ptr<Core::CustomTexCache> custom_tex_cache;
|
||||
|
||||
/// Image interface
|
||||
std::shared_ptr<Frontend::ImageInterface> registered_image_interface;
|
||||
|
||||
/// RPC Server for scripting support
|
||||
std::unique_ptr<RPC::RPCServer> rpc_server;
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
#include "custom_tex_cache.h"
|
||||
|
||||
namespace Core {
|
||||
CustomTexCache::CustomTexCache() {}
|
||||
CustomTexCache::CustomTexCache() = default;
|
||||
|
||||
CustomTexCache::~CustomTexCache() {}
|
||||
CustomTexCache::~CustomTexCache() = default;
|
||||
|
||||
bool CustomTexCache::IsTextureDumped(u64 hash) const {
|
||||
return dumped_textures.find(hash) != dumped_textures.end();
|
||||
|
|
28
src/core/frontend/image_interface.h
Normal file
28
src/core/frontend/image_interface.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2019 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "common/common_types.h"
|
||||
#include "common/logging/log.h"
|
||||
|
||||
namespace Frontend {
|
||||
|
||||
class ImageInterface {
|
||||
public:
|
||||
// Error logging should be handled by the frontend
|
||||
virtual bool DecodePNG(std::vector<u8>& dst, u32& width, u32& height, const std::string& path) {
|
||||
LOG_CRITICAL(Frontend, "Attempted to decode PNG without an image interface!");
|
||||
return false;
|
||||
};
|
||||
virtual bool EncodePNG(const std::string& path, const std::vector<u8>& src, u32 width,
|
||||
u32 height) {
|
||||
LOG_CRITICAL(Frontend, "Attempted to encode PNG without an image interface!");
|
||||
return false;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace Frontend
|
Loading…
Add table
Add a link
Reference in a new issue