mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-15 07:46:01 +01:00
e
This commit is contained in:
parent
bf6d425bba
commit
66880afcb4
3 changed files with 23 additions and 1 deletions
|
@ -445,10 +445,29 @@ SP<Aquamarine::IBuffer> CPointerManager::renderHWCursorBuffer(SP<CPointerManager
|
||||||
const auto SURFACE = currentCursorImage.surface->resource();
|
const auto SURFACE = currentCursorImage.surface->resource();
|
||||||
auto& shmBuffer = CCursorSurfaceRole::cursorPixelData(SURFACE);
|
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())
|
if (shmBuffer.data())
|
||||||
texData = shmBuffer;
|
texData = shmBuffer;
|
||||||
else
|
else
|
||||||
texData = {texture->m_vSize.x * 4 * texture->m_vSize.y, 0};
|
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 {
|
} else {
|
||||||
Debug::log(TRACE, "Cannot use dumb copy on dmabuf cursor buffers");
|
Debug::log(TRACE, "Cannot use dumb copy on dmabuf cursor buffers");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -17,7 +17,7 @@ CTexture::~CTexture() {
|
||||||
destroyTexture();
|
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_);
|
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);
|
auto [pixelData, fmt, bufLen] = buffer->beginDataPtr(0);
|
||||||
|
|
||||||
|
m_iDrmFormat = fmt;
|
||||||
|
|
||||||
createFromShm(fmt, pixelData, bufLen, shm.size);
|
createFromShm(fmt, pixelData, bufLen, shm.size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ class CTexture {
|
||||||
void* m_pEglImage = nullptr;
|
void* m_pEglImage = nullptr;
|
||||||
eTransform m_eTransform = HYPRUTILS_TRANSFORM_NORMAL;
|
eTransform m_eTransform = HYPRUTILS_TRANSFORM_NORMAL;
|
||||||
bool m_bOpaque = false;
|
bool m_bOpaque = false;
|
||||||
|
uint32_t m_iDrmFormat = DRM_FORMAT_INVALID; // for shm
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createFromShm(uint32_t drmFormat, uint8_t* pixels, uint32_t stride, const Vector2D& size);
|
void createFromShm(uint32_t drmFormat, uint8_t* pixels, uint32_t stride, const Vector2D& size);
|
||||||
|
|
Loading…
Reference in a new issue