summaryrefslogtreecommitdiff
path: root/src/render/Texture.hpp
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/render/Texture.hpp
parenta5858018d896e0e0f0db517f893cd9a0936dd881 (diff)
renderer: refactor Texture, Framebuffer and Renderbuffer (#13437)
Part 1 of the renderer refactors
Diffstat (limited to 'src/render/Texture.hpp')
-rw-r--r--src/render/Texture.hpp74
1 files changed, 28 insertions, 46 deletions
diff --git a/src/render/Texture.hpp b/src/render/Texture.hpp
index a5806e26..38c3ff01 100644
--- a/src/render/Texture.hpp
+++ b/src/render/Texture.hpp
@@ -16,61 +16,43 @@ enum eTextureType : int8_t {
TEXTURE_EXTERNAL, // EGLImage
};
-class CTexture {
+class ITexture {
public:
- CTexture();
+ ITexture(ITexture&) = delete;
+ ITexture(ITexture&&) = delete;
+ ITexture(const ITexture&&) = delete;
+ ITexture(const ITexture&) = delete;
- CTexture(CTexture&) = delete;
- CTexture(CTexture&&) = delete;
- CTexture(const CTexture&&) = delete;
- CTexture(const CTexture&) = delete;
+ virtual ~ITexture() = default;
- CTexture(uint32_t drmFormat, uint8_t* pixels, uint32_t stride, const Vector2D& size, bool keepDataCopy = false);
- CTexture(std::span<const float> lut3D, size_t N);
+ virtual void setTexParameter(GLenum pname, GLint param) = 0;
+ virtual void allocate(const Vector2D& size, uint32_t drmFormat = 0) = 0;
+ virtual void update(uint32_t drmFormat, uint8_t* pixels, uint32_t stride, const CRegion& damage) = 0;
+ virtual void bind() {};
+ virtual void unbind() {};
+ virtual bool ok();
+ virtual bool isDMA();
- CTexture(const SP<Aquamarine::IBuffer> buffer, bool keepDataCopy = false);
- // this ctor takes ownership of the eglImage.
- CTexture(const Aquamarine::SDMABUFAttrs&, void* image);
- ~CTexture();
-
- void destroyTexture();
- void allocate();
- void update(uint32_t drmFormat, uint8_t* pixels, uint32_t stride, const CRegion& damage);
const std::vector<uint8_t>& dataCopy();
- void bind();
- void unbind();
- void setTexParameter(GLenum pname, GLint param);
- void swizzle(const std::array<GLint, 4>& colors);
- eTextureType m_type = TEXTURE_RGBA;
- GLenum m_target = GL_TEXTURE_2D;
- GLuint m_texID = 0;
- Vector2D m_size = {};
- void* m_eglImage = nullptr;
- eTransform m_transform = HYPRUTILS_TRANSFORM_NORMAL;
- bool m_opaque = false;
+ eTextureType m_type = TEXTURE_RGBA;
+ Vector2D m_size = {};
+ eTransform m_transform = HYPRUTILS_TRANSFORM_NORMAL;
+ bool m_opaque = false;
+
uint32_t m_drmFormat = 0; // for shm
bool m_isSynchronous = false;
- GLenum magFilter = GL_LINEAR; // useNearestNeighbor overwrites these
- GLenum minFilter = GL_LINEAR;
-
- private:
- enum eTextureParam : uint8_t {
- TEXTURE_PAR_WRAP_S = 0,
- TEXTURE_PAR_WRAP_T,
- TEXTURE_PAR_MAG_FILTER,
- TEXTURE_PAR_MIN_FILTER,
- TEXTURE_PAR_SWIZZLE_R,
- TEXTURE_PAR_SWIZZLE_B,
- TEXTURE_PAR_LAST,
- };
+ // TODO move to GLTexture
+ GLuint m_texID = 0;
+ GLenum magFilter = GL_LINEAR; // useNearestNeighbor overwrites these
+ GLenum minFilter = GL_LINEAR;
- void createFromShm(uint32_t drmFormat, uint8_t* pixels, uint32_t stride, const Vector2D& size);
- void createFromDma(const Aquamarine::SDMABUFAttrs&, void* image);
- inline constexpr std::optional<size_t> getCacheStateIndex(GLenum pname);
+ protected:
+ ITexture() = default;
+ ITexture(uint32_t drmFormat, uint8_t* pixels, uint32_t stride, const Vector2D& size, bool keepDataCopy = false, bool opaque = false);
+ ITexture(std::span<const float> lut3D, size_t N);
- bool m_keepDataCopy = false;
- std::vector<uint8_t> m_dataCopy;
- std::array<std::optional<GLint>, TEXTURE_PAR_LAST> m_cachedStates;
+ bool m_keepDataCopy = false;
+ std::vector<uint8_t> m_dataCopy;
};