implemented a client side (and very slow) version of BView::ClipToPicture. See bug #1397
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27321 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -4394,6 +4394,61 @@ BView::_ClipToPicture(BPicture *picture, BPoint where,
|
||||
if (!picture)
|
||||
return;
|
||||
|
||||
#if 1
|
||||
// TODO: Move the implementation to the server!!!
|
||||
|
||||
// Here the idea is to get rid of the padding bytes in the bitmap,
|
||||
// as padding complicates and slows down the iteration.
|
||||
// TODO: Maybe it's not so nice as it assumes BBitmaps to be aligned
|
||||
// to a 4 byte boundary.
|
||||
BRect bounds(Bounds());
|
||||
if ((bounds.IntegerWidth() + 1) % 32)
|
||||
bounds.right = bounds.left + ((bounds.IntegerWidth() + 1) / 32 + 1) * 32 - 1;
|
||||
|
||||
// TODO: I used a RGBA32 bitmap because drawing on a GRAY8 doesn't work.
|
||||
BBitmap *bitmap = new BBitmap(bounds, B_RGBA32, true);
|
||||
if (bitmap && bitmap->InitCheck() == B_OK && bitmap->Lock()) {
|
||||
BView *view = new BView(bounds, "drawing view", B_FOLLOW_NONE, 0);
|
||||
bitmap->AddChild(view);
|
||||
view->DrawPicture(picture, where);
|
||||
view->Sync();
|
||||
bitmap->Unlock();
|
||||
}
|
||||
|
||||
BRegion region;
|
||||
int32 width = bounds.IntegerWidth() + 1;
|
||||
int32 height = bounds.IntegerHeight() + 1;
|
||||
if (bitmap->LockBits() == B_OK) {
|
||||
uint32 bit = 0;
|
||||
uint32 *bits = (uint32 *)bitmap->Bits();
|
||||
clipping_rect rect;
|
||||
|
||||
// TODO: A possible optimization would be adding "spans" instead
|
||||
// of 1x1 rects. That would probably help with very complex
|
||||
// BPictures
|
||||
for (int32 y = 0; y < height; y++) {
|
||||
for (int32 x = 0; x < width; x++) {
|
||||
bit = *bits++;
|
||||
if (bit != (uint32)-1) {
|
||||
rect.left = x;
|
||||
rect.right = rect.left;
|
||||
rect.top = rect.bottom = y;
|
||||
region.Include(rect);
|
||||
}
|
||||
}
|
||||
}
|
||||
bitmap->UnlockBits();
|
||||
}
|
||||
delete bitmap;
|
||||
|
||||
if (invert) {
|
||||
BRegion inverseRegion;
|
||||
inverseRegion.Include(Bounds());
|
||||
inverseRegion.Exclude(®ion);
|
||||
ConstrainClippingRegion(&inverseRegion);
|
||||
} else
|
||||
ConstrainClippingRegion(®ion);
|
||||
#else
|
||||
if (_CheckOwnerLockAndSwitchCurrent()) {
|
||||
fOwner->fLink->StartMessage(AS_VIEW_CLIP_TO_PICTURE);
|
||||
fOwner->fLink->Attach<int32>(picture->Token());
|
||||
@@ -4409,6 +4464,7 @@ BView::_ClipToPicture(BPicture *picture, BPoint where,
|
||||
}
|
||||
|
||||
fState->archiving_flags |= B_VIEW_CLIP_REGION_BIT;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user