Files
haiku-beta6/src/tests/kits/interface/NewRegion/ServerLink.cpp
T
Stefano Ceccherini 3edb84e5ed DirectWindow and ServerLink updated to the new ClipRegion, as I'm tired to edit them every time. Only for the test app.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15787 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-02 10:02:51 +00:00

94 lines
1.6 KiB
C++

/*
* Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Pahtz <[email protected]>
* Axel Dörfler, [email protected]
*/
/** Class for low-overhead port-based messaging */
#include <stdlib.h>
#include <string.h>
#include <new>
#include <Region.h>
#include <Shape.h>
#include <ClipRegion.h>
#include <ServerLink.h>
#include <ServerProtocol.h>
namespace BPrivate {
ServerLink::ServerLink()
{
}
ServerLink::~ServerLink()
{
}
status_t
ServerLink::ReadRegion(BRegion *region)
{
return region->fRegion->ReadFromLink(*this);
}
status_t
ServerLink::AttachRegion(const BRegion &region)
{
return region.fRegion->WriteToLink(*this);
}
status_t
ServerLink::ReadShape(BShape *shape)
{
int32 opCount, ptCount;
fReceiver->Read(&opCount, sizeof(int32));
fReceiver->Read(&ptCount, sizeof(int32));
uint32 opList[opCount];
fReceiver->Read(opList, opCount * sizeof(uint32));
BPoint ptList[ptCount];
fReceiver->Read(ptList, ptCount * sizeof(BPoint));
shape->SetData(opCount, ptCount, opList, ptList);
return B_OK;
}
status_t
ServerLink::AttachShape(BShape &shape)
{
int32 opCount, ptCount;
uint32 *opList;
BPoint *ptList;
shape.GetData(&opCount, &ptCount, &opList, &ptList);
fSender->Attach(&opCount, sizeof(int32));
fSender->Attach(&ptCount, sizeof(int32));
fSender->Attach(opList, opCount * sizeof(uint32));
return fSender->Attach(ptList, ptCount * sizeof(BPoint));
}
status_t
ServerLink::FlushWithReply(int32 &code)
{
status_t status = Flush(B_INFINITE_TIMEOUT, true);
if (status < B_OK)
return status;
return GetNextMessage(code);
}
} // namespace BPrivate