From: John Hodge Date: Sat, 22 Oct 2011 09:41:05 +0000 (+0800) Subject: Kernel/drvutil - Fixes to cursor handling X-Git-Tag: rel0.13~4 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=800a321284a80799330ecf59be3a117c61babdb5;p=tpg%2Facess2.git Kernel/drvutil - Fixes to cursor handling --- diff --git a/Kernel/drvutil.c b/Kernel/drvutil.c index 8847ae27..6de004bc 100644 --- a/Kernel/drvutil.c +++ b/Kernel/drvutil.c @@ -32,22 +32,22 @@ tVideo_IOCtl_Bitmap gDrvUtil_TextModeCursor = { 8, 16, 0, 0, { - 0, 0 , 0, 0, 0, 0, 0, 0, - -1, 0xFF000000, 0, 0, 0, 0, 0, 0, - -1, 0xFF000000, 0, 0, 0, 0, 0, 0, - -1, 0xFF000000, 0, 0, 0, 0, 0, 0, - -1, 0xFF000000, 0, 0, 0, 0, 0, 0, - -1, 0xFF000000, 0, 0, 0, 0, 0, 0, - -1, 0xFF000000, 0, 0, 0, 0, 0, 0, - -1, 0xFF000000, 0, 0, 0, 0, 0, 0, - -1, 0xFF000000, 0, 0, 0, 0, 0, 0, - -1, 0xFF000000, 0, 0, 0, 0, 0, 0, - -1, 0xFF000000, 0, 0, 0, 0, 0, 0, - -1, 0xFF000000, 0, 0, 0, 0, 0, 0, - -1, 0xFF000000, 0, 0, 0, 0, 0, 0, - -1, 0xFF000000, 0, 0, 0, 0, 0, 0, - -1, 0xFF000000, 0, 0, 0, 0, 0, 0, - 0, 0 , 0, 0, 0, 0, 0, 0 + 0, 0, 0 , 0, 0, 0, 0, 0, + 0,-1, 0xFF000000, 0, 0, 0, 0, 0, + 0,-1, 0xFF000000, 0, 0, 0, 0, 0, + 0,-1, 0xFF000000, 0, 0, 0, 0, 0, + 0,-1, 0xFF000000, 0, 0, 0, 0, 0, + 0,-1, 0xFF000000, 0, 0, 0, 0, 0, + 0,-1, 0xFF000000, 0, 0, 0, 0, 0, + 0,-1, 0xFF000000, 0, 0, 0, 0, 0, + 0,-1, 0xFF000000, 0, 0, 0, 0, 0, + 0,-1, 0xFF000000, 0, 0, 0, 0, 0, + 0,-1, 0xFF000000, 0, 0, 0, 0, 0, + 0,-1, 0xFF000000, 0, 0, 0, 0, 0, + 0,-1, 0xFF000000, 0, 0, 0, 0, 0, + 0,-1, 0xFF000000, 0, 0, 0, 0, 0, + 0, 0, 0 , 0, 0, 0, 0, 0, + 0, 0, 0 , 0, 0, 0, 0, 0 } }; @@ -131,8 +131,15 @@ int DrvUtil_Video_2DStream(void *Ent, void *Buffer, int Length, int DrvUtil_Video_WriteLFB(tDrvUtil_Video_BufInfo *FBInfo, size_t Offset, size_t Length, void *Buffer) { Uint8 *dest; + int csr_x, csr_y; ENTER("pFBInfo xOffset xLength pBuffer", Mode, FBInfo, Offset, Length, Buffer); + + csr_x = FBInfo->CursorX; + csr_y = FBInfo->CursorY; + + DrvUtil_Video_RemoveCursor(FBInfo); + switch( FBInfo->BufferFormat ) { case VIDEO_BUFFMT_TEXT: @@ -225,11 +232,14 @@ int DrvUtil_Video_WriteLFB(tDrvUtil_Video_BufInfo *FBInfo, size_t Offset, size_t LEAVE('i', -1); return -1; } + + DrvUtil_Video_DrawCursor(FBInfo, csr_x, csr_y); + LEAVE('x', Length); return Length; } -void DrvUtil_Video_SetCursor(tDrvUtil_Video_BufInfo *Buf, tVideo_IOCtl_Bitmap *Bitmap) +int DrvUtil_Video_SetCursor(tDrvUtil_Video_BufInfo *Buf, tVideo_IOCtl_Bitmap *Bitmap) { int csrX = Buf->CursorX, csrY = Buf->CursorY; size_t size; @@ -253,29 +263,34 @@ void DrvUtil_Video_SetCursor(tDrvUtil_Video_BufInfo *Buf, tVideo_IOCtl_Bitmap *B { Buf->CursorX = -1; Buf->CursorY = -1; - return ; + return 0; + } + + // Sanity check the bitmap + if( !CheckMem(Bitmap, sizeof(*Bitmap)) || !CheckMem(Bitmap->Data, Bitmap->W*Bitmap->H*sizeof(Uint32)) ) + { + Log_Warning("DrvUtil", "DrvUtil_Video_SetCursor: Bitmap (%p) is in invalid memory", Bitmap); + errno = -EINVAL; + return -1; } - if( Bitmap != &gDrvUtil_TextModeCursor ) + // Don't take a copy of the DrvUtil provided cursor + if( Bitmap == &gDrvUtil_TextModeCursor ) + { + Buf->CursorBitmap = Bitmap; + } + else { - // Check the new bitmap is valid size = sizeof(tVideo_IOCtl_Bitmap) + Bitmap->W*Bitmap->H*4; - if( !CheckMem(Bitmap, size) ) { - Log_Warning("DrvUtil", "DrvUtil_Video_SetCursor: Bitmap (%p) is in invalid memory", Bitmap); - return; - } // Take a copy Buf->CursorBitmap = malloc( size ); memcpy(Buf->CursorBitmap, Bitmap, size); } - else - { - Buf->CursorBitmap = &gDrvUtil_TextModeCursor; - } // Restore cursor position DrvUtil_Video_DrawCursor(Buf, csrX, csrY); + return 0; } void DrvUtil_Video_DrawCursor(tDrvUtil_Video_BufInfo *Buf, int X, int Y) diff --git a/Kernel/include/api_drv_video.h b/Kernel/include/api_drv_video.h index ab7dcdb9..f2d1a2d1 100644 --- a/Kernel/include/api_drv_video.h +++ b/Kernel/include/api_drv_video.h @@ -460,7 +460,7 @@ extern int DrvUtil_Video_WriteLFB(tDrvUtil_Video_BufInfo *FBInfo, size_t Offset, * \param Buf Framebuffer descriptor * \param Bitmap New cursor bitmap */ -extern void DrvUtil_Video_SetCursor(tDrvUtil_Video_BufInfo *Buf, tVideo_IOCtl_Bitmap *Bitmap); +extern int DrvUtil_Video_SetCursor(tDrvUtil_Video_BufInfo *Buf, tVideo_IOCtl_Bitmap *Bitmap); /** * \brief Render the cursor at (\a X, \a Y) * \param Buf Framebuffer descriptor, see type for details diff --git a/Modules/Display/VESA/main.c b/Modules/Display/VESA/main.c index 8b227eae..b543c239 100644 --- a/Modules/Display/VESA/main.c +++ b/Modules/Display/VESA/main.c @@ -206,6 +206,10 @@ int Vesa_IOCtl(tVFS_Node *Node, int ID, void *Data) giVesaCursorY = ((tVideo_IOCtl_Pos*)Data)->y; Vesa_int_ShowCursor(); return 0; + + case VIDEO_IOCTL_SETCURSORBITMAP: + DrvUtil_Video_SetCursor( &gVesa_BufInfo, Data ); + return 0; } return 0; }