From 1c33148d102b4aff988cb557510caa4be5c6b080 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Tue, 3 Jan 2006 12:44:29 +0000 Subject: [PATCH] Implemented handlers needed for Begin/EndPicture, and a handler for DrawPicture(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15816 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/ServerApp.cpp | 25 ++++++++++----- src/servers/app/ServerWindow.cpp | 53 +++++++++++++++++++++++++++++--- 2 files changed, 66 insertions(+), 12 deletions(-) diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index d7222c6e5c..8d49479658 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -726,27 +726,37 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link) STRACE(("ServerApp %s: Create Picture unimplemented\n", Signature())); break; } +#endif case AS_DELETE_PICTURE: { - // TODO: Implement AS_DELETE_PICTURE - STRACE(("ServerApp %s: Delete Picture unimplemented\n", Signature())); + STRACE(("ServerApp %s: Delete Picture\n", Signature())); + int32 token; + if (link.Read(&token) == B_OK) + DeletePicture(token); + break; } +#if 0 case AS_CLONE_PICTURE: { // TODO: Implement AS_CLONE_PICTURE STRACE(("ServerApp %s: Clone Picture unimplemented\n", Signature())); break; } + case AS_DOWNLOAD_PICTURE: { - // TODO; Implement AS_DOWNLOAD_PICTURE STRACE(("ServerApp %s: Download Picture unimplemented\n", Signature())); + int32 token; + link.Read(&token); + ServerPicture *picture = App()->FindPicture(token); + if (picture != NULL) { + link.StartMessage(B_OK); + } else + link.StartMessage(B_ERROR); - // What is this particular function call for, anyway? + link.Flush(); - // DW: I think originally it might have been to support - // the undocumented Flatten function. break; } #endif @@ -2546,7 +2556,8 @@ ServerApp::CreatePicture(int32 *token) fPictureList.AddItem(picture); if (token != NULL) *token = picture->Token(); - } + } + return picture; } diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index 5141534f3a..87460da965 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -2155,17 +2155,60 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code, BPrivate::LinkReceiver &li free(string); break; } -#if 0 + case AS_LAYER_BEGIN_PICTURE: - CRITICAL("AS_LAYER_BEGIN_PICTURE not implemented\n"); + { + DTRACE(("ServerWindow %s: Message AS_LAYER_BEGIN_PICTURE\n", Title())); + ServerPicture *picture = App()->CreatePicture(); + fCurrentLayer->SetPicture(picture); break; + } + case AS_LAYER_APPEND_TO_PICTURE: - CRITICAL("AS_LAYER_APPEND_TO_PICTURE not implemented\n"); + { + DTRACE(("ServerWindow %s: Message AS_LAYER_APPEND_TO_PICTURE\n", Title())); + + int32 pictureToken; + link.Read(&pictureToken); + + fCurrentLayer->SetPicture(App()->FindPicture(pictureToken)); + // we don't care if it's NULL break; + } + case AS_LAYER_END_PICTURE: - CRITICAL("AS_LAYER_END_PICTURE not implemented\n"); + { + DTRACE(("ServerWindow %s: Message AS_LAYER_END_PICTURE\n", Title())); + + ServerPicture *picture = fCurrentLayer->Picture(); + if (picture != NULL) { + fCurrentLayer->SetPicture(NULL); + fLink.StartMessage(B_OK); + fLink.Attach(picture->Token()); + } else + fLink.StartMessage(B_ERROR); + + fLink.Flush(); break; -#endif + } + + case AS_LAYER_DRAW_PICTURE: + { + int32 token; + if (link.Read(&token) == B_OK) { + BPoint where; + link.Read(&where); + + ServerPicture *picture = App()->FindPicture(token); + if (picture != NULL) { + fCurrentLayer->ConvertToScreenForDrawing(&where); + fCurrentLayer->CurrentState()->SetPenLocation(where); + picture->Play(fCurrentLayer); + } + } + break; + } + default: printf("ServerWindow %s received unexpected code - message offset %ld\n", Title(), code - B_OK);