diff options
| author | UjinT34 <41110182+UjinT34@users.noreply.github.com> | 2026-03-29 00:41:45 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-28 21:41:45 +0000 |
| commit | 38a7f03cf0e5ee116794a78581634ba3dab508fa (patch) | |
| tree | 969891411b2af4e437a183004018cfc359a3057e /src/render/Framebuffer.cpp | |
| parent | ef2e8dfd5f7e6ee55fa7bc48e44974e64938d14a (diff) | |
renderer: refactor part 7: api fixes (#13631)
Part 7 of ujin's refactors
---------
Co-authored-by: Vaxry <vaxry@vaxry.net>
Diffstat (limited to 'src/render/Framebuffer.cpp')
| -rw-r--r-- | src/render/Framebuffer.cpp | 41 |
1 files changed, 38 insertions, 3 deletions
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<ITexture> IFramebuffer::getTexture() { return m_tex; } +SP<ITexture> IFramebuffer::getMirrorTexture() { + return m_mirrorTex; +} + SP<ITexture> IFramebuffer::getStencilTex() { return m_stencilTex; } + +void IFramebuffer::enableMirror(SP<ITexture> 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; +} |
