diff --git a/src/servers/app/ServerPicture.cpp b/src/servers/app/ServerPicture.cpp index f6d01c9fae..c3ae96c0a6 100644 --- a/src/servers/app/ServerPicture.cpp +++ b/src/servers/app/ServerPicture.cpp @@ -128,6 +128,7 @@ ShapePainter::Draw(ViewLayer *view, BRect frame, bool filled) for(i = (ptCount - 1);i >= 0;i--) { ptList[i] = fPtStack.top(); fPtStack.pop(); + view->ConvertToScreenForDrawing(&ptList[i]); } view->Window()->GetDrawingEngine()->DrawShape(frame, opCount, opList, ptCount, ptList, @@ -173,16 +174,24 @@ nop() static void move_pen_by(ViewLayer *view, BPoint delta) { - view->CurrentState()->SetPenLocation(delta - view->CurrentState()->PenLocation()); +// view->CurrentState()->SetPenLocation(delta - view->CurrentState()->PenLocation()); ?!? + view->CurrentState()->SetPenLocation(view->CurrentState()->PenLocation() + delta); } static void stroke_line(ViewLayer *view, BPoint start, BPoint end) { + BPoint penPos = end; + view->ConvertToScreenForDrawing(&start); view->ConvertToScreenForDrawing(&end); view->Window()->GetDrawingEngine()->StrokeLine(start, end); + + view->CurrentState()->SetPenLocation(penPos); + // the DrawingEngine/Painter does not need to be updated, since this + // effects only the view->screen coord conversion, which is handled + // by the view only } @@ -376,13 +385,20 @@ static void draw_string(ViewLayer *view, const char *string, float deltaSpace, float deltaNonSpace) { + // NOTE: the picture data was recorded with a "set pen location" command + // inserted before the "draw string" command, so we can use PenLocation() BPoint location = view->CurrentState()->PenLocation(); + escapement_delta delta = {deltaSpace, deltaNonSpace }; view->ConvertToScreenForDrawing(&location); view->Window()->GetDrawingEngine()->DrawString(string, strlen(string), location, &delta); - // TODO: Update pen location ? - + + view->ConvertFromScreenForDrawing(&location); + view->CurrentState()->SetPenLocation(location); + // the DrawingEngine/Painter does not need to be updated, since this + // effects only the view->screen coord conversion, which is handled + // by the view only } @@ -482,12 +498,9 @@ static void set_pen_location(ViewLayer *view, BPoint pt) { view->CurrentState()->SetPenLocation(pt); - - // TODO: faster version - IntPoint p = view->ScrollingOffset(); - p += IntPoint(view->CurrentState()->Origin()); - view->Window()->GetDrawingEngine()->SetDrawState( - view->CurrentState(), p.x, p.y); + // the DrawingEngine/Painter does not need to be updated, since this + // effects only the view->screen coord conversion, which is handled + // by the view only } @@ -546,6 +559,9 @@ static void set_scale(ViewLayer *view, float scale) { view->CurrentState()->SetScale(scale); + // the DrawingEngine/Painter does not need to be updated, since this + // effects only the view->screen coord conversion, which is handled + // by the view only } diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index 1d79232194..a1c4e67787 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -1550,8 +1550,6 @@ ServerWindow::_DispatchViewMessage(int32 code, link.Read(&y); fCurrentLayer->CurrentState()->SetPenLocation(BPoint(x, y)); - // TODO: is this necessary? - _UpdateDrawState(fCurrentLayer); break; } case AS_LAYER_GET_PEN_LOC: @@ -1570,15 +1568,16 @@ ServerWindow::_DispatchViewMessage(int32 code, link.Read(&penSize); fCurrentLayer->CurrentState()->SetPenSize(penSize); - //_UpdateDrawState(fCurrentLayer); - fWindowLayer->GetDrawingEngine()->SetPenSize(penSize); + fWindowLayer->GetDrawingEngine()->SetPenSize( + fCurrentLayer->CurrentState()->PenSize()); break; } case AS_LAYER_GET_PEN_SIZE: { DTRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_SIZE: ViewLayer: %s\n", Title(), fCurrentLayer->Name())); fLink.StartMessage(B_OK); - fLink.Attach(fCurrentLayer->CurrentState()->PenSize()); + fLink.Attach( + fCurrentLayer->CurrentState()->UnscaledPenSize()); fLink.Flush(); break; @@ -1854,7 +1853,6 @@ ServerWindow::_DispatchViewMessage(int32 code, link.Read(&c, sizeof(rgb_color)); fCurrentLayer->CurrentState()->SetHighColor(RGBColor(c)); -// _UpdateDrawState(fCurrentLayer); fWindowLayer->GetDrawingEngine()->SetHighColor(c); break; } @@ -1866,7 +1864,6 @@ ServerWindow::_DispatchViewMessage(int32 code, link.Read(&c, sizeof(rgb_color)); fCurrentLayer->CurrentState()->SetLowColor(RGBColor(c)); -// _UpdateDrawState(fCurrentLayer); fWindowLayer->GetDrawingEngine()->SetLowColor(c); break; } @@ -1878,7 +1875,6 @@ ServerWindow::_DispatchViewMessage(int32 code, link.Read(&pat, sizeof(pattern)); fCurrentLayer->CurrentState()->SetPattern(Pattern(pat)); -// _UpdateDrawState(fCurrentLayer); fWindowLayer->GetDrawingEngine()->SetPattern(pat); break; } @@ -2575,14 +2571,11 @@ ServerWindow::_DispatchPictureMessage(int32 code, BPrivate::LinkReceiver &link) && link.Read(opList, opCount * sizeof(uint32)) >= B_OK && link.Read(ptList, ptCount * sizeof(BPoint)) >= B_OK) { - // TODO: I'm not sure If I have to do this here (when the BPicture is - // recorded, or inside ServerPicture, when the picture is replayed. // This might seem a bit weird, but under R5, the shapes // are always offset by the current pen location BPoint penLocation = fCurrentLayer->CurrentState()->PenLocation(); for (int32 i = 0; i < ptCount; i++) { ptList[i] += penLocation; - fCurrentLayer->ConvertToScreenForDrawing(&ptList[i]); } const bool fill = (code == AS_FILL_SHAPE); picture->WriteDrawShape(opCount, opList, ptCount, ptList, fill);