diff options
author | crupest <crupest@outlook.com> | 2023-10-06 20:55:42 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2023-10-06 20:55:42 +0800 |
commit | 538616817a749642836ad3b2faff16706500602e (patch) | |
tree | 4c1f00d653e7b339a4fbd505cd686993589c2c8c | |
parent | ded4428d7286925db1f5ab9f18f549c85033839d (diff) | |
download | cru-538616817a749642836ad3b2faff16706500602e.tar.gz cru-538616817a749642836ad3b2faff16706500602e.tar.bz2 cru-538616817a749642836ad3b2faff16706500602e.zip |
...
-rw-r--r-- | demos/CMakeLists.txt | 2 | ||||
-rw-r--r-- | demos/Graphics/DrawCircle/CMakeLists.txt | 5 | ||||
-rw-r--r-- | demos/Graphics/DrawCircle/CairoMain.cpp | 12 | ||||
-rw-r--r-- | demos/Graphics/DrawCircle/DrawCircle.cpp (renamed from demos/graphics/DrawCircle.cpp) | 10 | ||||
-rw-r--r-- | demos/Graphics/DrawCircle/DrawCircle.h | 7 | ||||
-rw-r--r-- | demos/Graphics/DrawCircle/PlatformMain.cpp | 12 | ||||
-rw-r--r-- | demos/graphics/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/platform/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/platform/graphics/CMakeLists.txt | 1 |
9 files changed, 42 insertions, 11 deletions
diff --git a/demos/CMakeLists.txt b/demos/CMakeLists.txt index e8b84472..6e4aa297 100644 --- a/demos/CMakeLists.txt +++ b/demos/CMakeLists.txt @@ -11,7 +11,7 @@ if(WIN32) add_subdirectory(InputMethod) add_subdirectory(SvgPath) elseif(APPLE) - add_subdirectory(graphics) + add_subdirectory(Graphics/DrawCircle) add_subdirectory(main) add_subdirectory(ScrollView) diff --git a/demos/Graphics/DrawCircle/CMakeLists.txt b/demos/Graphics/DrawCircle/CMakeLists.txt new file mode 100644 index 00000000..da6611ef --- /dev/null +++ b/demos/Graphics/DrawCircle/CMakeLists.txt @@ -0,0 +1,5 @@ +add_executable(CruDemoGraphicsDrawCircle DrawCircle.cpp PlatformMain.cpp) +add_executable(CruDemoGraphicsDrawCircleCairo DrawCircle.cpp CairoMain.cpp) + +target_link_libraries(CruDemoGraphicsDrawCircle PRIVATE CruDemoBase) +target_link_libraries(CruDemoGraphicsDrawCircleCairo PRIVATE CruDemoBase CruPlatformGraphicsCairo) diff --git a/demos/Graphics/DrawCircle/CairoMain.cpp b/demos/Graphics/DrawCircle/CairoMain.cpp new file mode 100644 index 00000000..35d6840b --- /dev/null +++ b/demos/Graphics/DrawCircle/CairoMain.cpp @@ -0,0 +1,12 @@ +#include "cru/platform/graphics/cairo/CairoGraphicsFactory.h" + +#include "DrawCircle.h" + +int main() { + std::unique_ptr<cru::platform::graphics::IGraphicsFactory> graphics_factory( + new cru::platform::graphics::cairo::CairoGraphicsFactory()); + + cru::demos::graphics::DrawCircle(graphics_factory.get()); + + return 0; +} diff --git a/demos/graphics/DrawCircle.cpp b/demos/Graphics/DrawCircle/DrawCircle.cpp index 1ec06744..aa73d44c 100644 --- a/demos/graphics/DrawCircle.cpp +++ b/demos/Graphics/DrawCircle/DrawCircle.cpp @@ -1,15 +1,13 @@ #include "cru/common/io/CFileStream.h" #include "cru/platform/Color.h" -#include "cru/platform/bootstrap/Bootstrap.h" #include "cru/platform/graphics/Factory.h" #include "cru/platform/graphics/ImageFactory.h" #include "cru/platform/graphics/Painter.h" #include <memory> -int main() { - std::unique_ptr<cru::platform::graphics::IGraphicsFactory> graphics_factory( - cru::platform::bootstrap::CreateGraphicsFactory()); +namespace cru::demos::graphics { + void DrawCircle(platform::graphics::IGraphicsFactory* graphics_factory) { auto image = graphics_factory->GetImageFactory()->CreateBitmap(500, 500); @@ -26,6 +24,6 @@ int main() { graphics_factory->GetImageFactory()->EncodeToStream( image.get(), &file_stream, cru::platform::graphics::ImageFormat::Png, 1.0f); - - return 0; + } } + diff --git a/demos/Graphics/DrawCircle/DrawCircle.h b/demos/Graphics/DrawCircle/DrawCircle.h new file mode 100644 index 00000000..8e14dc84 --- /dev/null +++ b/demos/Graphics/DrawCircle/DrawCircle.h @@ -0,0 +1,7 @@ +#pragma once +#include "cru/platform/graphics/Factory.h" + +namespace cru::demos::graphics { + void DrawCircle(platform::graphics::IGraphicsFactory* graphics_factory); +} + diff --git a/demos/Graphics/DrawCircle/PlatformMain.cpp b/demos/Graphics/DrawCircle/PlatformMain.cpp new file mode 100644 index 00000000..3da1ec89 --- /dev/null +++ b/demos/Graphics/DrawCircle/PlatformMain.cpp @@ -0,0 +1,12 @@ +#include "cru/platform/bootstrap/Bootstrap.h" + +#include "DrawCircle.h" + +int main() { + std::unique_ptr<cru::platform::graphics::IGraphicsFactory> graphics_factory( + cru::platform::bootstrap::CreateGraphicsFactory()); + + cru::demos::graphics::DrawCircle(graphics_factory.get()); + + return 0; +} diff --git a/demos/graphics/CMakeLists.txt b/demos/graphics/CMakeLists.txt deleted file mode 100644 index b290ba13..00000000 --- a/demos/graphics/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -add_executable(CruDemoGraphicsDrawCircle DrawCircle.cpp) - -target_link_libraries(CruDemoGraphicsDrawCircle PRIVATE CruDemoBase) diff --git a/src/platform/CMakeLists.txt b/src/platform/CMakeLists.txt index 204660a4..0a94a26e 100644 --- a/src/platform/CMakeLists.txt +++ b/src/platform/CMakeLists.txt @@ -16,6 +16,7 @@ if (WIN32) elseif (APPLE) add_subdirectory(osx) add_subdirectory(graphics/quartz) + add_subdirectory(graphics/cairo) add_subdirectory(gui/osx) elseif (EMSCRIPTEN) add_subdirectory(web) diff --git a/src/platform/graphics/CMakeLists.txt b/src/platform/graphics/CMakeLists.txt index e9c6a9d1..b6362961 100644 --- a/src/platform/graphics/CMakeLists.txt +++ b/src/platform/graphics/CMakeLists.txt @@ -7,4 +7,3 @@ add_library(CruPlatformGraphics target_compile_definitions(CruPlatformGraphics PRIVATE CRU_PLATFORM_GRAPHICS_EXPORT_API) target_link_libraries(CruPlatformGraphics PUBLIC CruPlatformBase) -add_subdirectory(cairo) |