[Haiku-commits] r21855 - haiku/trunk/src/servers/app
stippi at BerliOS
stippi at mail.berlios.de
Wed Aug 8 20:36:23 CEST 2007
Author: stippi
Date: 2007-08-08 20:36:23 +0200 (Wed, 08 Aug 2007)
New Revision: 21855
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21855&view=rev
Modified:
haiku/trunk/src/servers/app/ServerPicture.cpp
haiku/trunk/src/servers/app/ServerWindow.cpp
Log:
* 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
Modified: haiku/trunk/src/servers/app/ServerPicture.cpp
===================================================================
--- haiku/trunk/src/servers/app/ServerPicture.cpp 2007-08-08 18:33:59 UTC (rev 21854)
+++ haiku/trunk/src/servers/app/ServerPicture.cpp 2007-08-08 18:36:23 UTC (rev 21855)
@@ -128,6 +128,7 @@
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 @@
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 @@
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 @@
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 @@
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
}
Modified: haiku/trunk/src/servers/app/ServerWindow.cpp
===================================================================
--- haiku/trunk/src/servers/app/ServerWindow.cpp 2007-08-08 18:33:59 UTC (rev 21854)
+++ haiku/trunk/src/servers/app/ServerWindow.cpp 2007-08-08 18:36:23 UTC (rev 21855)
@@ -1550,8 +1550,6 @@
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 @@
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 @@
link.Read(&c, sizeof(rgb_color));
fCurrentLayer->CurrentState()->SetHighColor(RGBColor(c));
-// _UpdateDrawState(fCurrentLayer);
fWindowLayer->GetDrawingEngine()->SetHighColor(c);
break;
}
@@ -1866,7 +1864,6 @@
link.Read(&c, sizeof(rgb_color));
fCurrentLayer->CurrentState()->SetLowColor(RGBColor(c));
-// _UpdateDrawState(fCurrentLayer);
fWindowLayer->GetDrawingEngine()->SetLowColor(c);
break;
}
@@ -1878,7 +1875,6 @@
link.Read(&pat, sizeof(pattern));
fCurrentLayer->CurrentState()->SetPattern(Pattern(pat));
-// _UpdateDrawState(fCurrentLayer);
fWindowLayer->GetDrawingEngine()->SetPattern(pat);
break;
}
@@ -2575,14 +2571,11 @@
&& 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);
More information about the Haiku-commits
mailing list