diff --git a/headers/os/interface/Shape.h b/headers/os/interface/Shape.h index a80517051f..6ff455b19d 100644 --- a/headers/os/interface/Shape.h +++ b/headers/os/interface/Shape.h @@ -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(); diff --git a/headers/private/app/PortLink.h b/headers/private/app/PortLink.h index ce990a2538..edfc95465e 100644 --- a/headers/private/app/PortLink.h +++ b/headers/private/app/PortLink.h @@ -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 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 status_t Read(T *data) { return fReader->Read(data,sizeof(T)); diff --git a/src/kits/app/PortLink.cpp b/src/kits/app/PortLink.cpp index 1978ea293d..4e1afea891 100644 --- a/src/kits/app/PortLink.cpp +++ b/src/kits/app/PortLink.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -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)); +} diff --git a/src/kits/interface/Font.cpp b/src/kits/interface/Font.cpp index 4fbf5dd126..8670995a20 100644 --- a/src/kits/interface/Font.cpp +++ b/src/kits/interface/Font.cpp @@ -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(&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]); } diff --git a/src/kits/interface/Shape.cpp b/src/kits/interface/Shape.cpp index 303efda790..a977d79a9e 100644 --- a/src/kits/interface/Shape.cpp +++ b/src/kits/interface/Shape.cpp @@ -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, diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index d1dc500092..fd07da4239 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -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); - replylink.Attach(buffer, size); - } + for (int32 i = 0; i < numChars; i++) + replylink.AttachShape(*shapes[i]); + replylink.Flush(); } else { replylink.StartMessage(SERVER_FALSE);