| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- #pragma once
- #include <glm/vec4.hpp>
- #include <memory>
- #include <optional>
- #include <vector>
- #include "TextureCache.h"
- #include "WallpaperEngine/Application/WallpaperApplication.h"
- #include "WallpaperEngine/Input/InputContext.h"
- #include "WallpaperEngine/Input/MouseInput.h"
- #include "WallpaperEngine/Render/Drivers/Output/Output.h"
- #include "WallpaperEngine/Render/Drivers/Output/OutputViewport.h"
- #include "WallpaperEngine/Render/Drivers/VideoDriver.h"
- namespace WallpaperEngine {
- namespace Application {
- class WallpaperApplication;
- }
- namespace Media {
- class MediaSource;
- }
- namespace Render {
- namespace Drivers {
- class VideoDriver;
- namespace Output {
- class Output;
- class OutputViewport;
- } // namespace Output
- } // namespace Drivers
- class CWallpaper;
- class TextureCache;
- class RenderContext {
- public:
- RenderContext (Drivers::VideoDriver& driver, WallpaperApplication& app, Media::MediaSource& mediaSource);
- void render (Drivers::Output::OutputViewport* viewport);
- /** holdPrevious keeps the old wallpaper's last frame on screen until the new one has content */
- void
- setWallpaper (const std::string& display, std::shared_ptr<CWallpaper> wallpaper, bool holdPrevious = false);
- void setPause (bool newState) const;
- void pruneTextures () const;
- [[nodiscard]] Input::InputContext& getInputContext () const;
- [[nodiscard]] const WallpaperApplication& getApp () const;
- [[nodiscard]] const Drivers::VideoDriver& getDriver () const;
- [[nodiscard]] const Drivers::Output::Output& getOutput () const;
- [[nodiscard]] std::shared_ptr<const TextureProvider>
- resolveTexture (const std::string& name, const Data::Model::Project& project) const;
- /** see TextureCache::iconTextureName */
- [[nodiscard]] std::string iconTextureName (const std::filesystem::path& icon) const;
- /** see TextureCache::findLoaded */
- [[nodiscard]] std::shared_ptr<const TextureProvider>
- findLoadedTexture (const std::string& name, const Data::Model::Project& project) const;
- [[nodiscard]] const std::map<std::string, std::shared_ptr<CWallpaper>>& getWallpapers () const;
- [[nodiscard]] Media::MediaSource& getMediaSource () const;
- /** Last frame's rect in the output framebuffer */
- [[nodiscard]] std::optional<glm::ivec4> getSlotRect (const std::string& slot) const;
- private:
- void renderWithStats (Drivers::Output::OutputViewport* viewport);
- void drawWallpapers (Drivers::Output::OutputViewport& viewport);
- void drawSplitScreen (
- Drivers::Output::OutputViewport& viewport, const Application::ApplicationContext::SplitScreen& split
- );
- void holdFrame (const std::string& display);
- void releaseHeldFrame (const std::string& display);
- void drawHeldFrame (const std::string& display, const glm::ivec4& rect, const CWallpaper& wallpaper);
- struct DrawTarget {
- Drivers::Output::OutputViewport* viewport = nullptr;
- glm::ivec4 rect {};
- };
- [[nodiscard]] std::optional<DrawTarget> findDrawTarget (const std::string& display) const;
- struct HeldFrame {
- GLuint framebuffer = GL_NONE;
- GLuint texture = GL_NONE;
- glm::ivec4 viewport {};
- };
- /** RGBA16F of the viewport's size, false on failure */
- static bool allocateHeldFrame (HeldFrame& held);
- Drivers::VideoDriver& m_driver;
- std::map<std::string, std::shared_ptr<CWallpaper>> m_wallpapers = {};
- WallpaperApplication& m_app;
- Media::MediaSource& m_mediaSource;
- std::unique_ptr<TextureCache> m_textureCache = nullptr;
- std::map<std::string, HeldFrame> m_heldFrames = {};
- std::map<std::string, glm::ivec4> m_slotRects = {};
- };
- } // namespace Render
- } // namespace WallpaperEngine
|