aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorVaxry <[email protected]>2024-11-11 15:44:41 +0000
committerMihai Fufezan <[email protected]>2024-11-14 12:59:23 +0200
commit66880afcb473a02d3bc63338eb48edc9eb9d3935 (patch)
tree5cba67c149f4e9346072eb3e0ff11bbe9f8ca903
parentbf6d425bba3bc96432883db75038b027f25ddf93 (diff)
downloadHyprland-66880afcb473a02d3bc63338eb48edc9eb9d3935.tar.gz
Hyprland-66880afcb473a02d3bc63338eb48edc9eb9d3935.zip
e
-rw-r--r--src/managers/PointerManager.cpp19
-rw-r--r--src/render/Texture.cpp4
-rw-r--r--src/render/Texture.hpp1
3 files changed, 23 insertions, 1 deletions
diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp
index d6189acd..e6bebdfd 100644
--- a/src/managers/PointerManager.cpp
+++ b/src/managers/PointerManager.cpp
@@ -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;
diff --git a/src/render/Texture.cpp b/src/render/Texture.cpp
index 4231dc17..633f0212 100644
--- a/src/render/Texture.cpp
+++ b/src/render/Texture.cpp
@@ -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;
}
diff --git a/src/render/Texture.hpp b/src/render/Texture.hpp
index 8b98e2a0..f814e06b 100644
--- a/src/render/Texture.hpp
+++ b/src/render/Texture.hpp
@@ -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);