Use DRM_CAP_CURSOR_{WIDTH,HEIGTH} for cursor buffer
Hardware often has cursor plane limitations for the buffer size. Co-authored-by: Simon Ser <contact@emersion.fr>
This commit is contained in:
parent
85ba5c6fe9
commit
ceeef3567d
3 changed files with 21 additions and 5 deletions
|
@ -396,6 +396,13 @@ int init_drm(struct drm_t *drm, const char *device, const char *mode_str, unsign
|
|||
|
||||
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);
|
||||
|
||||
|
|
|
@ -51,6 +51,8 @@ struct fb {
|
|||
struct drm_t {
|
||||
int fd;
|
||||
|
||||
uint64_t cursor_width, cursor_height;
|
||||
|
||||
/* only used for atomic: */
|
||||
struct plane *plane;
|
||||
struct crtc *crtc;
|
||||
|
|
|
@ -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,14 +841,16 @@ 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 ) {
|
||||
if ( cursorDataBuffer[i * m_width + j] & 0x000000ff ) {
|
||||
bNoCursor = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bNoCursor != m_imageEmpty) {
|
||||
m_imageEmpty = bNoCursor;
|
||||
|
|
Loading…
Reference in a new issue