Fix initialization and memory issues
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2158 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
325a5f6bb6
commit
7348e71fc3
@ -306,7 +306,6 @@ ScreenDriver::ScreenDriver(void)
|
||||
under_cursor=NULL;
|
||||
|
||||
cursorframe.Set(0,0,0,0);
|
||||
oldcursorframe.Set(0,0,0,0);
|
||||
}
|
||||
|
||||
ScreenDriver::~ScreenDriver(void)
|
||||
@ -319,12 +318,19 @@ ScreenDriver::~ScreenDriver(void)
|
||||
|
||||
bool ScreenDriver::Initialize(void)
|
||||
{
|
||||
int8 cross[] = { 16,1,5,5,
|
||||
14,0,4,0,4,0,4,0,128,32,241,224,128,32,4,0,
|
||||
4,0,4,0,14,0,0,0,0,0,0,0,0,0,0,0,
|
||||
14,0,4,0,4,0,4,0,128,32,245,224,128,32,4,0,
|
||||
4,0,4,0,14,0,0,0,0,0,0,0,0,0,0,0 };
|
||||
ServerBitmap *crosscursor;
|
||||
fbuffer->Show();
|
||||
|
||||
// draw on the module's default cursor here to make it look preety
|
||||
|
||||
// wait 1 sec for the window to show...
|
||||
snooze(500000);
|
||||
crosscursor = new ServerBitmap(cross);
|
||||
SetCursor(crosscursor,BPoint(5,5));
|
||||
delete crosscursor;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1303,16 +1309,13 @@ void ScreenDriver::MoveCursorTo(float x, float y)
|
||||
printf("ScreenDriver::MoveCursorTo(%f,%f)\n",x,y);
|
||||
#endif
|
||||
Lock();
|
||||
if(!IsCursorHidden() && under_cursor)
|
||||
if(!IsCursorHidden())
|
||||
BlitBitmap(under_cursor,under_cursor->Bounds(),cursorframe);
|
||||
|
||||
oldcursorframe=cursorframe;
|
||||
|
||||
cursorframe.OffsetTo(x,y);
|
||||
if (under_cursor)
|
||||
ExtractToBitmap(under_cursor,under_cursor->Bounds(),cursorframe);
|
||||
|
||||
if(!IsCursorHidden() && cursor)
|
||||
if(!IsCursorHidden())
|
||||
BlitBitmap(cursor,cursor->Bounds(),cursorframe);
|
||||
|
||||
Unlock();
|
||||
@ -1327,7 +1330,7 @@ printf("ScreenDriver::ShowCursor\n");
|
||||
if(fbuffer->IsConnected())
|
||||
{
|
||||
SetCursorHidden(false);
|
||||
if(CursorStateChanged() && cursor)
|
||||
if(CursorStateChanged())
|
||||
BlitBitmap(cursor,cursor->Bounds(),cursorframe);
|
||||
}
|
||||
Unlock();
|
||||
@ -1340,7 +1343,7 @@ printf("ScreenDriver::ObscureCursor\n");
|
||||
#endif
|
||||
Lock();
|
||||
SetCursorObscured(true);
|
||||
if(!IsCursorHidden() && fbuffer->IsConnected() && under_cursor)
|
||||
if(!IsCursorHidden() && fbuffer->IsConnected())
|
||||
BlitBitmap(under_cursor,under_cursor->Bounds(),cursorframe);
|
||||
Unlock();
|
||||
}
|
||||
@ -1372,13 +1375,12 @@ printf("ScreenDriver::SetCursor\n");
|
||||
else
|
||||
SetHotSpot(BPoint(0,0));
|
||||
|
||||
cursorframe.right=cursorframe.left+csr->Bounds().Width()-1;
|
||||
cursorframe.bottom=cursorframe.top+csr->Bounds().Height()-1;
|
||||
oldcursorframe=cursorframe;
|
||||
cursorframe.right=cursorframe.left+csr->Bounds().Width();
|
||||
cursorframe.bottom=cursorframe.top+csr->Bounds().Height();
|
||||
|
||||
ExtractToBitmap(under_cursor,under_cursor->Bounds(),cursorframe);
|
||||
|
||||
if(!IsCursorHidden() && cursor)
|
||||
if(!IsCursorHidden())
|
||||
BlitBitmap(cursor,cursor->Bounds(),cursorframe);
|
||||
|
||||
Unlock();
|
||||
@ -1477,7 +1479,7 @@ printf("ScreenDriver::BlitBitmap(): Incompatible bitmap pixel depth\n");
|
||||
return;
|
||||
}
|
||||
|
||||
uint8 colorspace_size=sourcebmp->BitsPerPixel();
|
||||
uint8 colorspace_size=sourcebmp->BitsPerPixel()/8;
|
||||
// First, clip source rect to destination
|
||||
if(sourcerect.Width() > destrect.Width())
|
||||
sourcerect.right=sourcerect.left+destrect.Width();
|
||||
@ -1532,7 +1534,7 @@ printf("ScreenDriver::BlitBitmap(): Incompatible bitmap pixel depth\n");
|
||||
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 line_length = uint32 ((destrect.right - destrect.left+1)*colorspace_size);
|
||||
uint32 lines = uint32 (destrect.bottom-destrect.top+1);
|
||||
|
||||
for (uint32 pos_y = 0; pos_y != lines; pos_y++)
|
||||
@ -1565,7 +1567,7 @@ printf("ScreenDriver::ExtractToBitmap(): Incompatible bitmap pixel depth\n");
|
||||
return;
|
||||
}
|
||||
|
||||
uint8 colorspace_size=destbmp->BitsPerPixel();
|
||||
uint8 colorspace_size=destbmp->BitsPerPixel()/8;
|
||||
// First, clip source rect to destination
|
||||
if(sourcerect.Width() > destrect.Width())
|
||||
sourcerect.right=sourcerect.left+destrect.Width();
|
||||
@ -1620,7 +1622,7 @@ printf("ScreenDriver::ExtractToBitmap(): Incompatible bitmap pixel depth\n");
|
||||
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 line_length = uint32 ((destrect.right - destrect.left+1)*colorspace_size);
|
||||
uint32 lines = uint32 (destrect.bottom-destrect.top+1);
|
||||
|
||||
for (uint32 pos_y = 0; pos_y != lines; pos_y++)
|
||||
|
@ -106,7 +106,7 @@ protected:
|
||||
int hide_cursor;
|
||||
ServerBitmap *cursor, *under_cursor;
|
||||
int32 drawmode;
|
||||
BRect cursorframe, oldcursorframe;
|
||||
BRect cursorframe;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -87,6 +87,7 @@ ServerBitmap::ServerBitmap(const char *path)
|
||||
bytesperline=bmp->BytesPerRow();
|
||||
buffer=new uint8[bmp->BitsLength()];
|
||||
memcpy(buffer,(void *)bmp->Bits(),bmp->BitsLength());
|
||||
HandleSpace(cspace,bytesperline);
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,6 +114,7 @@ ServerBitmap::ServerBitmap(uint32 type,int32 id)
|
||||
bytesperline=bmp->BytesPerRow();
|
||||
buffer=new uint8[bmp->BitsLength()];
|
||||
memcpy(buffer,(void *)bmp->Bits(),bmp->BitsLength());
|
||||
HandleSpace(cspace,bytesperline);
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,6 +140,7 @@ ServerBitmap::ServerBitmap(uint32 type, const char *name)
|
||||
bytesperline=bmp->BytesPerRow();
|
||||
buffer=new uint8[bmp->BitsLength()];
|
||||
memcpy(buffer,(void *)bmp->Bits(),bmp->BitsLength());
|
||||
HandleSpace(cspace,bytesperline);
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,6 +149,7 @@ ServerBitmap::ServerBitmap(ServerBitmap *bitmap)
|
||||
is_initialized=true;
|
||||
width=bitmap->width;
|
||||
height=bitmap->height;
|
||||
bytesperline = bitmap->bytesperline;
|
||||
cspace=bitmap->cspace;
|
||||
areaid=B_ERROR;
|
||||
|
||||
@ -178,6 +182,8 @@ ServerBitmap::ServerBitmap(int8 *data)
|
||||
width=16;
|
||||
height=16;
|
||||
bytesperline=64;
|
||||
cspace=B_RGBA32;
|
||||
HandleSpace(cspace,bytesperline);
|
||||
|
||||
// for each row in the cursor data
|
||||
for(j=0;j<16;j++)
|
||||
@ -206,6 +212,7 @@ ServerBitmap::ServerBitmap(int8 *data)
|
||||
width=0;
|
||||
height=0;
|
||||
bytesperline=0;
|
||||
cspace=B_NO_COLOR_SPACE;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_SERVER_CURSOR
|
||||
@ -216,7 +223,7 @@ ServerBitmap::ServerBitmap(int8 *data)
|
||||
ServerBitmap::~ServerBitmap(void)
|
||||
{
|
||||
if(buffer)
|
||||
delete buffer;
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
void ServerBitmap::UpdateSettings(void)
|
||||
|
Loading…
Reference in New Issue
Block a user