You also need to delete cloned areas - they are areas like any other (just their
contents are shared)! Some cleanup. BBitmap::Cleanup() doesn't ask for a reply from the server anymore (why should it care, anyway?). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15380 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -2174,7 +2174,7 @@ BBitmap::get_server_token() const
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
BBitmap::InitObject(BRect bounds, color_space colorSpace, uint32 flags,
|
BBitmap::InitObject(BRect bounds, color_space colorSpace, uint32 flags,
|
||||||
int32 bytesPerRow, screen_id screenID)
|
int32 bytesPerRow, screen_id screenID)
|
||||||
{
|
{
|
||||||
//printf("BBitmap::InitObject(bounds: BRect(%.1f, %.1f, %.1f, %.1f), format: %ld, flags: %ld, bpr: %ld\n",
|
//printf("BBitmap::InitObject(bounds: BRect(%.1f, %.1f, %.1f, %.1f), format: %ld, flags: %ld, bpr: %ld\n",
|
||||||
// bounds.left, bounds.top, bounds.right, bounds.bottom, colorSpace, flags, bytesPerRow);
|
// bounds.left, bounds.top, bounds.right, bounds.bottom, colorSpace, flags, bytesPerRow);
|
||||||
@@ -2254,42 +2254,36 @@ BBitmap::InitObject(BRect bounds, color_space colorSpace, uint32 flags,
|
|||||||
// Reply Code: SERVER_FALSE
|
// Reply Code: SERVER_FALSE
|
||||||
// Reply Data:
|
// Reply Data:
|
||||||
// None
|
// None
|
||||||
int32 code = SERVER_FALSE;
|
error = B_ERROR;
|
||||||
error = link.FlushWithReply(code);
|
if (link.FlushWithReply(error) == B_OK && error == B_OK) {
|
||||||
|
// server side success
|
||||||
|
// Get token
|
||||||
|
link.Read<int32>(&fServerToken);
|
||||||
|
|
||||||
if (error >= B_OK) {
|
area_id area;
|
||||||
// *communication* with server successful
|
int32 areaOffset;
|
||||||
if (code == SERVER_TRUE) {
|
link.Read<area_id>(&area);
|
||||||
// server side success
|
link.Read<int32>(&areaOffset);
|
||||||
// Get token
|
|
||||||
area_id bmparea;
|
|
||||||
int32 areaoffset;
|
|
||||||
|
|
||||||
link.Read<int32>(&fServerToken);
|
|
||||||
link.Read<area_id>(&bmparea);
|
|
||||||
link.Read<int32>(&areaoffset);
|
|
||||||
|
|
||||||
// Get the area in which the data resides
|
|
||||||
fArea = clone_area("shared bitmap area",
|
|
||||||
(void**)&fBasePtr,
|
|
||||||
B_ANY_ADDRESS,
|
|
||||||
B_READ_AREA | B_WRITE_AREA,
|
|
||||||
bmparea);
|
|
||||||
|
|
||||||
|
// Get the area in which the data resides
|
||||||
|
fArea = clone_area("shared bitmap area",
|
||||||
|
(void**)&fBasePtr,
|
||||||
|
B_ANY_ADDRESS,
|
||||||
|
B_READ_AREA | B_WRITE_AREA,
|
||||||
|
area);
|
||||||
|
if (fArea >= B_OK) {
|
||||||
// Jump to the location in the area
|
// Jump to the location in the area
|
||||||
fBasePtr = (int8*)fBasePtr + areaoffset;
|
fBasePtr = (int8*)fBasePtr + areaOffset;
|
||||||
|
|
||||||
fSize = size;
|
fSize = size;
|
||||||
fColorSpace = colorSpace;
|
fColorSpace = colorSpace;
|
||||||
fBounds = bounds;
|
fBounds = bounds;
|
||||||
fBytesPerRow = bytesPerRow;
|
fBytesPerRow = bytesPerRow;
|
||||||
fFlags = flags;
|
fFlags = flags;
|
||||||
} else {
|
} else
|
||||||
// server side error, we assume:
|
error = fArea;
|
||||||
error = B_NO_MEMORY;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// NOTE: not "else" to handle B_NO_MEMORY on server side!
|
|
||||||
if (error < B_OK) {
|
if (error < B_OK) {
|
||||||
fBasePtr = NULL;
|
fBasePtr = NULL;
|
||||||
fServerToken = -1;
|
fServerToken = -1;
|
||||||
@@ -2318,47 +2312,39 @@ BBitmap::InitObject(BRect bounds, color_space colorSpace, uint32 flags,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp
|
|
||||||
/*! \brief Cleans up any memory allocated by the bitmap or
|
/*!
|
||||||
informs the server to do so.
|
\brief Cleans up any memory allocated by the bitmap and
|
||||||
|
informs the server to do so as well (if needed).
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
BBitmap::CleanUp()
|
BBitmap::CleanUp()
|
||||||
{
|
{
|
||||||
if (fBasePtr) {
|
if (fBasePtr == NULL)
|
||||||
if (fFlags & B_BITMAP_NO_SERVER_LINK) {
|
return;
|
||||||
free(fBasePtr);
|
|
||||||
} else {
|
|
||||||
BPrivate::AppServerLink link;
|
|
||||||
// AS_DELETE_BITMAP:
|
|
||||||
// Attached Data:
|
|
||||||
// 1) int32 server token
|
|
||||||
|
|
||||||
// Reply Code: SERVER_TRUE if successful,
|
if (fFlags & B_BITMAP_NO_SERVER_LINK) {
|
||||||
// SERVER_FALSE if the buffer was already deleted
|
free(fBasePtr);
|
||||||
// Reply Data: none
|
} else {
|
||||||
// status_t freestat;
|
BPrivate::AppServerLink link;
|
||||||
int32 code = SERVER_FALSE;
|
// AS_DELETE_BITMAP:
|
||||||
link.StartMessage(AS_DELETE_BITMAP);
|
// Attached Data:
|
||||||
link.Attach<int32>(fServerToken);
|
// 1) int32 server token
|
||||||
link.FlushWithReply(code);
|
link.StartMessage(AS_DELETE_BITMAP);
|
||||||
if (code == SERVER_FALSE) {
|
link.Attach<int32>(fServerToken);
|
||||||
// TODO: Find out if "SERVER_FALSE if the buffer
|
link.Flush();
|
||||||
// was already deleted" is true. If not, maybe we
|
|
||||||
// need to take additional action.
|
delete_area(fArea);
|
||||||
}
|
fArea = -1;
|
||||||
fArea = -1;
|
fServerToken = -1;
|
||||||
fServerToken = -1;
|
|
||||||
}
|
|
||||||
fBasePtr = NULL;
|
|
||||||
}
|
}
|
||||||
|
fBasePtr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// AssertPtr
|
|
||||||
/*! \brief ???
|
|
||||||
*/
|
|
||||||
void
|
void
|
||||||
BBitmap::AssertPtr()
|
BBitmap::AssertPtr()
|
||||||
{
|
{
|
||||||
|
// TODO: what's this supposed to do?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user