egl: add pixelsPerBlock and minStride

add two helpers, pixelsPerBlock and minStride
This commit is contained in:
Tom Englund 2026-01-14 18:29:04 +01:00
parent b7eb992abc
commit 3084df112a
2 changed files with 11 additions and 0 deletions

View file

@ -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);
}

View file

@ -1,3 +1,4 @@
#include <cmath>
#include <hyprgraphics/egl/Egl.hpp>
#include <hyprutils/memory/Casts.hpp>
#include <vector>
@ -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));
}
}