From 9762297909a41a93c5695f9adee6f00c14bb361a Mon Sep 17 00:00:00 2001 From: Kai Blaschke Date: Fri, 29 Dec 2023 17:40:02 +0100 Subject: [PATCH] Properly namespace all classes under "::libprojectM" --- src/libprojectM/BackgroundWorker.hpp | 4 + .../MilkdropPreset/BlurTexture.cpp | 28 ++++--- .../MilkdropPreset/BlurTexture.hpp | 28 ++++--- src/libprojectM/MilkdropPreset/Border.cpp | 8 +- src/libprojectM/MilkdropPreset/Border.hpp | 9 ++- src/libprojectM/MilkdropPreset/CMakeLists.txt | 4 +- src/libprojectM/MilkdropPreset/Constants.hpp | 6 ++ .../MilkdropPreset/CustomShape.cpp | 10 ++- .../MilkdropPreset/CustomShape.hpp | 8 +- .../MilkdropPreset/CustomWaveform.cpp | 8 +- .../MilkdropPreset/CustomWaveform.hpp | 8 +- .../MilkdropPreset/DarkenCenter.cpp | 8 +- .../MilkdropPreset/DarkenCenter.hpp | 8 +- ...{MilkdropPresetFactory.cpp => Factory.cpp} | 15 ++-- ...{MilkdropPresetFactory.hpp => Factory.hpp} | 8 +- src/libprojectM/MilkdropPreset/Filters.cpp | 8 +- src/libprojectM/MilkdropPreset/Filters.hpp | 8 +- .../MilkdropPreset/FinalComposite.cpp | 12 ++- .../MilkdropPreset/FinalComposite.hpp | 8 +- src/libprojectM/MilkdropPreset/IdlePreset.cpp | 7 +- src/libprojectM/MilkdropPreset/IdlePreset.hpp | 11 ++- .../MilkdropPreset/MilkdropPreset.cpp | 22 ++++-- .../MilkdropPreset/MilkdropPreset.hpp | 28 ++++--- .../MilkdropPresetExceptions.hpp | 6 ++ .../MilkdropPreset/MilkdropShader.cpp | 41 +++++----- .../MilkdropPreset/MilkdropShader.hpp | 14 +++- .../MilkdropStaticShaders.cpp.in | 2 +- .../MilkdropStaticShaders.hpp.in | 6 +- .../MilkdropPreset/MotionVectors.cpp | 10 ++- .../MilkdropPreset/MotionVectors.hpp | 16 +++- .../MilkdropPreset/PerFrameContext.cpp | 8 +- .../MilkdropPreset/PerFrameContext.hpp | 6 ++ .../MilkdropPreset/PerPixelContext.cpp | 8 +- .../MilkdropPreset/PerPixelContext.hpp | 6 ++ .../MilkdropPreset/PerPixelMesh.cpp | 14 +++- .../MilkdropPreset/PerPixelMesh.hpp | 12 ++- .../MilkdropPreset/PresetFileParser.cpp | 6 ++ .../MilkdropPreset/PresetFileParser.hpp | 6 ++ .../MilkdropPreset/PresetState.cpp | 6 ++ .../MilkdropPreset/PresetState.hpp | 38 ++++++---- .../MilkdropPreset/ShapePerFrameContext.cpp | 6 ++ .../MilkdropPreset/ShapePerFrameContext.hpp | 7 +- src/libprojectM/MilkdropPreset/VideoEcho.cpp | 10 ++- src/libprojectM/MilkdropPreset/VideoEcho.hpp | 10 ++- src/libprojectM/MilkdropPreset/Waveform.cpp | 10 ++- src/libprojectM/MilkdropPreset/Waveform.hpp | 9 ++- .../WaveformPerFrameContext.cpp | 6 ++ .../WaveformPerFrameContext.hpp | 7 +- .../WaveformPerPointContext.cpp | 8 +- .../WaveformPerPointContext.hpp | 7 +- src/libprojectM/Preset.hpp | 13 ++-- src/libprojectM/PresetFactory.cpp | 4 + src/libprojectM/PresetFactory.hpp | 4 + src/libprojectM/PresetFactoryManager.cpp | 8 +- src/libprojectM/PresetFactoryManager.hpp | 4 + src/libprojectM/ProjectM.cpp | 23 +++--- src/libprojectM/ProjectM.hpp | 46 ++++++----- src/libprojectM/ProjectMCWrapper.cpp | 10 ++- src/libprojectM/ProjectMCWrapper.hpp | 4 + src/libprojectM/RandomNumberGenerators.hpp | 9 ++- src/libprojectM/Renderer/CopyTexture.cpp | 7 ++ src/libprojectM/Renderer/CopyTexture.hpp | 6 ++ src/libprojectM/Renderer/FileScanner.cpp | 38 ++++++---- src/libprojectM/Renderer/FileScanner.hpp | 20 ++--- src/libprojectM/Renderer/Framebuffer.cpp | 5 +- src/libprojectM/Renderer/Framebuffer.hpp | 6 ++ src/libprojectM/Renderer/IdleTextures.hpp | 6 ++ src/libprojectM/Renderer/MilkdropNoise.cpp | 6 ++ src/libprojectM/Renderer/MilkdropNoise.hpp | 6 +- src/libprojectM/Renderer/PresetTransition.cpp | 6 ++ src/libprojectM/Renderer/PresetTransition.hpp | 6 ++ src/libprojectM/Renderer/RenderContext.hpp | 6 ++ src/libprojectM/Renderer/RenderItem.cpp | 6 ++ src/libprojectM/Renderer/RenderItem.hpp | 6 ++ src/libprojectM/Renderer/Sampler.cpp | 6 ++ src/libprojectM/Renderer/Sampler.hpp | 8 +- src/libprojectM/Renderer/Shader.cpp | 8 +- src/libprojectM/Renderer/Shader.hpp | 6 ++ src/libprojectM/Renderer/Texture.cpp | 6 ++ src/libprojectM/Renderer/Texture.hpp | 6 ++ .../Renderer/TextureAttachment.cpp | 6 ++ .../Renderer/TextureAttachment.hpp | 6 ++ src/libprojectM/Renderer/TextureManager.cpp | 5 ++ src/libprojectM/Renderer/TextureManager.hpp | 5 ++ .../Renderer/TextureSamplerDescriptor.cpp | 8 +- .../Renderer/TextureSamplerDescriptor.hpp | 6 ++ .../Renderer/TransitionShaderManager.cpp | 6 ++ .../Renderer/TransitionShaderManager.hpp | 6 ++ src/libprojectM/StaticLibDummy.cpp | 4 + src/libprojectM/TimeKeeper.cpp | 4 + src/libprojectM/TimeKeeper.hpp | 4 + src/playlist/Filter.cpp | 4 +- src/playlist/Filter.hpp | 4 +- src/playlist/Item.cpp | 4 +- src/playlist/Item.hpp | 4 +- src/playlist/Playlist.cpp | 4 +- src/playlist/Playlist.hpp | 4 +- src/playlist/PlaylistCWrapper.cpp | 37 ++++----- src/playlist/PlaylistCWrapper.hpp | 8 +- tests/libprojectM/PresetFileParserTest.cpp | 2 + tests/playlist/APITest.cpp | 76 +++++++++---------- tests/playlist/FilterTest.cpp | 24 +++--- tests/playlist/ItemTest.cpp | 6 +- tests/playlist/PlaylistCWrapperMock.h | 6 +- tests/playlist/PlaylistTest.cpp | 23 +++--- 105 files changed, 798 insertions(+), 312 deletions(-) rename src/libprojectM/MilkdropPreset/{MilkdropPresetFactory.cpp => Factory.cpp} (72%) rename src/libprojectM/MilkdropPreset/{MilkdropPresetFactory.hpp => Factory.hpp} (78%) diff --git a/src/libprojectM/BackgroundWorker.hpp b/src/libprojectM/BackgroundWorker.hpp index 74d3e2c35..37ef8b5c8 100644 --- a/src/libprojectM/BackgroundWorker.hpp +++ b/src/libprojectM/BackgroundWorker.hpp @@ -3,6 +3,8 @@ #include #include +namespace libprojectM { + /** * Small class to encapsulate synchronization of a simple background task runner */ @@ -70,3 +72,5 @@ private: volatile bool m_finished{ false }; }; + +} // namespace libprojectM diff --git a/src/libprojectM/MilkdropPreset/BlurTexture.cpp b/src/libprojectM/MilkdropPreset/BlurTexture.cpp index 5f8bd2e51..637dc2bff 100644 --- a/src/libprojectM/MilkdropPreset/BlurTexture.cpp +++ b/src/libprojectM/MilkdropPreset/BlurTexture.cpp @@ -7,8 +7,11 @@ #include +namespace libprojectM { +namespace MilkdropPreset { + BlurTexture::BlurTexture() - : m_blurSampler(std::make_shared(GL_CLAMP_TO_EDGE, GL_LINEAR)) + : m_blurSampler(std::make_shared(GL_CLAMP_TO_EDGE, GL_LINEAR)) { auto staticShaders = libprojectM::MilkdropPreset::MilkdropStaticShaders::Get(); @@ -38,7 +41,7 @@ BlurTexture::BlurTexture() glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); - glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, nullptr); // Position at index 0 and 1 + glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, nullptr); // Position at index 0 and 1 glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, reinterpret_cast(sizeof(float) * 2)); // Texture coord at index 2 and 3 glBindVertexArray(0); @@ -53,7 +56,7 @@ BlurTexture::BlurTexture() textureName = "blur" + std::to_string(i / 2 + 1); } - m_blurTextures[i] = std::make_shared(textureName, 0, GL_TEXTURE_2D, 0, 0, false); + m_blurTextures[i] = std::make_shared(textureName, 0, GL_TEXTURE_2D, 0, 0, false); } } @@ -68,9 +71,9 @@ void BlurTexture::SetRequiredBlurLevel(BlurTexture::BlurLevel level) m_blurLevel = std::max(level, m_blurLevel); } -auto BlurTexture::GetDescriptorsForBlurLevel(BlurTexture::BlurLevel blurLevel) const -> std::vector +auto BlurTexture::GetDescriptorsForBlurLevel(BlurTexture::BlurLevel blurLevel) const -> std::vector { - std::vector descriptors; + std::vector descriptors; if (blurLevel == BlurLevel::Blur3) { @@ -91,7 +94,7 @@ auto BlurTexture::GetDescriptorsForBlurLevel(BlurTexture::BlurLevel blurLevel) c return descriptors; } -void BlurTexture::Update(const Texture& sourceTexture, const PerFrameContext& perFrameContext) +void BlurTexture::Update(const Renderer::Texture& sourceTexture, const PerFrameContext& perFrameContext) { if (m_blurLevel == BlurLevel::None) { @@ -150,7 +153,7 @@ void BlurTexture::Update(const Texture& sourceTexture, const PerFrameContext& pe } // set pixel shader - Shader* blurShader; + Renderer::Shader* blurShader; if ((pass % 2) == 0) { blurShader = &m_blur1Shader; @@ -255,10 +258,10 @@ void BlurTexture::Update(const Texture& sourceTexture, const PerFrameContext& pe glBindFramebuffer(GL_DRAW_FRAMEBUFFER, origDrawFramebuffer); glViewport(0, 0, sourceTexture.Width(), sourceTexture.Height()); - Shader::Unbind(); + Renderer::Shader::Unbind(); } -void BlurTexture::Bind(GLint& unit, Shader& shader) const +void BlurTexture::Bind(GLint& unit, Renderer::Shader& shader) const { for (size_t i = 0; i < static_cast(m_blurLevel) * 2; i++) { @@ -309,7 +312,7 @@ void BlurTexture::GetSafeBlurMinMaxValues(const PerFrameContext& perFrameContext } } -void BlurTexture::AllocateTextures(const Texture& sourceTexture) +void BlurTexture::AllocateTextures(const Renderer::Texture& sourceTexture) { int width = sourceTexture.Width(); int height = sourceTexture.Height(); @@ -354,9 +357,12 @@ void BlurTexture::AllocateTextures(const Texture& sourceTexture) } // This will automatically replace any old texture. - m_blurTextures[i] = std::make_shared(textureName, width2, height2, false); + m_blurTextures[i] = std::make_shared(textureName, width2, height2, false); } m_sourceTextureWidth = sourceTexture.Width(); m_sourceTextureHeight = sourceTexture.Height(); } + +} // namespace MilkdropPreset +} // namespace libprojectM diff --git a/src/libprojectM/MilkdropPreset/BlurTexture.hpp b/src/libprojectM/MilkdropPreset/BlurTexture.hpp index 8ac566b7e..2f6a7998e 100644 --- a/src/libprojectM/MilkdropPreset/BlurTexture.hpp +++ b/src/libprojectM/MilkdropPreset/BlurTexture.hpp @@ -11,6 +11,9 @@ #include #include +namespace libprojectM { +namespace MilkdropPreset { + class PerFrameContext; class PresetState; @@ -58,14 +61,14 @@ public: * The blur textures don't need to be present and can be empty placeholders. * @param blurLevel The blur level. */ - auto GetDescriptorsForBlurLevel(BlurLevel blurLevel) const -> std::vector; + auto GetDescriptorsForBlurLevel(BlurLevel blurLevel) const -> std::vector; /** * @brief Renders the required blur passes on the given texture. * @param sourceTexture The texture to create the blur levels from. * @param perFrameContext The per-frame variables. */ - void Update(const Texture& sourceTexture, const PerFrameContext& perFrameContext); + void Update(const Renderer::Texture& sourceTexture, const PerFrameContext& perFrameContext); /** * @brief Binds the user-readable blur textures to the texture slots starting with the given index. @@ -74,7 +77,7 @@ public: * free unit, which can be the same as the input slot if no blur textures * are used. */ - void Bind(GLint& unit, Shader& shader) const; + void Bind(GLint& unit, Renderer::Shader& shader) const; /** * @brief Returns properly scaled and clamped vlur values from the given context. @@ -93,19 +96,22 @@ private: * Allocates the blur textures. * @param sourceTexture The source texture. */ - void AllocateTextures(const Texture& sourceTexture); + void AllocateTextures(const Renderer::Texture& sourceTexture); GLuint m_vboBlur; //!< Vertex buffer object for the fullscreen blur quad. GLuint m_vaoBlur; //!< Vertex array object for the fullscreen blur quad. - Shader m_blur1Shader; //!< The shader used on the first blur pass. - Shader m_blur2Shader; //!< The shader used for subsequent blur passes after the initial pass. + Renderer::Shader m_blur1Shader; //!< The shader used on the first blur pass. + Renderer::Shader m_blur2Shader; //!< The shader used for subsequent blur passes after the initial pass. - int m_sourceTextureWidth{}; //!< Width of the source texture used to create the blur textures. + int m_sourceTextureWidth{}; //!< Width of the source texture used to create the blur textures. int m_sourceTextureHeight{}; //!< Height of the source texture used to create the blur textures. - Framebuffer m_blurFramebuffer; //!< The framebuffer used to draw the blur textures. - std::shared_ptr m_blurSampler; //!< The blur sampler. - std::array, NumBlurTextures> m_blurTextures; //!< The blur textures for each pass. - BlurLevel m_blurLevel{BlurLevel::None}; //!< Current blur level. + Renderer::Framebuffer m_blurFramebuffer; //!< The framebuffer used to draw the blur textures. + std::shared_ptr m_blurSampler; //!< The blur sampler. + std::array, NumBlurTextures> m_blurTextures; //!< The blur textures for each pass. + BlurLevel m_blurLevel{BlurLevel::None}; //!< Current blur level. }; + +} // namespace MilkdropPreset +} // namespace libprojectM diff --git a/src/libprojectM/MilkdropPreset/Border.cpp b/src/libprojectM/MilkdropPreset/Border.cpp index 0df79cec7..e20ff17ba 100644 --- a/src/libprojectM/MilkdropPreset/Border.cpp +++ b/src/libprojectM/MilkdropPreset/Border.cpp @@ -2,6 +2,9 @@ #include +namespace libprojectM { +namespace MilkdropPreset { + Border::Border(PresetState& presetState) : RenderItem() , m_presetState(presetState) @@ -75,9 +78,12 @@ void Border::Draw(const PerFrameContext& presetPerFrameContext) } } - Shader::Unbind(); + Renderer::Shader::Unbind(); glDisable(GL_BLEND); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindVertexArray(0); } + +} // namespace MilkdropPreset +} // namespace libprojectM diff --git a/src/libprojectM/MilkdropPreset/Border.hpp b/src/libprojectM/MilkdropPreset/Border.hpp index e71ab532f..8b258f6d0 100644 --- a/src/libprojectM/MilkdropPreset/Border.hpp +++ b/src/libprojectM/MilkdropPreset/Border.hpp @@ -5,10 +5,14 @@ #include "Renderer/RenderItem.hpp" +namespace libprojectM { +namespace MilkdropPreset { + + /** * @brief Renders a border around the screen. */ -class Border : public RenderItem +class Border : public Renderer::RenderItem { public: Border() = delete; @@ -26,3 +30,6 @@ public: private: PresetState& m_presetState; //!< The global preset state. }; + +} // namespace MilkdropPreset +} // namespace libprojectM diff --git a/src/libprojectM/MilkdropPreset/CMakeLists.txt b/src/libprojectM/MilkdropPreset/CMakeLists.txt index 5b95364d2..ba2e8bdb8 100644 --- a/src/libprojectM/MilkdropPreset/CMakeLists.txt +++ b/src/libprojectM/MilkdropPreset/CMakeLists.txt @@ -61,8 +61,8 @@ add_library(MilkdropPreset OBJECT MilkdropPreset.cpp MilkdropPreset.hpp MilkdropPresetExceptions.hpp - MilkdropPresetFactory.cpp - MilkdropPresetFactory.hpp + Factory.cpp + Factory.hpp MilkdropShader.cpp MilkdropShader.hpp MilkdropStaticShaders.cpp.in diff --git a/src/libprojectM/MilkdropPreset/Constants.hpp b/src/libprojectM/MilkdropPreset/Constants.hpp index 1d9d71cd9..407769678 100644 --- a/src/libprojectM/MilkdropPreset/Constants.hpp +++ b/src/libprojectM/MilkdropPreset/Constants.hpp @@ -6,6 +6,9 @@ #include