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:
parent
b9b38bc7b2
commit
45ca1c948c
@ -1948,21 +1948,7 @@ BView::TruncateString(BString *in_out, uint32 mode, float width) const
|
|||||||
void
|
void
|
||||||
BView::ClipToPicture(BPicture *picture, BPoint where, bool sync)
|
BView::ClipToPicture(BPicture *picture, BPoint where, bool sync)
|
||||||
{
|
{
|
||||||
if (!picture)
|
DoPictureClip(picture, where, false, sync);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1970,21 +1956,7 @@ void
|
|||||||
BView::ClipToInversePicture(BPicture *picture,
|
BView::ClipToInversePicture(BPicture *picture,
|
||||||
BPoint where, bool sync)
|
BPoint where, bool sync)
|
||||||
{
|
{
|
||||||
if (!picture)
|
DoPictureClip(picture, where, true, sync);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
@ -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
|
bool
|
||||||
BView::removeSelf()
|
BView::removeSelf()
|
||||||
{
|
{
|
||||||
|
@ -89,9 +89,6 @@ Layer::Layer(BRect frame, const char* name, int32 token,
|
|||||||
|
|
||||||
fClipReg (&fVisible),
|
fClipReg (&fVisible),
|
||||||
|
|
||||||
clipToPicture (NULL),
|
|
||||||
clipToPictureInverse(false),
|
|
||||||
|
|
||||||
fServerWin (NULL),
|
fServerWin (NULL),
|
||||||
fName (new BString(name ? name : B_EMPTY_STRING)),
|
fName (new BString(name ? name : B_EMPTY_STRING)),
|
||||||
fViewToken (token),
|
fViewToken (token),
|
||||||
@ -135,11 +132,6 @@ Layer::~Layer(void)
|
|||||||
|
|
||||||
// fServerWin->RemoveChild(fDriver);
|
// fServerWin->RemoveChild(fDriver);
|
||||||
// delete fDriver;
|
// delete fDriver;
|
||||||
|
|
||||||
if (clipToPicture) {
|
|
||||||
// TODO: allocate and release a ServerPicture Object.
|
|
||||||
}
|
|
||||||
delete clipToPicture;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -468,14 +460,6 @@ Layer::RebuildFullRegion(void)
|
|||||||
fFull.IntersectWith(userClipping);
|
fFull.IntersectWith(userClipping);
|
||||||
|
|
||||||
} while ((ld = ld->prevState));
|
} while ((ld = ld->prevState));
|
||||||
|
|
||||||
// clip to user picture region
|
|
||||||
if (clipToPicture) {
|
|
||||||
if(clipToPictureInverse)
|
|
||||||
fFull.Exclude( clipToPicture );
|
|
||||||
else
|
|
||||||
fFull.IntersectWith( clipToPicture );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// StartRebuildRegions
|
// StartRebuildRegions
|
||||||
|
@ -219,9 +219,6 @@ class Layer {
|
|||||||
|
|
||||||
BRegion* fClipReg;
|
BRegion* fClipReg;
|
||||||
|
|
||||||
BRegion* clipToPicture;
|
|
||||||
bool clipToPictureInverse;
|
|
||||||
|
|
||||||
ServerWindow* fServerWin;
|
ServerWindow* fServerWin;
|
||||||
BString* fName;
|
BString* fName;
|
||||||
int32 fViewToken;
|
int32 fViewToken;
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
#include "ServerWindow.h"
|
#include "ServerWindow.h"
|
||||||
#include "ServerApp.h"
|
#include "ServerApp.h"
|
||||||
#include "ServerProtocol.h"
|
#include "ServerProtocol.h"
|
||||||
|
#include "ServerPicture.h"
|
||||||
#include "WinBorder.h"
|
#include "WinBorder.h"
|
||||||
#include "TokenHandler.h"
|
#include "TokenHandler.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
@ -73,42 +74,6 @@
|
|||||||
# define DTRACE(x) ;
|
# define DTRACE(x) ;
|
||||||
#endif
|
#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 -
|
// #pragma mark -
|
||||||
|
|
||||||
@ -917,86 +882,39 @@ ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link)
|
|||||||
case AS_LAYER_CLIP_TO_PICTURE:
|
case AS_LAYER_CLIP_TO_PICTURE:
|
||||||
{
|
{
|
||||||
DTRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_PICTURE: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
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!!!
|
// TODO: you are not allowed to use Layer regions here!!!
|
||||||
// If there is no other way, then first lock RootLayer object first.
|
// 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
|
// TODO: Watch out for the coordinate system in AS_LAYER_CLIP_TO_PICTURE
|
||||||
int32 pictureToken;
|
int32 pictureToken;
|
||||||
BPoint where;
|
BPoint where;
|
||||||
|
bool inverse = false;
|
||||||
|
|
||||||
link.Read<int32>(&pictureToken);
|
link.Read<int32>(&pictureToken);
|
||||||
link.Read<BPoint>(&where);
|
link.Read<BPoint>(&where);
|
||||||
|
link.Read<bool>(&inverse);
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
// if a picture has been found...
|
// search for a picture with the specified token.
|
||||||
if (fCurrentLayer->clipToPicture) {
|
ServerPicture *picture = fServerApp->FindPicture(pictureToken);
|
||||||
fCurrentLayer->clipToPictureInverse = true;
|
// TODO: Increase that picture's reference count.(~ allocate a picture)
|
||||||
fCurrentLayer->RebuildFullRegion();
|
if (picture == NULL)
|
||||||
//fCurrentLayer->RequestDraw(fCurrentLayer->clipToPicture->Frame());
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case AS_LAYER_GET_CLIP_REGION:
|
case AS_LAYER_GET_CLIP_REGION:
|
||||||
{
|
{
|
||||||
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_CLIP_REGION: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
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;
|
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;
|
||||||
|
}
|
||||||
|
@ -51,6 +51,7 @@ class WinBorder;
|
|||||||
class Workspace;
|
class Workspace;
|
||||||
class RootLayer;
|
class RootLayer;
|
||||||
class Layer;
|
class Layer;
|
||||||
|
class ServerPicture;
|
||||||
|
|
||||||
#define AS_UPDATE_DECORATOR 'asud'
|
#define AS_UPDATE_DECORATOR 'asud'
|
||||||
#define AS_UPDATE_COLORS 'asuc'
|
#define AS_UPDATE_COLORS 'asuc'
|
||||||
@ -133,7 +134,11 @@ private:
|
|||||||
protected:
|
protected:
|
||||||
friend class WinBorder;
|
friend class WinBorder;
|
||||||
friend class Layer;
|
friend class Layer;
|
||||||
|
// TODO: Move me elsewhere
|
||||||
|
status_t PictureToRegion(ServerPicture *picture,
|
||||||
|
BRegion &,
|
||||||
|
bool inverse,
|
||||||
|
BPoint where);
|
||||||
char fName[50];
|
char fName[50];
|
||||||
|
|
||||||
ServerApp* fServerApp;
|
ServerApp* fServerApp;
|
||||||
|
Loading…
Reference in New Issue
Block a user