Implemented BPortLink::AttachShape and BPortLink::ReadShape and used them for passing the shapes in AS_GET_GLYPH_SHAPES.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12215 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
ebf8af66c9
commit
c2da902f2e
@ -78,6 +78,8 @@ virtual void _ReservedShape4();
|
||||
friend class TPicture;
|
||||
friend class BView;
|
||||
friend class BFont;
|
||||
friend class BPortLink;
|
||||
|
||||
void GetData(int32 *opCount, int32 *ptCount, uint32 **opList, BPoint **ptList);
|
||||
void SetData(int32 opCount, int32 ptCount, uint32 *opList, BPoint *ptList);
|
||||
void InitData();
|
||||
|
@ -68,6 +68,7 @@ public:
|
||||
status_t Attach(const void *data, ssize_t size);
|
||||
status_t AttachString(const char *string);
|
||||
status_t AttachRegion(const BRegion ®ion);
|
||||
status_t AttachShape(BShape &shape);
|
||||
template <class Type> status_t Attach(const Type& data)
|
||||
{
|
||||
return Attach(&data, sizeof(Type));
|
||||
@ -77,6 +78,7 @@ public:
|
||||
status_t Read(void *data, ssize_t size);
|
||||
status_t ReadString(char **string);
|
||||
status_t ReadRegion(BRegion *region);
|
||||
status_t ReadShape(BShape *shape);
|
||||
template <class T> status_t Read(T *data)
|
||||
{
|
||||
return fReader->Read(data,sizeof(T));
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <string.h>
|
||||
#include <new>
|
||||
#include <Region.h>
|
||||
#include <Shape.h>
|
||||
|
||||
#include <ServerProtocol.h>
|
||||
#include <PortLink.h>
|
||||
@ -122,3 +123,33 @@ status_t BPortLink::AttachRegion(const BRegion ®ion)
|
||||
fSender->Attach(®ion.bound, sizeof(clipping_rect));
|
||||
return fSender->Attach(region.data, region.count * sizeof(clipping_rect));
|
||||
}
|
||||
|
||||
status_t BPortLink::ReadShape(BShape *shape)
|
||||
{
|
||||
int32 opCount, ptCount;
|
||||
fReader->Read(&opCount, sizeof(int32));
|
||||
fReader->Read(&ptCount, sizeof(int32));
|
||||
|
||||
uint32 opList[opCount];
|
||||
fReader->Read(opList, opCount * sizeof(uint32));
|
||||
|
||||
BPoint ptList[ptCount];
|
||||
fReader->Read(ptList, ptCount * sizeof(BPoint));
|
||||
|
||||
shape->SetData(opCount, ptCount, opList, ptList);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
status_t BPortLink::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));
|
||||
}
|
||||
|
@ -1163,32 +1163,8 @@ BFont::GetGlyphShapes(const char charArray[], int32 numChars, BShape *glyphShape
|
||||
if(code!=SERVER_TRUE)
|
||||
return;
|
||||
|
||||
// This is going to be dog slow, but it'll do for now
|
||||
char *buffer=NULL;
|
||||
size_t buffersize=0;
|
||||
|
||||
for(int32 i=0; i<numChars; i++)
|
||||
{
|
||||
size_t msgsize;
|
||||
|
||||
link.Read<size_t>(&msgsize);
|
||||
if(msgsize>buffersize)
|
||||
{
|
||||
delete buffer;
|
||||
buffer=new char[msgsize];
|
||||
}
|
||||
|
||||
link.Read(buffer,msgsize);
|
||||
|
||||
BMessage shapemsg;
|
||||
shapemsg.Unflatten(buffer);
|
||||
|
||||
BShape shape(&shapemsg);
|
||||
glyphShapeArray[i]->Clear();
|
||||
glyphShapeArray[i]->AddShape(&shape);
|
||||
}
|
||||
|
||||
delete buffer;
|
||||
for(int32 i = 0; i < numChars; i++)
|
||||
link.ReadShape(glyphShapeArray[i]);
|
||||
}
|
||||
|
||||
|
||||
|
@ -518,7 +518,7 @@ void BShape::GetData(int32 *opCount, int32 *ptCount, uint32 **opList,
|
||||
*opCount = data->opCount;
|
||||
*ptCount = data->ptCount;
|
||||
*opList = data->opList;
|
||||
*ptList =data->ptList;
|
||||
*ptList = data->ptList;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BShape::SetData(int32 opCount, int32 ptCount, uint32 *opList,
|
||||
|
@ -1699,8 +1699,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
|
||||
// 9) port_id - reply port
|
||||
|
||||
// Returns:
|
||||
// 1) size_t - message size
|
||||
// 2) flattened BMessage containing archived BShape
|
||||
// 1) BShape with glyph shape
|
||||
// numChars times
|
||||
|
||||
uint16 famid, styid;
|
||||
@ -1735,22 +1734,9 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
|
||||
BShape **shapes = font.GetGlyphShapes(charArray, numChars);
|
||||
if (shapes) {
|
||||
replylink.StartMessage(SERVER_TRUE);
|
||||
for (int32 i = 0; i < numChars; i++) {
|
||||
BMessage message;
|
||||
if (shapes[i]->Archive(&message) != B_OK)
|
||||
break;
|
||||
delete shapes[i];
|
||||
|
||||
size_t size = message.FlattenedSize();
|
||||
char *buffer = new char[size];
|
||||
if (message.Flatten(buffer, size) != B_OK) {
|
||||
delete buffer;
|
||||
break;
|
||||
}
|
||||
|
||||
replylink.Attach<size_t>(size);
|
||||
replylink.Attach(buffer, size);
|
||||
}
|
||||
for (int32 i = 0; i < numChars; i++)
|
||||
replylink.AttachShape(*shapes[i]);
|
||||
|
||||
replylink.Flush();
|
||||
} else {
|
||||
replylink.StartMessage(SERVER_FALSE);
|
||||
|
Loading…
Reference in New Issue
Block a user