Implemented SetClipping op, but it's not working yet (looks like it's
never written into the data stream) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21947 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -32,6 +32,8 @@ public:
|
||||
status_t WriteSetLineMode(const cap_mode &cap, const join_mode &join, const float &miterLimit);
|
||||
status_t WriteSetScale(const float &scale);
|
||||
status_t WriteSetPattern(const pattern &pat);
|
||||
status_t WriteSetClipping(/*const */BRegion ®ion);
|
||||
status_t WriteClearClipping();
|
||||
|
||||
status_t WritePushState();
|
||||
status_t WritePopState();
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <DataIO.h>
|
||||
#include <Point.h>
|
||||
#include <Rect.h>
|
||||
#include <Region.h>
|
||||
|
||||
#include <PictureProtocol.h>
|
||||
|
||||
@@ -163,6 +164,40 @@ PictureDataWriter::WriteSetPattern(const pattern &pat)
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
PictureDataWriter::WriteSetClipping(/*const */BRegion ®ion)
|
||||
{
|
||||
// TODO: I don't know if it's compatible with R5's BPicture version
|
||||
try {
|
||||
const int32 numRects = region.CountRects();
|
||||
if (numRects > 0 && region.Frame().IsValid()) {
|
||||
BeginOp(B_PIC_SET_CLIPPING_RECTS);
|
||||
Write<int32>(numRects);
|
||||
for (int32 i = 0; i < numRects; i++)
|
||||
Write<BRect>(region.RectAt(i));
|
||||
EndOp();
|
||||
} else
|
||||
WriteClearClipping();
|
||||
} catch (status_t &status) {
|
||||
return status;
|
||||
}
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
PictureDataWriter::WriteClearClipping()
|
||||
{
|
||||
try {
|
||||
BeginOp(B_PIC_CLEAR_CLIPPING_RECTS);
|
||||
EndOp();
|
||||
} catch (status_t &status) {
|
||||
return status;
|
||||
}
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
PictureDataWriter::WriteSetHighColor(const rgb_color &color)
|
||||
{
|
||||
|
||||
@@ -35,7 +35,7 @@ typedef void (*fnc_f)(void*, float);
|
||||
typedef void (*fnc_Color)(void*, rgb_color);
|
||||
typedef void (*fnc_Pattern)(void*, pattern);
|
||||
typedef void (*fnc_ss)(void *, int16, int16);
|
||||
typedef void (*fnc_PBRecti)(void*, const BRect*, int32);
|
||||
typedef void (*fnc_PBRecti)(void*, const BRect*, uint32);
|
||||
typedef void (*fnc_DrawPixels)(void *, BRect, BRect, int32, int32, int32,
|
||||
int32, int32, const void *);
|
||||
typedef void (*fnc_DrawPicture)(void *, BPoint, int32);
|
||||
@@ -283,15 +283,18 @@ PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData)
|
||||
case B_PIC_SET_CLIPPING_RECTS:
|
||||
{
|
||||
if (tableEntries <= 20)
|
||||
break;
|
||||
// TODO: Implement
|
||||
break;
|
||||
// TODO: Not sure if it's compatible with R5's BPicture version
|
||||
((fnc_PBRecti)callBackTable[20])(userData,
|
||||
reinterpret_cast<const BRect *>(data + sizeof(uint32)),
|
||||
*reinterpret_cast<const uint32 *>(data));
|
||||
break;
|
||||
}
|
||||
|
||||
case B_PIC_CLEAR_CLIPPING_RECTS:
|
||||
{
|
||||
if (tableEntries <= 20)
|
||||
break;
|
||||
break;
|
||||
((fnc_PBRecti)callBackTable[20])(userData, NULL, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -437,7 +437,8 @@ draw_picture(ViewLayer *view, BPoint where, int32 token)
|
||||
static void
|
||||
set_clipping_rects(ViewLayer *view, const BRect *rects, uint32 numRects)
|
||||
{
|
||||
// TODO: This is too slow, we should copy the rects directly to BRegion's internal data
|
||||
// TODO: This might be too slow, we should copy the rects
|
||||
// directly to BRegion's internal data
|
||||
BRegion region;
|
||||
for (uint32 c = 0; c < numRects; c++)
|
||||
region.Include(rects[c]);
|
||||
|
||||
@@ -2709,6 +2709,31 @@ ServerWindow::_DispatchPictureMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
break;
|
||||
}
|
||||
|
||||
case AS_LAYER_SET_CLIP_REGION:
|
||||
{
|
||||
int32 rectCount;
|
||||
status_t status = link.Read<int32>(&rectCount);
|
||||
// a negative count means no
|
||||
// region for the current draw state,
|
||||
// but an *empty* region is actually valid!
|
||||
// even if it means no drawing is allowed
|
||||
|
||||
if (status < B_OK)
|
||||
break;
|
||||
|
||||
if (rectCount >= 0) {
|
||||
// we are supposed to set the clipping region
|
||||
BRegion region;
|
||||
if (rectCount > 0 && link.ReadRegion(®ion) < B_OK)
|
||||
break;
|
||||
picture->WriteSetClipping(region);
|
||||
} else {
|
||||
// we are supposed to clear the clipping region
|
||||
picture->WriteClearClipping();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_BEGIN_PICTURE:
|
||||
{
|
||||
ServerPicture *newPicture = App()->CreatePicture();
|
||||
|
||||
Reference in New Issue
Block a user