renderer/native: Look up prefers-shadow cap via MetaKmsDevice

This eliminates the second last user of drmGetCap() from outside of
MetaKmsImplDevice.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
This commit is contained in:
Jonas Ådahl 2021-03-29 11:48:59 +02:00
parent 93f9c99cc5
commit 86c4369f41
5 changed files with 21 additions and 20 deletions

View File

@ -121,6 +121,12 @@ meta_kms_device_get_cursor_size (MetaKmsDevice *device,
}
}
gboolean
meta_kms_device_prefers_shadow_buffer (MetaKmsDevice *device)
{
return device->caps.prefers_shadow_buffer;
}
GList *
meta_kms_device_get_connectors (MetaKmsDevice *device)
{

View File

@ -45,6 +45,8 @@ gboolean meta_kms_device_get_cursor_size (MetaKmsDevice *device,
uint64_t *out_cursor_width,
uint64_t *out_cursor_height);
gboolean meta_kms_device_prefers_shadow_buffer (MetaKmsDevice *device);
GList * meta_kms_device_get_connectors (MetaKmsDevice *device);
GList * meta_kms_device_get_crtcs (MetaKmsDevice *device);

View File

@ -300,6 +300,7 @@ init_caps (MetaKmsImplDevice *impl_device)
meta_kms_impl_device_get_instance_private (impl_device);
int fd;
uint64_t cursor_width, cursor_height;
uint64_t prefer_shadow;
fd = meta_device_file_get_fd (priv->device_file);
if (drmGetCap (fd, DRM_CAP_CURSOR_WIDTH, &cursor_width) == 0 &&
@ -309,6 +310,14 @@ init_caps (MetaKmsImplDevice *impl_device)
priv->caps.cursor_width = cursor_width;
priv->caps.cursor_height = cursor_height;
}
if (drmGetCap (fd, DRM_CAP_DUMB_PREFER_SHADOW, &prefer_shadow) == 0)
{
if (prefer_shadow)
g_message ("Device '%s' prefers shadow buffer", priv->path);
priv->caps.prefers_shadow_buffer = prefer_shadow;
}
}
static void

View File

@ -37,6 +37,8 @@ typedef struct _MetaKmsDeviceCaps
gboolean has_cursor_size;
uint64_t cursor_width;
uint64_t cursor_height;
gboolean prefers_shadow_buffer;
} MetaKmsDeviceCaps;
typedef struct _MetaKmsProp MetaKmsProp;

View File

@ -978,8 +978,7 @@ should_force_shadow_fb (MetaRendererNative *renderer_native,
MetaRenderer *renderer = META_RENDERER (renderer_native);
CoglContext *cogl_context =
cogl_context_from_renderer_native (renderer_native);
int kms_fd;
uint64_t prefer_shadow = 0;
MetaKmsDevice *kms_device = meta_gpu_kms_get_kms_device (primary_gpu);
if (meta_renderer_is_hardware_accelerated (renderer))
return FALSE;
@ -987,24 +986,7 @@ should_force_shadow_fb (MetaRendererNative *renderer_native,
if (!cogl_has_feature (cogl_context, COGL_FEATURE_ID_BLIT_FRAMEBUFFER))
return FALSE;
kms_fd = meta_gpu_kms_get_fd (primary_gpu);
if (drmGetCap (kms_fd, DRM_CAP_DUMB_PREFER_SHADOW, &prefer_shadow) == 0)
{
if (prefer_shadow)
{
static gboolean logged_once = FALSE;
if (!logged_once)
{
g_message ("Forcing shadow framebuffer");
logged_once = TRUE;
}
return TRUE;
}
}
return FALSE;
return meta_kms_device_prefers_shadow_buffer (kms_device);
}
static CoglFramebuffer *