Fix up cursor stuff
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2077 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1291,7 +1291,7 @@ printf("ScreenDriver::HideCursor\n");
|
||||
{
|
||||
SetCursorHidden(true);
|
||||
if(CursorStateChanged())
|
||||
BlitBitmap(under_cursor,under_cursor->Bounds(),oldcursorframe);
|
||||
BlitBitmap(under_cursor,under_cursor->Bounds(),cursorframe);
|
||||
|
||||
}
|
||||
Unlock();
|
||||
@@ -1303,12 +1303,14 @@ void ScreenDriver::MoveCursorTo(float x, float y)
|
||||
printf("ScreenDriver::MoveCursorTo(%f,%f)\n",x,y);
|
||||
#endif
|
||||
Lock();
|
||||
if(!IsCursorHidden() && cursor)
|
||||
if(!IsCursorHidden() && under_cursor)
|
||||
BlitBitmap(under_cursor,under_cursor->Bounds(),cursorframe);
|
||||
|
||||
oldcursorframe=cursorframe;
|
||||
|
||||
// TODO: save cursorframe to under_cursor
|
||||
cursorframe.OffsetTo(x,y);
|
||||
if (under_cursor)
|
||||
ExtractToBitmap(under_cursor,under_cursor->Bounds(),cursorframe);
|
||||
|
||||
if(!IsCursorHidden() && cursor)
|
||||
BlitBitmap(cursor,cursor->Bounds(),cursorframe);
|
||||
@@ -1324,7 +1326,7 @@ printf("ScreenDriver::ShowCursor\n");
|
||||
Lock();
|
||||
if(fbuffer->IsConnected())
|
||||
{
|
||||
hide_cursor--;
|
||||
SetCursorHidden(false);
|
||||
if(CursorStateChanged() && cursor)
|
||||
BlitBitmap(cursor,cursor->Bounds(),cursorframe);
|
||||
}
|
||||
@@ -1339,7 +1341,7 @@ printf("ScreenDriver::ObscureCursor\n");
|
||||
Lock();
|
||||
SetCursorObscured(true);
|
||||
if(!IsCursorHidden() && fbuffer->IsConnected() && under_cursor)
|
||||
BlitBitmap(under_cursor,under_cursor->Bounds(),oldcursorframe);
|
||||
BlitBitmap(under_cursor,under_cursor->Bounds(),cursorframe);
|
||||
Unlock();
|
||||
}
|
||||
|
||||
@@ -1348,14 +1350,14 @@ void ScreenDriver::SetCursor(ServerBitmap *csr, const BPoint &spot)
|
||||
#ifdef DEBUG_DRIVER
|
||||
printf("ScreenDriver::SetCursor\n");
|
||||
#endif
|
||||
/* if(!csr)
|
||||
if(!csr)
|
||||
return;
|
||||
|
||||
Lock();
|
||||
|
||||
// erase old if visible
|
||||
if(!IsCursorHidden() && under_cursor)
|
||||
BlitBitmap(under_cursor,under_cursor->Bounds(),oldcursorframe);
|
||||
BlitBitmap(under_cursor,under_cursor->Bounds(),cursorframe);
|
||||
|
||||
if(cursor)
|
||||
delete cursor;
|
||||
@@ -1370,17 +1372,16 @@ printf("ScreenDriver::SetCursor\n");
|
||||
else
|
||||
SetHotSpot(BPoint(0,0));
|
||||
|
||||
cursorframe.right=cursorframe.left+csr->Bounds().Width();
|
||||
cursorframe.bottom=cursorframe.top+csr->Bounds().Height();
|
||||
cursorframe.right=cursorframe.left+csr->Bounds().Width()-1;
|
||||
cursorframe.bottom=cursorframe.top+csr->Bounds().Height()-1;
|
||||
oldcursorframe=cursorframe;
|
||||
|
||||
// TODO: Save to oldcursorframe area to under_cursor
|
||||
ExtractToBitmap(under_cursor,under_cursor->Bounds(),cursorframe);
|
||||
|
||||
if(!IsCursorHidden() && cursor)
|
||||
BlitBitmap(cursor,cursor->Bounds(),cursorframe);
|
||||
|
||||
Unlock();
|
||||
*/
|
||||
}
|
||||
|
||||
void ScreenDriver::HLine(int32 x1, int32 x2, int32 y, RGBColor color)
|
||||
@@ -1544,6 +1545,94 @@ printf("ScreenDriver::BlitBitmap(): Incompatible bitmap pixel depth\n");
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenDriver::ExtractToBitmap(ServerBitmap *destbmp,BRect destrect, BRect sourcerect)
|
||||
{
|
||||
// Another internal function called from other functions.
|
||||
|
||||
if(!destbmp)
|
||||
{
|
||||
#ifdef DEBUG_DRIVER
|
||||
printf("ScreenDriver::ExtractToBitmap(): NULL destination bitmap\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
if(destbmp->bpp != fbuffer->gcinfo.bits_per_pixel)
|
||||
{
|
||||
#ifdef DEBUG_DRIVER
|
||||
printf("ScreenDriver::ExtractToBitmap(): Incompatible bitmap pixel depth\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
uint8 colorspace_size=destbmp->BitsPerPixel();
|
||||
// First, clip source rect to destination
|
||||
if(sourcerect.Width() > destrect.Width())
|
||||
sourcerect.right=sourcerect.left+destrect.Width();
|
||||
|
||||
|
||||
if(sourcerect.Height() > destrect.Height())
|
||||
sourcerect.bottom=sourcerect.top+destrect.Height();
|
||||
|
||||
|
||||
// Second, check rectangle bounds against their own bitmaps
|
||||
BRect work_rect;
|
||||
|
||||
work_rect.Set( destbmp->Bounds().left,
|
||||
destbmp->Bounds().top,
|
||||
destbmp->Bounds().right,
|
||||
destbmp->Bounds().bottom );
|
||||
if( !(work_rect.Contains(destrect)) )
|
||||
{ // something in selection must be clipped
|
||||
if(destrect.left < 0)
|
||||
destrect.left = 0;
|
||||
if(destrect.right > work_rect.right)
|
||||
destrect.right = work_rect.right;
|
||||
if(destrect.top < 0)
|
||||
destrect.top = 0;
|
||||
if(destrect.bottom > work_rect.bottom)
|
||||
destrect.bottom = work_rect.bottom;
|
||||
}
|
||||
|
||||
work_rect.Set( 0,0,fbuffer->gcinfo.width-1,fbuffer->gcinfo.height-1);
|
||||
|
||||
if( !(work_rect.Contains(sourcerect)) )
|
||||
{ // something in selection must be clipped
|
||||
if(sourcerect.left < 0)
|
||||
sourcerect.left = 0;
|
||||
if(sourcerect.right > work_rect.right)
|
||||
sourcerect.right = work_rect.right;
|
||||
if(sourcerect.top < 0)
|
||||
sourcerect.top = 0;
|
||||
if(sourcerect.bottom > work_rect.bottom)
|
||||
sourcerect.bottom = work_rect.bottom;
|
||||
}
|
||||
|
||||
// Set pointers to the actual data
|
||||
uint8 *dest_bits = (uint8*) destbmp->Bits();
|
||||
uint8 *src_bits = (uint8*) fbuffer->gcinfo.frame_buffer;
|
||||
|
||||
// Get row widths for offset looping
|
||||
uint32 dest_width = uint32 (destbmp->BytesPerRow());
|
||||
uint32 src_width = uint32 (fbuffer->gcinfo.bytes_per_row);
|
||||
|
||||
// Offset bitmap pointers to proper spot in each bitmap
|
||||
src_bits += uint32 ( (sourcerect.top * src_width) + (sourcerect.left * colorspace_size) );
|
||||
dest_bits += uint32 ( (destrect.top * dest_width) + (destrect.left * colorspace_size) );
|
||||
|
||||
uint32 line_length = uint32 ((destrect.right - destrect.left)*colorspace_size);
|
||||
uint32 lines = uint32 (destrect.bottom-destrect.top+1);
|
||||
|
||||
for (uint32 pos_y = 0; pos_y != lines; pos_y++)
|
||||
{
|
||||
memcpy(dest_bits,src_bits,line_length);
|
||||
|
||||
// Increment offsets
|
||||
src_bits += src_width;
|
||||
dest_bits += dest_width;
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenDriver::InvertRect(BRect r)
|
||||
{
|
||||
Lock();
|
||||
|
||||
@@ -89,6 +89,7 @@ protected:
|
||||
void BlitMono2RGB32(FT_Bitmap *src, BPoint pt, LayerData *d);
|
||||
void BlitGray2RGB32(FT_Bitmap *src, BPoint pt, LayerData *d);
|
||||
void BlitBitmap(ServerBitmap *sourcebmp, BRect sourcerect, BRect destrect);
|
||||
void ExtractToBitmap(ServerBitmap *destbmp, BRect destrect, BRect sourcerect);
|
||||
void SetPixelPattern(int x, int y, uint8 *pattern, uint8 patternindex);
|
||||
void Line(BPoint start, BPoint end, LayerData *d, int8 *pat);
|
||||
void HLine(int32 x1, int32 x2, int32 y, RGBColor color);
|
||||
|
||||
Reference in New Issue
Block a user