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,
|
priv->shadow.dma_buf.handles[0] = cogl_renderer_create_dma_buf (cogl_renderer,
|
||||||
|
COGL_PIXEL_FORMAT_BGRX_8888,
|
||||||
width, height,
|
width, height,
|
||||||
error);
|
error);
|
||||||
if (!priv->shadow.dma_buf.handles[0])
|
if (!priv->shadow.dma_buf.handles[0])
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
priv->shadow.dma_buf.handles[1] = cogl_renderer_create_dma_buf (cogl_renderer,
|
priv->shadow.dma_buf.handles[1] = cogl_renderer_create_dma_buf (cogl_renderer,
|
||||||
|
COGL_PIXEL_FORMAT_BGRX_8888,
|
||||||
width, height,
|
width, height,
|
||||||
error);
|
error);
|
||||||
if (!priv->shadow.dma_buf.handles[1])
|
if (!priv->shadow.dma_buf.handles[1])
|
||||||
|
@ -747,6 +747,7 @@ cogl_renderer_foreach_output (CoglRenderer *renderer,
|
|||||||
|
|
||||||
CoglDmaBufHandle *
|
CoglDmaBufHandle *
|
||||||
cogl_renderer_create_dma_buf (CoglRenderer *renderer,
|
cogl_renderer_create_dma_buf (CoglRenderer *renderer,
|
||||||
|
CoglPixelFormat format,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
GError **error)
|
GError **error)
|
||||||
@ -754,7 +755,9 @@ cogl_renderer_create_dma_buf (CoglRenderer *renderer,
|
|||||||
const CoglWinsysVtable *winsys = _cogl_renderer_get_winsys (renderer);
|
const CoglWinsysVtable *winsys = _cogl_renderer_get_winsys (renderer);
|
||||||
|
|
||||||
if (winsys->renderer_create_dma_buf)
|
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,
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||||
"CoglRenderer doesn't support creating DMA buffers");
|
"CoglRenderer doesn't support creating DMA buffers");
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include "cogl/cogl-types.h"
|
#include "cogl/cogl-types.h"
|
||||||
#include "cogl/cogl-onscreen-template.h"
|
#include "cogl/cogl-onscreen-template.h"
|
||||||
#include "cogl/cogl-output.h"
|
#include "cogl/cogl-output.h"
|
||||||
|
#include "cogl/cogl-pixel-format.h"
|
||||||
|
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
|
|
||||||
@ -365,12 +366,13 @@ cogl_renderer_foreach_output (CoglRenderer *renderer,
|
|||||||
/**
|
/**
|
||||||
* cogl_renderer_create_dma_buf: (skip)
|
* cogl_renderer_create_dma_buf: (skip)
|
||||||
* @renderer: A #CoglRenderer
|
* @renderer: A #CoglRenderer
|
||||||
|
* @format: A #CoglPixelFormat
|
||||||
* @width: width of the new
|
* @width: width of the new
|
||||||
* @height: height of the new
|
* @height: height of the new
|
||||||
* @error: (nullable): return location for a #GError
|
* @error: (nullable): return location for a #GError
|
||||||
*
|
*
|
||||||
* Creates a new #CoglFramebuffer with @width x @height, and format
|
* Creates a new #CoglFramebuffer with @width x @height, with pixel
|
||||||
* hardcoded to XRGB, and exports the new framebuffer's DMA buffer
|
* format @format, and exports the new framebuffer's DMA buffer
|
||||||
* handle.
|
* handle.
|
||||||
*
|
*
|
||||||
* Returns: (nullable)(transfer full): a #CoglDmaBufHandle. The
|
* Returns: (nullable)(transfer full): a #CoglDmaBufHandle. The
|
||||||
@ -379,6 +381,7 @@ cogl_renderer_foreach_output (CoglRenderer *renderer,
|
|||||||
*/
|
*/
|
||||||
COGL_EXPORT CoglDmaBufHandle *
|
COGL_EXPORT CoglDmaBufHandle *
|
||||||
cogl_renderer_create_dma_buf (CoglRenderer *renderer,
|
cogl_renderer_create_dma_buf (CoglRenderer *renderer,
|
||||||
|
CoglPixelFormat format,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
@ -94,6 +94,7 @@ typedef struct _CoglWinsysVtable
|
|||||||
|
|
||||||
CoglDmaBufHandle *
|
CoglDmaBufHandle *
|
||||||
(*renderer_create_dma_buf) (CoglRenderer *renderer,
|
(*renderer_create_dma_buf) (CoglRenderer *renderer,
|
||||||
|
CoglPixelFormat format,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
@ -79,6 +79,7 @@ meta_screen_cast_create_dma_buf_handle (MetaScreenCast *screen_cast,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
dmabuf_handle = cogl_renderer_create_dma_buf (cogl_renderer,
|
dmabuf_handle = cogl_renderer_create_dma_buf (cogl_renderer,
|
||||||
|
COGL_PIXEL_FORMAT_BGRX_8888,
|
||||||
width, height,
|
width, height,
|
||||||
&error);
|
&error);
|
||||||
if (!dmabuf_handle)
|
if (!dmabuf_handle)
|
||||||
|
@ -183,6 +183,7 @@ maybe_disable_screen_cast_dma_bufs (MetaBackendNative *native)
|
|||||||
}
|
}
|
||||||
|
|
||||||
dmabuf_handle = cogl_renderer_create_dma_buf (cogl_renderer,
|
dmabuf_handle = cogl_renderer_create_dma_buf (cogl_renderer,
|
||||||
|
COGL_PIXEL_FORMAT_BGRX_8888,
|
||||||
1, 1,
|
1, 1,
|
||||||
&error);
|
&error);
|
||||||
if (!dmabuf_handle)
|
if (!dmabuf_handle)
|
||||||
|
@ -930,6 +930,7 @@ unset_disabled_crtcs (MetaRendererNative *renderer_native)
|
|||||||
|
|
||||||
static CoglDmaBufHandle *
|
static CoglDmaBufHandle *
|
||||||
meta_renderer_native_create_dma_buf (CoglRenderer *cogl_renderer,
|
meta_renderer_native_create_dma_buf (CoglRenderer *cogl_renderer,
|
||||||
|
CoglPixelFormat format,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
GError **error)
|
GError **error)
|
||||||
@ -954,6 +955,13 @@ meta_renderer_native_create_dma_buf (CoglRenderer *cogl_renderer,
|
|||||||
CoglFramebuffer *dmabuf_fb;
|
CoglFramebuffer *dmabuf_fb;
|
||||||
CoglDmaBufHandle *dmabuf_handle;
|
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;
|
render_device = renderer_gpu_data->render_device;
|
||||||
flags = META_DRM_BUFFER_FLAG_NONE;
|
flags = META_DRM_BUFFER_FLAG_NONE;
|
||||||
|
Loading…
Reference in New Issue
Block a user