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

Use kimageformats to decode AVIF #230

Merged
merged 7 commits into from
Aug 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .CI/CreateUbuntuDeb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ deb_path="Chatterino-ubuntu-${ubuntu_release}-x86_64.deb"
# Refactor opportunity:
case "$ubuntu_release" in
20.04)
dependencies="libc6, libstdc++6, libqt5core5a, libqt5concurrent5, libqt5dbus5, libqt5gui5, libqt5network5, libqt5svg5, libqt5widgets5, qt5-image-formats-plugins, libboost-filesystem1.71.0"
dependencies="libc6, libstdc++6, libqt5core5a, libqt5concurrent5, libqt5dbus5, libqt5gui5, libqt5network5, libqt5svg5, libqt5widgets5, qt5-image-formats-plugins, libboost-filesystem1.71.0, libavif"
;;
22.04)
if [ -n "$Qt6_DIR" ]; then
echo "Qt6_DIR set, assuming Qt6"
dependencies="libc6, libstdc++6, libqt6core6, libqt6widgets6, libqt6network6, libqt6core5compat6, libqt6svg6, qt6-qpa-plugins, qt6-image-formats-plugins"
dependencies="libc6, libstdc++6, libqt6core6, libqt6widgets6, libqt6network6, libqt6core5compat6, libqt6svg6, qt6-qpa-plugins, qt6-image-formats-plugins, libavif"
else
dependencies="libc6, libstdc++6, libqt5core5a, libqt5concurrent5, libqt5dbus5, libqt5gui5, libqt5network5, libqt5svg5, libqt5widgets5, qt5-image-formats-plugins, libboost-filesystem1.74.0"
dependencies="libc6, libstdc++6, libqt5core5a, libqt5concurrent5, libqt5dbus5, libqt5gui5, libqt5network5, libqt5svg5, libqt5widgets5, qt5-image-formats-plugins, libboost-filesystem1.74.0, libavif"
fi
;;
*)
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ jobs:
libboost-dev, libboost-system-dev, libboost-filesystem-dev,
libssl-dev,
rapidjson-dev,
libbenchmark-dev
libbenchmark-dev,
libavif-dev

- name: clang-tidy-review upload
if: matrix.clang-tidy-review && github.event_name == 'pull_request'
Expand Down Expand Up @@ -345,7 +346,7 @@ jobs:
- name: Install dependencies (MacOS)
if: startsWith(matrix.os, 'macos')
run: |
brew install boost openssl rapidjson p7zip create-dmg cmake tree
brew install boost openssl rapidjson p7zip create-dmg cmake tree libavif
shell: bash

- name: Build (MacOS)
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@
[submodule "lib/crashpad"]
path = lib/crashpad
url = https://github.com/getsentry/crashpad
[submodule "lib/kimageformats"]
path = lib/kimageformats
url = https://github.com/KDE/kimageformats
8 changes: 4 additions & 4 deletions BUILDING_ON_LINUX.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ Note on Qt version compatibility: If you are installing Qt from a package manage

_Most likely works the same for other Debian-like distros_

Install all of the dependencies using `sudo apt install qttools5-dev qt5-image-formats-plugins libqt5svg5-dev libboost-dev libssl-dev libboost-system-dev libboost-filesystem-dev cmake g++ libsecret-1-dev`
Install all of the dependencies using `sudo apt install qttools5-dev qt5-image-formats-plugins libqt5svg5-dev libboost-dev libssl-dev libboost-system-dev libboost-filesystem-dev cmake g++ libsecret-1-dev libavif-dev`

### Arch Linux

Install all of the dependencies using `sudo pacman -S --needed qt5-base qt5-imageformats qt5-svg qt5-tools boost rapidjson pkgconf openssl cmake`
Install all of the dependencies using `sudo pacman -S --needed qt5-base qt5-imageformats qt5-svg qt5-tools boost rapidjson pkgconf openssl cmake libavif-git`

Alternatively you can use the [chatterino2-git](https://aur.archlinux.org/packages/chatterino2-git/) package to build and install Chatterino for you.

### Fedora 28 and above

_Most likely works the same for other Red Hat-like distros. Substitute `dnf` with `yum`._

Install all of the dependencies using `sudo dnf install qt5-qtbase-devel qt5-imageformats qt5-qtsvg-devel qt5-linguist libsecret-devel openssl-devel boost-devel cmake`
Install all of the dependencies using `sudo dnf install qt5-qtbase-devel qt5-imageformats qt5-qtsvg-devel qt5-linguist libsecret-devel openssl-devel boost-devel cmake libavif-devel`

### NixOS 18.09+

Enter the development environment with all of the dependencies: `nix-shell -p openssl boost qt5.full pkg-config cmake`
Enter the development environment with all of the dependencies: `nix-shell -p openssl boost qt5.full pkg-config cmake libavif`

## Compile

Expand Down
2 changes: 1 addition & 1 deletion BUILDING_ON_MAC.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Local dev machines for testing are available on Apple Silicon on macOS 13.
1. Install [Homebrew](https://brew.sh/#install)
We use this for dependency management on macOS
1. Install all dependencies:
`brew install boost [email protected] rapidjson cmake qt@5`
`brew install boost [email protected] rapidjson cmake qt@5 libavif`

## Building

Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Generate resource files
include(cmake/resources/generate_resources.cmake)

add_subdirectory(${CMAKE_SOURCE_DIR}/lib/qt-plugins)

add_subdirectory(src)

if (BUILD_TESTS OR BUILD_BENCHMARKS)
Expand Down
10 changes: 10 additions & 0 deletions cmake/AVIF.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
find_package(libavif)

if (libavif_FOUND)
set(kimageformats_SRC ${CMAKE_SOURCE_DIR}/lib/kimageformats/src/imageformats)

add_library(kimageformats STATIC ${kimageformats_SRC}/avif.cpp)
set_target_properties(kimageformats PROPERTIES AUTOMOC ON)
target_link_libraries(kimageformats PRIVATE Qt${MAJOR_QT_VERSON}::Gui avif)
target_compile_definitions(kimageformats PRIVATE QT_STATICPLUGIN)
endif()
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class Chatterino(ConanFile):
name = "Chatterino"
requires = "boost/1.81.0"
requires = "boost/1.81.0", "libavif/0.11.1"
settings = "os", "compiler", "build_type", "arch"
default_options = {
"with_benchmark": False,
Expand Down
1 change: 1 addition & 0 deletions lib/kimageformats
Submodule kimageformats added at bcb530
10 changes: 10 additions & 0 deletions lib/qt-plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(${CMAKE_SOURCE_DIR}/cmake/AVIF.cmake)

add_library(chatterino-qt-plugins OBJECT ${CMAKE_CURRENT_LIST_DIR}/QtPlugins.cpp)
target_link_libraries(chatterino-qt-plugins PRIVATE Qt${MAJOR_QT_VERSION}::Core Qt${MAJOR_QT_VERSION}::Gui)
target_compile_definitions(chatterino-qt-plugins PRIVATE QT_STATICPLUGIN)

if (libavif_FOUND)
target_compile_definitions(chatterino-qt-plugins PRIVATE WITH_AVIF)
target_link_libraries(chatterino-qt-plugins PRIVATE kimageformats)
endif()
7 changes: 7 additions & 0 deletions lib/qt-plugins/QtPlugins.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

#include <QtCore/QtPlugin>

#ifdef WITH_AVIF
Q_IMPORT_PLUGIN(QAVIFPlugin)
#endif
Loading
Loading