fixes origin and scale handling, it behaves mostly like R5 now (it is used for drawing only, yes not mouse coords or anything else). Also fixes offscreen layers clipping rebuilding when the user defined clipping is added or changed

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15040 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2005-11-20 15:10:18 +00:00
parent 3ce6b663e6
commit b223f78041
5 changed files with 223 additions and 75 deletions
+10 -20
View File
@@ -59,6 +59,16 @@ class DrawState {
float Scale() const float Scale() const
{ return fScale; } { return fScale; }
// coordinate transformations
void Transform(float* x, float* y) const;
void InverseTransform(float* x, float* y) const;
void Transform(BPoint* point) const;
void Transform(BRect* rect) const;
void Transform(BRegion* region) const;
void InverseTransform(BPoint* point) const;
// additional clipping as requested by client // additional clipping as requested by client
void SetClippingRegion(const BRegion& region); void SetClippingRegion(const BRegion& region);
const BRegion* ClippingRegion() const const BRegion* ClippingRegion() const
@@ -124,8 +134,6 @@ class DrawState {
{ return fMiterLimit; } { return fMiterLimit; }
// convenience functions // convenience functions
inline BPoint Transform(const BPoint& point) const;
inline BRect Transform(const BRect& rect) const;
void PrintToStream() const; void PrintToStream() const;
void SetSubPixelPrecise(bool precise); void SetSubPixelPrecise(bool precise);
@@ -177,24 +185,6 @@ class DrawState {
// inline implementations // inline implementations
// Transform
BPoint
DrawState::Transform(const BPoint& point) const
{
BPoint p(point);
p += fOrigin;
p.x *= fScale;
p.y *= fScale;
return p;
}
// Transform
BRect
DrawState::Transform(const BRect& rect) const
{
return BRect(Transform(rect.LeftTop()),
Transform(rect.LeftBottom()));
}
/* /*
// ClippingRectAt // ClippingRectAt
BRect BRect
+73
View File
@@ -301,6 +301,79 @@ DrawState::SetScale(float scale)
} }
} }
// Transform
void
DrawState::Transform(float* x, float* y) const
{
*x += fOrigin.x;
*y += fOrigin.y;
*x *= fScale;
*y *= fScale;
}
// InverseTransform
void
DrawState::InverseTransform(float* x, float* y) const
{
// TODO: watch out for fScale = 0?
*x /= fScale;
*y /= fScale;
*x -= fOrigin.x;
*y -= fOrigin.y;
}
// Transform
void
DrawState::Transform(BPoint* point) const
{
Transform(&(point->x), &(point->y));
}
// Transform
void
DrawState::Transform(BRect* rect) const
{
Transform(&(rect->left), &(rect->top));
Transform(&(rect->right), &(rect->bottom));
}
// Transform
void
DrawState::Transform(BRegion* region) const
{
if (fScale == 1.0) {
if (fOrigin.x != 0.0 || fOrigin.y != 0.0)
region->OffsetBy((int32)fOrigin.x, (int32)fOrigin.y);
} else {
// TODO: optimize some more
BRegion converted;
int32 count = region->CountRects();
for (int32 i = 0; i < count; i++) {
BRect r = region->RectAt(i);
BPoint lt(r.LeftTop());
BPoint rb(r.RightBottom());
// offset to bottom right corner of pixel before transformation
rb.x++;
rb.y++;
// apply transformation
Transform(&lt.x, &lt.y);
Transform(&rb.x, &rb.y);
// reset bottom right to pixel "index"
rb.x++;
rb.y++;
}
*region = converted;
}
}
// InverseTransform
void
DrawState::InverseTransform(BPoint* point) const
{
InverseTransform(&(point->x), &(point->y));
}
void void
DrawState::SetClippingRegion(const BRegion& region) DrawState::SetClippingRegion(const BRegion& region)
+92 -20
View File
@@ -45,6 +45,7 @@ Layer::Layer(BRect frame, const char* name, int32 token,
: :
fName(name), fName(name),
fFrame(frame), fFrame(frame),
fScrollingOffset(0.0, 0.0),
fDriver(driver), fDriver(driver),
fRootLayer(NULL), fRootLayer(NULL),
@@ -559,8 +560,7 @@ BRect
Layer::Bounds() const Layer::Bounds() const
{ {
BRect r(fFrame); BRect r(fFrame);
// r.OffsetTo(fBoundsLeftTop); r.OffsetTo(ScrollingOffset());
r.OffsetTo(BoundsOrigin());
return r; return r;
} }
@@ -730,9 +730,11 @@ Layer::ScrollBy(float x, float y)
if (x == 0.0f && y == 0.0f) if (x == 0.0f && y == 0.0f)
return; return;
fScrollingOffset.x += x;
fScrollingOffset.y += y;
// must lock, even if we change frame/origin coordinates // must lock, even if we change frame/origin coordinates
if (!IsHidden() && GetRootLayer() && GetRootLayer()->Lock()) { if (!IsHidden() && GetRootLayer() && GetRootLayer()->Lock()) {
fDrawState->OffsetOrigin(BPoint(x, y));
// set the region to be invalidated. // set the region to be invalidated.
BRegion invalid(fFullVisible); BRegion invalid(fFullVisible);
@@ -762,9 +764,6 @@ Layer::ScrollBy(float x, float y)
GetRootLayer()->Unlock(); GetRootLayer()->Unlock();
} }
else {
fDrawState->OffsetOrigin(BPoint(x, y));
}
ScrolledByHook(x, y); ScrolledByHook(x, y);
@@ -877,17 +876,28 @@ Layer::Activated(bool active)
BPoint BPoint
Layer::BoundsOrigin() const Layer::ScrollingOffset() const
{
return fScrollingOffset;
}
void
Layer::SetDrawingOrigin(BPoint origin)
{
fDrawState->SetOrigin(origin);
// rebuild clipping
if (fDrawState->ClippingRegion())
_RebuildDrawingRegion();
}
BPoint
Layer::DrawingOrigin() const
{ {
BPoint origin(fDrawState->Origin()); BPoint origin(fDrawState->Origin());
float scale = Scale(); float scale = Scale();
// TODO: Figure this out, BoundsOrigin()
// is used for BView::Bounds(), but I think
// that the scale has nothing to do with it
// "local coordinate system origin" does have
// something to do with scale.
origin.x *= scale; origin.x *= scale;
origin.y *= scale; origin.y *= scale;
@@ -895,6 +905,17 @@ Layer::BoundsOrigin() const
} }
void
Layer::SetScale(float scale)
{
fDrawState->SetScale(scale);
// rebuild clipping
if (fDrawState->ClippingRegion())
_RebuildDrawingRegion();
}
float float
Layer::Scale() const Layer::Scale() const
{ {
@@ -950,7 +971,7 @@ void
Layer::ConvertToParent(BPoint* pt) const Layer::ConvertToParent(BPoint* pt) const
{ {
if (fParent) { if (fParent) {
BPoint origin = BoundsOrigin(); BPoint origin = ScrollingOffset();
pt->x -= origin.x; pt->x -= origin.x;
pt->y -= origin.y; pt->y -= origin.y;
pt->x += fFrame.left; pt->x += fFrame.left;
@@ -963,7 +984,7 @@ void
Layer::ConvertToParent(BRect* rect) const Layer::ConvertToParent(BRect* rect) const
{ {
if (fParent) { if (fParent) {
BPoint origin = BoundsOrigin(); BPoint origin = ScrollingOffset();
rect->OffsetBy(-origin.x, -origin.y); rect->OffsetBy(-origin.x, -origin.y);
rect->OffsetBy(fFrame.left, fFrame.top); rect->OffsetBy(fFrame.left, fFrame.top);
} }
@@ -974,7 +995,7 @@ void
Layer::ConvertToParent(BRegion* reg) const Layer::ConvertToParent(BRegion* reg) const
{ {
if (fParent) { if (fParent) {
BPoint origin = BoundsOrigin(); BPoint origin = ScrollingOffset();
reg->OffsetBy(-origin.x, -origin.y); reg->OffsetBy(-origin.x, -origin.y);
reg->OffsetBy(fFrame.left, fFrame.top); reg->OffsetBy(fFrame.left, fFrame.top);
} }
@@ -985,7 +1006,7 @@ void
Layer::ConvertFromParent(BPoint* pt) const Layer::ConvertFromParent(BPoint* pt) const
{ {
if (fParent) { if (fParent) {
BPoint origin = BoundsOrigin(); BPoint origin = ScrollingOffset();
pt->x += origin.x; pt->x += origin.x;
pt->y += origin.y; pt->y += origin.y;
pt->x -= fFrame.left; pt->x -= fFrame.left;
@@ -998,7 +1019,7 @@ void
Layer::ConvertFromParent(BRect* rect) const Layer::ConvertFromParent(BRect* rect) const
{ {
if (fParent) { if (fParent) {
BPoint origin = BoundsOrigin(); BPoint origin = ScrollingOffset();
rect->OffsetBy(origin.x, origin.y); rect->OffsetBy(origin.x, origin.y);
rect->OffsetBy(-fFrame.left, -fFrame.top); rect->OffsetBy(-fFrame.left, -fFrame.top);
} }
@@ -1009,7 +1030,7 @@ void
Layer::ConvertFromParent(BRegion* reg) const Layer::ConvertFromParent(BRegion* reg) const
{ {
if (fParent) { if (fParent) {
BPoint origin = BoundsOrigin(); BPoint origin = ScrollingOffset();
reg->OffsetBy(origin.x, origin.y); reg->OffsetBy(origin.x, origin.y);
reg->OffsetBy(-fFrame.left, -fFrame.top); reg->OffsetBy(-fFrame.left, -fFrame.top);
} }
@@ -1075,6 +1096,57 @@ Layer::ConvertFromScreen(BRegion* reg) const
} }
} }
//! converts a point from local *drawing* to screen coordinate system
void
Layer::ConvertToScreenForDrawing(BPoint* pt) const
{
if (fParent) {
fDrawState->Transform(pt);
// NOTE: from here on, don't use the
// "*ForDrawing()" versions of the parent!
ConvertToParent(pt);
fParent->ConvertToScreen(pt);
}
}
//! converts a rect from local *drawing* to screen coordinate system
void
Layer::ConvertToScreenForDrawing(BRect* rect) const
{
if (fParent) {
fDrawState->Transform(rect);
// NOTE: from here on, don't use the
// "*ForDrawing()" versions of the parent!
ConvertToParent(rect);
fParent->ConvertToScreen(rect);
}
}
//! converts a region from local *drawing* to screen coordinate system
void
Layer::ConvertToScreenForDrawing(BRegion* region) const
{
if (fParent) {
fDrawState->Transform(region);
// NOTE: from here on, don't use the
// "*ForDrawing()" versions of the parent!
ConvertToParent(region);
fParent->ConvertToScreen(region);
}
}
//! converts a point from screen to local coordinate system
void
Layer::ConvertFromScreenForDrawing(BPoint* pt) const
{
if (fParent) {
ConvertFromParent(pt);
fParent->ConvertFromScreen(pt);
fDrawState->InverseTransform(pt);
}
}
void void
Layer::_ResizeLayerFrameBy(float x, float y) Layer::_ResizeLayerFrameBy(float x, float y)
{ {
@@ -1333,7 +1405,7 @@ Layer::_RebuildDrawingRegion()
// apply user clipping which is in native coordinate system // apply user clipping which is in native coordinate system
if (const BRegion* userClipping = fDrawState->ClippingRegion()) { if (const BRegion* userClipping = fDrawState->ClippingRegion()) {
BRegion screenUserClipping(*userClipping); BRegion screenUserClipping(*userClipping);
ConvertToScreen(&screenUserClipping); ConvertToScreenForDrawing(&screenUserClipping);
fDrawingRegion.IntersectWith(&screenUserClipping); fDrawingRegion.IntersectWith(&screenUserClipping);
} }
} }
+13 -6
View File
@@ -119,7 +119,12 @@ class Layer {
// coordinate system // coordinate system
BRect Bounds() const; BRect Bounds() const;
BRect Frame() const; BRect Frame() const;
BPoint BoundsOrigin() const; // BoundsFrameDiff()? BPoint ScrollingOffset() const;
void SetDrawingOrigin(BPoint origin);
BPoint DrawingOrigin() const;
void SetScale(float scale);
float Scale() const; float Scale() const;
void ConvertToParent(BPoint* pt) const; void ConvertToParent(BPoint* pt) const;
@@ -136,6 +141,12 @@ class Layer {
void ConvertFromScreen(BRect* rect) const; void ConvertFromScreen(BRect* rect) const;
void ConvertFromScreen(BRegion* reg) const; void ConvertFromScreen(BRegion* reg) const;
void ConvertToScreenForDrawing(BPoint* pt) const;
void ConvertToScreenForDrawing(BRect* rect) const;
void ConvertToScreenForDrawing(BRegion* reg) const;
void ConvertFromScreenForDrawing(BPoint* pt) const;
virtual void MoveBy(float x, float y); virtual void MoveBy(float x, float y);
virtual void ResizeBy(float x, float y); virtual void ResizeBy(float x, float y);
virtual void ScrollBy(float x, float y); virtual void ScrollBy(float x, float y);
@@ -226,11 +237,7 @@ class Layer {
BString fName; BString fName;
BRect fFrame; BRect fFrame;
// TODO: should be removed or reused in a similar fashion BPoint fScrollingOffset;
// to hold the accumulated origins from the graphics state stack.
// The same needs to be done for "scale". (Keeping an accumulated
// value.)
// BPoint fBoundsLeftTop;
BRegion fVisible; BRegion fVisible;
BRegion fFullVisible; BRegion fFullVisible;
+35 -29
View File
@@ -515,6 +515,7 @@ ServerWindow::CreateLayerTree(BPrivate::LinkReceiver &link, Layer **_parent)
// TODO: rework the clipping stuff to remove RootLayer dependency and then // TODO: rework the clipping stuff to remove RootLayer dependency and then
// remove this hack: // remove this hack:
if (fWinBorder->IsOffscreenWindow()) { if (fWinBorder->IsOffscreenWindow()) {
newLayer->fVisible.Set(newLayer->fFrame);
newLayer->fDrawingRegion.Set(newLayer->fFrame); newLayer->fDrawingRegion.Set(newLayer->fFrame);
} }
@@ -570,7 +571,9 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<BRect>(&src); link.Read<BRect>(&src);
link.Read<BRect>(&dst); link.Read<BRect>(&dst);
// TODO: Are origin and scale handled in this conversion? // TODO: confirm that in R5 this call is affected by origin and scale
// fCurrentLayer->ConvertToScreenForDrawing(&src);
// fCurrentLayer->ConvertToScreenForDrawing(&dst);
fCurrentLayer->ConvertToScreen(&src); fCurrentLayer->ConvertToScreen(&src);
fCurrentLayer->ConvertToScreen(&dst); fCurrentLayer->ConvertToScreen(&dst);
@@ -798,14 +801,16 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<float>(&x); link.Read<float>(&x);
link.Read<float>(&y); link.Read<float>(&y);
fCurrentLayer->CurrentState()->SetOrigin(BPoint(x, y)); fCurrentLayer->SetDrawingOrigin(BPoint(x, y));
break; break;
} }
case AS_LAYER_GET_ORIGIN: case AS_LAYER_GET_ORIGIN:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_GET_ORIGIN: Layer: %s\n", Title(), fCurrentLayer->Name())); STRACE(("ServerWindow %s: Message AS_LAYER_GET_ORIGIN: Layer: %s\n", Title(), fCurrentLayer->Name()));
fLink.StartMessage(SERVER_TRUE); fLink.StartMessage(SERVER_TRUE);
fLink.Attach<BPoint>(fCurrentLayer->CurrentState()->Origin()); // TODO: rename this where it is used in the BView code!
// (it wants to know scrolling offset, not drawing origin)
fLink.Attach<BPoint>(fCurrentLayer->ScrollingOffset());
fLink.Flush(); fLink.Flush();
break; break;
} }
@@ -899,7 +904,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
float scale; float scale;
link.Read<float>(&scale); link.Read<float>(&scale);
fCurrentLayer->CurrentState()->SetScale(scale); fCurrentLayer->SetScale(scale);
break; break;
} }
case AS_LAYER_GET_SCALE: case AS_LAYER_GET_SCALE:
@@ -1138,8 +1143,9 @@ if (rootLayer)
{ {
DTRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n", Title(), fCurrentLayer->Name())); DTRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n", Title(), fCurrentLayer->Name()));
// TODO: handle transformation (origin and scale) prior to converting to top // NOTE: looks like this call is NOT affected by origin and scale on R5
BRect invalRect; // so this implementation is "correct"
BRect invalRect;
link.Read<BRect>(&invalRect); link.Read<BRect>(&invalRect);
@@ -1159,8 +1165,8 @@ if (rootLayer)
{ {
DTRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n", Title(), fCurrentLayer->Name())); DTRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n", Title(), fCurrentLayer->Name()));
// TODO: handle transformation (origin and scale) prior to converting to top // NOTE: looks like this call is NOT affected by origin and scale on R5
// TODO: Handle conversion to top // so this implementation is "correct"
BRegion invalidReg; BRegion invalidReg;
int32 noOfRects; int32 noOfRects;
BRect rect; BRect rect;
@@ -1683,8 +1689,8 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
BPoint p1(x1, y1); BPoint p1(x1, y1);
BPoint p2(x2, y2); BPoint p2(x2, y2);
BPoint penPos = p2; BPoint penPos = p2;
fCurrentLayer->ConvertToScreen(&p1); fCurrentLayer->ConvertToScreenForDrawing(&p1);
fCurrentLayer->ConvertToScreen(&p2); fCurrentLayer->ConvertToScreenForDrawing(&p2);
driver->StrokeLine(p1, p2, fCurrentLayer->CurrentState()); driver->StrokeLine(p1, p2, fCurrentLayer->CurrentState());
// We update the pen here because many DrawingEngine calls which do not update the // We update the pen here because many DrawingEngine calls which do not update the
@@ -1703,7 +1709,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
BRect rect; BRect rect;
link.Read<BRect>(&rect); link.Read<BRect>(&rect);
fCurrentLayer->ConvertToScreen(&rect); fCurrentLayer->ConvertToScreenForDrawing(&rect);
driver->InvertRect(rect); driver->InvertRect(rect);
break; break;
} }
@@ -1718,7 +1724,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<float>(&bottom); link.Read<float>(&bottom);
BRect rect(left,top,right,bottom); BRect rect(left,top,right,bottom);
fCurrentLayer->ConvertToScreen(&rect); fCurrentLayer->ConvertToScreenForDrawing(&rect);
driver->StrokeRect(rect, fCurrentLayer->CurrentState()); driver->StrokeRect(rect, fCurrentLayer->CurrentState());
break; break;
@@ -1730,7 +1736,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
BRect rect; BRect rect;
link.Read<BRect>(&rect); link.Read<BRect>(&rect);
fCurrentLayer->ConvertToScreen(&rect); fCurrentLayer->ConvertToScreenForDrawing(&rect);
driver->FillRect(rect, fCurrentLayer->CurrentState()); driver->FillRect(rect, fCurrentLayer->CurrentState());
break; break;
} }
@@ -1748,7 +1754,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
if (sbmp) { if (sbmp) {
BRect src = sbmp->Bounds(); BRect src = sbmp->Bounds();
BRect dst = src.OffsetToCopy(point); BRect dst = src.OffsetToCopy(point);
fCurrentLayer->ConvertToScreen(&dst); fCurrentLayer->ConvertToScreenForDrawing(&dst);
driver->DrawBitmap(sbmp, src, dst, fCurrentLayer->CurrentState()); driver->DrawBitmap(sbmp, src, dst, fCurrentLayer->CurrentState());
} }
@@ -1772,7 +1778,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
ServerBitmap* sbmp = fServerApp->FindBitmap(bitmapToken); ServerBitmap* sbmp = fServerApp->FindBitmap(bitmapToken);
if (sbmp) { if (sbmp) {
fCurrentLayer->ConvertToScreen(&dstRect); fCurrentLayer->ConvertToScreenForDrawing(&dstRect);
driver->DrawBitmap(sbmp, srcRect, dstRect, fCurrentLayer->CurrentState()); driver->DrawBitmap(sbmp, srcRect, dstRect, fCurrentLayer->CurrentState());
} }
@@ -1792,7 +1798,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<float>(&angle); link.Read<float>(&angle);
link.Read<float>(&span); link.Read<float>(&span);
fCurrentLayer->ConvertToScreen(&r); fCurrentLayer->ConvertToScreenForDrawing(&r);
driver->DrawArc(r, angle, span, fCurrentLayer->CurrentState(), code == AS_FILL_ARC); driver->DrawArc(r, angle, span, fCurrentLayer->CurrentState(), code == AS_FILL_ARC);
break; break;
@@ -1805,7 +1811,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
BPoint pts[4]; BPoint pts[4];
for (int32 i = 0; i < 4; i++) { for (int32 i = 0; i < 4; i++) {
link.Read<BPoint>(&(pts[i])); link.Read<BPoint>(&(pts[i]));
fCurrentLayer->ConvertToScreen(&pts[i]); fCurrentLayer->ConvertToScreenForDrawing(&pts[i]);
} }
driver->DrawBezier(pts, fCurrentLayer->CurrentState(), code == AS_FILL_BEZIER); driver->DrawBezier(pts, fCurrentLayer->CurrentState(), code == AS_FILL_BEZIER);
@@ -1820,7 +1826,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
BRect rect; BRect rect;
link.Read<BRect>(&rect); link.Read<BRect>(&rect);
fCurrentLayer->ConvertToScreen(&rect); fCurrentLayer->ConvertToScreenForDrawing(&rect);
driver->DrawEllipse(rect, fCurrentLayer->CurrentState(), code == AS_FILL_ELLIPSE); driver->DrawEllipse(rect, fCurrentLayer->CurrentState(), code == AS_FILL_ELLIPSE);
break; break;
@@ -1836,7 +1842,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<float>(&xrad); link.Read<float>(&xrad);
link.Read<float>(&yrad); link.Read<float>(&yrad);
fCurrentLayer->ConvertToScreen(&rect); fCurrentLayer->ConvertToScreenForDrawing(&rect);
driver->DrawRoundRect(rect, xrad, yrad, fCurrentLayer->CurrentState(), code == AS_FILL_ROUNDRECT); driver->DrawRoundRect(rect, xrad, yrad, fCurrentLayer->CurrentState(), code == AS_FILL_ROUNDRECT);
break; break;
@@ -1851,12 +1857,12 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
for (int32 i = 0; i < 3; i++) { for (int32 i = 0; i < 3; i++) {
link.Read<BPoint>(&(pts[i])); link.Read<BPoint>(&(pts[i]));
fCurrentLayer->ConvertToScreen(&pts[i]); fCurrentLayer->ConvertToScreenForDrawing(&pts[i]);
} }
link.Read<BRect>(&rect); link.Read<BRect>(&rect);
fCurrentLayer->ConvertToScreen(&rect); fCurrentLayer->ConvertToScreenForDrawing(&rect);
driver->DrawTriangle(pts, rect, fCurrentLayer->CurrentState(), code == AS_FILL_TRIANGLE); driver->DrawTriangle(pts, rect, fCurrentLayer->CurrentState(), code == AS_FILL_TRIANGLE);
break; break;
@@ -1879,14 +1885,14 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
if (link.Read(pointList, pointCount * sizeof(BPoint)) >= B_OK) { if (link.Read(pointList, pointCount * sizeof(BPoint)) >= B_OK) {
for (int32 i = 0; i < pointCount; i++) for (int32 i = 0; i < pointCount; i++)
fCurrentLayer->ConvertToScreen(&pointList[i]); fCurrentLayer->ConvertToScreenForDrawing(&pointList[i]);
driver->DrawPolygon(pointList, pointCount, polyFrame, driver->DrawPolygon(pointList, pointCount, polyFrame,
fCurrentLayer->CurrentState(), code == AS_FILL_POLYGON, fCurrentLayer->CurrentState(), code == AS_FILL_POLYGON,
isClosed && pointCount > 2); isClosed && pointCount > 2);
delete[] pointList;
} }
delete[] pointList;
break; break;
} }
@@ -1909,7 +1915,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read(ptList, ptCount * sizeof(BPoint)) >= B_OK) { link.Read(ptList, ptCount * sizeof(BPoint)) >= B_OK) {
for (int32 i = 0; i < ptCount; i++) for (int32 i = 0; i < ptCount; i++)
fCurrentLayer->ConvertToScreen(&ptList[i]); fCurrentLayer->ConvertToScreenForDrawing(&ptList[i]);
driver->DrawShape(shapeFrame, opCount, opList, ptCount, ptList, driver->DrawShape(shapeFrame, opCount, opList, ptCount, ptList,
fCurrentLayer->CurrentState(), code == AS_FILL_SHAPE); fCurrentLayer->CurrentState(), code == AS_FILL_SHAPE);
@@ -1941,7 +1947,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
region.Include(rects[i]); region.Include(rects[i]);
} }
fCurrentLayer->ConvertToScreen(&region); fCurrentLayer->ConvertToScreenForDrawing(&region);
driver->FillRegion(region, fCurrentLayer->CurrentState()); driver->FillRegion(region, fCurrentLayer->CurrentState());
delete[] rects; delete[] rects;
@@ -1974,8 +1980,8 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<float>(&(index->pt2.y)); link.Read<float>(&(index->pt2.y));
link.Read<rgb_color>(&(index->color)); link.Read<rgb_color>(&(index->color));
fCurrentLayer->ConvertToScreen(&index->pt1); fCurrentLayer->ConvertToScreenForDrawing(&index->pt1);
fCurrentLayer->ConvertToScreen(&index->pt2); fCurrentLayer->ConvertToScreenForDrawing(&index->pt2);
} }
driver->StrokeLineArray(linecount, linedata, fCurrentLayer->CurrentState()); driver->StrokeLineArray(linecount, linedata, fCurrentLayer->CurrentState());
} }
@@ -1994,10 +2000,10 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<escapement_delta>(&delta); link.Read<escapement_delta>(&delta);
link.ReadString(&string); link.ReadString(&string);
fCurrentLayer->ConvertToScreen(&location); fCurrentLayer->ConvertToScreenForDrawing(&location);
BPoint penLocation = driver->DrawString(string, length, location, BPoint penLocation = driver->DrawString(string, length, location,
fCurrentLayer->CurrentState(), &delta); fCurrentLayer->CurrentState(), &delta);
fCurrentLayer->ConvertFromScreen(&penLocation); fCurrentLayer->ConvertFromScreenForDrawing(&penLocation);
fCurrentLayer->CurrentState()->SetPenLocation(penLocation); fCurrentLayer->CurrentState()->SetPenLocation(penLocation);
free(string); free(string);