diff --git a/.gitignore b/.gitignore index fe5bfbff..e33e45b1 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,5 @@ build-* build/ /temp -/out \ No newline at end of file +/out +/target \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 96aeddb3..14e036b6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,6 @@ { "files.associations": { + "*.temp": "plaintext", "*.cc": "cpp", "*.conf": "apacheconf", "*.h": "cpp", @@ -11,7 +12,72 @@ "*.pch": "objective-cpp", "utility": "cpp", "random": "cpp", - "cstdlib": "cpp" + "cstdlib": "cpp", + "algorithm": "cpp", + "atomic": "cpp", + "bit": "cpp", + "cctype": "cpp", + "charconv": "cpp", + "chrono": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "compare": "cpp", + "concepts": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "exception": "cpp", + "format": "cpp", + "forward_list": "cpp", + "fstream": "cpp", + "functional": "cpp", + "initializer_list": "cpp", + "iomanip": "cpp", + "ios": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "iterator": "cpp", + "limits": "cpp", + "list": "cpp", + "locale": "cpp", + "map": "cpp", + "memory": "cpp", + "new": "cpp", + "numeric": "cpp", + "optional": "cpp", + "ostream": "cpp", + "ratio": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "string": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "typeinfo": "cpp", + "unordered_map": "cpp", + "vector": "cpp", + "xfacet": "cpp", + "xhash": "cpp", + "xiosbase": "cpp", + "xlocale": "cpp", + "xlocbuf": "cpp", + "xlocinfo": "cpp", + "xlocmes": "cpp", + "xlocmon": "cpp", + "xlocnum": "cpp", + "xloctime": "cpp", + "xmemory": "cpp", + "xstring": "cpp", + "xtr1common": "cpp", + "xtree": "cpp", + "xutility": "cpp", + "*.rh": "cpp" }, "C_Cpp.errorSquiggles": "disabled", } \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index afae7edd..bd5628d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,7 +92,7 @@ endif() add_library(xege STATIC) -target_include_directories(xege PUBLIC include) +target_include_directories(xege PUBLIC ${PROJECT_SOURCE_DIR}/export) # 是否使用 libpng 和 zlib 处理 PNG 图片。 # 目前只能为 ON,未来或允许选择使用 WIC。 @@ -259,7 +259,7 @@ endmacro() add_subdirectory(src) if(EGE_BUILD_DEMO) - add_subdirectory(demo) + add_subdirectory(examples) endif() if(EGE_BUILD_TEMP AND EXISTS "${PROJECT_SOURCE_DIR}/temp/CMakeLists.txt") diff --git a/cup.toml b/cup.toml new file mode 100644 index 00000000..62d64288 --- /dev/null +++ b/cup.toml @@ -0,0 +1,58 @@ +[project] +name = "xege" +version = "0.1.0" +type = "static" + +[build] +# generator = "Ninja" +# generator = "MinGW Makefiles" +# generator = "Visual Studio 17 2022" +jobs = 0 +defines = ["CUP_BUILD"] + +[dependencies] +libpng = { url = "@Anglebase/libpng", version = "0.1.0" } + +[tests] +sources = [ + "tests/tests/image_generator.cpp", + "tests/tests/performance_timer.cpp", + "tests/tests/test_framework.cpp", +] +includes = ["tests/tests"] +defines = ["CUP_BUILD"] + +[examples] +defines = ["CUP_BUILD"] + +[generator."Visual Studio 17 2022"] +compile_options = ["/utf-8"] +[generator."Visual Studio 16 2019"] +compile_options = ["/utf-8"] +[generator."Visual Studio 15 2017"] +compile_options = ["/utf-8"] +[generator."Visual Studio 14 2015"] +compile_options = ["/utf-8"] + +[generator."MinGW Makefiles"] +link_libs = [ + "gdi32", + "user32", + "kernel32", + "gdiplus", + "ole32", + "oleaut32", + "uuid", + "winmm", +] +[generator."Ninja"] +link_libs = [ + "gdi32", + "user32", + "kernel32", + "gdiplus", + "ole32", + "oleaut32", + "uuid", + "winmm", +] \ No newline at end of file diff --git a/demo/CMakeLists.txt b/examples/CMakeLists.txt similarity index 100% rename from demo/CMakeLists.txt rename to examples/CMakeLists.txt diff --git a/demo/README.md b/examples/README.md similarity index 100% rename from demo/README.md rename to examples/README.md diff --git a/demo/egelogo.rc b/examples/egelogo.rc similarity index 97% rename from demo/egelogo.rc rename to examples/egelogo.rc index 06f9f081..8d2bf643 100644 --- a/demo/egelogo.rc +++ b/examples/egelogo.rc @@ -1 +1 @@ -EGE_LOGO_JPG JPG "../egelogo.jpg" +EGE_LOGO_JPG JPG "../egelogo.jpg" diff --git a/demo/game_gomoku.cpp b/examples/game_gomoku.cpp similarity index 100% rename from demo/game_gomoku.cpp rename to examples/game_gomoku.cpp diff --git a/demo/game_snake.cpp b/examples/game_snake.cpp similarity index 100% rename from demo/game_snake.cpp rename to examples/game_snake.cpp diff --git a/demo/game_tetris.cpp b/examples/game_tetris.cpp similarity index 100% rename from demo/game_tetris.cpp rename to examples/game_tetris.cpp diff --git a/demo/game_type.cpp b/examples/game_type.cpp similarity index 100% rename from demo/game_type.cpp rename to examples/game_type.cpp diff --git a/demo/getimage.jpg b/examples/getimage.jpg similarity index 100% rename from demo/getimage.jpg rename to examples/getimage.jpg diff --git a/demo/getimage.png b/examples/getimage.png similarity index 100% rename from demo/getimage.png rename to examples/getimage.png diff --git a/demo/gmp-demo/MandelbrotSet.cpp b/examples/gmp-demo/MandelbrotSet.cpp similarity index 100% rename from demo/gmp-demo/MandelbrotSet.cpp rename to examples/gmp-demo/MandelbrotSet.cpp diff --git a/demo/gmp-demo/MandelbrotSetAni.cpp b/examples/gmp-demo/MandelbrotSetAni.cpp similarity index 100% rename from demo/gmp-demo/MandelbrotSetAni.cpp rename to examples/gmp-demo/MandelbrotSetAni.cpp diff --git a/demo/gmp-demo/MandelbrotSetAniLarge.cpp b/examples/gmp-demo/MandelbrotSetAniLarge.cpp similarity index 100% rename from demo/gmp-demo/MandelbrotSetAniLarge.cpp rename to examples/gmp-demo/MandelbrotSetAniLarge.cpp diff --git a/demo/graph_5star.cpp b/examples/graph_5star.cpp similarity index 100% rename from demo/graph_5star.cpp rename to examples/graph_5star.cpp diff --git a/demo/graph_alpha.cpp b/examples/graph_alpha.cpp similarity index 100% rename from demo/graph_alpha.cpp rename to examples/graph_alpha.cpp diff --git a/demo/graph_arrow.cpp b/examples/graph_arrow.cpp similarity index 100% rename from demo/graph_arrow.cpp rename to examples/graph_arrow.cpp diff --git a/demo/graph_ball.cpp b/examples/graph_ball.cpp similarity index 100% rename from demo/graph_ball.cpp rename to examples/graph_ball.cpp diff --git a/demo/graph_catharine.cpp b/examples/graph_catharine.cpp similarity index 100% rename from demo/graph_catharine.cpp rename to examples/graph_catharine.cpp diff --git a/demo/graph_clock.cpp b/examples/graph_clock.cpp similarity index 100% rename from demo/graph_clock.cpp rename to examples/graph_clock.cpp diff --git a/demo/graph_function_visualization.cpp b/examples/graph_function_visualization.cpp similarity index 100% rename from demo/graph_function_visualization.cpp rename to examples/graph_function_visualization.cpp diff --git a/demo/graph_getimage.cpp b/examples/graph_getimage.cpp similarity index 100% rename from demo/graph_getimage.cpp rename to examples/graph_getimage.cpp diff --git a/demo/graph_julia.cpp b/examples/graph_julia.cpp similarity index 100% rename from demo/graph_julia.cpp rename to examples/graph_julia.cpp diff --git a/demo/graph_lines.cpp b/examples/graph_lines.cpp similarity index 100% rename from demo/graph_lines.cpp rename to examples/graph_lines.cpp diff --git a/demo/graph_mandelbrot.cpp b/examples/graph_mandelbrot.cpp similarity index 100% rename from demo/graph_mandelbrot.cpp rename to examples/graph_mandelbrot.cpp diff --git a/demo/graph_mouseball.cpp b/examples/graph_mouseball.cpp similarity index 100% rename from demo/graph_mouseball.cpp rename to examples/graph_mouseball.cpp diff --git a/demo/graph_new_drawimage.cpp b/examples/graph_new_drawimage.cpp similarity index 100% rename from demo/graph_new_drawimage.cpp rename to examples/graph_new_drawimage.cpp diff --git a/demo/graph_rotateimage.cpp b/examples/graph_rotateimage.cpp similarity index 100% rename from demo/graph_rotateimage.cpp rename to examples/graph_rotateimage.cpp diff --git a/demo/graph_rotatetransparent.cpp b/examples/graph_rotatetransparent.cpp similarity index 100% rename from demo/graph_rotatetransparent.cpp rename to examples/graph_rotatetransparent.cpp diff --git a/demo/graph_sort_visualization.cpp b/examples/graph_sort_visualization.cpp similarity index 100% rename from demo/graph_sort_visualization.cpp rename to examples/graph_sort_visualization.cpp diff --git a/demo/graph_star.cpp b/examples/graph_star.cpp similarity index 100% rename from demo/graph_star.cpp rename to examples/graph_star.cpp diff --git a/demo/graph_triangle.cpp b/examples/graph_triangle.cpp similarity index 100% rename from demo/graph_triangle.cpp rename to examples/graph_triangle.cpp diff --git a/demo/graph_wave_net.cpp b/examples/graph_wave_net.cpp similarity index 100% rename from demo/graph_wave_net.cpp rename to examples/graph_wave_net.cpp diff --git a/demo/test_demo.cpp b/examples/test_demo.cpp similarity index 100% rename from demo/test_demo.cpp rename to examples/test_demo.cpp diff --git a/demo/test_doubleclick.cpp b/examples/test_doubleclick.cpp similarity index 100% rename from demo/test_doubleclick.cpp rename to examples/test_doubleclick.cpp diff --git a/demo/test_input_demo.cpp b/examples/test_input_demo.cpp similarity index 100% rename from demo/test_input_demo.cpp rename to examples/test_input_demo.cpp diff --git a/demo/test_main.cpp b/examples/test_main.cpp similarity index 100% rename from demo/test_main.cpp rename to examples/test_main.cpp diff --git a/demo/test_multiplesys_edit.cpp b/examples/test_multiplesys_edit.cpp similarity index 100% rename from demo/test_multiplesys_edit.cpp rename to examples/test_multiplesys_edit.cpp diff --git a/demo/test_setviewport.cpp b/examples/test_setviewport.cpp similarity index 100% rename from demo/test_setviewport.cpp rename to examples/test_setviewport.cpp diff --git a/demo/tools/buildlogo.cpp b/examples/tools/buildlogo.cpp similarity index 100% rename from demo/tools/buildlogo.cpp rename to examples/tools/buildlogo.cpp diff --git a/demo/tools/setup.cpp b/examples/tools/setup.cpp similarity index 100% rename from demo/tools/setup.cpp rename to examples/tools/setup.cpp diff --git a/demo/tutorial/tutorial.cpp b/examples/tutorial/tutorial.cpp similarity index 100% rename from demo/tutorial/tutorial.cpp rename to examples/tutorial/tutorial.cpp diff --git a/include/ege.h b/export/ege.h similarity index 99% rename from include/ege.h rename to export/ege.h index f3cea5c9..21891412 100644 --- a/include/ege.h +++ b/export/ege.h @@ -45,13 +45,19 @@ # endif #endif +#ifdef CUP_BUILD +# define _LINK_NAME "xege.lib" +#else +# define _LINK_NAME "graphics.lib" +#endif + #if !defined(EGE_GRAPH_LIB_BUILD) && !defined(EGE_GRAPH_NO_LIB) # ifdef _MSC_VER # pragma comment(lib,"gdiplus.lib") # ifdef _WIN64 // 64 bit libs -# pragma comment(lib,"graphics.lib") +# pragma comment(lib,_LINK_NAME) # else // 32 bit libs -# pragma comment(lib,"graphics.lib") +# pragma comment(lib,_LINK_NAME) # endif # endif #endif diff --git a/include/ege.zh_CN.h b/export/ege.zh_CN.h similarity index 100% rename from include/ege.zh_CN.h rename to export/ege.zh_CN.h diff --git a/include/ege/button.h b/export/ege/button.h similarity index 100% rename from include/ege/button.h rename to export/ege/button.h diff --git a/include/ege/egecontrolbase.h b/export/ege/egecontrolbase.h similarity index 100% rename from include/ege/egecontrolbase.h rename to export/ege/egecontrolbase.h diff --git a/include/ege/fps.h b/export/ege/fps.h similarity index 100% rename from include/ege/fps.h rename to export/ege/fps.h diff --git a/include/ege/label.h b/export/ege/label.h similarity index 100% rename from include/ege/label.h rename to export/ege/label.h diff --git a/include/ege/stdint.h b/export/ege/stdint.h similarity index 100% rename from include/ege/stdint.h rename to export/ege/stdint.h diff --git a/include/ege/sys_edit.h b/export/ege/sys_edit.h similarity index 100% rename from include/ege/sys_edit.h rename to export/ege/sys_edit.h diff --git a/include/ege/types.h b/export/ege/types.h similarity index 100% rename from include/ege/types.h rename to export/ege/types.h diff --git a/include/graphics.h b/export/graphics.h similarity index 100% rename from include/graphics.h rename to export/graphics.h diff --git a/src/array.h b/include/array.h similarity index 100% rename from src/array.h rename to include/array.h diff --git a/src/color.h b/include/color.h similarity index 100% rename from src/color.h rename to include/color.h diff --git a/src/console.h b/include/console.h similarity index 100% rename from src/console.h rename to include/console.h diff --git a/src/debug.h b/include/debug.h similarity index 100% rename from src/debug.h rename to include/debug.h diff --git a/src/ege_base.h b/include/ege_base.h similarity index 100% rename from src/ege_base.h rename to include/ege_base.h diff --git a/src/ege_common.h b/include/ege_common.h similarity index 100% rename from src/ege_common.h rename to include/ege_common.h diff --git a/src/ege_def.h b/include/ege_def.h similarity index 100% rename from src/ege_def.h rename to include/ege_def.h diff --git a/src/ege_dllimport.h b/include/ege_dllimport.h similarity index 100% rename from src/ege_dllimport.h rename to include/ege_dllimport.h diff --git a/src/ege_extension.h b/include/ege_extension.h similarity index 100% rename from src/ege_extension.h rename to include/ege_extension.h diff --git a/src/ege_graph.h b/include/ege_graph.h similarity index 100% rename from src/ege_graph.h rename to include/ege_graph.h diff --git a/src/ege_head.h b/include/ege_head.h similarity index 100% rename from src/ege_head.h rename to include/ege_head.h diff --git a/src/ege_math.h b/include/ege_math.h similarity index 100% rename from src/ege_math.h rename to include/ege_math.h diff --git a/src/ege_time.h b/include/ege_time.h similarity index 100% rename from src/ege_time.h rename to include/ege_time.h diff --git a/src/encodeconv.h b/include/encodeconv.h similarity index 100% rename from src/encodeconv.h rename to include/encodeconv.h diff --git a/src/font.h b/include/font.h similarity index 100% rename from src/font.h rename to include/font.h diff --git a/src/gdi_conv.h b/include/gdi_conv.h similarity index 100% rename from src/gdi_conv.h rename to include/gdi_conv.h diff --git a/src/image.h b/include/image.h similarity index 100% rename from src/image.h rename to include/image.h diff --git a/src/keyboard.h b/include/keyboard.h similarity index 100% rename from src/keyboard.h rename to include/keyboard.h diff --git a/src/message.h b/include/message.h similarity index 100% rename from src/message.h rename to include/message.h diff --git a/src/mouse.h b/include/mouse.h similarity index 100% rename from src/mouse.h rename to include/mouse.h diff --git a/src/music.h b/include/music.h similarity index 100% rename from src/music.h rename to include/music.h diff --git a/src/sbt.h b/include/sbt.h similarity index 100% rename from src/sbt.h rename to include/sbt.h diff --git a/src/set.h b/include/set.h similarity index 100% rename from src/set.h rename to include/set.h diff --git a/src/thread_queue.h b/include/thread_queue.h similarity index 100% rename from src/thread_queue.h rename to include/thread_queue.h diff --git a/src/utils.h b/include/utils.h similarity index 100% rename from src/utils.h rename to include/utils.h diff --git a/src/window.h b/include/window.h similarity index 100% rename from src/window.h rename to include/window.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ee52a524..4d841529 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,6 +4,10 @@ target_sources(xege PRIVATE ${EGE_CPP_SRC} ) +target_include_directories(xege + PRIVATE ${PROJECT_SOURCE_DIR}/include +) + target_include_directories(xege PRIVATE lpng ) diff --git a/src/compress.cpp b/src/compress.cpp index 21af9fad..ba77126a 100644 --- a/src/compress.cpp +++ b/src/compress.cpp @@ -1,6 +1,9 @@ #include "ege_head.h" +#ifdef CUP_BUILD +#include "zlib/zlib.h" +#else #include - +#endif namespace ege { diff --git a/src/image.cpp b/src/image.cpp index cd30e913..9f5a2001 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -22,8 +22,11 @@ // #undef _ITERATOR_DEBUG_LEVEL // #endif +#ifdef CUP_BUILD +#include "libpng/png.h" +#else #include - +#endif #include #include diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 93d89901..571a126e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,133 +1 @@ -# 包含EGE头文件目录 -include_directories(../include) - -# 添加编译定义 -add_definitions(-DSHOW_CONSOLE=1) -add_definitions(-DEGE_GRAPH_NO_LIB) -add_definitions(-DNOMINMAX) - -# 添加Windows系统库 -set(SYSTEM_LIBS - gdi32 - user32 - kernel32 - gdiplus - ole32 - oleaut32 - uuid - winmm -) - -# 创建测试工具库 -add_library(test_framework STATIC - test_framework.cpp - test_framework.h - image_generator.cpp - image_generator.h - performance_timer.cpp - performance_timer.h -) - -target_link_libraries(test_framework ${SYSTEM_LIBS}) - -if(MSVC) - target_compile_options(test_framework PUBLIC - /source-charset:utf-8 - /Zc:__cplusplus - ) -endif() - -# 主性能测试程序 -add_executable(putimage_performance_test - tests/putimage_performance_test.cpp -) - -target_link_libraries(putimage_performance_test - test_framework - xege - ${SYSTEM_LIBS} -) - -# 单独的测试用例 -add_executable(putimage_basic_test - tests/putimage_basic_test.cpp -) - -target_link_libraries(putimage_basic_test - test_framework - xege - ${SYSTEM_LIBS} -) - -add_executable(putimage_alphablend_test - tests/putimage_alphablend_test.cpp -) - -target_link_libraries(putimage_alphablend_test - test_framework - xege - ${SYSTEM_LIBS} -) - -add_executable(putimage_transparent_test - tests/putimage_transparent_test.cpp -) - -target_link_libraries(putimage_transparent_test - test_framework - xege - ${SYSTEM_LIBS} -) - -add_executable(putimage_rotate_test - tests/putimage_rotate_test.cpp -) - -target_link_libraries(putimage_rotate_test - test_framework - xege - ${SYSTEM_LIBS} -) - -add_executable(putimage_comparison_test - tests/putimage_comparison_test.cpp -) - -target_link_libraries(putimage_comparison_test - test_framework - xege - ${SYSTEM_LIBS} -) - -add_executable(putimage_alphablend_comprehensive_test - tests/putimage_alphablend_comprehensive_test.cpp -) - -target_link_libraries(putimage_alphablend_comprehensive_test - test_framework - xege - ${SYSTEM_LIBS} -) - -# 设置输出目录 -set_target_properties( - putimage_performance_test - putimage_basic_test - putimage_alphablend_test - putimage_transparent_test - putimage_rotate_test - putimage_comparison_test - putimage_alphablend_comprehensive_test - PROPERTIES - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin -) - -# 创建测试目标 -enable_testing() -add_test(NAME putimage_performance COMMAND putimage_performance_test) -add_test(NAME putimage_basic COMMAND putimage_basic_test) -add_test(NAME putimage_alphablend COMMAND putimage_alphablend_test) -add_test(NAME putimage_transparent COMMAND putimage_transparent_test) -add_test(NAME putimage_rotate COMMAND putimage_rotate_test) -add_test(NAME putimage_comparison COMMAND putimage_comparison_test) -add_test(NAME putimage_alphablend_comprehensive COMMAND putimage_alphablend_comprehensive_test) +add_subdirectory(tests) \ No newline at end of file diff --git a/tests/tests/putimage_alphablend_comprehensive_test.cpp b/tests/putimage_alphablend_comprehensive_test.cpp similarity index 99% rename from tests/tests/putimage_alphablend_comprehensive_test.cpp rename to tests/putimage_alphablend_comprehensive_test.cpp index 4035bcc1..99395e5c 100644 --- a/tests/tests/putimage_alphablend_comprehensive_test.cpp +++ b/tests/putimage_alphablend_comprehensive_test.cpp @@ -27,10 +27,11 @@ */ #define SHOW_CONSOLE 1 +#define NOMINMAX 1 #include "ege.h" -#include "../image_generator.h" -#include "../performance_timer.h" -#include "../test_framework.h" +#include "image_generator.h" +#include "performance_timer.h" +#include "test_framework.h" #include #include diff --git a/tests/tests/putimage_alphablend_test.cpp b/tests/putimage_alphablend_test.cpp similarity index 98% rename from tests/tests/putimage_alphablend_test.cpp rename to tests/putimage_alphablend_test.cpp index ef6fe5ab..2602c402 100644 --- a/tests/tests/putimage_alphablend_test.cpp +++ b/tests/putimage_alphablend_test.cpp @@ -8,9 +8,9 @@ */ #define SHOW_CONSOLE 1 -#include "../image_generator.h" -#include "../performance_timer.h" -#include "../test_framework.h" +#include "image_generator.h" +#include "performance_timer.h" +#include "test_framework.h" #include "ege.h" #include diff --git a/tests/tests/putimage_basic_test.cpp b/tests/putimage_basic_test.cpp similarity index 94% rename from tests/tests/putimage_basic_test.cpp rename to tests/putimage_basic_test.cpp index f5bf487a..7dd2baf9 100644 --- a/tests/tests/putimage_basic_test.cpp +++ b/tests/putimage_basic_test.cpp @@ -4,9 +4,9 @@ #define SHOW_CONSOLE 1 #include "ege.h" -#include "../image_generator.h" -#include "../performance_timer.h" -#include "../test_framework.h" +#include "image_generator.h" +#include "performance_timer.h" +#include "test_framework.h" #include diff --git a/tests/tests/putimage_comparison_test.cpp b/tests/putimage_comparison_test.cpp similarity index 99% rename from tests/tests/putimage_comparison_test.cpp rename to tests/putimage_comparison_test.cpp index 799c8c1c..9744b83e 100644 --- a/tests/tests/putimage_comparison_test.cpp +++ b/tests/putimage_comparison_test.cpp @@ -7,9 +7,9 @@ #define SHOW_CONSOLE 1 #include "ege.h" -#include "../image_generator.h" -#include "../performance_timer.h" -#include "../test_framework.h" +#include "image_generator.h" +#include "performance_timer.h" +#include "test_framework.h" #include #include diff --git a/tests/tests/putimage_performance_test.cpp b/tests/putimage_performance_test.cpp similarity index 99% rename from tests/tests/putimage_performance_test.cpp rename to tests/putimage_performance_test.cpp index 2a178ea5..c234797a 100644 --- a/tests/tests/putimage_performance_test.cpp +++ b/tests/putimage_performance_test.cpp @@ -7,9 +7,9 @@ #define SHOW_CONSOLE 1 #include "ege.h" -#include "../image_generator.h" -#include "../performance_timer.h" -#include "../test_framework.h" +#include "image_generator.h" +#include "performance_timer.h" +#include "test_framework.h" #include #include diff --git a/tests/tests/putimage_rotate_test.cpp b/tests/putimage_rotate_test.cpp similarity index 98% rename from tests/tests/putimage_rotate_test.cpp rename to tests/putimage_rotate_test.cpp index e2621cca..4966a501 100644 --- a/tests/tests/putimage_rotate_test.cpp +++ b/tests/putimage_rotate_test.cpp @@ -3,9 +3,9 @@ */ #define SHOW_CONSOLE 1 -#include "../test_framework.h" -#include "../performance_timer.h" -#include "../image_generator.h" +#include "test_framework.h" +#include "performance_timer.h" +#include "image_generator.h" #include "ege.h" #include diff --git a/tests/tests/putimage_transparent_test.cpp b/tests/putimage_transparent_test.cpp similarity index 98% rename from tests/tests/putimage_transparent_test.cpp rename to tests/putimage_transparent_test.cpp index 0d9484e6..5a318f15 100644 --- a/tests/tests/putimage_transparent_test.cpp +++ b/tests/putimage_transparent_test.cpp @@ -4,9 +4,9 @@ #define SHOW_CONSOLE 1 #include "ege.h" -#include "../image_generator.h" -#include "../performance_timer.h" -#include "../test_framework.h" +#include "image_generator.h" +#include "performance_timer.h" +#include "test_framework.h" #include diff --git a/tests/.clang-format b/tests/tests/.clang-format similarity index 100% rename from tests/.clang-format rename to tests/tests/.clang-format diff --git a/tests/tests/CMakeLists.txt b/tests/tests/CMakeLists.txt new file mode 100644 index 00000000..8d4329a1 --- /dev/null +++ b/tests/tests/CMakeLists.txt @@ -0,0 +1,137 @@ +# 包含EGE头文件目录 +include_directories(../include) + +# 添加编译定义 +add_definitions(-DSHOW_CONSOLE=1) +add_definitions(-DEGE_GRAPH_NO_LIB) +add_definitions(-DNOMINMAX) + +# 添加Windows系统库 +set(SYSTEM_LIBS + gdi32 + user32 + kernel32 + gdiplus + ole32 + oleaut32 + uuid + winmm +) + +# 创建测试工具库 +add_library(test_framework STATIC + test_framework.cpp + test_framework.h + image_generator.cpp + image_generator.h + performance_timer.cpp + performance_timer.h +) + +target_link_libraries(test_framework ${SYSTEM_LIBS}) +target_include_directories(test_framework PUBLIC + ${PROJECT_SOURCE_DIR}/export + ${CMAKE_CURRENT_SOURCE_DIR} +) + +if(MSVC) + target_compile_options(test_framework PUBLIC + /source-charset:utf-8 + /Zc:__cplusplus + ) +endif() + +# 主性能测试程序 +add_executable(putimage_performance_test + ../putimage_performance_test.cpp +) + +target_link_libraries(putimage_performance_test + test_framework + xege + ${SYSTEM_LIBS} +) + +# 单独的测试用例 +add_executable(putimage_basic_test + ../putimage_basic_test.cpp +) + +target_link_libraries(putimage_basic_test + test_framework + xege + ${SYSTEM_LIBS} +) + +add_executable(putimage_alphablend_test + ../putimage_alphablend_test.cpp +) + +target_link_libraries(putimage_alphablend_test + test_framework + xege + ${SYSTEM_LIBS} +) + +add_executable(putimage_transparent_test + ../putimage_transparent_test.cpp +) + +target_link_libraries(putimage_transparent_test + test_framework + xege + ${SYSTEM_LIBS} +) + +add_executable(putimage_rotate_test + ../putimage_rotate_test.cpp +) + +target_link_libraries(putimage_rotate_test + test_framework + xege + ${SYSTEM_LIBS} +) + +add_executable(putimage_comparison_test + ../putimage_comparison_test.cpp +) + +target_link_libraries(putimage_comparison_test + test_framework + xege + ${SYSTEM_LIBS} +) + +add_executable(putimage_alphablend_comprehensive_test + ../putimage_alphablend_comprehensive_test.cpp +) + +target_link_libraries(putimage_alphablend_comprehensive_test + test_framework + xege + ${SYSTEM_LIBS} +) + +# 设置输出目录 +set_target_properties( + putimage_performance_test + putimage_basic_test + putimage_alphablend_test + putimage_transparent_test + putimage_rotate_test + putimage_comparison_test + putimage_alphablend_comprehensive_test + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin +) + +# 创建测试目标 +enable_testing() +add_test(NAME putimage_performance COMMAND putimage_performance_test) +add_test(NAME putimage_basic COMMAND putimage_basic_test) +add_test(NAME putimage_alphablend COMMAND putimage_alphablend_test) +add_test(NAME putimage_transparent COMMAND putimage_transparent_test) +add_test(NAME putimage_rotate COMMAND putimage_rotate_test) +add_test(NAME putimage_comparison COMMAND putimage_comparison_test) +add_test(NAME putimage_alphablend_comprehensive COMMAND putimage_alphablend_comprehensive_test) diff --git a/tests/README.md b/tests/tests/README.md similarity index 100% rename from tests/README.md rename to tests/tests/README.md diff --git a/tests/image_generator.cpp b/tests/tests/image_generator.cpp similarity index 100% rename from tests/image_generator.cpp rename to tests/tests/image_generator.cpp diff --git a/tests/image_generator.h b/tests/tests/image_generator.h similarity index 100% rename from tests/image_generator.h rename to tests/tests/image_generator.h diff --git a/tests/performance_timer.cpp b/tests/tests/performance_timer.cpp similarity index 100% rename from tests/performance_timer.cpp rename to tests/tests/performance_timer.cpp diff --git a/tests/performance_timer.h b/tests/tests/performance_timer.h similarity index 100% rename from tests/performance_timer.h rename to tests/tests/performance_timer.h diff --git a/tests/run_putimage_comparison.sh b/tests/tests/run_putimage_comparison.sh similarity index 100% rename from tests/run_putimage_comparison.sh rename to tests/tests/run_putimage_comparison.sh diff --git a/tests/test_framework.cpp b/tests/tests/test_framework.cpp similarity index 100% rename from tests/test_framework.cpp rename to tests/tests/test_framework.cpp diff --git a/tests/test_framework.h b/tests/tests/test_framework.h similarity index 100% rename from tests/test_framework.h rename to tests/tests/test_framework.h