summaryrefslogtreecommitdiff
path: root/src/protocols
diff options
context:
space:
mode:
authorUjinT34 <41110182+UjinT34@users.noreply.github.com>2026-03-07 00:44:10 +0300
committerGitHub <noreply@github.com>2026-03-06 21:44:10 +0000
commit4152ac76d0813d9d0f67d2f04653a13fa6e17433 (patch)
treec341f1883cf5a182d32e4ad00192ba8786a9bb75 /src/protocols
parenta5858018d896e0e0f0db517f893cd9a0936dd881 (diff)
renderer: refactor Texture, Framebuffer and Renderbuffer (#13437)
Part 1 of the renderer refactors
Diffstat (limited to 'src/protocols')
-rw-r--r--src/protocols/SinglePixel.cpp4
-rw-r--r--src/protocols/types/Buffer.hpp2
-rw-r--r--src/protocols/types/DMABuffer.cpp19
-rw-r--r--src/protocols/types/SurfaceState.cpp5
-rw-r--r--src/protocols/types/SurfaceState.hpp6
5 files changed, 17 insertions, 19 deletions
diff --git a/src/protocols/SinglePixel.cpp b/src/protocols/SinglePixel.cpp
index 51c3551c..c32379a3 100644
--- a/src/protocols/SinglePixel.cpp
+++ b/src/protocols/SinglePixel.cpp
@@ -12,11 +12,11 @@ CSinglePixelBuffer::CSinglePixelBuffer(uint32_t id, wl_client* client, CHyprColo
m_opaque = col_.a >= 1.F;
- m_texture = makeShared<CTexture>(DRM_FORMAT_ARGB8888, rc<uint8_t*>(&m_color), 4, Vector2D{1, 1});
+ m_texture = g_pHyprRenderer->createTexture(DRM_FORMAT_ARGB8888, rc<uint8_t*>(&m_color), 4, Vector2D{1, 1});
m_resource = CWLBufferResource::create(makeShared<CWlBuffer>(client, 1, id));
- m_success = m_texture->m_texID;
+ m_success = m_texture->ok();
size = {1, 1};
diff --git a/src/protocols/types/Buffer.hpp b/src/protocols/types/Buffer.hpp
index bda44ebc..afff11a5 100644
--- a/src/protocols/types/Buffer.hpp
+++ b/src/protocols/types/Buffer.hpp
@@ -26,7 +26,7 @@ class IHLBuffer : public Aquamarine::IBuffer {
void onBackendRelease(const std::function<void()>& fn);
void addReleasePoint(CDRMSyncPointState& point);
- SP<CTexture> m_texture;
+ SP<ITexture> m_texture;
bool m_opaque = false;
SP<CWLBufferResource> m_resource;
std::vector<UP<CSyncReleaser>> m_syncReleasers;
diff --git a/src/protocols/types/DMABuffer.cpp b/src/protocols/types/DMABuffer.cpp
index f3c3e067..86db8ca6 100644
--- a/src/protocols/types/DMABuffer.cpp
+++ b/src/protocols/types/DMABuffer.cpp
@@ -13,31 +13,28 @@
using namespace Hyprutils::OS;
CDMABuffer::CDMABuffer(uint32_t id, wl_client* client, Aquamarine::SDMABUFAttrs const& attrs_) : m_attrs(attrs_) {
- g_pHyprRenderer->makeEGLCurrent();
-
m_listeners.resourceDestroy = events.destroy.listen([this] {
closeFDs();
m_listeners.resourceDestroy.reset();
});
- size = m_attrs.size;
- m_resource = CWLBufferResource::create(makeShared<CWlBuffer>(client, 1, id));
- auto eglImage = g_pHyprOpenGL->createEGLImage(m_attrs);
+ size = m_attrs.size;
+ m_resource = CWLBufferResource::create(makeShared<CWlBuffer>(client, 1, id));
+ m_opaque = NFormatUtils::isFormatOpaque(m_attrs.format);
+ m_texture = g_pHyprRenderer->createTexture(m_attrs, m_opaque); // texture takes ownership of the eglImage
- if UNLIKELY (!eglImage) {
+ if UNLIKELY (!m_texture) {
Log::logger->log(Log::ERR, "CDMABuffer: failed to import EGLImage, retrying as implicit");
m_attrs.modifier = DRM_FORMAT_MOD_INVALID;
- eglImage = g_pHyprOpenGL->createEGLImage(m_attrs);
+ m_texture = g_pHyprRenderer->createTexture(m_attrs, m_opaque);
- if UNLIKELY (!eglImage) {
+ if UNLIKELY (!m_texture) {
Log::logger->log(Log::ERR, "CDMABuffer: failed to import EGLImage");
return;
}
}
- m_texture = makeShared<CTexture>(m_attrs, eglImage); // texture takes ownership of the eglImage
- m_opaque = NFormatUtils::isFormatOpaque(m_attrs.format);
- m_success = m_texture->m_texID;
+ m_success = m_texture->ok();
if UNLIKELY (!m_success)
Log::logger->log(Log::ERR, "Failed to create a dmabuf: texture is null");
diff --git a/src/protocols/types/SurfaceState.cpp b/src/protocols/types/SurfaceState.cpp
index 46f2a563..da98d3fb 100644
--- a/src/protocols/types/SurfaceState.cpp
+++ b/src/protocols/types/SurfaceState.cpp
@@ -1,6 +1,7 @@
#include "SurfaceState.hpp"
#include "helpers/Format.hpp"
#include "protocols/types/Buffer.hpp"
+#include "render/Renderer.hpp"
#include "render/Texture.hpp"
Vector2D SSurfaceState::sourceSize() {
@@ -34,7 +35,7 @@ CRegion SSurfaceState::accumulateBufferDamage() {
return bufferDamage;
}
-void SSurfaceState::updateSynchronousTexture(SP<CTexture> lastTexture) {
+void SSurfaceState::updateSynchronousTexture(SP<ITexture> lastTexture) {
auto [dataPtr, fmt, size] = buffer->beginDataPtr(0);
if (dataPtr) {
auto drmFmt = NFormatUtils::shmToDRM(fmt);
@@ -43,7 +44,7 @@ void SSurfaceState::updateSynchronousTexture(SP<CTexture> lastTexture) {
texture = lastTexture;
texture->update(drmFmt, dataPtr, stride, accumulateBufferDamage());
} else
- texture = makeShared<CTexture>(drmFmt, dataPtr, stride, bufferSize);
+ texture = g_pHyprRenderer->createTexture(drmFmt, dataPtr, stride, bufferSize);
}
buffer->endDataPtr();
}
diff --git a/src/protocols/types/SurfaceState.hpp b/src/protocols/types/SurfaceState.hpp
index f6caa83c..d5b7e4b9 100644
--- a/src/protocols/types/SurfaceState.hpp
+++ b/src/protocols/types/SurfaceState.hpp
@@ -6,7 +6,7 @@
#include "../WaylandProtocol.hpp"
#include "./Buffer.hpp"
-class CTexture;
+class ITexture;
class CDRMSyncPointState;
class CWLCallbackResource;
@@ -88,8 +88,8 @@ struct SSurfaceState {
eLockReason lockMask = LOCK_REASON_NONE;
// texture of surface content, used for rendering
- SP<CTexture> texture;
- void updateSynchronousTexture(SP<CTexture> lastTexture);
+ SP<ITexture> texture;
+ void updateSynchronousTexture(SP<ITexture> lastTexture);
// fifo
bool barrierSet = false;