Compare commits
No commits in common. "854d09f05caa2549cffa0e44c1743138c8503356" and "dadc72c8e0b852befe8dc2f0ceae66f545370c28" have entirely different histories.
854d09f05c
...
dadc72c8e0
20
.github/workflows/cd.yml
vendored
20
.github/workflows/cd.yml
vendored
@ -7,7 +7,7 @@ on:
|
||||
branches: [ master ]
|
||||
|
||||
env:
|
||||
BUILD_TYPE: RelWithDebInfo
|
||||
BUILD_TYPE: Release
|
||||
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
|
||||
|
||||
jobs:
|
||||
@ -17,7 +17,7 @@ jobs:
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@ -63,7 +63,7 @@ jobs:
|
||||
runs-on: windows-2019
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@ -75,11 +75,8 @@ jobs:
|
||||
with:
|
||||
arch: amd64
|
||||
|
||||
## sdl_image vendored needs nasm for dav1d
|
||||
#- uses: ilammy/setup-nasm@v1
|
||||
|
||||
- name: Configure CMake
|
||||
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DSDL3IMAGE_VENDORED=ON -DSDL3IMAGE_DEPS_SHARED=ON -DSDL3IMAGE_JXL=OFF -DSDL3IMAGE_AVIF=OFF
|
||||
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static
|
||||
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
||||
@ -117,7 +114,7 @@ jobs:
|
||||
runs-on: windows-2019
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@ -129,11 +126,8 @@ jobs:
|
||||
with:
|
||||
arch: amd64
|
||||
|
||||
## sdl_image vendored needs nasm for dav1d
|
||||
#- uses: ilammy/setup-nasm@v1
|
||||
|
||||
- name: Configure CMake
|
||||
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DTOMATO_ASAN=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DSDL3IMAGE_VENDORED=ON -DSDL3IMAGE_DEPS_SHARED=ON -DSDL3IMAGE_JXL=OFF -DSDL3IMAGE_AVIF=OFF
|
||||
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DTOMATO_ASAN=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
|
||||
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||
@ -178,7 +172,7 @@ jobs:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
|
13
.github/workflows/ci.yml
vendored
13
.github/workflows/ci.yml
vendored
@ -16,7 +16,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@ -35,7 +35,7 @@ jobs:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@ -49,12 +49,12 @@ jobs:
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||
|
||||
windows:
|
||||
timeout-minutes: 15
|
||||
timeout-minutes: 10
|
||||
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@ -66,11 +66,8 @@ jobs:
|
||||
with:
|
||||
arch: amd64
|
||||
|
||||
## sdl_image vendored needs nasm for dav1d
|
||||
#- uses: ilammy/setup-nasm@v1
|
||||
|
||||
- name: Configure CMake
|
||||
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DSDL3IMAGE_VENDORED=ON -DSDL3IMAGE_DEPS_SHARED=ON -DSDL3IMAGE_JXL=OFF -DSDL3IMAGE_AVIF=OFF
|
||||
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static
|
||||
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||
|
1
external/CMakeLists.txt
vendored
1
external/CMakeLists.txt
vendored
@ -21,5 +21,4 @@ add_subdirectory(./imgui)
|
||||
add_subdirectory(./stb)
|
||||
add_subdirectory(./libwebp)
|
||||
add_subdirectory(./qoi)
|
||||
add_subdirectory(./sdl_image)
|
||||
|
||||
|
23
external/sdl_image/CMakeLists.txt
vendored
23
external/sdl_image/CMakeLists.txt
vendored
@ -1,23 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.16...3.24 FATAL_ERROR)
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
if (NOT TARGET SDL3_image::SDL3_image)
|
||||
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
|
||||
# TODO: make pr to make this an option
|
||||
set(SDL3IMAGE_BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
|
||||
set(SDL3IMAGE_BACKEND_STB OFF CACHE BOOL "" FORCE) # important for security
|
||||
set(SDL3IMAGE_BACKEND_IMAGEIO OFF CACHE BOOL "" FORCE) # some funky apple cmake bug
|
||||
#set(SDL3IMAGE_JXL ON CACHE BOOL "" FORCE) # default to off
|
||||
set(SDL3IMAGE_QOI OFF CACHE BOOL "" FORCE) # we have our own
|
||||
set(SDL3IMAGE_WEBP OFF CACHE BOOL "" FORCE) # we have our own
|
||||
|
||||
FetchContent_Declare(SDL3_image
|
||||
GIT_REPOSITORY https://github.com/libsdl-org/SDL_image
|
||||
# waiting on the imgui pr to get merged so i can update sdl <.<
|
||||
GIT_TAG a45d6e5b84ccc0f3faae6ba7d561709ed600eee7 # tip last check
|
||||
FIND_PACKAGE_ARGS # for the future
|
||||
)
|
||||
FetchContent_MakeAvailable(SDL3_image)
|
||||
endif()
|
||||
|
32
flake.lock
generated
32
flake.lock
generated
@ -5,11 +5,11 @@
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1710146030,
|
||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||
"lastModified": 1694529238,
|
||||
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -20,11 +20,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1713189761,
|
||||
"narHash": "sha256-MPp1dBhlY066IeBo+EPGEUN+s+aSUA+LWkvnzKh+rts=",
|
||||
"lastModified": 1709953752,
|
||||
"narHash": "sha256-LW84B4vM1cn7E6cDNQn2LndT9iJXI1dRE5fwbNFbQa8=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "ff44be4d8ff33f797ff3e3f87153d4f3b6a85ffb",
|
||||
"rev": "fcaa81ed3c273237217330cf342ef1873b77c80a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -56,8 +56,7 @@
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"nlohmann-json": "nlohmann-json",
|
||||
"sdl3": "sdl3",
|
||||
"sdl3_image": "sdl3_image"
|
||||
"sdl3": "sdl3"
|
||||
}
|
||||
},
|
||||
"sdl3": {
|
||||
@ -77,23 +76,6 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"sdl3_image": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1712700609,
|
||||
"narHash": "sha256-PVPH1uJ6g65SzHUboeQE6ZkC+72doMz9t9SG2LBo+7I=",
|
||||
"owner": "libsdl-org",
|
||||
"repo": "SDL_image",
|
||||
"rev": "a45d6e5b84ccc0f3faae6ba7d561709ed600eee7",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "libsdl-org",
|
||||
"repo": "SDL_image",
|
||||
"rev": "a45d6e5b84ccc0f3faae6ba7d561709ed600eee7",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
|
15
flake.nix
15
flake.nix
@ -14,13 +14,9 @@
|
||||
url = "github:libsdl-org/SDL/0429f5d6a36fc35b551bcc2acd4a40c2db6dab82"; # keep in sync this cmake
|
||||
flake = false;
|
||||
};
|
||||
sdl3_image = {
|
||||
url = "github:libsdl-org/SDL_image/a45d6e5b84ccc0f3faae6ba7d561709ed600eee7";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils, nlohmann-json, sdl3, sdl3_image }:
|
||||
outputs = { self, nixpkgs, flake-utils, nlohmann-json, sdl3 }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
@ -61,13 +57,6 @@
|
||||
libGL
|
||||
|
||||
pipewire
|
||||
|
||||
# sdl3_image:
|
||||
libpng
|
||||
libjpeg
|
||||
libjxl
|
||||
libavif
|
||||
#libwebp # still using our own loader
|
||||
];
|
||||
|
||||
buildInputs = with pkgs; [
|
||||
@ -85,8 +74,6 @@
|
||||
"-DFETCHCONTENT_SOURCE_DIR_ZSTD=${pkgs.zstd.src}" # we dont care about the version (we use 1.4.x features)
|
||||
"-DFETCHCONTENT_SOURCE_DIR_LIBWEBP=${pkgs.libwebp.src}"
|
||||
"-DFETCHCONTENT_SOURCE_DIR_SDL3=${sdl3}"
|
||||
"-DFETCHCONTENT_SOURCE_DIR_SDL3_IMAGE=${sdl3_image}"
|
||||
"-DSDL3IMAGE_JXL=ON"
|
||||
];
|
||||
|
||||
# TODO: replace with install command
|
||||
|
@ -29,8 +29,6 @@ add_executable(tomato
|
||||
./image_loader_webp.cpp
|
||||
./image_loader_qoi.hpp
|
||||
./image_loader_qoi.cpp
|
||||
./image_loader_sdl_image.hpp
|
||||
./image_loader_sdl_image.cpp
|
||||
|
||||
./texture_uploader.hpp
|
||||
./sdlrenderer_texture_uploader.hpp
|
||||
@ -100,6 +98,5 @@ target_link_libraries(tomato PUBLIC
|
||||
webpdemux
|
||||
libwebpmux # the f why (needed for anim encode)
|
||||
qoi
|
||||
SDL3_image::SDL3_image
|
||||
)
|
||||
|
||||
|
@ -1,118 +0,0 @@
|
||||
#include "./image_loader_sdl_image.hpp"
|
||||
|
||||
#include <SDL3_image/SDL_image.h>
|
||||
|
||||
#include <optional>
|
||||
#include <iostream>
|
||||
|
||||
static std::optional<const char*> getExt(SDL_IOStream* ios) {
|
||||
if (IMG_isAVIF(ios)) {
|
||||
return "avif";
|
||||
} else if (IMG_isCUR(ios)) {
|
||||
return "cur";
|
||||
} else if (IMG_isICO(ios)) {
|
||||
return "ico";
|
||||
} else if (IMG_isBMP(ios)) {
|
||||
return "bmp";
|
||||
} else if (IMG_isGIF(ios)) {
|
||||
return "gif";
|
||||
} else if (IMG_isJPG(ios)) {
|
||||
return "jpg";
|
||||
} else if (IMG_isJXL(ios)) {
|
||||
return "jxl";
|
||||
} else if (IMG_isLBM(ios)) {
|
||||
return "lbm";
|
||||
} else if (IMG_isPCX(ios)) {
|
||||
return "pcx";
|
||||
} else if (IMG_isPNG(ios)) {
|
||||
return "png";
|
||||
} else if (IMG_isPNM(ios)) {
|
||||
return "pnm";
|
||||
} else if (IMG_isSVG(ios)) {
|
||||
return "svg";
|
||||
} else if (IMG_isTIF(ios)) {
|
||||
return "tiff";
|
||||
} else if (IMG_isXCF(ios)) {
|
||||
return "xcf";
|
||||
} else if (IMG_isXPM(ios)) {
|
||||
return "xpm";
|
||||
} else if (IMG_isXV(ios)) {
|
||||
return "xv";
|
||||
} else if (IMG_isWEBP(ios)) {
|
||||
return "webp";
|
||||
} else if (IMG_isQOI(ios)) {
|
||||
return "qoi";
|
||||
} else {
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
ImageLoaderSDLImage::ImageInfo ImageLoaderSDLImage::loadInfoFromMemory(const uint8_t* data, uint64_t data_size) {
|
||||
ImageInfo res;
|
||||
|
||||
auto* ios = SDL_IOFromConstMem(data, data_size);
|
||||
|
||||
// we ignore tga
|
||||
auto ext_opt = getExt(ios);
|
||||
if (!ext_opt.has_value()) {
|
||||
return res;
|
||||
}
|
||||
|
||||
SDL_Surface* surf = IMG_Load_IO(ios, SDL_TRUE);
|
||||
if (surf == nullptr) {
|
||||
return res;
|
||||
}
|
||||
|
||||
res.width = surf->w;
|
||||
res.height = surf->h;
|
||||
res.file_ext = ext_opt.value();
|
||||
|
||||
SDL_DestroySurface(surf);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
ImageLoaderSDLImage::ImageResult ImageLoaderSDLImage::loadFromMemoryRGBA(const uint8_t* data, uint64_t data_size) {
|
||||
ImageResult res;
|
||||
|
||||
auto* ios = SDL_IOFromConstMem(data, data_size);
|
||||
|
||||
// we ignore tga
|
||||
auto ext_opt = getExt(ios);
|
||||
if (!ext_opt.has_value()) {
|
||||
return res;
|
||||
}
|
||||
|
||||
IMG_Animation* anim = IMG_LoadAnimation_IO(ios, SDL_TRUE);
|
||||
if (anim == nullptr) {
|
||||
return res;
|
||||
}
|
||||
|
||||
for (int i = 0; i < anim->count; i++) {
|
||||
SDL_Surface* conv_surf = SDL_ConvertSurfaceFormat(anim->frames[i], SDL_PIXELFORMAT_RGBA32);
|
||||
if (conv_surf == nullptr) {
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
SDL_LockSurface(conv_surf);
|
||||
|
||||
auto& new_frame = res.frames.emplace_back();
|
||||
new_frame.ms = anim->delays[i];
|
||||
new_frame.data.insert(new_frame.data.cbegin(), (const uint8_t*)conv_surf->pixels, ((const uint8_t*)conv_surf->pixels) + (anim->w*anim->h*4));
|
||||
|
||||
SDL_UnlockSurface(conv_surf);
|
||||
SDL_DestroySurface(conv_surf);
|
||||
}
|
||||
|
||||
res.width = anim->w;
|
||||
res.height = anim->h;
|
||||
res.file_ext = ext_opt.value();
|
||||
|
||||
IMG_FreeAnimation(anim);
|
||||
|
||||
std::cout << "IL_SDLI: loaded img " << res.width << "x" << res.height << "\n";
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "./image_loader.hpp"
|
||||
|
||||
struct ImageLoaderSDLImage : public ImageLoaderI {
|
||||
ImageInfo loadInfoFromMemory(const uint8_t* data, uint64_t data_size) override;
|
||||
ImageResult loadFromMemoryRGBA(const uint8_t* data, uint64_t data_size) override;
|
||||
};
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include "./image_loader_sdl_bmp.hpp"
|
||||
#include "./image_loader_qoi.hpp"
|
||||
#include "./image_loader_stb.hpp"
|
||||
#include "./image_loader_sdl_image.hpp"
|
||||
|
||||
#include <solanaceae/message3/components.hpp>
|
||||
|
||||
@ -80,7 +79,6 @@ MediaMetaInfoLoader::MediaMetaInfoLoader(RegistryMessageModel& rmm) : _rmm(rmm)
|
||||
_image_loaders.push_back(std::make_unique<ImageLoaderWebP>());
|
||||
_image_loaders.push_back(std::make_unique<ImageLoaderSDLBMP>());
|
||||
_image_loaders.push_back(std::make_unique<ImageLoaderQOI>());
|
||||
_image_loaders.push_back(std::make_unique<ImageLoaderSDLImage>());
|
||||
_image_loaders.push_back(std::make_unique<ImageLoaderSTB>());
|
||||
|
||||
_rmm.subscribe(this, RegistryMessageModel_Event::message_construct);
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include "./image_loader_qoi.hpp"
|
||||
#include "./image_loader_stb.hpp"
|
||||
#include "./image_loader_webp.hpp"
|
||||
#include "./image_loader_sdl_image.hpp"
|
||||
#include "./media_meta_info_loader.hpp"
|
||||
|
||||
#include <solanaceae/message3/components.hpp>
|
||||
@ -23,7 +22,6 @@ MessageImageLoader::MessageImageLoader(void) {
|
||||
_image_loaders.push_back(std::make_unique<ImageLoaderSDLBMP>());
|
||||
_image_loaders.push_back(std::make_unique<ImageLoaderQOI>());
|
||||
_image_loaders.push_back(std::make_unique<ImageLoaderWebP>());
|
||||
_image_loaders.push_back(std::make_unique<ImageLoaderSDLImage>());
|
||||
_image_loaders.push_back(std::make_unique<ImageLoaderSTB>());
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include "./image_loader_qoi.hpp"
|
||||
#include "./image_loader_stb.hpp"
|
||||
#include "./image_loader_webp.hpp"
|
||||
#include "./image_loader_sdl_image.hpp"
|
||||
|
||||
#include <solanaceae/contact/components.hpp>
|
||||
#include <solanaceae/tox_contacts/components.hpp>
|
||||
@ -25,7 +24,6 @@ ToxAvatarLoader::ToxAvatarLoader(Contact3Registry& cr) : _cr(cr) {
|
||||
_image_loaders.push_back(std::make_unique<ImageLoaderSDLBMP>());
|
||||
_image_loaders.push_back(std::make_unique<ImageLoaderQOI>());
|
||||
_image_loaders.push_back(std::make_unique<ImageLoaderWebP>());
|
||||
_image_loaders.push_back(std::make_unique<ImageLoaderSDLImage>());
|
||||
_image_loaders.push_back(std::make_unique<ImageLoaderSTB>());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user