cogl/renderer: Pass pixel format to DMA-BUF constructor
In future commits, we will want to create DMA-BUFs with pixel formats other than COGL_PIXEL_FORMAT_BGRX_8888. In preparation for that, let's start passing a new pixel format parameter to this function, and the corresponding winsys vfunc. All callers of this function pass COGL_PIXEL_FORMAT_BGRX_8888 for now. Next commits will change that. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3175>
This commit is contained in:
parent
14ed29e7b2
commit
fdc3f3fec3
@ -351,12 +351,14 @@ init_dma_buf_shadowfbs (ClutterStageView *view,
|
||||
}
|
||||
|
||||
priv->shadow.dma_buf.handles[0] = cogl_renderer_create_dma_buf (cogl_renderer,
|
||||
COGL_PIXEL_FORMAT_BGRX_8888,
|
||||
width, height,
|
||||
error);
|
||||
if (!priv->shadow.dma_buf.handles[0])
|
||||
return FALSE;
|
||||
|
||||
priv->shadow.dma_buf.handles[1] = cogl_renderer_create_dma_buf (cogl_renderer,
|
||||
COGL_PIXEL_FORMAT_BGRX_8888,
|
||||
width, height,
|
||||
error);
|
||||
if (!priv->shadow.dma_buf.handles[1])
|
||||
|
@ -746,15 +746,18 @@ cogl_renderer_foreach_output (CoglRenderer *renderer,
|
||||
}
|
||||
|
||||
CoglDmaBufHandle *
|
||||
cogl_renderer_create_dma_buf (CoglRenderer *renderer,
|
||||
int width,
|
||||
int height,
|
||||
GError **error)
|
||||
cogl_renderer_create_dma_buf (CoglRenderer *renderer,
|
||||
CoglPixelFormat format,
|
||||
int width,
|
||||
int height,
|
||||
GError **error)
|
||||
{
|
||||
const CoglWinsysVtable *winsys = _cogl_renderer_get_winsys (renderer);
|
||||
|
||||
if (winsys->renderer_create_dma_buf)
|
||||
return winsys->renderer_create_dma_buf (renderer, width, height, error);
|
||||
return winsys->renderer_create_dma_buf (renderer, format,
|
||||
width, height,
|
||||
error);
|
||||
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
"CoglRenderer doesn't support creating DMA buffers");
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "cogl/cogl-types.h"
|
||||
#include "cogl/cogl-onscreen-template.h"
|
||||
#include "cogl/cogl-output.h"
|
||||
#include "cogl/cogl-pixel-format.h"
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
@ -365,12 +366,13 @@ cogl_renderer_foreach_output (CoglRenderer *renderer,
|
||||
/**
|
||||
* cogl_renderer_create_dma_buf: (skip)
|
||||
* @renderer: A #CoglRenderer
|
||||
* @format: A #CoglPixelFormat
|
||||
* @width: width of the new
|
||||
* @height: height of the new
|
||||
* @error: (nullable): return location for a #GError
|
||||
*
|
||||
* Creates a new #CoglFramebuffer with @width x @height, and format
|
||||
* hardcoded to XRGB, and exports the new framebuffer's DMA buffer
|
||||
* Creates a new #CoglFramebuffer with @width x @height, with pixel
|
||||
* format @format, and exports the new framebuffer's DMA buffer
|
||||
* handle.
|
||||
*
|
||||
* Returns: (nullable)(transfer full): a #CoglDmaBufHandle. The
|
||||
@ -378,10 +380,11 @@ cogl_renderer_foreach_output (CoglRenderer *renderer,
|
||||
* after use.
|
||||
*/
|
||||
COGL_EXPORT CoglDmaBufHandle *
|
||||
cogl_renderer_create_dma_buf (CoglRenderer *renderer,
|
||||
int width,
|
||||
int height,
|
||||
GError **error);
|
||||
cogl_renderer_create_dma_buf (CoglRenderer *renderer,
|
||||
CoglPixelFormat format,
|
||||
int width,
|
||||
int height,
|
||||
GError **error);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -93,10 +93,11 @@ typedef struct _CoglWinsysVtable
|
||||
(*display_destroy) (CoglDisplay *display);
|
||||
|
||||
CoglDmaBufHandle *
|
||||
(*renderer_create_dma_buf) (CoglRenderer *renderer,
|
||||
int width,
|
||||
int height,
|
||||
GError **error);
|
||||
(*renderer_create_dma_buf) (CoglRenderer *renderer,
|
||||
CoglPixelFormat format,
|
||||
int width,
|
||||
int height,
|
||||
GError **error);
|
||||
|
||||
gboolean
|
||||
(*renderer_is_dma_buf_supported) (CoglRenderer *renderer);
|
||||
|
@ -79,6 +79,7 @@ meta_screen_cast_create_dma_buf_handle (MetaScreenCast *screen_cast,
|
||||
return NULL;
|
||||
|
||||
dmabuf_handle = cogl_renderer_create_dma_buf (cogl_renderer,
|
||||
COGL_PIXEL_FORMAT_BGRX_8888,
|
||||
width, height,
|
||||
&error);
|
||||
if (!dmabuf_handle)
|
||||
|
@ -183,6 +183,7 @@ maybe_disable_screen_cast_dma_bufs (MetaBackendNative *native)
|
||||
}
|
||||
|
||||
dmabuf_handle = cogl_renderer_create_dma_buf (cogl_renderer,
|
||||
COGL_PIXEL_FORMAT_BGRX_8888,
|
||||
1, 1,
|
||||
&error);
|
||||
if (!dmabuf_handle)
|
||||
|
@ -929,10 +929,11 @@ unset_disabled_crtcs (MetaRendererNative *renderer_native)
|
||||
}
|
||||
|
||||
static CoglDmaBufHandle *
|
||||
meta_renderer_native_create_dma_buf (CoglRenderer *cogl_renderer,
|
||||
int width,
|
||||
int height,
|
||||
GError **error)
|
||||
meta_renderer_native_create_dma_buf (CoglRenderer *cogl_renderer,
|
||||
CoglPixelFormat format,
|
||||
int width,
|
||||
int height,
|
||||
GError **error)
|
||||
{
|
||||
CoglRendererEGL *cogl_renderer_egl = cogl_renderer->winsys;
|
||||
MetaRendererNativeGpuData *renderer_gpu_data = cogl_renderer_egl->platform;
|
||||
@ -954,6 +955,13 @@ meta_renderer_native_create_dma_buf (CoglRenderer *cogl_renderer,
|
||||
CoglFramebuffer *dmabuf_fb;
|
||||
CoglDmaBufHandle *dmabuf_handle;
|
||||
|
||||
if (format != COGL_PIXEL_FORMAT_BGRX_8888)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
"Native renderer doesn't support creating DMA buffer with format %s",
|
||||
cogl_pixel_format_to_string (format));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
render_device = renderer_gpu_data->render_device;
|
||||
flags = META_DRM_BUFFER_FLAG_NONE;
|
||||
|
Loading…
Reference in New Issue
Block a user