This commit is contained in:
Vaxry 2024-11-11 15:44:41 +00:00 committed by Mihai Fufezan
parent bf6d425bba
commit 66880afcb4
Signed by: fufexan
SSH key fingerprint: SHA256:SdnKmEpJrDu1+2UO1QpB/Eg4HKcdDi6n+xSRqFNJVpg
3 changed files with 23 additions and 1 deletions

View file

@ -445,10 +445,29 @@ SP<Aquamarine::IBuffer> CPointerManager::renderHWCursorBuffer(SP<CPointerManager
const auto SURFACE = currentCursorImage.surface->resource();
auto& shmBuffer = CCursorSurfaceRole::cursorPixelData(SURFACE);
bool flipRB = false;
if (SURFACE->current.texture) {
Debug::log(TRACE, "Cursor CPU surface: format {}, expecting AR24", FormatUtils::drmFormatName(SURFACE->current.texture->m_iDrmFormat));
if (SURFACE->current.texture->m_iDrmFormat == DRM_FORMAT_ABGR8888) {
Debug::log(TRACE, "Cursor CPU surface format AB24, will flip. WARNING: this will break on big endian!");
flipRB = true;
} else if (SURFACE->current.texture->m_iDrmFormat != DRM_FORMAT_ARGB8888) {
Debug::log(TRACE, "Cursor CPU surface format rejected, falling back to sw");
return nullptr;
}
}
if (shmBuffer.data())
texData = shmBuffer;
else
texData = {texture->m_vSize.x * 4 * texture->m_vSize.y, 0};
if (flipRB) {
for (size_t i = 0; i < shmBuffer.size(); i += 4) {
std::swap(shmBuffer.at(i), shmBuffer.at(i + 2)); // little-endian!!!!!!
}
}
} else {
Debug::log(TRACE, "Cannot use dumb copy on dmabuf cursor buffers");
return nullptr;

View file

@ -17,7 +17,7 @@ CTexture::~CTexture() {
destroyTexture();
}
CTexture::CTexture(uint32_t drmFormat, uint8_t* pixels, uint32_t stride, const Vector2D& size_, bool keepDataCopy) : m_bKeepDataCopy(keepDataCopy) {
CTexture::CTexture(uint32_t drmFormat, uint8_t* pixels, uint32_t stride, const Vector2D& size_, bool keepDataCopy) : m_iDrmFormat(drmFormat), m_bKeepDataCopy(keepDataCopy) {
createFromShm(drmFormat, pixels, stride, size_);
}
@ -44,6 +44,8 @@ CTexture::CTexture(const SP<Aquamarine::IBuffer> buffer, bool keepDataCopy) : m_
auto [pixelData, fmt, bufLen] = buffer->beginDataPtr(0);
m_iDrmFormat = fmt;
createFromShm(fmt, pixelData, bufLen, shm.size);
return;
}

View file

@ -43,6 +43,7 @@ class CTexture {
void* m_pEglImage = nullptr;
eTransform m_eTransform = HYPRUTILS_TRANSFORM_NORMAL;
bool m_bOpaque = false;
uint32_t m_iDrmFormat = DRM_FORMAT_INVALID; // for shm
private:
void createFromShm(uint32_t drmFormat, uint8_t* pixels, uint32_t stride, const Vector2D& size);