Merge pull request #1080 from alfalfa-star/feat/videoout-window-icon

feat(videoout): use sce_sys/icon0.png as the window icon
This commit is contained in:
Adrià
2026-10-10 00:16:44 +02:00
committed by GitHub
2 changed files with 15 additions and 1 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ target_include_directories(libSceVideoOut PRIVATE
${CMAKE_SOURCE_DIR}/3rdparty/SDL2/include
${CMAKE_SOURCE_DIR}/3rdparty/Vulkan-Headers/include
)
target_link_libraries(libSceVideoOut PRIVATE libSceAgcDriver libScePad libSceMouse libSceKeyboard libc libkernel SDL2-static)
target_link_libraries(libSceVideoOut PRIVATE libSceAgcDriver libScePad libSceMouse libSceKeyboard libc libkernel decoder_png SDL2-static)
if(WIN32)
target_link_libraries(libSceVideoOut PRIVATE comctl32)
endif()
@@ -3,8 +3,10 @@
#include "prx/libSceAgcDriver/Execution/include/Driver.hpp"
#include "prx/libkernel/AppMetadata/include/AppMetadata.hpp"
#include "prx/libkernel/Time/include/Time.hpp"
#include "Decoder/Png.hpp"
#include "SDL_vulkan.h"
#include <cstdio>
#include <span>
#include <stdexcept>
#include <string>
@@ -20,6 +22,17 @@ void require(bool condition, const char* reason) {
if (!condition) throw std::runtime_error(std::string("DisplayWindow: ") + reason);
}
void applyAppIcon(SDL_Window* window) {
if (!HasAppIcon_nid_postfix()) return;
const auto data = GetAppIconData_nid_postfix();
auto image = Decoder::Png::Decode(std::span<const std::uint8_t>(data.bytes, static_cast<std::size_t>(data.size)));
require(image.has_value(), "failed to decode icon0.png");
SDL_Surface* icon = SDL_CreateRGBSurfaceWithFormatFrom(image->pixels.data(), static_cast<int>(image->width), static_cast<int>(image->height), 32, static_cast<int>(image->width * 4), SDL_PIXELFORMAT_RGBA32);
require(icon != nullptr, SDL_GetError());
SDL_SetWindowIcon(window, icon);
SDL_FreeSurface(icon);
}
#ifdef _WIN32
constexpr UINT_PTR DisplayWindowSubclassId = 0x41505335u;
#endif
@@ -51,6 +64,7 @@ void DisplayWindow::create(std::uint32_t sourceWidth, std::uint32_t sourceHeight
AgcDriverUnlockVulkanLoader_nid_postfix();
require(window != nullptr, SDL_GetError());
SDL_SetWindowMinimumSize(window, static_cast<int>(DisplayWindowMinimumWidth), static_cast<int>(DisplayWindowMinimumHeight));
applyAppIcon(window);
installSubclass();
}