diff --git a/src/kits/interface/View.cpp b/src/kits/interface/View.cpp index 6f1c98b38b..275852a9e7 100644 --- a/src/kits/interface/View.cpp +++ b/src/kits/interface/View.cpp @@ -1948,21 +1948,7 @@ BView::TruncateString(BString *in_out, uint32 mode, float width) const void BView::ClipToPicture(BPicture *picture, BPoint where, bool sync) { - if (!picture) - return; - - if (do_owner_check()) { - owner->fLink->StartMessage(AS_LAYER_CLIP_TO_PICTURE); - owner->fLink->Attach(picture->token); - owner->fLink->Attach(where); - - if (sync) - owner->fLink->Flush(); - - fState->flags |= B_VIEW_CLIP_REGION_BIT; - } - - fState->archivingFlags |= B_VIEW_CLIP_REGION_BIT; + DoPictureClip(picture, where, false, sync); } @@ -1970,21 +1956,7 @@ void BView::ClipToInversePicture(BPicture *picture, BPoint where, bool sync) { - if (!picture) - return; - - if (do_owner_check()) { - owner->fLink->StartMessage(AS_LAYER_CLIP_TO_INVERSE_PICTURE); - owner->fLink->Attach(picture->token); - owner->fLink->Attach(where); - - if (sync) - owner->fLink->Flush(); - - fState->flags |= B_VIEW_CLIP_REGION_BIT; - } - - fState->archivingFlags |= B_VIEW_CLIP_REGION_BIT; + DoPictureClip(picture, where, true, sync); } //--------------------------------------------------------------------------- @@ -3687,6 +3659,31 @@ BView::setOwner(BWindow *theOwner) } +void +BView::DoPictureClip(BPicture *picture, BPoint where, + bool invert, bool sync) +{ + if (!picture) + return; + + if (do_owner_check()) { + owner->fLink->StartMessage(AS_LAYER_CLIP_TO_PICTURE); + owner->fLink->Attach(picture->token); + owner->fLink->Attach(where); + owner->fLink->Attach(invert); + + // TODO: I think that "sync" means another thing here: + // the bebook, at least, says so. + if (sync) + owner->fLink->Flush(); + + fState->flags |= B_VIEW_CLIP_REGION_BIT; + } + + fState->archivingFlags |= B_VIEW_CLIP_REGION_BIT; +} + + bool BView::removeSelf() { diff --git a/src/servers/app/Layer.cpp b/src/servers/app/Layer.cpp index 31dee32cc8..67a5d7ee93 100644 --- a/src/servers/app/Layer.cpp +++ b/src/servers/app/Layer.cpp @@ -89,9 +89,6 @@ Layer::Layer(BRect frame, const char* name, int32 token, fClipReg (&fVisible), - clipToPicture (NULL), - clipToPictureInverse(false), - fServerWin (NULL), fName (new BString(name ? name : B_EMPTY_STRING)), fViewToken (token), @@ -135,11 +132,6 @@ Layer::~Layer(void) // fServerWin->RemoveChild(fDriver); // delete fDriver; - - if (clipToPicture) { - // TODO: allocate and release a ServerPicture Object. - } - delete clipToPicture; } /*! @@ -468,14 +460,6 @@ Layer::RebuildFullRegion(void) fFull.IntersectWith(userClipping); } while ((ld = ld->prevState)); - - // clip to user picture region - if (clipToPicture) { - if(clipToPictureInverse) - fFull.Exclude( clipToPicture ); - else - fFull.IntersectWith( clipToPicture ); - } } // StartRebuildRegions diff --git a/src/servers/app/Layer.h b/src/servers/app/Layer.h index d1faf07caa..7d221571a1 100644 --- a/src/servers/app/Layer.h +++ b/src/servers/app/Layer.h @@ -219,9 +219,6 @@ class Layer { BRegion* fClipReg; - BRegion* clipToPicture; - bool clipToPictureInverse; - ServerWindow* fServerWin; BString* fName; int32 fViewToken; diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index 2cb6153809..e5059ea428 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -46,6 +46,7 @@ #include "ServerWindow.h" #include "ServerApp.h" #include "ServerProtocol.h" +#include "ServerPicture.h" #include "WinBorder.h" #include "TokenHandler.h" #include "Utils.h" @@ -73,42 +74,6 @@ # define DTRACE(x) ; #endif -//------------------------------------------------------------------------------ - -template Type -read_from_buffer(int8 **_buffer) -{ - Type *typedBuffer = (Type *)(*_buffer); - Type value = *typedBuffer; - - typedBuffer++; - *_buffer = (int8 *)(typedBuffer); - - return value; -} -//------------------------------------------------------------------------------ -/* -static int8 *read_pattern_from_buffer(int8 **_buffer) -{ - int8 *pattern = *_buffer; - - *_buffer += AS_PATTERN_SIZE; - - return pattern; -} -*/ -//------------------------------------------------------------------------------ -template void -write_to_buffer(int8 **_buffer, Type value) -{ - Type *typedBuffer = (Type *)(*_buffer); - - *typedBuffer = value; - typedBuffer++; - - *_buffer = (int8 *)(typedBuffer); -} - // #pragma mark - @@ -917,86 +882,39 @@ ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link) case AS_LAYER_CLIP_TO_PICTURE: { DTRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_PICTURE: Layer: %s\n",fName, fCurrentLayer->fName->String())); - // TODO: you are not allowed to use Layer regions here!!! // If there is no other way, then first lock RootLayer object first. - + // TODO: Watch out for the coordinate system in AS_LAYER_CLIP_TO_PICTURE int32 pictureToken; BPoint where; + bool inverse = false; link.Read(&pictureToken); link.Read(&where); - - - BRegion reg; - bool redraw = false; - - // if we had a picture to clip to, include the FULL visible region(if any) in the area to be redrawn - // in other words: invalidate what ever is visible for this layer and his children. - if (fCurrentLayer->clipToPicture && fCurrentLayer->fFullVisible.CountRects() > 0) - { - reg.Include(&fCurrentLayer->fFullVisible); - redraw = true; - } - - // search for a picture with the specified token. - ServerPicture *sp = 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 (fCurrentLayer->clipToPicture) { - fCurrentLayer->clipToPictureInverse = false; - fCurrentLayer->RebuildFullRegion(); - } - - // we need to rebuild the visible region, we may have a valid one. - if (fCurrentLayer->fParent && !fCurrentLayer->fHidden) { - //fCurrentLayer->fParent->RebuildChildRegions(fCurrentLayer->fFull.Frame(), fCurrentLayer); - } else { - // will this happen? Maybe... - //fCurrentLayer->RebuildRegions(fCurrentLayer->fFull.Frame()); - } - - // include our full visible region in the region to be redrawn - if (!fCurrentLayer->fHidden && (fCurrentLayer->fFullVisible.CountRects() > 0)) { - reg.Include(&(fCurrentLayer->fFullVisible)); - redraw = true; - } - - // redraw if we previously had or if we have acquired a picture to clip to. - // TODO: Are you sure about triggering a redraw? - if (redraw) - myRootLayer->GoRedraw(fCurrentLayer, reg); - - break; - } - case AS_LAYER_CLIP_TO_INVERSE_PICTURE: - { - DTRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_INVERSE_PICTURE: Layer: %s\n",fName, fCurrentLayer->fName->String())); - - // TODO: Watch out for the coordinate system in AS_LAYER_CLIP_TO_INVERSE_PICTURE - int32 pictureToken; - BPoint where; - - link.Read(&pictureToken); - link.Read(&where); - - // TODO: Increase that picture's reference count.(~ allocate a picture) - ServerPicture *sp = fServerApp->FindPicture(pictureToken); - if (sp == NULL) - break; + link.Read(&inverse); - // if a picture has been found... - if (fCurrentLayer->clipToPicture) { - fCurrentLayer->clipToPictureInverse = true; - fCurrentLayer->RebuildFullRegion(); - //fCurrentLayer->RequestDraw(fCurrentLayer->clipToPicture->Frame()); - } + // search for a picture with the specified token. + ServerPicture *picture = fServerApp->FindPicture(pictureToken); + // TODO: Increase that picture's reference count.(~ allocate a picture) + if (picture == NULL) + break; + + BRegion region; + // TODO: I think we also need the BView's token + // I think PictureToRegion would fit better into the Layer class (?) + if (PictureToRegion(picture, region, inverse, where) < B_OK) + break; + + fCurrentLayer->fLayerData->SetClippingRegion(region); + + fCurrentLayer->RebuildFullRegion(); + if (!(fCurrentLayer->IsHidden())) + myRootLayer->GoInvalidate(fCurrentLayer, fCurrentLayer->fFull); + break; } + case AS_LAYER_GET_CLIP_REGION: { DTRACE(("ServerWindow %s: Message AS_LAYER_GET_CLIP_REGION: Layer: %s\n",fName, fCurrentLayer->fName->String())); @@ -2166,3 +2084,12 @@ ServerWindow::SendMessageToClient(const BMessage* msg, int32 target, bool usePre delete[] buffer; } + +status_t +ServerWindow::PictureToRegion(ServerPicture *picture, BRegion ®ion, + bool inverse, BPoint where) +{ + fprintf(stderr, "ServerWindow::PictureToRegion() not implemented\n"); + region.MakeEmpty(); + return B_ERROR; +} diff --git a/src/servers/app/ServerWindow.h b/src/servers/app/ServerWindow.h index bea7d2dba1..ed88f5cb8e 100644 --- a/src/servers/app/ServerWindow.h +++ b/src/servers/app/ServerWindow.h @@ -51,6 +51,7 @@ class WinBorder; class Workspace; class RootLayer; class Layer; +class ServerPicture; #define AS_UPDATE_DECORATOR 'asud' #define AS_UPDATE_COLORS 'asuc' @@ -133,7 +134,11 @@ private: protected: friend class WinBorder; friend class Layer; - + // TODO: Move me elsewhere + status_t PictureToRegion(ServerPicture *picture, + BRegion &, + bool inverse, + BPoint where); char fName[50]; ServerApp* fServerApp;