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:
@@ -78,6 +78,8 @@ virtual void _ReservedShape4();
|
|||||||
friend class TPicture;
|
friend class TPicture;
|
||||||
friend class BView;
|
friend class BView;
|
||||||
friend class BFont;
|
friend class BFont;
|
||||||
|
friend class BPortLink;
|
||||||
|
|
||||||
void GetData(int32 *opCount, int32 *ptCount, uint32 **opList, BPoint **ptList);
|
void GetData(int32 *opCount, int32 *ptCount, uint32 **opList, BPoint **ptList);
|
||||||
void SetData(int32 opCount, int32 ptCount, uint32 *opList, BPoint *ptList);
|
void SetData(int32 opCount, int32 ptCount, uint32 *opList, BPoint *ptList);
|
||||||
void InitData();
|
void InitData();
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ public:
|
|||||||
status_t Attach(const void *data, ssize_t size);
|
status_t Attach(const void *data, ssize_t size);
|
||||||
status_t AttachString(const char *string);
|
status_t AttachString(const char *string);
|
||||||
status_t AttachRegion(const BRegion ®ion);
|
status_t AttachRegion(const BRegion ®ion);
|
||||||
|
status_t AttachShape(BShape &shape);
|
||||||
template <class Type> status_t Attach(const Type& data)
|
template <class Type> status_t Attach(const Type& data)
|
||||||
{
|
{
|
||||||
return Attach(&data, sizeof(Type));
|
return Attach(&data, sizeof(Type));
|
||||||
@@ -77,6 +78,7 @@ public:
|
|||||||
status_t Read(void *data, ssize_t size);
|
status_t Read(void *data, ssize_t size);
|
||||||
status_t ReadString(char **string);
|
status_t ReadString(char **string);
|
||||||
status_t ReadRegion(BRegion *region);
|
status_t ReadRegion(BRegion *region);
|
||||||
|
status_t ReadShape(BShape *shape);
|
||||||
template <class T> status_t Read(T *data)
|
template <class T> status_t Read(T *data)
|
||||||
{
|
{
|
||||||
return fReader->Read(data,sizeof(T));
|
return fReader->Read(data,sizeof(T));
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <new>
|
#include <new>
|
||||||
#include <Region.h>
|
#include <Region.h>
|
||||||
|
#include <Shape.h>
|
||||||
|
|
||||||
#include <ServerProtocol.h>
|
#include <ServerProtocol.h>
|
||||||
#include <PortLink.h>
|
#include <PortLink.h>
|
||||||
@@ -122,3 +123,33 @@ status_t BPortLink::AttachRegion(const BRegion ®ion)
|
|||||||
fSender->Attach(®ion.bound, sizeof(clipping_rect));
|
fSender->Attach(®ion.bound, sizeof(clipping_rect));
|
||||||
return fSender->Attach(region.data, region.count * 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)
|
if(code!=SERVER_TRUE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// This is going to be dog slow, but it'll do for now
|
for(int32 i = 0; i < numChars; i++)
|
||||||
char *buffer=NULL;
|
link.ReadShape(glyphShapeArray[i]);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -518,7 +518,7 @@ void BShape::GetData(int32 *opCount, int32 *ptCount, uint32 **opList,
|
|||||||
*opCount = data->opCount;
|
*opCount = data->opCount;
|
||||||
*ptCount = data->ptCount;
|
*ptCount = data->ptCount;
|
||||||
*opList = data->opList;
|
*opList = data->opList;
|
||||||
*ptList =data->ptList;
|
*ptList = data->ptList;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void BShape::SetData(int32 opCount, int32 ptCount, uint32 *opList,
|
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
|
// 9) port_id - reply port
|
||||||
|
|
||||||
// Returns:
|
// Returns:
|
||||||
// 1) size_t - message size
|
// 1) BShape with glyph shape
|
||||||
// 2) flattened BMessage containing archived BShape
|
|
||||||
// numChars times
|
// numChars times
|
||||||
|
|
||||||
uint16 famid, styid;
|
uint16 famid, styid;
|
||||||
@@ -1735,22 +1734,9 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
|
|||||||
BShape **shapes = font.GetGlyphShapes(charArray, numChars);
|
BShape **shapes = font.GetGlyphShapes(charArray, numChars);
|
||||||
if (shapes) {
|
if (shapes) {
|
||||||
replylink.StartMessage(SERVER_TRUE);
|
replylink.StartMessage(SERVER_TRUE);
|
||||||
for (int32 i = 0; i < numChars; i++) {
|
for (int32 i = 0; i < numChars; i++)
|
||||||
BMessage message;
|
replylink.AttachShape(*shapes[i]);
|
||||||
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);
|
|
||||||
}
|
|
||||||
replylink.Flush();
|
replylink.Flush();
|
||||||
} else {
|
} else {
|
||||||
replylink.StartMessage(SERVER_FALSE);
|
replylink.StartMessage(SERVER_FALSE);
|
||||||
|
|||||||
Reference in New Issue
Block a user