File tree Expand file tree Collapse file tree 6 files changed +92
-0
lines changed Expand file tree Collapse file tree 6 files changed +92
-0
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,8 @@ qt_add_qml_module(scratchcpp-render
5858 penlayerpainter.h
5959 penattributes.h
6060 penstate.h
61+ graphicseffect.cpp
62+ graphicseffect.h
6163 blocks/penextension.cpp
6264 blocks/penextension.h
6365 blocks/penblocks.cpp
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: LGPL-3.0-or-later
2+
3+ #include " graphicseffect.h"
4+
5+ using namespace scratchcpprender ;
6+
7+ GraphicsEffect::GraphicsEffect (ShaderManager::Effect effect, const std::string &name) :
8+ m_effect(effect),
9+ m_name(name)
10+ {
11+ }
12+
13+ ShaderManager::Effect GraphicsEffect::effect () const
14+ {
15+ return m_effect;
16+ }
17+
18+ std::string GraphicsEffect::name () const
19+ {
20+ return m_name;
21+ }
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: LGPL-3.0-or-later
2+
3+ #pragma once
4+
5+ #include < scratchcpp/igraphicseffect.h>
6+
7+ #include " shadermanager.h"
8+
9+ namespace scratchcpprender
10+ {
11+
12+ class GraphicsEffect : public libscratchcpp ::IGraphicsEffect
13+ {
14+ public:
15+ GraphicsEffect (ShaderManager::Effect effect, const std::string &name);
16+
17+ ShaderManager::Effect effect () const ;
18+ std::string name () const override ;
19+
20+ private:
21+ ShaderManager::Effect m_effect = static_cast <ShaderManager::Effect>(0 );
22+ std::string m_name;
23+ };
24+
25+ } // namespace scratchcpprender
Original file line number Diff line number Diff line change @@ -36,3 +36,4 @@ add_subdirectory(penstate)
3636add_subdirectory (penlayer)
3737add_subdirectory (penlayerpainter)
3838add_subdirectory (blocks)
39+ add_subdirectory (graphicseffect)
Original file line number Diff line number Diff line change 1+ add_executable (
2+ graphicseffect_test
3+ graphicseffect_test.cpp
4+ )
5+
6+ target_link_libraries (
7+ graphicseffect_test
8+ GTest::gtest_main
9+ scratchcpp-render
10+ qnanopainter
11+ )
12+
13+ add_test (graphicseffect_test)
14+ gtest_discover_tests(graphicseffect_test)
Original file line number Diff line number Diff line change 1+ #include < graphicseffect.h>
2+
3+ #include " ../common.h"
4+
5+ using namespace scratchcpprender ;
6+ using namespace libscratchcpp ;
7+
8+ TEST (GraphicsEffectTest, Constructor)
9+ {
10+ {
11+ GraphicsEffect effect (ShaderManager::Effect::Color, " color" );
12+ ASSERT_EQ (effect.effect (), ShaderManager::Effect::Color);
13+ ASSERT_EQ (effect.name (), " color" );
14+
15+ IGraphicsEffect *iface = dynamic_cast <IGraphicsEffect *>(&effect);
16+ ASSERT_TRUE (iface);
17+ ASSERT_EQ (iface->name (), " color" );
18+ }
19+
20+ {
21+ GraphicsEffect effect (ShaderManager::Effect::Brightness, " brightness" );
22+ ASSERT_EQ (effect.effect (), ShaderManager::Effect::Brightness);
23+ ASSERT_EQ (effect.name (), " brightness" );
24+
25+ IGraphicsEffect *iface = dynamic_cast <IGraphicsEffect *>(&effect);
26+ ASSERT_TRUE (iface);
27+ ASSERT_EQ (iface->name (), " brightness" );
28+ }
29+ }
You can’t perform that action at this time.
0 commit comments