diff --git a/src/WallpaperEngine/Assets/CCombinedContainer.cpp b/src/WallpaperEngine/Assets/CCombinedContainer.cpp index 5b8854c..bfa7607 100644 --- a/src/WallpaperEngine/Assets/CCombinedContainer.cpp +++ b/src/WallpaperEngine/Assets/CCombinedContainer.cpp @@ -41,7 +41,7 @@ std::filesystem::path CCombinedContainer::resolveRealFile (const std::string& fi throw CAssetLoadException (filename, "Cannot resolve file in any of the containers"); } -const void* CCombinedContainer::readFile (const std::string& filename, uint32_t* length) const { +const uint8_t* CCombinedContainer::readFile (const std::string& filename, uint32_t* length) const { for (const auto cur : this->m_containers) { try { // try to read the file on the current container, if the file doesn't exists diff --git a/src/WallpaperEngine/Assets/CCombinedContainer.h b/src/WallpaperEngine/Assets/CCombinedContainer.h index b2dbf4c..2ccceb5 100644 --- a/src/WallpaperEngine/Assets/CCombinedContainer.h +++ b/src/WallpaperEngine/Assets/CCombinedContainer.h @@ -30,7 +30,7 @@ class CCombinedContainer final : public CContainer { /** @inheritdoc */ [[nodiscard]] std::filesystem::path resolveRealFile (const std::string& filename) const override; /** @inheritdoc */ - [[nodiscard]] const void* readFile (const std::string& filename, uint32_t* length) const override; + [[nodiscard]] const uint8_t* readFile (const std::string& filename, uint32_t* length) const override; private: /** The list of containers to search files off from */ diff --git a/src/WallpaperEngine/Assets/CContainer.cpp b/src/WallpaperEngine/Assets/CContainer.cpp index 0e84db3..1223f3d 100644 --- a/src/WallpaperEngine/Assets/CContainer.cpp +++ b/src/WallpaperEngine/Assets/CContainer.cpp @@ -70,7 +70,7 @@ std::string CContainer::readFileAsString (const std::string& filename) const { uint32_t length = 0; // read file contents and allocate a buffer for a string - const void* contents = this->readFile (std::move (filename), &length); + const uint8_t* contents = this->readFile (filename, &length); char* buffer = new char [length + 1]; // ensure there's a 0 at the end diff --git a/src/WallpaperEngine/Assets/CContainer.h b/src/WallpaperEngine/Assets/CContainer.h index 61c5a7b..4827512 100644 --- a/src/WallpaperEngine/Assets/CContainer.h +++ b/src/WallpaperEngine/Assets/CContainer.h @@ -30,7 +30,7 @@ class CContainer { * * @return */ - [[nodiscard]] virtual const void* readFile (const std::string& filename, uint32_t* length) const = 0; + [[nodiscard]] virtual const uint8_t* readFile (const std::string& filename, uint32_t* length) const = 0; /** * Wrapper for readFile, appends the texture extension at the end of the filename diff --git a/src/WallpaperEngine/Assets/CDirectory.cpp b/src/WallpaperEngine/Assets/CDirectory.cpp index dab7526..004195f 100644 --- a/src/WallpaperEngine/Assets/CDirectory.cpp +++ b/src/WallpaperEngine/Assets/CDirectory.cpp @@ -23,7 +23,7 @@ std::filesystem::path CDirectory::resolveRealFile (const std::string& filename) return std::filesystem::path (this->m_basepath) / filename; } -const void* CDirectory::readFile (const std::string& filename, uint32_t* length) const { +const uint8_t* CDirectory::readFile (const std::string& filename, uint32_t* length) const { const std::filesystem::path final = std::filesystem::path (this->m_basepath) / filename; // first check the cache, if the file is there already just return the data in there @@ -47,7 +47,7 @@ const void* CDirectory::readFile (const std::string& filename, uint32_t* length) fseek (fp, 0, SEEK_SET); // now read the whole file - auto* contents = new char [size]; + auto* contents = new uint8_t [size]; if (fread (contents, size, 1, fp) != 1) { delete [] contents; diff --git a/src/WallpaperEngine/Assets/CDirectory.h b/src/WallpaperEngine/Assets/CDirectory.h index 4bb584b..a8fce1d 100644 --- a/src/WallpaperEngine/Assets/CDirectory.h +++ b/src/WallpaperEngine/Assets/CDirectory.h @@ -19,7 +19,7 @@ class CDirectory final : public CContainer { /** @inheritdoc */ [[nodiscard]] std::filesystem::path resolveRealFile (const std::string& filename) const override; /** @inheritdoc */ - [[nodiscard]] const void* readFile (const std::string& filename, uint32_t* length) const override; + [[nodiscard]] const uint8_t* readFile (const std::string& filename, uint32_t* length) const override; private: /** The basepath for the directory */ diff --git a/src/WallpaperEngine/Assets/CFileEntry.h b/src/WallpaperEngine/Assets/CFileEntry.h index 6f3ca00..3db710f 100644 --- a/src/WallpaperEngine/Assets/CFileEntry.h +++ b/src/WallpaperEngine/Assets/CFileEntry.h @@ -8,14 +8,14 @@ namespace WallpaperEngine::Assets { */ class CFileEntry { public: - CFileEntry (const char* address, uint32_t length) : address (address), length (length) {} + CFileEntry (const uint8_t* address, uint32_t length) : address (address), length (length) {} ~CFileEntry () { delete [] address; } /** File contents */ - const char* address; + const uint8_t* address; /** File length */ uint32_t length; }; diff --git a/src/WallpaperEngine/Assets/CPackage.cpp b/src/WallpaperEngine/Assets/CPackage.cpp index d5a81db..ce3c5a6 100644 --- a/src/WallpaperEngine/Assets/CPackage.cpp +++ b/src/WallpaperEngine/Assets/CPackage.cpp @@ -24,7 +24,7 @@ CPackage::CPackage (std::filesystem::path path) : m_path (std::move (path)) { this->init (); } -const void* CPackage::readFile (const std::string& filename, uint32_t* length) const { +const uint8_t* CPackage::readFile (const std::string& filename, uint32_t* length) const { const auto it = this->m_contents.find (filename); if (it == this->m_contents.end ()) @@ -35,7 +35,7 @@ const void* CPackage::readFile (const std::string& filename, uint32_t* length) c *length = it->second->length; // clone original first - auto* result = new char [it->second->length]; + auto* result = new uint8_t [it->second->length]; memcpy (result, it->second->address, it->second->length); @@ -128,7 +128,7 @@ void CPackage::loadFiles (FILE* fp) { sLog.exception ("Cannot find file ", cur.filename, " from package ", this->m_path); // allocate memory for the file's contents and read it from the file - char* fileContents = new char [cur.length]; + auto* fileContents = new uint8_t [cur.length]; if (fread (fileContents, cur.length, 1, fp) != 1) { delete [] fileContents; diff --git a/src/WallpaperEngine/Assets/CPackage.h b/src/WallpaperEngine/Assets/CPackage.h index 70e6aef..ea41bb0 100644 --- a/src/WallpaperEngine/Assets/CPackage.h +++ b/src/WallpaperEngine/Assets/CPackage.h @@ -20,7 +20,7 @@ class CPackage final : public CContainer { public: explicit CPackage (std::filesystem::path path); - [[nodiscard]] const void* readFile (const std::string& filename, uint32_t* length) const override; + [[nodiscard]] const uint8_t* readFile (const std::string& filename, uint32_t* length) const override; protected: /** diff --git a/src/WallpaperEngine/Assets/CVirtualContainer.cpp b/src/WallpaperEngine/Assets/CVirtualContainer.cpp index 9f0dca9..5526def 100644 --- a/src/WallpaperEngine/Assets/CVirtualContainer.cpp +++ b/src/WallpaperEngine/Assets/CVirtualContainer.cpp @@ -5,12 +5,12 @@ using namespace WallpaperEngine::Assets; -void CVirtualContainer::add (const std::string& filename, const char* contents, uint32_t length) { +void CVirtualContainer::add (const std::string& filename, const uint8_t* contents, uint32_t length) { this->m_virtualFiles.insert (std::make_pair (filename, new CFileEntry (contents, length))); } void CVirtualContainer::add (const std::string& filename, const std::string& contents) { - char* copy = new char [contents.length () + 1]; + auto* copy = new uint8_t [contents.length () + 1]; // copy the text AND the \0 memcpy (copy, contents.c_str (), contents.length () + 1); @@ -19,7 +19,7 @@ void CVirtualContainer::add (const std::string& filename, const std::string& con this->add (filename, copy, contents.length () + 1); } -const void* CVirtualContainer::readFile (const std::string& filename, uint32_t* length) const { +const uint8_t* CVirtualContainer::readFile (const std::string& filename, uint32_t* length) const { const auto cur = this->m_virtualFiles.find (filename); if (cur == this->m_virtualFiles.end ()) @@ -29,7 +29,7 @@ const void* CVirtualContainer::readFile (const std::string& filename, uint32_t* *length = cur->second->length; // clone original first - char* result = new char [cur->second->length]; + auto* result = new uint8_t [cur->second->length]; memcpy (result, cur->second->address, cur->second->length); diff --git a/src/WallpaperEngine/Assets/CVirtualContainer.h b/src/WallpaperEngine/Assets/CVirtualContainer.h index bf8e760..4181ac3 100644 --- a/src/WallpaperEngine/Assets/CVirtualContainer.h +++ b/src/WallpaperEngine/Assets/CVirtualContainer.h @@ -19,7 +19,7 @@ class CVirtualContainer final : public CContainer { * @param contents * @param length */ - void add (const std::string& filename, const char* contents, uint32_t length); + void add (const std::string& filename, const uint8_t* contents, uint32_t length); /** * Adds a new file to the virtual container @@ -29,7 +29,7 @@ class CVirtualContainer final : public CContainer { */ void add (const std::string& filename, const std::string& contents); /** @inheritdoc */ - const void* readFile (const std::string& filename, uint32_t* length) const override; + const uint8_t* readFile (const std::string& filename, uint32_t* length) const override; private: /** The recorded files in this virtual container */ diff --git a/src/WallpaperEngine/Audio/CAudioStream.cpp b/src/WallpaperEngine/Audio/CAudioStream.cpp index c4dc725..5405883 100644 --- a/src/WallpaperEngine/Audio/CAudioStream.cpp +++ b/src/WallpaperEngine/Audio/CAudioStream.cpp @@ -95,7 +95,7 @@ CAudioStream::CAudioStream (CAudioContext& context, const std::string& filename) this->loadCustomContent (filename.c_str ()); } -CAudioStream::CAudioStream (CAudioContext& context, const void* buffer, int length) : +CAudioStream::CAudioStream (CAudioContext& context, const uint8_t* buffer, uint32_t length) : m_audioContext (context), m_swrctx (nullptr) { // setup a custom context first @@ -142,13 +142,17 @@ void CAudioStream::loadCustomContent (const char* filename) { if (avformat_find_stream_info (this->m_formatContext, nullptr) < 0) sLog.exception ("Cannot determine file format: ", filename); + bool hasAudioStream = false; + // find the audio stream - for (int i = 0; i < this->m_formatContext->nb_streams; i++) { - if (this->m_formatContext->streams [i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && this->m_audioStream < 0) + for (unsigned int i = 0; i < this->m_formatContext->nb_streams; i++) { + if (this->m_formatContext->streams [i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && hasAudioStream == false) { + hasAudioStream = true; this->m_audioStream = i; + } } - if (this->m_audioStream == -1) + if (!hasAudioStream) sLog.exception ("Cannot find an audio stream in file ", filename); // get the decoder for it and alloc the required context @@ -308,11 +312,11 @@ AVFormatContext* CAudioStream::getFormatContext () { return this->m_formatContext; } -int CAudioStream::getAudioStream () { +unsigned int CAudioStream::getAudioStream () const { return this->m_audioStream; } -bool CAudioStream::isInitialized () { +bool CAudioStream::isInitialized () const { return this->m_initialized; } @@ -320,23 +324,23 @@ void CAudioStream::setRepeat (bool newRepeat) { this->m_repeat = newRepeat; } -bool CAudioStream::isRepeat () { +bool CAudioStream::isRepeat () const { return this->m_repeat; } -const void* CAudioStream::getBuffer () { +const uint8_t* CAudioStream::getBuffer () { return this->m_buffer; } -int CAudioStream::getLength () { +uint32_t CAudioStream::getLength () const { return this->m_length; } -int CAudioStream::getPosition () { +uint32_t CAudioStream::getPosition () const { return this->m_position; } -void CAudioStream::setPosition (int current) { +void CAudioStream::setPosition (uint32_t current) { this->m_position = current; } diff --git a/src/WallpaperEngine/Audio/CAudioStream.h b/src/WallpaperEngine/Audio/CAudioStream.h index 25d732b..5fde04f 100644 --- a/src/WallpaperEngine/Audio/CAudioStream.h +++ b/src/WallpaperEngine/Audio/CAudioStream.h @@ -25,7 +25,7 @@ class CAudioContext; class CAudioStream { public: CAudioStream (CAudioContext& context, const std::string& filename); - CAudioStream (CAudioContext& context, const void* buffer, int length); + CAudioStream (CAudioContext& context, const uint8_t* buffer, uint32_t length); CAudioStream (CAudioContext& audioContext, AVCodecContext* context); ~CAudioStream (); @@ -56,11 +56,11 @@ class CAudioStream { /** * @return The audio stream index of the given file */ - int getAudioStream (); + [[nodiscard]] unsigned int getAudioStream () const; /** * @return If the audio stream can be played or not */ - bool isInitialized (); + [[nodiscard]] bool isInitialized () const; /** * @param newRepeat true = repeat, false = no repeat */ @@ -68,7 +68,7 @@ class CAudioStream { /** * @return If the stream is to be repeated at the end or not */ - bool isRepeat (); + [[nodiscard]] bool isRepeat () const; /** * Stops decoding and playbak of the stream */ @@ -76,21 +76,21 @@ class CAudioStream { /** * @return The file data buffer */ - const void* getBuffer (); + [[nodiscard]] const uint8_t* getBuffer (); /** * @return The length of the file data buffer */ - int getLength (); + [[nodiscard]] uint32_t getLength () const; /** * @return The read position of the data buffer */ - int getPosition (); + [[nodiscard]] uint32_t getPosition () const; /** * Updates the read position of the data buffer * * @param current */ - void setPosition (int current); + void setPosition (uint32_t current); /** * @return The SDL_cond used to signal waiting for data */ @@ -175,13 +175,13 @@ class CAudioStream { /** The format context that controls how data is read off the file */ AVFormatContext* m_formatContext = nullptr; /** The stream index for the audio being played */ - int m_audioStream = -1; + unsigned int m_audioStream; /** File data pointer */ - const void* m_buffer {}; + const uint8_t* m_buffer {}; /** The length of the file data pointer */ - int m_length {}; + uint32_t m_length {}; /** The read position on the file data pointer */ - int m_position = 0; + uint32_t m_position = 0; struct MyAVPacketList { AVPacket* packet; diff --git a/src/WallpaperEngine/Audio/Drivers/Recorders/CPulseAudioPlaybackRecorder.cpp b/src/WallpaperEngine/Audio/Drivers/Recorders/CPulseAudioPlaybackRecorder.cpp index acfdd4d..b2fe743 100644 --- a/src/WallpaperEngine/Audio/Drivers/Recorders/CPulseAudioPlaybackRecorder.cpp +++ b/src/WallpaperEngine/Audio/Drivers/Recorders/CPulseAudioPlaybackRecorder.cpp @@ -25,9 +25,9 @@ void pa_stream_read_cb (pa_stream* stream, const size_t /*nbytes*/, void* userda // Careful when to pa_stream_peek() and pa_stream_drop()! // c.f. https://www.freedesktop.org/software/pulseaudio/doxygen/stream_8h.html#ac2838c449cde56e169224d7fe3d00824 - const void* data = nullptr; + const uint8_t* data = nullptr; size_t currentSize; - if (pa_stream_peek (stream, &data, ¤tSize) != 0) { + if (pa_stream_peek (stream, reinterpret_cast (&data), ¤tSize) != 0) { sLog.error ("Failed to peek at stream data..."); return; } diff --git a/src/WallpaperEngine/Core/CObject.cpp b/src/WallpaperEngine/Core/CObject.cpp index c3ef188..f198b5a 100644 --- a/src/WallpaperEngine/Core/CObject.cpp +++ b/src/WallpaperEngine/Core/CObject.cpp @@ -15,7 +15,7 @@ using namespace WallpaperEngine::Core; using namespace WallpaperEngine::Assets; using namespace WallpaperEngine::Core::UserSettings; -CObject::CObject (CScene* scene, CUserSettingBoolean* visible, uint32_t id, std::string name, std::string type, +CObject::CObject (CScene* scene, CUserSettingBoolean* visible, int id, std::string name, std::string type, CUserSettingVector3* origin, CUserSettingVector3* scale, const glm::vec3& angles) : m_scene (scene), m_visible (visible), @@ -108,7 +108,7 @@ const std::vector& CObject::getEffects () const { return this->m_effects; } -const std::vector& CObject::getDependencies () const { +const std::vector& CObject::getDependencies () const { return this->m_dependencies; } @@ -129,6 +129,6 @@ void CObject::insertEffect (Objects::CEffect* effect) { this->m_effects.push_back (effect); } -void CObject::insertDependency (uint32_t dependency) { +void CObject::insertDependency (int dependency) { this->m_dependencies.push_back (dependency); } \ No newline at end of file diff --git a/src/WallpaperEngine/Core/CObject.h b/src/WallpaperEngine/Core/CObject.h index 4cc1061..4269cf3 100644 --- a/src/WallpaperEngine/Core/CObject.h +++ b/src/WallpaperEngine/Core/CObject.h @@ -45,37 +45,37 @@ class CObject { return this->m_type == T::Type; } - const std::vector& getEffects () const; - const std::vector& getDependencies () const; - int getId () const; + [[nodiscard]] const std::vector& getEffects () const; + [[nodiscard]] const std::vector& getDependencies () const; + [[nodiscard]] int getId () const; - glm::vec3 getOrigin () const; - glm::vec3 getScale () const; - const glm::vec3& getAngles () const; - const std::string& getName () const; + [[nodiscard]] glm::vec3 getOrigin () const; + [[nodiscard]] glm::vec3 getScale () const; + [[nodiscard]] const glm::vec3& getAngles () const; + [[nodiscard]] const std::string& getName () const; - bool isVisible () const; - CScene* getScene () const; + [[nodiscard]] bool isVisible () const; + [[nodiscard]] CScene* getScene () const; protected: - CObject (CScene* scene, CUserSettingBoolean* visible, uint32_t id, std::string name, std::string type, + CObject (CScene* scene, CUserSettingBoolean* visible, int id, std::string name, std::string type, CUserSettingVector3* origin, CUserSettingVector3* scale, const glm::vec3& angles); void insertEffect (Objects::CEffect* effect); - void insertDependency (uint32_t dependency); + void insertDependency (int dependency); private: std::string m_type; CUserSettingBoolean* m_visible; - uint32_t m_id; + int m_id; std::string m_name; CUserSettingVector3* m_origin; CUserSettingVector3* m_scale; glm::vec3 m_angles; std::vector m_effects; - std::vector m_dependencies; + std::vector m_dependencies; CScene* m_scene; }; diff --git a/src/WallpaperEngine/Core/Objects/CEffect.cpp b/src/WallpaperEngine/Core/Objects/CEffect.cpp index 08ee743..4e820f9 100644 --- a/src/WallpaperEngine/Core/Objects/CEffect.cpp +++ b/src/WallpaperEngine/Core/Objects/CEffect.cpp @@ -67,7 +67,7 @@ CEffect* CEffect::fromJSON (json data, CUserSettingBoolean* visible, CObject* ob for (const auto& passCur : material->getPasses ()) { if (textures_it != cur->end ()) { - int textureNumber = 0; + std::vector::size_type textureNumber = 0; for (const auto& texturesCur : (*textures_it)) { std::string texture; diff --git a/src/WallpaperEngine/Core/Objects/CImage.cpp b/src/WallpaperEngine/Core/Objects/CImage.cpp index 689c7d6..36b96bd 100644 --- a/src/WallpaperEngine/Core/Objects/CImage.cpp +++ b/src/WallpaperEngine/Core/Objects/CImage.cpp @@ -12,7 +12,7 @@ using namespace WallpaperEngine::Core::Objects; using namespace WallpaperEngine::Core::UserSettings; -CImage::CImage (CScene* scene, Images::CMaterial* material, CUserSettingBoolean* visible, uint32_t id, std::string name, +CImage::CImage (CScene* scene, Images::CMaterial* material, CUserSettingBoolean* visible, int id, std::string name, CUserSettingVector3* origin, CUserSettingVector3* scale, const glm::vec3& angles, const glm::vec2& size, std::string alignment, CUserSettingVector3* color, CUserSettingFloat* alpha, float brightness, uint32_t colorBlendMode, const glm::vec2& parallaxDepth, bool fullscreen, bool passthrough, @@ -31,7 +31,7 @@ CImage::CImage (CScene* scene, Images::CMaterial* material, CUserSettingBoolean* m_autosize (autosize) {} WallpaperEngine::Core::CObject* CImage::fromJSON (CScene* scene, json data, CContainer* container, - CUserSettingBoolean* visible, uint32_t id, std::string name, + CUserSettingBoolean* visible, int id, std::string name, CUserSettingVector3* origin, CUserSettingVector3* scale, const glm::vec3& angles) { const auto image_it = data.find ("image"); diff --git a/src/WallpaperEngine/Core/Objects/CImage.h b/src/WallpaperEngine/Core/Objects/CImage.h index a5e72c3..d8e1145 100644 --- a/src/WallpaperEngine/Core/Objects/CImage.h +++ b/src/WallpaperEngine/Core/Objects/CImage.h @@ -28,7 +28,7 @@ class CImage : public CObject { public: static CObject* fromJSON (CScene* scene, json data, CContainer* container, CUserSettingBoolean* visible, - uint32_t id, std::string name, CUserSettingVector3* origin, CUserSettingVector3* scale, + int id, std::string name, CUserSettingVector3* origin, CUserSettingVector3* scale, const glm::vec3& angles); /** @@ -77,7 +77,7 @@ class CImage : public CObject { [[nodiscard]] bool isAutosize () const; protected: - CImage (CScene* scene, Images::CMaterial* material, CUserSettingBoolean* visible, uint32_t id, std::string name, + CImage (CScene* scene, Images::CMaterial* material, CUserSettingBoolean* visible, int id, std::string name, CUserSettingVector3* origin, CUserSettingVector3* scale, const glm::vec3& angles, const glm::vec2& size, std::string alignment, CUserSettingVector3* color, CUserSettingFloat* alpha, float brightness, uint32_t colorBlendMode, const glm::vec2& parallaxDepth, bool fullscreen, bool passthrough, bool autosize); diff --git a/src/WallpaperEngine/Core/Objects/CParticle.cpp b/src/WallpaperEngine/Core/Objects/CParticle.cpp index c988462..5bdd6ce 100644 --- a/src/WallpaperEngine/Core/Objects/CParticle.cpp +++ b/src/WallpaperEngine/Core/Objects/CParticle.cpp @@ -6,8 +6,8 @@ using namespace WallpaperEngine::Core::Objects; CParticle* CParticle::fromFile (CScene* scene, const std::string& filename, CContainer* container, - CUserSettingBoolean* visible, uint32_t id, std::string name, - CUserSettingVector3* origin, CUserSettingVector3* scale) { + CUserSettingBoolean* visible, int id, std::string name, CUserSettingVector3* origin, + CUserSettingVector3* scale) { json data = json::parse (WallpaperEngine::FileSystem::loadFullFile (filename, container)); const auto controlpoint_it = data.find ("controlpoint"); const auto starttime_it = jsonFindRequired (data, "starttime", "Particles must have start time"); @@ -29,7 +29,7 @@ CParticle* CParticle::fromFile (CScene* scene, const std::string& filename, CCon return particle; } -CParticle::CParticle (CScene* scene, uint32_t starttime, uint32_t maxcount, CUserSettingBoolean* visible, uint32_t id, +CParticle::CParticle (CScene* scene, uint32_t starttime, uint32_t maxcount, CUserSettingBoolean* visible, int id, std::string name, CUserSettingVector3* origin, CUserSettingVector3* scale) : CObject (scene, visible, id, std::move (name), Type, origin, scale, glm::vec3 ()), m_starttime (starttime), diff --git a/src/WallpaperEngine/Core/Objects/CParticle.h b/src/WallpaperEngine/Core/Objects/CParticle.h index a235ede..9d288a2 100644 --- a/src/WallpaperEngine/Core/Objects/CParticle.h +++ b/src/WallpaperEngine/Core/Objects/CParticle.h @@ -18,7 +18,7 @@ class CParticle : public CObject { public: static CParticle* fromFile (CScene* scene, const std::string& filename, CContainer* container, - CUserSettingBoolean* visible, uint32_t id, std::string name, + CUserSettingBoolean* visible, int id, std::string name, CUserSettingVector3* origin, CUserSettingVector3* scale); /** @@ -35,7 +35,7 @@ class CParticle : public CObject { [[nodiscard]] const std::vector& getInitializers () const; protected: - CParticle (CScene* scene, uint32_t starttime, uint32_t maxcount, CUserSettingBoolean* visible, uint32_t id, + CParticle (CScene* scene, uint32_t starttime, uint32_t maxcount, CUserSettingBoolean* visible, int id, std::string name, CUserSettingVector3* origin, CUserSettingVector3* scale); /** diff --git a/src/WallpaperEngine/Core/Objects/CSound.cpp b/src/WallpaperEngine/Core/Objects/CSound.cpp index 8fa5aef..e6e9238 100644 --- a/src/WallpaperEngine/Core/Objects/CSound.cpp +++ b/src/WallpaperEngine/Core/Objects/CSound.cpp @@ -4,12 +4,12 @@ using namespace WallpaperEngine::Core::Objects; -CSound::CSound (CScene* scene, CUserSettingBoolean* visible, uint32_t id, std::string name, CUserSettingVector3* origin, +CSound::CSound (CScene* scene, CUserSettingBoolean* visible, int id, std::string name, CUserSettingVector3* origin, CUserSettingVector3* scale, const glm::vec3& angles, bool repeat) : CObject (scene, visible, id, std::move (name), Type, origin, scale, angles), m_repeat (repeat) {} -WallpaperEngine::Core::CObject* CSound::fromJSON (CScene* scene, json data, CUserSettingBoolean* visible, uint32_t id, +WallpaperEngine::Core::CObject* CSound::fromJSON (CScene* scene, json data, CUserSettingBoolean* visible, int id, const std::string& name, CUserSettingVector3* origin, CUserSettingVector3* scale, const glm::vec3& angles) { bool repeat = false; diff --git a/src/WallpaperEngine/Core/Objects/CSound.h b/src/WallpaperEngine/Core/Objects/CSound.h index 8ffadd9..783af9f 100644 --- a/src/WallpaperEngine/Core/Objects/CSound.h +++ b/src/WallpaperEngine/Core/Objects/CSound.h @@ -15,7 +15,7 @@ class CSound : public CObject { friend class CObject; public: - static CObject* fromJSON (CScene* scene, json data, CUserSettingBoolean* visible, uint32_t id, + static CObject* fromJSON (CScene* scene, json data, CUserSettingBoolean* visible, int id, const std::string& name, CUserSettingVector3* origin, CUserSettingVector3* scale, const glm::vec3& angles); @@ -29,7 +29,7 @@ class CSound : public CObject { [[nodiscard]] bool isRepeat () const; protected: - CSound (CScene* scene, CUserSettingBoolean* visible, uint32_t id, std::string name, CUserSettingVector3* origin, + CSound (CScene* scene, CUserSettingBoolean* visible, int id, std::string name, CUserSettingVector3* origin, CUserSettingVector3* scale, const glm::vec3& angles, bool repeat); /** diff --git a/src/WallpaperEngine/Core/Objects/Images/Materials/CPass.cpp b/src/WallpaperEngine/Core/Objects/Images/Materials/CPass.cpp index 7b7c5fa..6fa4902 100644 --- a/src/WallpaperEngine/Core/Objects/Images/Materials/CPass.cpp +++ b/src/WallpaperEngine/Core/Objects/Images/Materials/CPass.cpp @@ -52,7 +52,7 @@ void CPass::insertTexture (const std::string& texture) { this->m_textures.push_back (texture); } -void CPass::setTexture (int index, const std::string& texture) { +void CPass::setTexture (std::vector::size_type index, const std::string& texture) { this->m_textures.at (index) = texture; } diff --git a/src/WallpaperEngine/Core/Objects/Images/Materials/CPass.h b/src/WallpaperEngine/Core/Objects/Images/Materials/CPass.h index 3dd49bb..bf36152 100644 --- a/src/WallpaperEngine/Core/Objects/Images/Materials/CPass.h +++ b/src/WallpaperEngine/Core/Objects/Images/Materials/CPass.h @@ -88,7 +88,7 @@ class CPass { * @param index * @param texture */ - void setTexture (int index, const std::string& texture); + void setTexture (std::vector::size_type index, const std::string& texture); private: // TODO: CREATE ENUMERATIONS FOR THESE INSTEAD OF USING STRING VALUES! diff --git a/src/WallpaperEngine/Core/Scenes/CProjection.cpp b/src/WallpaperEngine/Core/Scenes/CProjection.cpp index 27aca72..c94960a 100644 --- a/src/WallpaperEngine/Core/Scenes/CProjection.cpp +++ b/src/WallpaperEngine/Core/Scenes/CProjection.cpp @@ -2,15 +2,15 @@ using namespace WallpaperEngine::Core::Scenes; -CProjection::CProjection (uint32_t width, uint32_t height) : m_isAuto (false), m_width (width), m_height (height) {} +CProjection::CProjection (int width, int height) : m_isAuto (false), m_width (width), m_height (height) {} CProjection::CProjection (bool isAuto) : m_isAuto (isAuto), m_width (0), m_height (0) {} -const uint32_t& CProjection::getWidth () const { +const int& CProjection::getWidth () const { return this->m_width; } -const uint32_t& CProjection::getHeight () const { +const int& CProjection::getHeight () const { return this->m_height; } @@ -18,11 +18,11 @@ bool CProjection::isAuto () const { return this->m_isAuto; } -void CProjection::setWidth (uint32_t width) { +void CProjection::setWidth (int width) { this->m_width = width; } -void CProjection::setHeight (uint32_t height) { +void CProjection::setHeight (int height) { this->m_height = height; } diff --git a/src/WallpaperEngine/Core/Scenes/CProjection.h b/src/WallpaperEngine/Core/Scenes/CProjection.h index 5269b2b..c531251 100644 --- a/src/WallpaperEngine/Core/Scenes/CProjection.h +++ b/src/WallpaperEngine/Core/Scenes/CProjection.h @@ -9,20 +9,20 @@ class CProjection { public: static CProjection* fromJSON (json data); - const uint32_t& getWidth () const; - const uint32_t& getHeight () const; - bool isAuto () const; + [[nodiscard]] const int& getWidth () const; + [[nodiscard]] const int& getHeight () const; + [[nodiscard]] bool isAuto () const; - void setWidth (uint32_t width); - void setHeight (uint32_t height); + void setWidth (int width); + void setHeight (int height); protected: - CProjection (uint32_t width, uint32_t height); + CProjection (int width, int height); explicit CProjection (bool isAuto); private: - uint32_t m_width; - uint32_t m_height; + int m_width; + int m_height; bool m_isAuto; }; } // namespace WallpaperEngine::Core::Scenes diff --git a/src/WallpaperEngine/Render/CWallpaper.h b/src/WallpaperEngine/Render/CWallpaper.h index 71aa484..50110eb 100644 --- a/src/WallpaperEngine/Render/CWallpaper.h +++ b/src/WallpaperEngine/Render/CWallpaper.h @@ -123,12 +123,12 @@ class CWallpaper : public Helpers::CContextAware { /** * @return The width of this wallpaper */ - [[nodiscard]] virtual uint32_t getWidth () const = 0; + [[nodiscard]] virtual int getWidth () const = 0; /** * @return The height of this wallpaper */ - [[nodiscard]] virtual uint32_t getHeight () const = 0; + [[nodiscard]] virtual int getHeight () const = 0; /** * Creates a new instance of CWallpaper based on the information provided by the read backgrounds diff --git a/src/WallpaperEngine/Render/CWallpaperState.cpp b/src/WallpaperEngine/Render/CWallpaperState.cpp index 7bf99cb..c22572c 100644 --- a/src/WallpaperEngine/Render/CWallpaperState.cpp +++ b/src/WallpaperEngine/Render/CWallpaperState.cpp @@ -61,8 +61,8 @@ template <> void CWallpaperState::updateTextureUVsgetViewportWidth (); const int viewportHeight = this->getViewportHeight (); - uint32_t projectionWidth = this->getProjectionWidth (); - uint32_t projectionHeight = this->getProjectionHeight (); + int projectionWidth = this->getProjectionWidth (); + int projectionHeight = this->getProjectionHeight (); const float m1 = static_cast (viewportWidth) / projectionWidth; const float m2 = static_cast (viewportHeight) / projectionHeight; @@ -82,8 +82,8 @@ template <> void CWallpaperState::updateTextureUVsgetViewportWidth (); const int viewportHeight = this->getViewportHeight (); - uint32_t projectionWidth = this->getProjectionWidth (); - uint32_t projectionHeight = this->getProjectionHeight (); + int projectionWidth = this->getProjectionWidth (); + int projectionHeight = this->getProjectionHeight (); const float m1 = static_cast (viewportWidth) / projectionWidth; const float m2 = static_cast (viewportHeight) / projectionHeight; @@ -103,8 +103,8 @@ template <> void CWallpaperState::updateTextureUVsgetViewportWidth (); const int viewportHeight = this->getViewportHeight (); - const uint32_t projectionWidth = this->getProjectionWidth (); - const uint32_t projectionHeight = this->getProjectionHeight (); + const int projectionWidth = this->getProjectionWidth (); + const int projectionHeight = this->getProjectionHeight (); if ((viewportHeight > viewportWidth && projectionWidth >= projectionHeight) || (viewportWidth > viewportHeight && projectionHeight > projectionWidth)) { diff --git a/src/WallpaperEngine/Render/CWallpaperState.h b/src/WallpaperEngine/Render/CWallpaperState.h index 1a00bb1..86b8cb3 100644 --- a/src/WallpaperEngine/Render/CWallpaperState.h +++ b/src/WallpaperEngine/Render/CWallpaperState.h @@ -70,12 +70,12 @@ class CWallpaperState { }; // @return The width of viewport - uint32_t getProjectionWidth () const { + int getProjectionWidth () const { return projection.width; }; // @return The height of viewport - uint32_t getProjectionHeight () const { + int getProjectionHeight () const { return projection.height; }; @@ -96,8 +96,8 @@ class CWallpaperState { // Wallpaper dimensions struct { - uint32_t width; - uint32_t height; + int width; + int height; } projection {}; // Are Vs coordinates fliped diff --git a/src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.cpp b/src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.cpp index b5715e9..20b5c29 100644 --- a/src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.cpp +++ b/src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.cpp @@ -203,7 +203,8 @@ void CWaylandOpenGLDriver::onLayerClose (Output::CWaylandOutputViewport* viewpor wl_surface_destroy (viewport->surface); // remove the output from the list - std::remove (this->m_screens.begin (), this->m_screens.end (), viewport); + this->m_screens.erase (std::remove (this->m_screens.begin (), this->m_screens.end (), viewport), + this->m_screens.end ()); // reset the viewports this->getOutput ().reset (); diff --git a/src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.cpp b/src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.cpp index 9302d79..9aa759d 100644 --- a/src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.cpp +++ b/src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.cpp @@ -74,7 +74,7 @@ bool CX11FullScreenDetector::anythingFullscreen () const { XFree (children); } - for (int i = 0; i < nchildren; i++) { + for (unsigned int i = 0; i < nchildren; i++) { if (!XGetWindowAttributes (this->m_display, children [i], &attribs)) continue; diff --git a/src/WallpaperEngine/Render/Objects/CImage.cpp b/src/WallpaperEngine/Render/Objects/CImage.cpp index 9d46b31..a6683af 100644 --- a/src/WallpaperEngine/Render/Objects/CImage.cpp +++ b/src/WallpaperEngine/Render/Objects/CImage.cpp @@ -377,7 +377,7 @@ void CImage::render () { #if !NDEBUG std::string str = "Rendering "; - if (this->getScene ()->getScene ()->isBloom () && this->getId () == 0xFFFFFFFF) + if (this->getScene ()->getScene ()->isBloom () && this->getId () == -1) str += "bloom"; else { str += this->getImage ()->getName () + " (" + std::to_string (this->getId ()) + ", " + diff --git a/src/WallpaperEngine/Render/Objects/CSound.cpp b/src/WallpaperEngine/Render/Objects/CSound.cpp index 68ac66e..413c240 100644 --- a/src/WallpaperEngine/Render/Objects/CSound.cpp +++ b/src/WallpaperEngine/Render/Objects/CSound.cpp @@ -12,7 +12,7 @@ CSound::CSound (CScene* scene, Core::Objects::CSound* sound) : CObject (scene, T void CSound::load () { for (const auto& cur : this->m_sound->getSounds ()) { uint32_t filesize = 0; - const void* filebuffer = this->getContainer ()->readFile (cur, &filesize); + const uint8_t* filebuffer = this->getContainer ()->readFile (cur, &filesize); auto stream = new Audio::CAudioStream (this->getScene ()->getAudioContext (), filebuffer, filesize); diff --git a/src/WallpaperEngine/Render/Shaders/Compiler.cpp b/src/WallpaperEngine/Render/Shaders/Compiler.cpp index 5710312..63e4348 100644 --- a/src/WallpaperEngine/Render/Shaders/Compiler.cpp +++ b/src/WallpaperEngine/Render/Shaders/Compiler.cpp @@ -701,7 +701,7 @@ void Compiler::parseParameterConfiguration (const std::string& type, const std:: // extract the texture number from the name const char value = name.at (std::string ("g_Texture").length ()); // now convert it to integer - int index = value - '0'; + size_t index = value - '0'; if (combo != data.end ()) { // if the texture exists (and is not null), add to the combo diff --git a/src/WallpaperEngine/Render/Wallpapers/CScene.cpp b/src/WallpaperEngine/Render/Wallpapers/CScene.cpp index e30c646..3c2cc7f 100644 --- a/src/WallpaperEngine/Render/Wallpapers/CScene.cpp +++ b/src/WallpaperEngine/Render/Wallpapers/CScene.cpp @@ -96,8 +96,7 @@ CScene::CScene (Core::CScene* scene, CRenderContext& context, CAudioContext& aud "\t\"origin\": \"" + std::to_string (sceneWidth / 2) + " " + std::to_string (sceneHeight / 2) + " 0.0\"," - "\t\"id\": " + - std::to_string (0xFFFFFFFF) + + "\t\"id\": -1" + "," "\t\"effects\":" "\t[" @@ -246,11 +245,11 @@ Core::CScene* CScene::getScene () const { return this->getWallpaperData ()->as (); } -uint32_t CScene::getWidth () const { +int CScene::getWidth () const { return this->getScene ()->getOrthogonalProjection ()->getWidth (); } -uint32_t CScene::getHeight () const { +int CScene::getHeight () const { return this->getScene ()->getOrthogonalProjection ()->getHeight (); } diff --git a/src/WallpaperEngine/Render/Wallpapers/CScene.h b/src/WallpaperEngine/Render/Wallpapers/CScene.h index 09d266b..1ec53d0 100644 --- a/src/WallpaperEngine/Render/Wallpapers/CScene.h +++ b/src/WallpaperEngine/Render/Wallpapers/CScene.h @@ -19,8 +19,8 @@ class CScene final : public CWallpaper { Core::CScene* getScene () const; - uint32_t getWidth () const override; - uint32_t getHeight () const override; + int getWidth () const override; + int getHeight () const override; glm::vec2* getMousePosition (); glm::vec2* getMousePositionLast (); diff --git a/src/WallpaperEngine/Render/Wallpapers/CVideo.cpp b/src/WallpaperEngine/Render/Wallpapers/CVideo.cpp index 5ed14fd..b8e6aaa 100644 --- a/src/WallpaperEngine/Render/Wallpapers/CVideo.cpp +++ b/src/WallpaperEngine/Render/Wallpapers/CVideo.cpp @@ -67,7 +67,7 @@ CVideo::CVideo (Core::CVideo* video, CRenderContext& context, CAudioContext& aud this->setupFramebuffers (); } -void CVideo::setSize (int64_t width, int64_t height) { +void CVideo::setSize (int width, int height) { this->m_width = width > 0 ? width : this->m_width; this->m_height = height > 0 ? height : this->m_height; @@ -117,11 +117,11 @@ Core::CVideo* CVideo::getVideo () { return this->getWallpaperData ()->as (); } -uint32_t CVideo::getWidth () const { +int CVideo::getWidth () const { return this->m_width; } -uint32_t CVideo::getHeight () const { +int CVideo::getHeight () const { return this->m_height; } diff --git a/src/WallpaperEngine/Render/Wallpapers/CVideo.h b/src/WallpaperEngine/Render/Wallpapers/CVideo.h index 3f6913b..5890b74 100644 --- a/src/WallpaperEngine/Render/Wallpapers/CVideo.h +++ b/src/WallpaperEngine/Render/Wallpapers/CVideo.h @@ -15,10 +15,10 @@ class CVideo final : public CWallpaper { Core::CVideo* getVideo (); - uint32_t getWidth () const override; - uint32_t getHeight () const override; + [[nodiscard]] int getWidth () const override; + [[nodiscard]] int getHeight () const override; - void setSize (int64_t width, int64_t height); + void setSize (int width, int height); protected: void renderFrame (glm::ivec4 viewport) override; diff --git a/src/WallpaperEngine/Render/Wallpapers/CWeb.cpp b/src/WallpaperEngine/Render/Wallpapers/CWeb.cpp index c859f63..971b2b8 100644 --- a/src/WallpaperEngine/Render/Wallpapers/CWeb.cpp +++ b/src/WallpaperEngine/Render/Wallpapers/CWeb.cpp @@ -36,7 +36,7 @@ CWeb::CWeb (Core::CWeb* web, CRenderContext& context, CAudioContext& audioContex CefBrowserHost::CreateBrowserSync (window_info, m_client.get (), htmlURL, browserSettings, nullptr, nullptr); } -void CWeb::setSize (int64_t width, int64_t height) { +void CWeb::setSize (int width, int height) { this->m_width = width > 0 ? width : this->m_width; this->m_height = height > 0 ? height : this->m_height; @@ -96,8 +96,6 @@ CWeb::~CWeb () { CWeb::RenderHandler::RenderHandler (CWeb* webdata) : m_webdata (webdata) {} -CWeb::RenderHandler::~RenderHandler () {} - // Required by CEF void CWeb::RenderHandler::GetViewRect (CefRefPtr browser, CefRect& rect) { rect = CefRect (0, 0, this->m_webdata->getWidth (), this->m_webdata->getHeight ()); diff --git a/src/WallpaperEngine/Render/Wallpapers/CWeb.h b/src/WallpaperEngine/Render/Wallpapers/CWeb.h index 566d669..4fe0fa6 100644 --- a/src/WallpaperEngine/Render/Wallpapers/CWeb.h +++ b/src/WallpaperEngine/Render/Wallpapers/CWeb.h @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -20,12 +21,12 @@ namespace WallpaperEngine::Render { public: CWeb (Core::CWeb* scene, CRenderContext& context, CAudioContext& audioContext, WallpaperEngine::WebBrowser::CWebBrowserContext& browserContext, const CWallpaperState::TextureUVsScaling& scalingMode); - ~CWeb(); - uint32_t getWidth () const override { return this->m_width; } + ~CWeb() override; + [[nodiscard]] int getWidth () const override { return this->m_width; } - uint32_t getHeight () const override { return this->m_height; } + [[nodiscard]] int getHeight () const override { return this->m_height; } - void setSize (int64_t width, int64_t height); + void setSize (int width, int height); protected: void renderFrame (glm::ivec4 viewport) override; @@ -46,14 +47,10 @@ namespace WallpaperEngine::Render class RenderHandler: public CefRenderHandler { public: - RenderHandler(CWeb* webdata); + explicit RenderHandler(CWeb* webdata); //! \brief - ~RenderHandler(); - - //! \brief Compile OpenGL shaders and create OpenGL objects (VAO, - //! VBO, texture, locations ...) - bool init(); + ~RenderHandler() override = default; //! \brief CefRenderHandler interface void GetViewRect(CefRefPtr browser, CefRect &rect) override; @@ -70,10 +67,10 @@ namespace WallpaperEngine::Render private: CWeb* m_webdata; - uint32_t getWidth () const { + int getWidth () const { return this->m_webdata->getWidth(); }; - uint32_t getHeight () const { + int getHeight () const { return this->m_webdata->getHeight(); }; //! \brief Return the OpenGL texture handle @@ -90,8 +87,8 @@ namespace WallpaperEngine::Render class BrowserClient: public CefClient { public: - BrowserClient(CefRefPtr ptr) - : m_renderHandler(ptr) + explicit BrowserClient(CefRefPtr ptr) + : m_renderHandler(std::move(ptr)) {} CefRefPtr GetRenderHandler() override @@ -109,8 +106,8 @@ namespace WallpaperEngine::Render CefRefPtr m_client; RenderHandler* m_render_handler = nullptr; - int64_t m_width; - int64_t m_height; + int m_width; + int m_height; glm::vec2 m_mousePosition; glm::vec2 m_mousePositionLast;