Moved CopyBits from ServerWindow to Layer. Also, made CopyBits code execute in RootLayer's thread
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13321 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1660,6 +1660,91 @@ Layer::SetOverlayBitmap(const ServerBitmap* bitmap)
|
||||
fOverlayBitmap = bitmap;
|
||||
}
|
||||
|
||||
void
|
||||
Layer::CopyBits(BRect& src, BRect& dst, int32 xOffset, int32 yOffset) {
|
||||
|
||||
BPrivate::PortLink msg(-1, -1);
|
||||
msg.StartMessage(AS_ROOTLAYER_LAYER_COPYBITS);
|
||||
msg.Attach<Layer*>(this);
|
||||
msg.Attach<BRect>(src);
|
||||
msg.Attach<BRect>(dst);
|
||||
msg.Attach<int32>(xOffset);
|
||||
msg.Attach<int32>(yOffset);
|
||||
GetRootLayer()->EnqueueMessage(msg);
|
||||
}
|
||||
|
||||
void
|
||||
Layer::do_CopyBits(BRect& src, BRect& dst, int32 xOffset, int32 yOffset) {
|
||||
// NOTE: The correct behaviour is this:
|
||||
// * The region that is copied is the
|
||||
// src rectangle, no matter if it fits
|
||||
// into the dst rectangle. It is copied
|
||||
// by the offset dst.LeftTop() - src.LeftTop()
|
||||
// * The dst rectangle is used for invalidation:
|
||||
// Any area in the dst rectangle that could
|
||||
// not be copied from src (because either the
|
||||
// src rectangle was not big enough, or because there
|
||||
// were parts cut off by the current layer clipping),
|
||||
// are triggering BView::Draw() to be called
|
||||
// and for these parts only.
|
||||
|
||||
#ifndef NEW_CLIPPING
|
||||
|
||||
// the region that is going to be copied
|
||||
BRegion copyRegion(src);
|
||||
// apply the current clipping of the layer
|
||||
|
||||
copyRegion.IntersectWith(&fVisible);
|
||||
|
||||
// offset the region to the destination
|
||||
// and apply the current clipping there as well
|
||||
copyRegion.OffsetBy(xOffset, yOffset);
|
||||
copyRegion.IntersectWith(&fVisible);
|
||||
|
||||
// the region at the destination that needs invalidation
|
||||
GetRootLayer()->fRedrawReg.Set(dst);
|
||||
// exclude the region drawn by the copy operation
|
||||
GetRootLayer()->fRedrawReg.Exclude(©Region);
|
||||
// apply the current clipping as well
|
||||
GetRootLayer()->fRedrawReg.IntersectWith(&fVisible);
|
||||
|
||||
// move the region back for the actual operation
|
||||
copyRegion.OffsetBy(-xOffset, -yOffset);
|
||||
|
||||
GetDisplayDriver()->CopyRegion(©Region, xOffset, yOffset);
|
||||
|
||||
// trigger the redraw
|
||||
GetRootLayer()->RequestDraw(GetRootLayer()->fRedrawReg, NULL);
|
||||
#else
|
||||
// the region that is going to be copied
|
||||
BRegion copyRegion(src);
|
||||
// apply the current clipping of the layer
|
||||
|
||||
copyRegion.IntersectWith(&fVisible2);
|
||||
|
||||
// offset the region to the destination
|
||||
// and apply the current clipping there as well
|
||||
copyRegion.OffsetBy(xOffset, yOffset);
|
||||
copyRegion.IntersectWith(&fVisible2);
|
||||
|
||||
// the region at the destination that needs invalidation
|
||||
GetRootLayer()->fRedrawReg.Set(dst);
|
||||
// exclude the region drawn by the copy operation
|
||||
GetRootLayer()->fRedrawReg.Exclude(©Region);
|
||||
// apply the current clipping as well
|
||||
GetRootLayer()->fRedrawReg.IntersectWith(&fVisible2);
|
||||
|
||||
// move the region back for the actual operation
|
||||
copyRegion.OffsetBy(-xOffset, -yOffset);
|
||||
|
||||
GetDisplayDriver()->CopyRegion(©Region, xOffset, yOffset);
|
||||
|
||||
// trigger the redraw
|
||||
GetRootLayer()->RequestDraw(GetRootLayer()->fRedrawReg, NULL);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#ifdef NEW_CLIPPING
|
||||
|
||||
void
|
||||
|
||||
+15
-8
@@ -41,7 +41,7 @@
|
||||
#include "RGBColor.h"
|
||||
#include "ServerWindow.h"
|
||||
|
||||
#define NEW_CLIPPING 1
|
||||
//#define NEW_CLIPPING 1
|
||||
|
||||
enum {
|
||||
B_LAYER_NONE = 1,
|
||||
@@ -208,6 +208,10 @@ class Layer {
|
||||
void SetOverlayBitmap(const ServerBitmap* bitmap);
|
||||
inline const ServerBitmap* OverlayBitmap() const
|
||||
{ return fOverlayBitmap; }
|
||||
|
||||
void CopyBits(BRect& src, BRect& dst,
|
||||
int32 xOffset, int32 yOffset);
|
||||
|
||||
#ifdef NEW_CLIPPING
|
||||
inline const BRegion& VisibleRegion() const { return fVisible2; }
|
||||
inline const BRegion& FullVisible() const { return fFullVisible2; }
|
||||
@@ -247,19 +251,22 @@ class Layer {
|
||||
void do_Redraw( const BRegion &invalid,
|
||||
const Layer *startFrom = NULL);
|
||||
|
||||
void rebuild_visible_regions(const BRegion &invalid,
|
||||
void rebuild_visible_regions(const BRegion &invalid,
|
||||
const BRegion &parentLocalVisible,
|
||||
const Layer *startFrom);
|
||||
|
||||
virtual bool alter_visible_for_children(BRegion ®ion);
|
||||
virtual void get_user_regions(BRegion ®);
|
||||
virtual bool alter_visible_for_children(BRegion ®ion);
|
||||
virtual void get_user_regions(BRegion ®);
|
||||
|
||||
void clear_visible_regions();
|
||||
void resize_layer_frame_by(float x, float y);
|
||||
void rezize_layer_redraw_more(BRegion ®, float dx, float dy);
|
||||
void resize_layer_full_update_on_resize(BRegion ®, float dx, float dy);
|
||||
void clear_visible_regions();
|
||||
void resize_layer_frame_by(float x, float y);
|
||||
void rezize_layer_redraw_more(BRegion ®, float dx, float dy);
|
||||
void resize_layer_full_update_on_resize(BRegion ®, float dx, float dy);
|
||||
|
||||
#endif
|
||||
private:
|
||||
void do_CopyBits(BRect& src, BRect& dst,
|
||||
int32 xOffset, int32 yOffset);
|
||||
|
||||
protected:
|
||||
friend class RootLayer;
|
||||
|
||||
@@ -355,6 +355,22 @@ RootLayer::WorkingThread(void *data)
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case AS_ROOTLAYER_LAYER_COPYBITS:
|
||||
{
|
||||
Layer *layer = NULL;
|
||||
int32 xOffset, yOffset;
|
||||
BRect src, dst;
|
||||
messageQueue.Read<Layer*>(&layer);
|
||||
messageQueue.Read<BRect>(&src);
|
||||
messageQueue.Read<BRect>(&dst);
|
||||
messageQueue.Read<int32>(&xOffset);
|
||||
messageQueue.Read<int32>(&yOffset);
|
||||
|
||||
layer->do_CopyBits(src, dst, xOffset, yOffset);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case AS_ROOTLAYER_ADD_TO_SUBSET:
|
||||
{
|
||||
WinBorder *winBorder = NULL;
|
||||
|
||||
@@ -435,7 +435,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
|
||||
fCurrentLayer->fLayerData->OffsetOrigin(BPoint(dh, dv));
|
||||
|
||||
_CopyBits(myRootLayer, fCurrentLayer, src, dst, xOffset, yOffset);
|
||||
fCurrentLayer->CopyBits(src, dst, xOffset, yOffset);
|
||||
#else
|
||||
fCurrentLayer->ScrollBy(dh, dv);
|
||||
#endif
|
||||
@@ -457,7 +457,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
int32 xOffset = (int32)(dst.left - src.left);
|
||||
int32 yOffset = (int32)(dst.top - src.top);
|
||||
|
||||
_CopyBits(myRootLayer, fCurrentLayer, src, dst, xOffset, yOffset);
|
||||
fCurrentLayer->CopyBits(src, dst, xOffset, yOffset);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -2095,58 +2095,6 @@ ServerWindow::_MessageLooper()
|
||||
}
|
||||
}
|
||||
|
||||
// _CopyBits
|
||||
void
|
||||
ServerWindow::_CopyBits(RootLayer* rootLayer, Layer* layer,
|
||||
BRect& src, BRect& dst,
|
||||
int32 xOffset, int32 yOffset) const
|
||||
{
|
||||
// NOTE: The correct behaviour is this:
|
||||
// * The region that is copied is the
|
||||
// src rectangle, no matter if it fits
|
||||
// into the dst rectangle. It is copied
|
||||
// by the offset dst.LeftTop() - src.LeftTop()
|
||||
// * The dst rectangle is used for invalidation:
|
||||
// Any area in the dst rectangle that could
|
||||
// not be copied from src (because either the
|
||||
// src rectangle was not big enough, or because there
|
||||
// were parts cut off by the current layer clipping),
|
||||
// are triggering BView::Draw() to be called
|
||||
// and for these parts only.
|
||||
|
||||
#ifndef NEW_CLIPPING
|
||||
|
||||
// the region that is going to be copied
|
||||
BRegion copyRegion(src);
|
||||
// apply the current clipping of the layer
|
||||
|
||||
copyRegion.IntersectWith(&layer->fVisible);
|
||||
|
||||
// offset the region to the destination
|
||||
// and apply the current clipping there as well
|
||||
copyRegion.OffsetBy(xOffset, yOffset);
|
||||
copyRegion.IntersectWith(&layer->fVisible);
|
||||
|
||||
// the region at the destination that needs invalidation
|
||||
BRegion invalidRegion(dst);
|
||||
// exclude the region drawn by the copy operation
|
||||
invalidRegion.Exclude(©Region);
|
||||
// apply the current clipping as well
|
||||
invalidRegion.IntersectWith(&layer->fVisible);
|
||||
|
||||
// move the region back for the actual operation
|
||||
copyRegion.OffsetBy(-xOffset, -yOffset);
|
||||
|
||||
layer->GetDisplayDriver()->CopyRegion(©Region, xOffset, yOffset);
|
||||
|
||||
// trigger the redraw
|
||||
// rootLayer->GoRedraw(fWinBorder, invalidRegion);
|
||||
rootLayer->RequestDraw(invalidRegion, fWinBorder);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ServerWindow::SendMessageToClient(const BMessage* msg, int32 target, bool usePreferred) const
|
||||
{
|
||||
|
||||
@@ -113,14 +113,6 @@ private:
|
||||
|
||||
static int32 _message_thread(void *_window);
|
||||
|
||||
// used by CopyBits and Scrolling
|
||||
void _CopyBits(RootLayer* rootLayer,
|
||||
Layer* layer,
|
||||
BRect& copy,
|
||||
BRect& dirty,
|
||||
int32 xOffset, int32 yOffset) const;
|
||||
|
||||
|
||||
// TODO: Move me elsewhere
|
||||
status_t PictureToRegion(ServerPicture *picture,
|
||||
BRegion &,
|
||||
|
||||
Reference in New Issue
Block a user