* convert shape coordinates to screen at the time of playing the picture
(fixes ticket #1367, stefano I thought you knew that I meant this in an earlier mail) * move_pen_by() looked wrong in ServerPicture, have not tested though * make sure the pen location is adjusted after stroke_line() and draw_string() in ServerPicture * set_pen_location() does not need to update the Painter drawing state * ServerWindow AS_LAYER_SET_PEN_SIZE needs to set the resulting pen size of the drawing state stack, not the one set on the current state * ServerWindow AS_LAYER_GET_PEN_SIZE needs to return the current state's size, not the result of the stack * small cleanups git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21855 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
eb85607872
commit
bbc424771b
@ -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
|
||||
}
|
||||
|
||||
|
||||
|
@ -1550,8 +1550,6 @@ ServerWindow::_DispatchViewMessage(int32 code,
|
||||
link.Read<float>(&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<float>(&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<float>(fCurrentLayer->CurrentState()->PenSize());
|
||||
fLink.Attach<float>(
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user