mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 09:30:45 -05:00
cogl/scanout: Add API for source/destination rectangles
These will get passed on to KMS later. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3177>
This commit is contained in:
parent
52c4b85161
commit
912cd80f10
@ -45,6 +45,11 @@ struct _CoglScanout
|
|||||||
GObject parent;
|
GObject parent;
|
||||||
|
|
||||||
CoglScanoutBuffer *scanout_buffer;
|
CoglScanoutBuffer *scanout_buffer;
|
||||||
|
|
||||||
|
gboolean has_src_rect;
|
||||||
|
graphene_rect_t src_rect;
|
||||||
|
gboolean has_dst_rect;
|
||||||
|
MtkRectangle dst_rect;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_FINAL_TYPE (CoglScanout, cogl_scanout, G_TYPE_OBJECT);
|
G_DEFINE_FINAL_TYPE (CoglScanout, cogl_scanout, G_TYPE_OBJECT);
|
||||||
@ -67,6 +72,24 @@ cogl_scanout_blit_to_framebuffer (CoglScanout *scanout,
|
|||||||
return iface->blit_to_framebuffer (scanout, framebuffer, x, y, error);
|
return iface->blit_to_framebuffer (scanout, framebuffer, x, y, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
cogl_scanout_buffer_get_width (CoglScanoutBuffer *scanout_buffer)
|
||||||
|
{
|
||||||
|
CoglScanoutBufferInterface *iface =
|
||||||
|
COGL_SCANOUT_BUFFER_GET_IFACE (scanout_buffer);
|
||||||
|
|
||||||
|
return iface->get_width (scanout_buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
cogl_scanout_buffer_get_height (CoglScanoutBuffer *scanout_buffer)
|
||||||
|
{
|
||||||
|
CoglScanoutBufferInterface *iface =
|
||||||
|
COGL_SCANOUT_BUFFER_GET_IFACE (scanout_buffer);
|
||||||
|
|
||||||
|
return iface->get_height (scanout_buffer);
|
||||||
|
}
|
||||||
|
|
||||||
CoglScanoutBuffer *
|
CoglScanoutBuffer *
|
||||||
cogl_scanout_get_buffer (CoglScanout *scanout)
|
cogl_scanout_get_buffer (CoglScanout *scanout)
|
||||||
{
|
{
|
||||||
@ -90,6 +113,58 @@ cogl_scanout_new (CoglScanoutBuffer *scanout_buffer)
|
|||||||
return scanout;
|
return scanout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_scanout_get_src_rect (CoglScanout *scanout,
|
||||||
|
graphene_rect_t *rect)
|
||||||
|
{
|
||||||
|
if (scanout->has_src_rect)
|
||||||
|
{
|
||||||
|
*rect = scanout->src_rect;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
rect->origin.x = 0;
|
||||||
|
rect->origin.y = 0;
|
||||||
|
rect->size.width = cogl_scanout_buffer_get_width (scanout->scanout_buffer);
|
||||||
|
rect->size.height = cogl_scanout_buffer_get_height (scanout->scanout_buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_scanout_set_src_rect (CoglScanout *scanout,
|
||||||
|
const graphene_rect_t *rect)
|
||||||
|
{
|
||||||
|
if (rect != NULL)
|
||||||
|
scanout->src_rect = *rect;
|
||||||
|
|
||||||
|
scanout->has_src_rect = rect != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_scanout_get_dst_rect (CoglScanout *scanout,
|
||||||
|
MtkRectangle *rect)
|
||||||
|
{
|
||||||
|
if (scanout->has_dst_rect)
|
||||||
|
{
|
||||||
|
*rect = scanout->dst_rect;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
rect->x = 0;
|
||||||
|
rect->y = 0;
|
||||||
|
rect->width = cogl_scanout_buffer_get_width (scanout->scanout_buffer);
|
||||||
|
rect->height = cogl_scanout_buffer_get_height (scanout->scanout_buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_scanout_set_dst_rect (CoglScanout *scanout,
|
||||||
|
const MtkRectangle *rect)
|
||||||
|
{
|
||||||
|
if (rect != NULL)
|
||||||
|
scanout->dst_rect = *rect;
|
||||||
|
|
||||||
|
scanout->has_dst_rect = rect != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cogl_scanout_finalize (GObject *object)
|
cogl_scanout_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include "cogl/cogl-types.h"
|
#include "cogl/cogl-types.h"
|
||||||
#include "cogl/cogl-framebuffer.h"
|
#include "cogl/cogl-framebuffer.h"
|
||||||
#include "cogl/cogl-onscreen.h"
|
#include "cogl/cogl-onscreen.h"
|
||||||
|
#include "mtk/mtk.h"
|
||||||
|
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
|
|
||||||
@ -52,6 +53,9 @@ struct _CoglScanoutBufferInterface
|
|||||||
int x,
|
int x,
|
||||||
int y,
|
int y,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
int (*get_width) (CoglScanoutBuffer *scanout_buffer);
|
||||||
|
int (*get_height) (CoglScanoutBuffer *scanout_buffer);
|
||||||
};
|
};
|
||||||
|
|
||||||
COGL_EXPORT
|
COGL_EXPORT
|
||||||
@ -61,6 +65,9 @@ gboolean cogl_scanout_blit_to_framebuffer (CoglScanout *scanout,
|
|||||||
int y,
|
int y,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
int cogl_scanout_buffer_get_width (CoglScanoutBuffer *scanout_buffer);
|
||||||
|
int cogl_scanout_buffer_get_height (CoglScanoutBuffer *scanout_buffer);
|
||||||
|
|
||||||
COGL_EXPORT
|
COGL_EXPORT
|
||||||
CoglScanoutBuffer * cogl_scanout_get_buffer (CoglScanout *scanout);
|
CoglScanoutBuffer * cogl_scanout_get_buffer (CoglScanout *scanout);
|
||||||
|
|
||||||
@ -70,3 +77,19 @@ void cogl_scanout_notify_failed (CoglScanout *scanout,
|
|||||||
|
|
||||||
COGL_EXPORT
|
COGL_EXPORT
|
||||||
CoglScanout * cogl_scanout_new (CoglScanoutBuffer *scanout_buffer);
|
CoglScanout * cogl_scanout_new (CoglScanoutBuffer *scanout_buffer);
|
||||||
|
|
||||||
|
COGL_EXPORT
|
||||||
|
void cogl_scanout_get_src_rect (CoglScanout *scanout,
|
||||||
|
graphene_rect_t *rect);
|
||||||
|
|
||||||
|
COGL_EXPORT
|
||||||
|
void cogl_scanout_set_src_rect (CoglScanout *scanout,
|
||||||
|
const graphene_rect_t *rect);
|
||||||
|
|
||||||
|
COGL_EXPORT
|
||||||
|
void cogl_scanout_get_dst_rect (CoglScanout *scanout,
|
||||||
|
MtkRectangle *rect);
|
||||||
|
|
||||||
|
COGL_EXPORT
|
||||||
|
void cogl_scanout_set_dst_rect (CoglScanout *scanout,
|
||||||
|
const MtkRectangle *rect);
|
||||||
|
@ -357,10 +357,28 @@ out:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
meta_drm_buffer_gbm_scanout_get_width (CoglScanoutBuffer *scanout_buffer)
|
||||||
|
{
|
||||||
|
MetaDrmBuffer *buffer = META_DRM_BUFFER (scanout_buffer);
|
||||||
|
|
||||||
|
return meta_drm_buffer_get_width (buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
meta_drm_buffer_gbm_scanout_get_height (CoglScanoutBuffer *scanout_buffer)
|
||||||
|
{
|
||||||
|
MetaDrmBuffer *buffer = META_DRM_BUFFER (scanout_buffer);
|
||||||
|
|
||||||
|
return meta_drm_buffer_get_height (buffer);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cogl_scanout_buffer_iface_init (CoglScanoutBufferInterface *iface)
|
cogl_scanout_buffer_iface_init (CoglScanoutBufferInterface *iface)
|
||||||
{
|
{
|
||||||
iface->blit_to_framebuffer = meta_drm_buffer_gbm_blit_to_framebuffer;
|
iface->blit_to_framebuffer = meta_drm_buffer_gbm_blit_to_framebuffer;
|
||||||
|
iface->get_width = meta_drm_buffer_gbm_scanout_get_width;
|
||||||
|
iface->get_height = meta_drm_buffer_gbm_scanout_get_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user