diff options
| author | Tom Englund <tomenglund26@gmail.com> | 2026-04-05 20:37:07 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-05 19:37:07 +0100 |
| commit | 809b9b9e78c69c53b62dfc7d5de5c20ff8fe0626 (patch) | |
| tree | c54f0261aad8e01e9dc7abcfefafb056cd448ac3 /src/render | |
| parent | 5c5ba65ad32aa59c9e769d7b2ae62ea632d773f0 (diff) | |
egl: move over to use hyprgraphics (#12988)
use the hyprgraphics helpers instead.
Diffstat (limited to 'src/render')
| -rw-r--r-- | src/render/gl/GLFramebuffer.cpp | 16 | ||||
| -rw-r--r-- | src/render/gl/GLTexture.cpp | 10 |
2 files changed, 14 insertions, 12 deletions
diff --git a/src/render/gl/GLFramebuffer.cpp b/src/render/gl/GLFramebuffer.cpp index 0ad84e62..3881c6f6 100644 --- a/src/render/gl/GLFramebuffer.cpp +++ b/src/render/gl/GLFramebuffer.cpp @@ -3,7 +3,9 @@ #include "../Renderer.hpp" #include "macros.hpp" #include "../Framebuffer.hpp" +#include <hyprgraphics/egl/Egl.hpp> +using namespace Hyprgraphics::Egl; using namespace Render::GL; CGLFramebuffer::CGLFramebuffer() : IFramebuffer() {} @@ -27,14 +29,14 @@ bool CGLFramebuffer::internalAlloc(int w, int h, uint32_t drmFormat) { m_fbAllocated = true; } - const auto format = NFormatUtils::getPixelFormatFromDRM(drmFormat); + const auto format = getPixelFormatFromDRM(drmFormat); m_tex->bind(); glTexImage2D(GL_TEXTURE_2D, 0, format->glInternalFormat ? format->glInternalFormat : format->glFormat, w, h, 0, format->glFormat, format->glType, nullptr); glBindFramebuffer(GL_FRAMEBUFFER, m_fb); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_tex->m_texID, 0); if (m_mirrorTex) { - const auto format = NFormatUtils::getPixelFormatFromDRM(m_mirrorTex->m_drmFormat); + const auto format = getPixelFormatFromDRM(m_mirrorTex->m_drmFormat); m_mirrorTex->bind(); glTexImage2D(GL_TEXTURE_2D, 0, format->glInternalFormat ? format->glInternalFormat : format->glFormat, w, h, 0, format->glFormat, format->glType, nullptr); glBindFramebuffer(GL_FRAMEBUFFER, m_fb); @@ -110,7 +112,7 @@ bool CGLFramebuffer::readPixels(CHLBufferReference buffer, uint32_t offsetX, uin auto shm = buffer->shm(); auto [pixelData, fmt, bufLen] = buffer->beginDataPtr(0); // no need for end, cuz it's shm - const auto PFORMAT = NFormatUtils::getPixelFormatFromDRM(shm.format); + const auto PFORMAT = getPixelFormatFromDRM(shm.format); if (!PFORMAT) { LOGM(Log::ERR, "Can't copy: failed to find a pixel format"); return false; @@ -122,7 +124,7 @@ bool CGLFramebuffer::readPixels(CHLBufferReference buffer, uint32_t offsetX, uin glPixelStorei(GL_PACK_ALIGNMENT, 1); - uint32_t packStride = NFormatUtils::minStride(PFORMAT, m_size.x); + uint32_t packStride = minStride(PFORMAT, m_size.x); int glFormat = PFORMAT->glFormat; if (glFormat == GL_RGBA) @@ -130,11 +132,9 @@ bool CGLFramebuffer::readPixels(CHLBufferReference buffer, uint32_t offsetX, uin if (glFormat != GL_BGRA_EXT && glFormat != GL_RGB) { if (PFORMAT->swizzle.has_value()) { - std::array<GLint, 4> RGBA = SWIZZLE_RGBA; - std::array<GLint, 4> BGRA = SWIZZLE_BGRA; - if (PFORMAT->swizzle == RGBA) + if (PFORMAT->swizzle == SWIZZLE_RGBA) glFormat = GL_RGBA; - else if (PFORMAT->swizzle == BGRA) + else if (PFORMAT->swizzle == SWIZZLE_BGRA) glFormat = GL_BGRA_EXT; else { LOGM(Log::ERR, "Copied frame via shm might be broken or color flipped"); diff --git a/src/render/gl/GLTexture.cpp b/src/render/gl/GLTexture.cpp index d34bdb60..22bb8146 100644 --- a/src/render/gl/GLTexture.cpp +++ b/src/render/gl/GLTexture.cpp @@ -4,7 +4,9 @@ #include "../../helpers/Format.hpp" #include "../Texture.hpp" #include <cstring> +#include <hyprgraphics/egl/Egl.hpp> +using namespace Hyprgraphics::Egl; using namespace Render::GL; CGLTexture::CGLTexture(bool opaque) { @@ -32,7 +34,7 @@ CGLTexture::CGLTexture(uint32_t drmFormat, uint8_t* pixels, uint32_t stride, con g_pHyprOpenGL->makeEGLCurrent(); - const auto format = NFormatUtils::getPixelFormatFromDRM(drmFormat); + const auto format = getPixelFormatFromDRM(drmFormat); ASSERT(format); m_type = format->withAlpha ? TEXTURE_RGBA : TEXTURE_RGBX; @@ -70,7 +72,7 @@ CGLTexture::CGLTexture(const Aquamarine::SDMABUFAttrs& attrs, void* image, bool return; } - m_opaque = NFormatUtils::isFormatOpaque(attrs.format); + m_opaque = isDrmFormatOpaque(attrs.format); // #TODO external only formats should be external aswell. // also needs a seperate color shader. @@ -79,7 +81,7 @@ CGLTexture::CGLTexture(const Aquamarine::SDMABUFAttrs& attrs, void* image, bool m_type = TEXTURE_EXTERNAL; } else {*/ m_target = GL_TEXTURE_2D; - m_type = NFormatUtils::isFormatOpaque(attrs.format) ? TEXTURE_RGBX : TEXTURE_RGBA; + m_type = isDrmFormatOpaque(attrs.format) ? TEXTURE_RGBX : TEXTURE_RGBA; //} allocate(attrs.size); @@ -124,7 +126,7 @@ void CGLTexture::update(uint32_t drmFormat, uint8_t* pixels, uint32_t stride, co g_pHyprOpenGL->makeEGLCurrent(); - const auto format = NFormatUtils::getPixelFormatFromDRM(drmFormat); + const auto format = getPixelFormatFromDRM(drmFormat); ASSERT(format); bind(); |
