Added ServerApp code for BBitmap handling
Added some support functions to ServerBitmap BitmapManager now adds ID tokens to ServerBitmaps git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2898 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -129,6 +129,13 @@ ServerBitmap * BitmapManager::CreateBitmap(BRect bounds, color_space space, int3
|
|||||||
}
|
}
|
||||||
bmp->_area=area_for(bmpbuffer);
|
bmp->_area=area_for(bmpbuffer);
|
||||||
bmp->_buffer=bmpbuffer;
|
bmp->_buffer=bmpbuffer;
|
||||||
|
bmp->_token=tokenizer.GetToken();
|
||||||
|
|
||||||
|
// calculate area offset
|
||||||
|
area_info ai;
|
||||||
|
get_area_info(bmp->_area,&ai);
|
||||||
|
bmp->_offset=bmpbuffer-(uint8*)ai.address;
|
||||||
|
|
||||||
bmplist->AddItem(bmp);
|
bmplist->AddItem(bmp);
|
||||||
release_sem(lock);
|
release_sem(lock);
|
||||||
return bmp;
|
return bmp;
|
||||||
|
|||||||
@@ -30,7 +30,9 @@
|
|||||||
#include <PortLink.h>
|
#include <PortLink.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <ServerProtocol.h>
|
||||||
|
|
||||||
|
#include "BitmapManager.h"
|
||||||
#include "CursorManager.h"
|
#include "CursorManager.h"
|
||||||
#include "Desktop.h"
|
#include "Desktop.h"
|
||||||
#include "DisplayDriver.h"
|
#include "DisplayDriver.h"
|
||||||
@@ -39,7 +41,6 @@
|
|||||||
#include "ServerWindow.h"
|
#include "ServerWindow.h"
|
||||||
#include "ServerCursor.h"
|
#include "ServerCursor.h"
|
||||||
#include "ServerBitmap.h"
|
#include "ServerBitmap.h"
|
||||||
#include "ServerProtocol.h"
|
|
||||||
#include "ServerConfig.h"
|
#include "ServerConfig.h"
|
||||||
#include "LayerData.h"
|
#include "LayerData.h"
|
||||||
|
|
||||||
@@ -248,7 +249,7 @@ int32 ServerApp::MonitorApp(void *data)
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
app->DispatchMessage(msgcode, msgbuffer);
|
app->_DispatchMessage(msgcode, msgbuffer);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -275,7 +276,7 @@ int32 ServerApp::MonitorApp(void *data)
|
|||||||
All attachments are placed in the buffer via a PortLink, so it will be a
|
All attachments are placed in the buffer via a PortLink, so it will be a
|
||||||
matter of casting and incrementing an index variable to access them.
|
matter of casting and incrementing an index variable to access them.
|
||||||
*/
|
*/
|
||||||
void ServerApp::DispatchMessage(int32 code, int8 *buffer)
|
void ServerApp::_DispatchMessage(int32 code, int8 *buffer)
|
||||||
{
|
{
|
||||||
int8 *index=buffer;
|
int8 *index=buffer;
|
||||||
LayerData ld;
|
LayerData ld;
|
||||||
@@ -350,6 +351,78 @@ void ServerApp::DispatchMessage(int32 code, int8 *buffer)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case AS_CREATE_BITMAP:
|
||||||
|
{
|
||||||
|
// Allocate a bitmap for an application
|
||||||
|
|
||||||
|
// Attached Data:
|
||||||
|
// 1) port_id reply port
|
||||||
|
// 2) BRect bounds
|
||||||
|
// 3) color_space space
|
||||||
|
// 4) int32 bitmap_flags
|
||||||
|
// 5) int32 bytes_per_row
|
||||||
|
// 6) int32 screen_id::id
|
||||||
|
|
||||||
|
// Reply Code: SERVER_TRUE
|
||||||
|
// Reply Data:
|
||||||
|
// 1) int32 server token
|
||||||
|
// 2) area_id id of the area in which the bitmap data resides
|
||||||
|
// 3) int32 area pointer offset used to calculate fBasePtr
|
||||||
|
|
||||||
|
// First, let's attempt to allocate the bitmap
|
||||||
|
port_id replyport=*((port_id*)index); index+=sizeof(port_id);
|
||||||
|
BRect r=*((BRect*)index); index+=sizeof(BRect);
|
||||||
|
color_space cs=*((color_space*)index); index+=sizeof(color_space);
|
||||||
|
int32 f=*((int32*)index); index+=sizeof(int32);
|
||||||
|
int32 bpr=*((int32*)index); index+=sizeof(int32);
|
||||||
|
|
||||||
|
screen_id s;
|
||||||
|
s.id=*((int32*)index);
|
||||||
|
|
||||||
|
ServerBitmap *sbmp=bitmapmanager->CreateBitmap(r,cs,f,bpr,s);
|
||||||
|
if(sbmp)
|
||||||
|
{
|
||||||
|
// list for doing faster lookups for a bitmap than what the BitmapManager
|
||||||
|
// can do.
|
||||||
|
_bmplist->AddItem(sbmp);
|
||||||
|
_applink->SetOpCode(SERVER_TRUE);
|
||||||
|
_applink->Attach(sbmp->Token());
|
||||||
|
_applink->Attach(sbmp->Area());
|
||||||
|
_applink->Attach(sbmp->AreaOffset());
|
||||||
|
_applink->Flush();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// alternatively, if something went wrong, we reply with SERVER_FALSE
|
||||||
|
write_port(replyport,SERVER_FALSE,NULL,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case AS_DELETE_BITMAP:
|
||||||
|
{
|
||||||
|
// Delete a bitmap's allocated memory
|
||||||
|
|
||||||
|
// Attached Data:
|
||||||
|
// 1) int32 reply port
|
||||||
|
// 2) int32 token
|
||||||
|
|
||||||
|
// Reply Code: SERVER_TRUE if successful,
|
||||||
|
// SERVER_FALSE if the buffer was already deleted or was not found
|
||||||
|
port_id replyport=*((port_id*)index); index+=sizeof(port_id);
|
||||||
|
|
||||||
|
ServerBitmap *sbmp=_FindBitmap(*((int32*)index));
|
||||||
|
if(sbmp)
|
||||||
|
{
|
||||||
|
_bmplist->RemoveItem(sbmp);
|
||||||
|
bitmapmanager->DeleteBitmap(sbmp);
|
||||||
|
write_port(replyport,SERVER_TRUE,NULL,0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
write_port(replyport,SERVER_FALSE,NULL,0);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
case AS_SET_SCREEN_MODE:
|
case AS_SET_SCREEN_MODE:
|
||||||
{
|
{
|
||||||
// Attached data
|
// Attached data
|
||||||
@@ -451,3 +524,20 @@ void ServerApp::DispatchMessage(int32 code, int8 *buffer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Looks up a ServerApp's ServerBitmap in its list
|
||||||
|
\param token ID token of the bitmap to find
|
||||||
|
\return The bitmap having that ID or NULL if not found
|
||||||
|
*/
|
||||||
|
ServerBitmap *ServerApp::_FindBitmap(int32 token)
|
||||||
|
{
|
||||||
|
ServerBitmap *temp;
|
||||||
|
for(int32 i=0; i<_bmplist->CountItems();i++)
|
||||||
|
{
|
||||||
|
temp=(ServerBitmap*)_bmplist->ItemAt(i);
|
||||||
|
if(temp && temp->Token()==token)
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|||||||
@@ -71,7 +71,8 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
friend AppServer;
|
friend AppServer;
|
||||||
friend ServerWindow;
|
friend ServerWindow;
|
||||||
void DispatchMessage(int32 code, int8 *buffer);
|
void _DispatchMessage(int32 code, int8 *buffer);
|
||||||
|
ServerBitmap *_FindBitmap(int32 token);
|
||||||
|
|
||||||
port_id _sender,_receiver;
|
port_id _sender,_receiver;
|
||||||
BString _signature;
|
BString _signature;
|
||||||
|
|||||||
@@ -57,6 +57,9 @@ public:
|
|||||||
*/
|
*/
|
||||||
area_id Area(void) { return _area; }
|
area_id Area(void) { return _area; }
|
||||||
|
|
||||||
|
// Returns the offset of the bitmap in its area
|
||||||
|
int32 AreaOffset(void) { return _offset; }
|
||||||
|
|
||||||
//! Returns the bitmap's buffer
|
//! Returns the bitmap's buffer
|
||||||
uint8 *Bits(void) { return _buffer; }
|
uint8 *Bits(void) { return _buffer; }
|
||||||
uint32 BitsLength(void);
|
uint32 BitsLength(void);
|
||||||
@@ -82,6 +85,9 @@ public:
|
|||||||
//! Returns whether the bitmap is valid
|
//! Returns whether the bitmap is valid
|
||||||
bool InitCheck(void) { return _initialized; }
|
bool InitCheck(void) { return _initialized; }
|
||||||
|
|
||||||
|
//! Returns the identifier token for the bitmap
|
||||||
|
int32 Token(void) { return _token; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend BitmapManager;
|
friend BitmapManager;
|
||||||
|
|
||||||
@@ -104,6 +110,8 @@ protected:
|
|||||||
color_space _space;
|
color_space _space;
|
||||||
int32 _flags;
|
int32 _flags;
|
||||||
int _bpp;
|
int _bpp;
|
||||||
|
int32 _token;
|
||||||
|
int32 _offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user