From 38a7f03cf0e5ee116794a78581634ba3dab508fa Mon Sep 17 00:00:00 2001 From: UjinT34 <41110182+UjinT34@users.noreply.github.com> Date: Sun, 29 Mar 2026 00:41:45 +0300 Subject: renderer: refactor part 7: api fixes (#13631) Part 7 of ujin's refactors --------- Co-authored-by: Vaxry --- src/render/Framebuffer.cpp | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) (limited to 'src/render/Framebuffer.cpp') diff --git a/src/render/Framebuffer.cpp b/src/render/Framebuffer.cpp index b2ff7e68..47a466c1 100644 --- a/src/render/Framebuffer.cpp +++ b/src/render/Framebuffer.cpp @@ -1,16 +1,23 @@ #include "Framebuffer.hpp" +#include "helpers/Format.hpp" +#include "helpers/cm/ColorManagement.hpp" + +using namespace Render; IFramebuffer::IFramebuffer(const std::string& name) : m_name(name) {} -bool IFramebuffer::alloc(int w, int h, uint32_t format) { +bool IFramebuffer::alloc(int w, int h, DRMFormat format) { RASSERT((w > 0 && h > 0), "cannot alloc a FB with negative / zero size! (attempted {}x{})", w, h); - const bool sizeChanged = (m_size != Vector2D(w, h)); - const bool formatChanged = (format != m_drmFormat); + const bool sizeChanged = m_size != Vector2D(w, h); + const bool formatChanged = format != m_drmFormat; if (m_fbAllocated && !sizeChanged && !formatChanged) return true; + if (sizeChanged || formatChanged) + m_tex.reset(); + m_size = {w, h}; m_drmFormat = format; m_fbAllocated = internalAlloc(w, h, format); @@ -25,6 +32,34 @@ SP IFramebuffer::getTexture() { return m_tex; } +SP IFramebuffer::getMirrorTexture() { + return m_mirrorTex; +} + SP IFramebuffer::getStencilTex() { return m_stencilTex; } + +void IFramebuffer::enableMirror(SP tex) { + if (!tex || tex == m_mirrorTex) + return; + m_mirrorTex = tex; + m_fbAllocated = internalAlloc(m_size.x, m_size.y, m_drmFormat); +} + +void IFramebuffer::disableMirror() { + if (m_mirrorTex) { + m_mirrorTex.reset(); + m_fbAllocated = internalAlloc(m_size.x, m_size.y, m_drmFormat); + } +} + +NColorManagement::PImageDescription IFramebuffer::imageDescription() { + return m_tex ? m_tex->m_imageDescription : m_imageDescription; +} + +void IFramebuffer::setImageDescription(NColorManagement::PImageDescription desc) { + m_imageDescription = desc; + if (m_tex) + m_tex->m_imageDescription = desc; +} -- cgit v1.2.3