[mutter] cursor-renderer/native: Support allocating dumb buffers
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] cursor-renderer/native: Support allocating dumb buffers
- Date: Fri, 29 Apr 2022 20:22:27 +0000 (UTC)
commit 2cfd4f325b06605f547fce2da1080958ca147e68
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Tue Feb 8 15:38:37 2022 +0100
cursor-renderer/native: Support allocating dumb buffers
This makes it possible to allocate HW cursor without a gbm_device, e.g.
when using EGLStream/EGLDevice.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1980
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2275>
src/backends/native/meta-cursor-renderer-native.c | 91 +++++++++++++++++------
1 file changed, 68 insertions(+), 23 deletions(-)
---
diff --git a/src/backends/native/meta-cursor-renderer-native.c
b/src/backends/native/meta-cursor-renderer-native.c
index ce2ca706fd..96c54baf02 100644
--- a/src/backends/native/meta-cursor-renderer-native.c
+++ b/src/backends/native/meta-cursor-renderer-native.c
@@ -41,6 +41,7 @@
#include "backends/native/meta-backend-native-private.h"
#include "backends/native/meta-crtc-kms.h"
#include "backends/native/meta-device-pool.h"
+#include "backends/native/meta-drm-buffer-dumb.h"
#include "backends/native/meta-drm-buffer-gbm.h"
#include "backends/native/meta-kms-device.h"
#include "backends/native/meta-kms-plane.h"
@@ -1218,25 +1219,24 @@ ensure_cursor_priv (MetaCursorSprite *cursor_sprite)
}
static MetaDrmBuffer *
-create_cursor_drm_buffer_gbm (MetaGpuKms *gpu_kms,
- MetaDeviceFile *device_file,
- uint8_t *pixels,
- int width,
- int height,
- int stride,
- int cursor_width,
- int cursor_height,
- uint32_t format,
- GError **error)
+create_cursor_drm_buffer_gbm (MetaGpuKms *gpu_kms,
+ MetaDeviceFile *device_file,
+ struct gbm_device *gbm_device,
+ uint8_t *pixels,
+ int width,
+ int height,
+ int stride,
+ int cursor_width,
+ int cursor_height,
+ uint32_t format,
+ GError **error)
{
- struct gbm_device *gbm_device;
struct gbm_bo *bo;
uint8_t buf[4 * cursor_width * cursor_height];
int i;
MetaDrmBufferFlags flags;
MetaDrmBufferGbm *buffer_gbm;
- gbm_device = meta_gbm_device_from_gpu (gpu_kms);
if (!gbm_device_is_format_supported (gbm_device, format,
GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE))
{
@@ -1276,6 +1276,38 @@ create_cursor_drm_buffer_gbm (MetaGpuKms *gpu_kms,
return META_DRM_BUFFER (buffer_gbm);
}
+static MetaDrmBuffer *
+create_cursor_drm_buffer_dumb (MetaGpuKms *gpu_kms,
+ MetaDeviceFile *device_file,
+ uint8_t *pixels,
+ int width,
+ int height,
+ int stride,
+ int cursor_width,
+ int cursor_height,
+ uint32_t format,
+ GError **error)
+{
+ MetaDrmBufferDumb *buffer_dumb;
+ int i;
+ uint8_t *data;
+
+ buffer_dumb = meta_drm_buffer_dumb_new (device_file,
+ cursor_width, cursor_height,
+ format,
+ error);
+ if (!buffer_dumb)
+ return NULL;
+
+ data = meta_drm_buffer_dumb_get_data (buffer_dumb);
+
+ memset (data, 0, cursor_width * cursor_height * 4);
+ for (i = 0; i < height; i++)
+ memcpy (data + i * 4 * cursor_width, pixels + i * stride, width * 4);
+
+ return META_DRM_BUFFER (buffer_dumb);
+}
+
static MetaDrmBuffer *
create_cursor_drm_buffer (MetaGpuKms *gpu_kms,
MetaDeviceFile *device_file,
@@ -1288,12 +1320,27 @@ create_cursor_drm_buffer (MetaGpuKms *gpu_kms,
uint32_t format,
GError **error)
{
- return create_cursor_drm_buffer_gbm (gpu_kms, device_file,
- pixels,
- width, height, stride,
- cursor_width, cursor_height,
- format,
- error);
+ struct gbm_device *gbm_device;
+
+ gbm_device = meta_gbm_device_from_gpu (gpu_kms);
+ if (gbm_device)
+ {
+ return create_cursor_drm_buffer_gbm (gpu_kms, device_file, gbm_device,
+ pixels,
+ width, height, stride,
+ cursor_width, cursor_height,
+ format,
+ error);
+ }
+ else
+ {
+ return create_cursor_drm_buffer_dumb (gpu_kms, device_file,
+ pixels,
+ width, height, stride,
+ cursor_width, cursor_height,
+ format,
+ error);
+ }
}
static void
@@ -1671,6 +1718,9 @@ realize_cursor_sprite_from_wl_buffer_for_gpu (MetaCursorRenderer *renderer,
}
gbm_device = meta_gbm_device_from_gpu (gpu_kms);
+ if (!gbm_device)
+ return;
+
bo = gbm_bo_import (gbm_device,
GBM_BO_IMPORT_WL_BUFFER,
buffer,
@@ -1851,13 +1901,8 @@ init_hw_cursor_support_for_gpu (MetaGpuKms *gpu_kms)
{
MetaKmsDevice *kms_device = meta_gpu_kms_get_kms_device (gpu_kms);
MetaCursorRendererNativeGpuData *cursor_renderer_gpu_data;
- struct gbm_device *gbm_device;
uint64_t width, height;
- gbm_device = meta_gbm_device_from_gpu (gpu_kms);
- if (!gbm_device)
- return;
-
cursor_renderer_gpu_data =
meta_create_cursor_renderer_native_gpu_data (gpu_kms);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]