mirror of
https://github.com/hyprwm/hyprgraphics.git
synced 2026-02-03 20:40:33 +01:00
egl: add pixelsPerBlock and minStride
add two helpers, pixelsPerBlock and minStride
This commit is contained in:
parent
b7eb992abc
commit
3084df112a
2 changed files with 11 additions and 0 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue