X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Fdrvutil.c;h=d2c86bfbcd971586bc079ae32546e22f24d72105;hb=bf1534c55e79995c0240551d8b0fb2d2c48937f8;hp=d19a050464806f72a58eb638a90e04a509d3893c;hpb=48743e39650eb1ef988380e9d95f27fd40d3a9ce;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/drvutil.c b/KernelLand/Kernel/drvutil.c index d19a0504..d2c86bfb 100644 --- a/KernelLand/Kernel/drvutil.c +++ b/KernelLand/Kernel/drvutil.c @@ -136,7 +136,7 @@ int DrvUtil_Video_WriteLFB(tDrvUtil_Video_BufInfo *FBInfo, size_t Offset, size_t int x, y; int bytes_per_px = (FBInfo->Depth + 7) / 8; ENTER("pFBInfo xOffset xLength pBuffer", - Mode, FBInfo, Offset, Length, Buffer); + FBInfo, Offset, Length, Buffer); csr_x = FBInfo->CursorX; csr_y = FBInfo->CursorY; @@ -287,9 +287,12 @@ int DrvUtil_Video_SetCursor(tDrvUtil_Video_BufInfo *Buf, tVideo_IOCtl_Bitmap *Bi int csrX = Buf->CursorX, csrY = Buf->CursorY; size_t size; + ENTER("pBuf pBitmap", Buf, Bitmap); + // Clear old bitmap if( Buf->CursorBitmap ) { + LOG("Clearing old cursor"); DrvUtil_Video_RemoveCursor(Buf); if( !Bitmap || Bitmap->W != Buf->CursorBitmap->W || Bitmap->H != Buf->CursorBitmap->H ) { @@ -306,24 +309,29 @@ int DrvUtil_Video_SetCursor(tDrvUtil_Video_BufInfo *Buf, tVideo_IOCtl_Bitmap *Bi { Buf->CursorX = -1; Buf->CursorY = -1; + LEAVE('i', 0); return 0; } // Sanity check the bitmap + LOG("Sanity checking plox"); 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; + LEAVE('i', -1); return -1; } // Don't take a copy of the DrvUtil provided cursor if( Bitmap == &gDrvUtil_TextModeCursor ) { + LOG("No copy (provided cursor)"); Buf->CursorBitmap = Bitmap; } else { + LOG("Make copy"); size = sizeof(tVideo_IOCtl_Bitmap) + Bitmap->W*Bitmap->H*4; // Take a copy @@ -332,7 +340,9 @@ int DrvUtil_Video_SetCursor(tDrvUtil_Video_BufInfo *Buf, tVideo_IOCtl_Bitmap *Bi } // Restore cursor position + LOG("Drawing"); DrvUtil_Video_DrawCursor(Buf, csrX, csrY); + LEAVE('i', 0); return 0; } @@ -340,24 +350,30 @@ void DrvUtil_Video_DrawCursor(tDrvUtil_Video_BufInfo *Buf, int X, int Y) { int render_ox=0, render_oy=0, render_w, render_h; + ENTER("pBuf iX iY", Buf, X, Y); DrvUtil_Video_RemoveCursor(Buf); // X < 0 disables the cursor if( X < 0 ) { Buf->CursorX = -1; + LEAVE('-'); return ; } // Sanity checking - if( X < 0 || Y < 0 ) return; - if( X >= Buf->Width || Y >= Buf->Height ) return; + if( X < 0 || Y < 0 || X >= Buf->Width || Y >= Buf->Height ) { + LEAVE('-'); + return ; + } // Ensure the cursor is enabled - if( !Buf->CursorBitmap ) return ; + if( !Buf->CursorBitmap ) { + LEAVE('-'); + return ; + } // Save cursor position (for changing the bitmap) Buf->CursorX = X; Buf->CursorY = Y; - // Apply cursor's center offset X -= Buf->CursorBitmap->XOfs; Y -= Buf->CursorBitmap->YOfs; @@ -375,8 +391,12 @@ void DrvUtil_Video_DrawCursor(tDrvUtil_Video_BufInfo *Buf, int X, int Y) Buf->CursorDestX = X; Buf->CursorDestY = Y; Buf->CursorReadX = render_ox; Buf->CursorReadY = render_oy; + LOG("%ix%i at %i,%i offset %i,%i", + render_w, render_h, X, Y, render_ox, render_oy); + // Call render routine DrvUtil_Video_RenderCursor(Buf); + LEAVE('-'); } void DrvUtil_Video_RenderCursor(tDrvUtil_Video_BufInfo *Buf) @@ -393,10 +413,13 @@ void DrvUtil_Video_RenderCursor(tDrvUtil_Video_BufInfo *Buf) dest = (Uint8*)Buf->Framebuffer + dest_y*Buf->Pitch + dest_x*bytes_per_px; src = Buf->CursorBitmap->Data + src_y * Buf->CursorBitmap->W + src_x; + LOG("dest = %p, src = %p", dest, src); + // Allocate save buffer if not already if( !Buf->CursorSaveBuf ) Buf->CursorSaveBuf = malloc( Buf->CursorBitmap->W*Buf->CursorBitmap->H*bytes_per_px ); + LOG("Saving back"); // Save behind the cursor for( y = 0; y < render_h; y ++ ) memcpy( @@ -413,6 +436,7 @@ void DrvUtil_Video_RenderCursor(tDrvUtil_Video_BufInfo *Buf) Log_Warning("DrvUtil", "TODO: Support 15/16 bpp modes in cursor draw"); break; case 24: + LOG("24-bit render"); for( y = 0; y < render_h; y ++ ) { Uint8 *px; @@ -435,6 +459,7 @@ void DrvUtil_Video_RenderCursor(tDrvUtil_Video_BufInfo *Buf) } break; case 32: + LOG("32-bit render"); for( y = 0; y < render_h; y ++ ) { Uint32 *px; @@ -448,6 +473,7 @@ void DrvUtil_Video_RenderCursor(tDrvUtil_Video_BufInfo *Buf) else ; // NOP, completely transparent } + LOG("row %i/%i (%p-%P) done", y+1, render_h, dest, MM_GetPhysAddr(dest)); src += Buf->CursorBitmap->W; dest = (Uint8*)dest + Buf->Pitch; } @@ -556,7 +582,7 @@ void DrvUtil_Video_2D_Blit(void *Ent, Uint16 DstX, Uint16 DstY, Uint16 SrcX, Uin // --- Disk Driver Helpers --- Uint64 DrvUtil_ReadBlock(Uint64 Start, Uint64 Length, void *Buffer, - tDrvUtil_Read_Callback ReadBlocks, Uint64 BlockSize, Uint Argument) + tDrvUtil_Read_Callback ReadBlocks, Uint64 BlockSize, void *Argument) { Uint8 tmp[BlockSize]; // C99 Uint64 block = Start / BlockSize; @@ -566,7 +592,7 @@ Uint64 DrvUtil_ReadBlock(Uint64 Start, Uint64 Length, void *Buffer, int tailings; Uint64 ret; - ENTER("XStart XLength pBuffer pReadBlocks XBlockSize xArgument", + ENTER("XStart XLength pBuffer pReadBlocks XBlockSize pArgument", Start, Length, Buffer, ReadBlocks, BlockSize, Argument); // Non aligned start, let's fix that! @@ -627,7 +653,7 @@ Uint64 DrvUtil_ReadBlock(Uint64 Start, Uint64 Length, void *Buffer, Uint64 DrvUtil_WriteBlock(Uint64 Start, Uint64 Length, const void *Buffer, tDrvUtil_Read_Callback ReadBlocks, tDrvUtil_Write_Callback WriteBlocks, - Uint64 BlockSize, Uint Argument) + Uint64 BlockSize, void *Argument) { Uint8 tmp[BlockSize]; // C99 Uint64 block = Start / BlockSize; @@ -637,7 +663,7 @@ Uint64 DrvUtil_WriteBlock(Uint64 Start, Uint64 Length, const void *Buffer, int tailings; Uint64 ret; - ENTER("XStart XLength pBuffer pReadBlocks pWriteBlocks XBlockSize xArgument", + ENTER("XStart XLength pBuffer pReadBlocks pWriteBlocks XBlockSize pArgument", Start, Length, Buffer, ReadBlocks, WriteBlocks, BlockSize, Argument); // Non aligned start, let's fix that!