FBOProvider.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "FBOProvider.h"
  2. #include <gmpxx.h>
  3. using namespace WallpaperEngine::Render;
  4. using namespace WallpaperEngine::Data::Model;
  5. FBOProvider::FBOProvider (const FBOProvider* parent) : m_parent (parent) { }
  6. std::shared_ptr<CFBO> FBOProvider::create (const FBO& base, uint32_t flags, const glm::vec2 size) {
  7. return this->m_fbos[base.name] = std::make_shared<CFBO> (
  8. base.name,
  9. // TODO: PROPERLY DETERMINE FBO FORMAT BASED ON THE STRING
  10. TextureFormat_ARGB8888, flags, base.scale, size.x / base.scale, size.y / base.scale, size.x / base.scale,
  11. size.y / base.scale
  12. );
  13. }
  14. std::shared_ptr<CFBO> FBOProvider::create (
  15. const std::string& name, TextureFormat format, uint32_t flags, float scale, glm::vec2 realSize,
  16. glm::vec2 textureSize
  17. ) {
  18. return this->m_fbos[name] = std::make_shared<CFBO> (
  19. name, TextureFormat_ARGB8888, flags, scale, realSize.x, realSize.y, textureSize.x, textureSize.y
  20. );
  21. }
  22. std::shared_ptr<CFBO> FBOProvider::alias (const std::string& newName, const std::string& original) {
  23. return this->m_fbos[newName] = this->m_fbos[original];
  24. }
  25. std::shared_ptr<CFBO> FBOProvider::find (const std::string& name) const {
  26. if (const auto it = this->m_fbos.find (name); it != this->m_fbos.end ()) {
  27. return it->second;
  28. }
  29. if (this->m_parent == nullptr) {
  30. return nullptr;
  31. }
  32. return this->m_parent->find (name);
  33. }