From ceeef3567d90798335ca6038258a86704d71878a Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Wed, 2 Dec 2020 15:40:04 +0100 Subject: [PATCH] Use DRM_CAP_CURSOR_{WIDTH,HEIGTH} for cursor buffer Hardware often has cursor plane limitations for the buffer size. Co-authored-by: Simon Ser --- src/drm.cpp | 7 +++++++ src/drm.hpp | 2 ++ src/steamcompmgr.cpp | 17 ++++++++++++----- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/drm.cpp b/src/drm.cpp index 0b6f32b..c24f828 100644 --- a/src/drm.cpp +++ b/src/drm.cpp @@ -395,6 +395,13 @@ int init_drm(struct drm_t *drm, const char *device, const char *mode_str, unsign drmModeFreeResources(resources); drm->connector_id = connector->connector_id; + + if (drmGetCap(drm->fd, DRM_CAP_CURSOR_WIDTH, &drm->cursor_width) != 0) { + drm->cursor_width = 64; + } + if (drmGetCap(drm->fd, DRM_CAP_CURSOR_HEIGHT, &drm->cursor_height) != 0) { + drm->cursor_height = 64; + } drmSetClientCap(drm->fd, DRM_CLIENT_CAP_ATOMIC, 1); drmSetClientCap(drm->fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1); diff --git a/src/drm.hpp b/src/drm.hpp index b9e12c1..7c3c22d 100644 --- a/src/drm.hpp +++ b/src/drm.hpp @@ -50,6 +50,8 @@ struct fb { struct drm_t { int fd; + + uint64_t cursor_width, cursor_height; /* only used for atomic: */ struct plane *plane; diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp index d7878c0..4976815 100644 --- a/src/steamcompmgr.cpp +++ b/src/steamcompmgr.cpp @@ -827,6 +827,11 @@ bool MouseCursor::getTexture() m_width = image->width; m_height = image->height; + if ( BIsNested() == false && alwaysComposite == False ) + { + m_width = g_DRM.cursor_width; + m_height = g_DRM.cursor_height; + } if (m_texture) { vulkan_free_texture(m_texture); @@ -836,12 +841,14 @@ bool MouseCursor::getTexture() // Assume the cursor is fully translucent unless proven otherwise. bool bNoCursor = true; - unsigned int cursorDataBuffer[m_width * m_height]; - for (int i = 0; i < m_width * m_height; i++) { - cursorDataBuffer[i] = image->pixels[i]; + uint32_t cursorDataBuffer[m_width * m_height] = {0}; + for (int i = 0; i < image->height; i++) { + for (int j = 0; j < image->width; j++) { + cursorDataBuffer[i * m_width + j] = image->pixels[i * image->width + j]; - if ( cursorDataBuffer[i] & 0x000000ff ) { - bNoCursor = false; + if ( cursorDataBuffer[i * m_width + j] & 0x000000ff ) { + bNoCursor = false; + } } }