add new operation do_blit in DrmDriverOps; use do_blit instead of returning callback of check_blit

This commit is contained in:
Vincent Wei
2023-07-24 08:22:10 +08:00
parent d52aa4c1a4
commit f6bf02aa5c
3 changed files with 18 additions and 20 deletions
+12 -6
View File
@@ -177,10 +177,6 @@ typedef struct _DrmBlitOperations {
uint8_t alpha;
} DrmBlitOperations;
typedef int (*CB_DRM_BLIT) (DrmDriver *driver,
DrmSurfaceBuffer *src_buf, const GAL_Rect *src_rc,
DrmSurfaceBuffer *dst_buf, const GAL_Rect *dst_rc,
const DrmBlitOperations *blit_ops);
/**
* The structure type defines the operations for a userland DRM driver.
*/
@@ -302,16 +298,26 @@ typedef struct _DrmDriverOps {
/**
* This operation checks whether a specified hardware accelerated blit
* can be done between the source buffer and the destination buffer.
* If succeed, it returns a callback for the specified blit operations.
* If succeed, it returns zero, otherwise for failure.
* If succeed, it is safe to call do_blit operation.
*
* \note If this operation is set as NULL, it will be supposed that
* the driver does not support any hardware accelerated blitting operation.
*/
CB_DRM_BLIT (* check_blit) (DrmDriver *driver,
int (* check_blit) (DrmDriver *driver,
DrmSurfaceBuffer* src_buf, const GAL_Rect* src_rc,
DrmSurfaceBuffer* dst_buf, const GAL_Rect* dst_rc,
const DrmBlitOperations *ops);
/**
* This operation does the real blit. It should not be NULL if check_blit
* is not NULL.
*/
int (* do_blit) (DrmDriver *driver,
DrmSurfaceBuffer *src_buf, const GAL_Rect *src_rc,
DrmSurfaceBuffer *dst_buf, const GAL_Rect *dst_rc,
const DrmBlitOperations *blit_ops);
/**
* This operation copies the pixels from the source buffer to
* the destination buffer, with or without scaling, rotation, and flip.
+1 -5
View File
@@ -83,11 +83,7 @@ typedef struct GAL_BlitMap {
GAL_VideoDevice *video;
/* data for hardware blittor */
union {
struct private_hwaccel *hw_data;
void *hw_void;
};
struct private_hwaccel *hw_data;
/* data for software blittor */
struct private_swaccel *sw_data;
+5 -9
View File
@@ -3517,8 +3517,7 @@ static int DRM_HWBlit(_THIS, GAL_Surface *src, GAL_Rect *src_rc,
src_buf = (DrmSurfaceBuffer*)src->hwdata;
dst_buf = (DrmSurfaceBuffer*)dst->hwdata;
CB_DRM_BLIT blitor = src->map->hw_void;
assert(blitor);
assert(vdata->driver_ops->do_blit);
DrmBlitOperations blit_ops = { };
blit_ops.cpy = BLIT_COPY_TRANSLATE;
@@ -3539,7 +3538,8 @@ static int DRM_HWBlit(_THIS, GAL_Surface *src, GAL_Rect *src_rc,
blit_ops.rop = COLOR_LOGICOP_COPY;
return blitor(vdata->driver, src_buf, src_rc, dst_buf, dst_rc, &blit_ops);
return vdata->driver_ops->do_blit(vdata->driver, src_buf, src_rc,
dst_buf, dst_rc, &blit_ops);
}
static int DRM_CheckHWBlit_Accl(_THIS, GAL_Surface *src, const GAL_Rect *srcrc,
@@ -3576,14 +3576,10 @@ static int DRM_CheckHWBlit_Accl(_THIS, GAL_Surface *src, const GAL_Rect *srcrc,
blit_ops.rop = op & COLOR_LOGICOP_MASK;
/* Check to see if final surface blit is accelerated */
CB_DRM_BLIT blitor;
blitor = vdata->driver_ops->check_blit(vdata->driver, src_buf, srcrc,
dst_buf, dstrc, &blit_ops);
if (blitor) {
if (vdata->driver_ops->check_blit(vdata->driver, src_buf, srcrc,
dst_buf, dstrc, &blit_ops) == 0) {
src->map->video = this;
src->map->hw_blit = DRM_HWBlit;
src->map->hw_void = blitor;
}
else {
src->map->video = NULL;