From 4152ac76d0813d9d0f67d2f04653a13fa6e17433 Mon Sep 17 00:00:00 2001 From: UjinT34 <41110182+UjinT34@users.noreply.github.com> Date: Sat, 7 Mar 2026 00:44:10 +0300 Subject: renderer: refactor Texture, Framebuffer and Renderbuffer (#13437) Part 1 of the renderer refactors --- src/render/Framebuffer.hpp | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) (limited to 'src/render/Framebuffer.hpp') diff --git a/src/render/Framebuffer.hpp b/src/render/Framebuffer.hpp index e6c93876..7e33f227 100644 --- a/src/render/Framebuffer.hpp +++ b/src/render/Framebuffer.hpp @@ -3,34 +3,38 @@ #include "../defines.hpp" #include "../helpers/Format.hpp" #include "Texture.hpp" +#include #include -class CFramebuffer { +class CHLBufferReference; + +class IFramebuffer { public: - CFramebuffer(); - ~CFramebuffer(); - - bool alloc(int w, int h, uint32_t format = DRM_FORMAT_ARGB8888); - void addStencil(SP tex); - void bind(); - void unbind(); - void release(); - void reset(); + IFramebuffer() = default; + IFramebuffer(const std::string& name); + virtual ~IFramebuffer() = default; + + virtual bool alloc(int w, int h, uint32_t format = DRM_FORMAT_ARGB8888); + virtual void release() = 0; + virtual bool readPixels(CHLBufferReference buffer, uint32_t offsetX = 0, uint32_t offsetY = 0, uint32_t width = 0, uint32_t height = 0) = 0; + + virtual void bind() = 0; + bool isAllocated(); - SP getTexture(); - SP getStencilTex(); - GLuint getFBID(); - void invalidate(const std::vector& attachments); + SP getTexture(); + SP getStencilTex(); + + virtual void addStencil(SP tex) = 0; Vector2D m_size; - DRMFormat m_drmFormat = 0 /* DRM_FORMAT_INVALID */; + DRMFormat m_drmFormat = DRM_FORMAT_INVALID; - private: - SP m_tex; - GLuint m_fb = -1; - bool m_fbAllocated = false; + protected: + virtual bool internalAlloc(int w, int h, uint32_t format = DRM_FORMAT_ARGB8888) = 0; - SP m_stencilTex; + SP m_tex; + bool m_fbAllocated = false; - friend class CRenderbuffer; + SP m_stencilTex; + std::string m_name; // name for logging }; -- cgit v1.2.3