diff --git a/include/hyprgraphics/egl/Egl.hpp b/include/hyprgraphics/egl/Egl.hpp index 2bac0bf..1b7eb64 100644 --- a/include/hyprgraphics/egl/Egl.hpp +++ b/include/hyprgraphics/egl/Egl.hpp @@ -42,4 +42,6 @@ namespace Hyprgraphics::Egl { const SPixelFormat* getPixelFormatFromDRM(uint32_t drmFormat); const SPixelFormat* getPixelFormatFromGL(uint32_t glFormat, uint32_t glType, bool alpha); bool isDrmFormatOpaque(uint32_t drmFormat); + int pixelsPerBlock(const SPixelFormat* const fmt); + int minStride(const SPixelFormat* const fmt, int32_t width); } diff --git a/src/egl/Egl.cpp b/src/egl/Egl.cpp index b2425cd..57f0dfa 100644 --- a/src/egl/Egl.cpp +++ b/src/egl/Egl.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -250,4 +251,12 @@ namespace Hyprgraphics::Egl { return !FMT->withAlpha; } + + int pixelsPerBlock(const SPixelFormat* const fmt) { + return fmt->blockSize.x * fmt->blockSize.y > 0 ? fmt->blockSize.x * fmt->blockSize.y : 1; + } + + int minStride(const SPixelFormat* const fmt, int32_t width) { + return std::ceil((width * fmt->bytesPerBlock) / pixelsPerBlock(fmt)); + } }