Added support for sending BRegions

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10943 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adi Oanca 2005-01-22 09:48:10 +00:00
parent 2a8a80a764
commit 27c5631fa3
2 changed files with 18 additions and 0 deletions

View File

@ -67,6 +67,7 @@ public:
status_t Attach(const void *data, ssize_t size);
status_t AttachString(const char *string);
status_t AttachRegion(const BRegion &region);
template <class Type> status_t Attach(const Type& data)
{
return Attach(&data, sizeof(Type));
@ -75,6 +76,7 @@ public:
status_t GetNextReply(int32 *code, bigtime_t timeout = B_INFINITE_TIMEOUT);
status_t Read(void *data, ssize_t size);
status_t ReadString(char **string);
status_t ReadRegion(BRegion *region);
template <class T> status_t Read(T *data)
{
return fReader->Read(data,sizeof(T));

View File

@ -27,6 +27,7 @@
#include <stdlib.h>
#include <string.h>
#include <new>
#include <Region.h>
#include <ServerProtocol.h>
#include <PortLink.h>
@ -106,3 +107,18 @@ status_t BPortLink::AttachString(const char *string)
{
return fSender->AttachString(string);
}
status_t BPortLink::ReadRegion(BRegion *region)
{
fReader->Read(&region->count, sizeof(long));
fReader->Read(&region->bound, sizeof(clipping_rect));
region->set_size(region->count + 1);
return fReader->Read(region->data, region->count * sizeof(clipping_rect));
}
status_t BPortLink::AttachRegion(const BRegion &region)
{
fSender->Attach(&region.count, sizeof(long));
fSender->Attach(&region.bound, sizeof(clipping_rect));
return fSender->Attach(region.data, region.count * sizeof(clipping_rect));
}