Simplified code for BView::ClipToPicture() a lot (both server side and client side). Regions passed with that method should take the place of regions passed with BView::ConstrainClippingRegion(). Note that the needed server support hasn't yet been implemented.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12939 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2005-06-03 14:20:10 +00:00
parent b9b38bc7b2
commit 45ca1c948c
5 changed files with 65 additions and 155 deletions

View File

@ -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<int32>(picture->token);
owner->fLink->Attach<BPoint>(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<int32>(picture->token);
owner->fLink->Attach<BPoint>(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<int32>(picture->token);
owner->fLink->Attach<BPoint>(where);
owner->fLink->Attach<bool>(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()
{

View File

@ -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

View File

@ -219,9 +219,6 @@ class Layer {
BRegion* fClipReg;
BRegion* clipToPicture;
bool clipToPictureInverse;
ServerWindow* fServerWin;
BString* fName;
int32 fViewToken;

View File

@ -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<class Type> 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<class Type> 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<int32>(&pictureToken);
link.Read<BPoint>(&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<int32>(&pictureToken);
link.Read<BPoint>(&where);
// TODO: Increase that picture's reference count.(~ allocate a picture)
ServerPicture *sp = fServerApp->FindPicture(pictureToken);
if (sp == NULL)
break;
link.Read<bool>(&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 &region,
bool inverse, BPoint where)
{
fprintf(stderr, "ServerWindow::PictureToRegion() not implemented\n");
region.MakeEmpty();
return B_ERROR;
}

View File

@ -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;