From 4625b55ad654f3bbef30a7badb667e653a575426 Mon Sep 17 00:00:00 2001 From: heinrich5991 Date: Tue, 21 Jun 2022 15:26:23 +0200 Subject: [PATCH] Move PNG handling to src/engine/gfx This way, it's no longer compiled into the server. --- CMakeLists.txt | 24 ++++++++++++------- src/engine/client/backend/backend_base.cpp | 2 +- .../client/backend/opengl/backend_opengl.cpp | 2 +- .../client/backend/opengl/backend_opengl3.cpp | 2 +- .../client/backend/vulkan/backend_vulkan.cpp | 2 +- src/engine/client/graphics_threaded.cpp | 6 ++--- src/engine/{shared => gfx}/image_loader.cpp | 0 src/engine/{shared => gfx}/image_loader.h | 6 ++--- .../{shared => gfx}/image_manipulation.cpp | 0 .../{shared => gfx}/image_manipulation.h | 6 ++--- src/game/editor/editor.cpp | 3 +-- src/tools/dilate.cpp | 4 ++-- src/tools/map_convert_07.cpp | 3 +-- src/tools/map_extract.cpp | 3 +-- src/tools/map_optimize.cpp | 2 +- src/tools/map_replace_image.cpp | 3 +-- 16 files changed, 34 insertions(+), 34 deletions(-) rename src/engine/{shared => gfx}/image_loader.cpp (100%) rename src/engine/{shared => gfx}/image_loader.h (86%) rename src/engine/{shared => gfx}/image_manipulation.cpp (100%) rename src/engine/{shared => gfx}/image_manipulation.h (75%) diff --git a/CMakeLists.txt b/CMakeLists.txt index da708cefe..c49067ac1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1759,10 +1759,6 @@ set_src(ENGINE_SHARED GLOB_RECURSE src/engine/shared http.h huffman.cpp huffman.h - image_loader.cpp - image_loader.h - image_manipulation.cpp - image_manipulation.h jobs.cpp jobs.h json.cpp @@ -1811,6 +1807,12 @@ set_src(ENGINE_SHARED GLOB_RECURSE src/engine/shared websockets.cpp websockets.h ) +set_src(ENGINE_GFX GLOB src/engine/gfx + image_loader.cpp + image_loader.h + image_manipulation.cpp + image_manipulation.h +) set_src(GAME_SHARED GLOB src/game bezier.cpp bezier.h @@ -1874,7 +1876,6 @@ set(LIBS ${CURL_LIBRARIES} ${SQLite3_LIBRARIES} ${WEBSOCKETS_LIBRARIES} - ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} ${PLATFORM_LIBS} # Add pthreads (on non-Windows) at the end, so that other libraries can depend @@ -1883,10 +1884,11 @@ set(LIBS ) # Targets +add_library(engine-gfx EXCLUDE_FROM_ALL OBJECT ${ENGINE_GFX}) +target_include_directories(engine-gfx PRIVATE ${PNG_INCLUDE_DIRS}) add_library(engine-shared EXCLUDE_FROM_ALL OBJECT ${ENGINE_INTERFACE} ${ENGINE_SHARED} ${ENGINE_UUID_SHARED} ${BASE}) -target_include_directories(engine-shared PRIVATE ${PNG_INCLUDE_DIRS}) add_library(game-shared EXCLUDE_FROM_ALL OBJECT ${GAME_SHARED} ${GAME_GENERATED_SHARED}) -list(APPEND TARGETS_OWN engine-shared game-shared) +list(APPEND TARGETS_OWN engine-gfx engine-shared game-shared) if(DISCORD AND NOT DISCORD_DYNAMIC) add_library(discord-shared SHARED IMPORTED) @@ -2168,6 +2170,7 @@ if(CLIENT) ${CLIENT_ICON} ${CLIENT_MANIFEST} ${DEPS_CLIENT} + $ $ $ ) @@ -2177,6 +2180,7 @@ if(CLIENT) ${CLIENT_ICON} ${CLIENT_MANIFEST} ${DEPS_CLIENT} + $ $ $ ) @@ -2351,7 +2355,6 @@ if(SERVER) # Libraries set(LIBS_SERVER ${LIBS} - ${PNG_LIBRARIES} ${MYSQL_LIBRARIES} ${TARGET_ANTIBOT} ${MINIUPNPC_LIBRARIES} @@ -2424,6 +2427,8 @@ if(TOOLS) set(TOOL_LIBS ${LIBS}) if(TOOL MATCHES "^(dilate|map_convert_07|map_optimize|map_extract|map_replace_image)$") list(APPEND TOOL_INCLUDE_DIRS ${PNG_INCLUDE_DIRS}) + list(APPEND TOOL_DEPS $) + list(APPEND TOOL_LIBS ${PNG_LIBRARIES}) endif() if(TOOL MATCHES "^config_") list(APPEND EXTRA_TOOL_SRC "src/tools/config_common.h") @@ -2548,11 +2553,12 @@ if(GTEST_FOUND OR DOWNLOAD_GTEST) add_executable(${TARGET_TESTRUNNER} EXCLUDE_FROM_ALL ${TESTS} ${TESTS_EXTRA} + $ $ $ ${DEPS} ) - target_link_libraries(${TARGET_TESTRUNNER} ${LIBS} ${MYSQL_LIBRARIES} ${GTEST_LIBRARIES}) + target_link_libraries(${TARGET_TESTRUNNER} ${LIBS} ${MYSQL_LIBRARIES} ${PNG_LIBRARIES} ${GTEST_LIBRARIES}) target_include_directories(${TARGET_TESTRUNNER} SYSTEM PRIVATE ${GTEST_INCLUDE_DIRS}) list(APPEND TARGETS_OWN ${TARGET_TESTRUNNER}) diff --git a/src/engine/client/backend/backend_base.cpp b/src/engine/client/backend/backend_base.cpp index 59efc932c..498217a9b 100644 --- a/src/engine/client/backend/backend_base.cpp +++ b/src/engine/client/backend/backend_base.cpp @@ -1,5 +1,5 @@ #include "backend_base.h" -#include "engine/shared/image_manipulation.h" +#include size_t CCommandProcessorFragment_GLBase::TexFormatToImageColorChannelCount(int TexFormat) { diff --git a/src/engine/client/backend/opengl/backend_opengl.cpp b/src/engine/client/backend/opengl/backend_opengl.cpp index 64a2bc8db..28e9e80bf 100644 --- a/src/engine/client/backend/opengl/backend_opengl.cpp +++ b/src/engine/client/backend/opengl/backend_opengl.cpp @@ -14,7 +14,7 @@ #include -#include +#include #ifndef BACKEND_AS_OPENGL_ES #include diff --git a/src/engine/client/backend/opengl/backend_opengl3.cpp b/src/engine/client/backend/opengl/backend_opengl3.cpp index 101243dc6..ddb2fa573 100644 --- a/src/engine/client/backend/opengl/backend_opengl3.cpp +++ b/src/engine/client/backend/opengl/backend_opengl3.cpp @@ -15,7 +15,7 @@ #include #include -#include +#include #include diff --git a/src/engine/client/backend/vulkan/backend_vulkan.cpp b/src/engine/client/backend/vulkan/backend_vulkan.cpp index aec2680c7..8d5c4662e 100644 --- a/src/engine/client/backend/vulkan/backend_vulkan.cpp +++ b/src/engine/client/backend/vulkan/backend_vulkan.cpp @@ -5,9 +5,9 @@ #include #include #include +#include #include #include -#include #include #include diff --git a/src/engine/client/graphics_threaded.cpp b/src/engine/client/graphics_threaded.cpp index 0198ce075..cbd683c94 100644 --- a/src/engine/client/graphics_threaded.cpp +++ b/src/engine/client/graphics_threaded.cpp @@ -10,9 +10,9 @@ #include -#include - #include +#include +#include #include #include #include @@ -20,8 +20,6 @@ #include #include -#include - #if defined(CONF_VIDEORECORDER) #include #endif diff --git a/src/engine/shared/image_loader.cpp b/src/engine/gfx/image_loader.cpp similarity index 100% rename from src/engine/shared/image_loader.cpp rename to src/engine/gfx/image_loader.cpp diff --git a/src/engine/shared/image_loader.h b/src/engine/gfx/image_loader.h similarity index 86% rename from src/engine/shared/image_loader.h rename to src/engine/gfx/image_loader.h index 0fce77f5d..e6b678594 100644 --- a/src/engine/shared/image_loader.h +++ b/src/engine/gfx/image_loader.h @@ -1,5 +1,5 @@ -#ifndef ENGINE_SHARED_IMAGE_LOADER_H -#define ENGINE_SHARED_IMAGE_LOADER_H +#ifndef ENGINE_GFX_IMAGE_LOADER_H +#define ENGINE_GFX_IMAGE_LOADER_H #include #include @@ -25,4 +25,4 @@ struct SImageByteBuffer bool LoadPNG(SImageByteBuffer &ByteLoader, const char *pFileName, int &Width, int &Height, uint8_t *&pImageBuff, EImageFormat &ImageFormat); bool SavePNG(EImageFormat ImageFormat, const uint8_t *pRawBuffer, SImageByteBuffer &WrittenBytes, int Width, int Height); -#endif +#endif // ENGINE_GFX_IMAGE_LOADER_H diff --git a/src/engine/shared/image_manipulation.cpp b/src/engine/gfx/image_manipulation.cpp similarity index 100% rename from src/engine/shared/image_manipulation.cpp rename to src/engine/gfx/image_manipulation.cpp diff --git a/src/engine/shared/image_manipulation.h b/src/engine/gfx/image_manipulation.h similarity index 75% rename from src/engine/shared/image_manipulation.h rename to src/engine/gfx/image_manipulation.h index bc78c4727..23a41cb6f 100644 --- a/src/engine/shared/image_manipulation.h +++ b/src/engine/gfx/image_manipulation.h @@ -1,5 +1,5 @@ -#ifndef ENGINE_SHARED_IMAGE_MANIPULATION_H -#define ENGINE_SHARED_IMAGE_MANIPULATION_H +#ifndef ENGINE_GFX_IMAGE_MANIPULATION_H +#define ENGINE_GFX_IMAGE_MANIPULATION_H #include @@ -11,4 +11,4 @@ uint8_t *ResizeImage(const uint8_t *pImageData, int Width, int Height, int NewWi int HighestBit(int OfVar); -#endif +#endif // ENGINE_GFX_IMAGE_MANIPULATION_H diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index d7df3537f..978c81915 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -26,8 +27,6 @@ #include #include -#include - #include "auto_map.h" #include "editor.h" diff --git a/src/tools/dilate.cpp b/src/tools/dilate.cpp index d3b70bb37..b436d5cfe 100644 --- a/src/tools/dilate.cpp +++ b/src/tools/dilate.cpp @@ -2,9 +2,9 @@ /* If you are missing that file, acquire a complete release at teeworlds.com. */ #include #include +#include +#include #include -#include -#include int DilateFile(const char *pFilename) { diff --git a/src/tools/map_convert_07.cpp b/src/tools/map_convert_07.cpp index 718f9e6ae..54f44a0fc 100644 --- a/src/tools/map_convert_07.cpp +++ b/src/tools/map_convert_07.cpp @@ -3,13 +3,12 @@ #include #include +#include #include #include #include #include #include - -#include /* Usage: map_convert_07 */ diff --git a/src/tools/map_extract.cpp b/src/tools/map_extract.cpp index c98119bf6..d70170cba 100644 --- a/src/tools/map_extract.cpp +++ b/src/tools/map_extract.cpp @@ -1,12 +1,11 @@ // Adapted from TWMapImagesRecovery by Tardo: https://github.com/Tardo/TWMapImagesRecovery #include #include +#include #include #include #include -#include - bool Process(IStorage *pStorage, const char *pMapName, const char *pPathSave) { CDataFileReader Reader; diff --git a/src/tools/map_optimize.cpp b/src/tools/map_optimize.cpp index c4c55f15d..09d35a58e 100644 --- a/src/tools/map_optimize.cpp +++ b/src/tools/map_optimize.cpp @@ -2,8 +2,8 @@ #include #include #include +#include #include -#include #include #include #include diff --git a/src/tools/map_replace_image.cpp b/src/tools/map_replace_image.cpp index c02c3e2bc..83a25b747 100644 --- a/src/tools/map_replace_image.cpp +++ b/src/tools/map_replace_image.cpp @@ -3,12 +3,11 @@ #include #include +#include #include #include #include #include - -#include /* Usage: map_replace_image Notes: map filepath must be relative to user default teeworlds folder