From cb80e15b3c577ab5e800b07024556f88b823f0f8 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Sat, 14 May 2005 13:22:26 +0000 Subject: [PATCH] ServerWindow is no more a ServerApp's friend. Some cleanups. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12663 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/ServerApp.cpp | 29 ++++++++++++++++++ src/servers/app/ServerApp.h | 20 +++++++++---- src/servers/app/ServerWindow.cpp | 50 +++++++------------------------- 3 files changed, 53 insertions(+), 46 deletions(-) diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index 12e3bad400..5376b3fa2f 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -1956,6 +1956,14 @@ ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg) } } + +int32 +ServerApp::CountBitmaps() const +{ + return fBitmapList ? fBitmapList->CountItems() : 0; +} + + /*! \brief Looks up a ServerApp's ServerBitmap in its list \param token ID token of the bitmap to find @@ -1975,6 +1983,27 @@ ServerApp::FindBitmap(int32 token) const } +int32 +ServerApp::CountPictures() const +{ + return fPictureList ? fPictureList->CountItems() : 0; +} + + +ServerPicture * +ServerApp::FindPicture(int32 token) const +{ + ServerPicture *picture; + for (int32 i = 0; i < fPictureList->CountItems(); i++) { + picture = static_cast(fPictureList->ItemAt(i)); + if (picture && picture->GetToken() == token) + return picture; + } + + return NULL; +} + + team_id ServerApp::ClientTeamID() const { diff --git a/src/servers/app/ServerApp.h b/src/servers/app/ServerApp.h index 768cd73060..dc2e90b067 100644 --- a/src/servers/app/ServerApp.h +++ b/src/servers/app/ServerApp.h @@ -40,6 +40,7 @@ class BList; class DisplayDriver; class LinkMsgReader; class LinkMsgSender; +class ServerPicture; class ServerCursor; class ServerBitmap; @@ -74,18 +75,22 @@ public: void SetAppCursor(void); - ServerBitmap *FindBitmap(int32 token) const; - team_id ClientTeamID() const; thread_id MonitorThreadID() const; + const char *Title() const { return fSignature.String(); } + + int32 CountBitmaps() const; + ServerBitmap *FindBitmap(int32 token) const; + + int32 CountPictures() const; + ServerPicture *FindPicture(int32 token) const; + + AreaPool *AppAreaPool() { return fSharedMem; } + FMWList fAppFMWList; - const char *Title() const { return fSignature.String(); } - private: - friend class ServerWindow; - void DispatchMessage(int32 code, LinkMsgReader &link); static int32 MonitorApp(void *data); @@ -107,6 +112,9 @@ private: LinkMsgReader *fMsgReader; LinkMsgSender *fMsgSender; + // TODO: + // - Are really Bitmaps and Pictures stored per application and not globally ? + // - As we reference these stuff by token, what about putting them in hash tables ? BList *fSWindowList, *fBitmapList, *fPictureList; diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index d6fd6228e8..d04e8413a3 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -1039,25 +1039,10 @@ void ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link) } // search for a picture with the specified token. - ServerPicture *sp = NULL; - int32 i = 0; - while(1) - { - sp=static_cast(cl->fServerWin->fServerApp->fPictureList->ItemAt(i++)); - if (!sp) - break; - - if(sp->GetToken() == pictureToken) - { - //cl->clipToPicture = sp; - - // TODO: Increase that picture's reference count.(~ allocate a picture) - break; - } - } - - // avoid compiler warning - i = 0; + ServerPicture *sp = cl->fServerWin->fServerApp->FindPicture(pictureToken); + // TODO: Increase that picture's reference count.(~ allocate a picture) + if (sp == NULL) + break; // we have a new picture to clip to, so rebuild our full region if(cl->clipToPicture) @@ -1102,26 +1087,11 @@ void ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link) link.Read(&pictureToken); link.Read(&where); - ServerPicture *sp = NULL; - int32 i = 0; - - while(1) - { - sp= static_cast(cl->fServerWin->fServerApp->fPictureList->ItemAt(i++)); - if (!sp) - break; - - if(sp->GetToken() == pictureToken) - { - //cl->clipToPicture = sp; - - // TODO: Increase that picture's reference count.(~ allocate a picture) - break; - } - } - // avoid compiler warning - i = 0; - + // TODO: Increase that picture's reference count.(~ allocate a picture) + ServerPicture *sp = cl->fServerWin->fServerApp->FindPicture(pictureToken); + if (sp == NULL) + break; + // if a picture has been found... if(cl->clipToPicture) { @@ -2023,7 +1993,7 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link) // This is a very special case in the sense that when ServerMemIO is used for this // purpose, it will be set to NOT automatically free the memory which it had // requested. This is the server's job once the message has been dispatched. - fServerApp->fSharedMem->ReleaseBuffer(msgpointer); + fServerApp->AppAreaPool()->ReleaseBuffer(msgpointer); break; }