23 #include "../../SDL_internal.h"
25 #if SDL_VIDEO_DRIVER_KMSDRM
32 #include "../../events/SDL_mouse_c.h"
33 #include "../../events/default_cursor.h"
35 static SDL_Cursor *KMSDRM_CreateDefaultCursor(
void);
41 static int KMSDRM_WarpMouseGlobal(
int x,
int y);
57 dispdata->
atomic_req = KMSDRM_drmModeAtomicAlloc();
76 void alpha_premultiply_ARGB8888 (
uint32_t *pixel) {
81 A = (*pixel >> (3 << 3)) & 0xFF;
82 R = (*pixel >> (2 << 3)) & 0xFF;
83 G = (*pixel >> (1 << 3)) & 0xFF;
84 B = (*pixel >> (0 << 3)) & 0xFF;
87 R = (float)A * ((
float)R /255);
88 G = (float)A * ((
float)
G /255);
89 B = (float)A * ((
float)B /255);
96 KMSDRM_CreateDefaultCursor(
void)
132 curdata->
hot_y = hot_y;
256 return SDL_SetError(
"Failed atomic commit in KMSDRM_ShowCursor.");
267 return SDL_SetError(
"Could not get display for mouse.");
270 return SDL_SetError(
"Could not get display driverdata.");
273 return SDL_SetError(
"Hardware cursor plane not initialized.");
279 return SDL_SetError(
"Cursor not initialized properly.");
283 bo_stride = KMSDRM_gbm_bo_get_stride(dispdata->
cursor_bo);
293 SDL_memset(ready_buffer, 0x00, bo_stride * curdata->
h);
297 for (
i = 0;
i < curdata->
h;
i++) {
298 for (
j = 0;
j < curdata->
w;
j++) {
300 alpha_premultiply_ARGB8888 (&pixel);
328 ret =
SDL_SetError(
"Failed atomic commit in KMSDRM_ShowCursor.");
370 KMSDRM_WarpMouseGlobal(
x,
y);
375 KMSDRM_WarpMouseGlobal(
int x,
int y)
388 if (drm_atomic_movecursor(curdata,
x,
y)) {
392 return SDL_SetError(
"Cursor not initialized properly.");
412 uint64_t usable_cursor_w, usable_cursor_h;
435 if (!KMSDRM_gbm_device_is_format_supported(viddata->
gbm_dev, GBM_FORMAT_ARGB8888,
436 GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE))
442 if (KMSDRM_drmGetCap(viddata->
drm_fd, DRM_CAP_CURSOR_WIDTH, &usable_cursor_w) ||
443 KMSDRM_drmGetCap(viddata->
drm_fd, DRM_CAP_CURSOR_HEIGHT, &usable_cursor_h))
445 SDL_SetError(
"Could not get the recommended GBM cursor size");
449 if (usable_cursor_w == 0 || usable_cursor_h == 0) {
450 SDL_SetError(
"Could not get an usable GBM cursor size");
454 dispdata->
cursor_w = usable_cursor_w;
455 dispdata->
cursor_h = usable_cursor_h;
458 usable_cursor_w, usable_cursor_h,
459 GBM_FORMAT_ARGB8888, GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE);
474 KMSDRM_gbm_bo_destroy(dispdata->
cursor_bo);
491 if (video_device && dispdata->
cursor_bo) {
499 SDL_SetError(
"Failed atomic commit in KMSDRM_DenitMouse.");
502 KMSDRM_gbm_bo_destroy(dispdata->
cursor_bo);
532 if (drm_atomic_movecursor(curdata, mouse->
x, mouse->
y)) {
#define SDL_assert(condition)
unsigned long long uint64_t
#define SDL_UnlockSurface
#define SDL_OutOfMemory()
int uint32_t uint32_t uint32_t uint32_t uint32_t int drmModeModeInfoPtr mode int uint32_t uint32_t uint32_t uint32_t int32_t hot_x
void KMSDRM_DeinitMouse(_THIS)
void KMSDRM_InitMouse(_THIS)
int setup_plane(_THIS, struct plane **plane, uint32_t plane_type)
int drm_atomic_commit(_THIS, SDL_bool blocking)
void drm_atomic_set_plane_props(struct KMSDRM_PlaneInfo *info)
int add_plane_property(drmModeAtomicReq *req, struct plane *plane, const char *name, uint64_t value)
KMSDRM_FBInfo * KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo)
void free_plane(struct plane **plane)
SDL_Mouse * SDL_GetMouse(void)
void SDL_SetDefaultCursor(SDL_Cursor *cursor)
int SDL_SendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y)
GLint GLint GLint GLint GLint GLint y
GLint GLint GLint GLint GLint x
GLenum GLuint GLsizei bufsize
@ SDL_PIXELFORMAT_ARGB8888
void * SDL_GetDisplayDriverData(int displayIndex)
SDL_VideoDevice * SDL_GetVideoDevice(void)
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
static SDL_VideoDevice * _this
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int in j)
static const unsigned char default_cdata[]
static const unsigned char default_cmask[]
EGLSurface EGLNativeWindowType * window
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld cleanup[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1 beq endif SRC MASK if dst_r_bpp DST_R else add endif PF add sub src_basereg pixdeinterleave mask_basereg pixdeinterleave dst_r_basereg process_pixblock_head pixblock_size cache_preload_simple process_pixblock_tail pixinterleave dst_w_basereg irp beq endif process_pixblock_tail_head tst beq irp if pixblock_size chunk_size tst beq pixld_src SRC pixld MASK if DST_R else pixld DST_R endif if src_basereg pixdeinterleave mask_basereg pixdeinterleave dst_r_basereg process_pixblock_head if pixblock_size cache_preload_simple endif process_pixblock_tail pixinterleave dst_w_basereg irp if pixblock_size chunk_size tst beq if DST_W else pixst DST_W else mov ORIG_W endif add lsl if lsl endif if lsl endif lsl endif lsl endif lsl endif subs mov DST_W if regs_shortage str endif bge start_of_loop_label endm macro generate_composite_function
drmModeAtomicReq * atomic_req
struct gbm_bo * cursor_bo
void(* WarpMouse)(SDL_Window *window, int x, int y)
SDL_Cursor *(* CreateCursor)(SDL_Surface *surface, int hot_x, int hot_y)
void(* FreeCursor)(SDL_Cursor *cursor)
int(* ShowCursor)(SDL_Cursor *cursor)
int(* WarpMouseGlobal)(int x, int y)
void(* MoveCursor)(SDL_Cursor *cursor)
A collection of pixels used in software blitting.
struct gbm_device * gbm_dev
The type used to identify a window.