From 3084df112a95ea7bf4a6971b7d854514dc5c8bc3 Mon Sep 17 00:00:00 2001 From: Tom Englund Date: Wed, 14 Jan 2026 18:29:04 +0100 Subject: [PATCH] egl: add pixelsPerBlock and minStride add two helpers, pixelsPerBlock and minStride --- include/hyprgraphics/egl/Egl.hpp | 2 ++ src/egl/Egl.cpp | 9 +++++++++ 2 files changed, 11 insertions(+) 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)); + } }