[Haiku-commits] r21900 - in haiku/trunk: headers/os/interface src/kits/interface src/servers/app
stippi at BerliOS
stippi at mail.berlios.de
Sun Aug 12 11:52:25 CEST 2007
Author: stippi
Date: 2007-08-12 11:52:25 +0200 (Sun, 12 Aug 2007)
New Revision: 21900
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21900&view=rev
Modified:
haiku/trunk/headers/os/interface/View.h
haiku/trunk/src/kits/interface/View.cpp
haiku/trunk/src/servers/app/ServerWindow.cpp
Log:
* there was a complete mixup of "drawing origin" and "scrolling offset" in the
BView implementation (client side)
* introduced some private methods for _Convert*(BPoint*) methods which avoid
doing the check_lock() thing in the recursion, also Origin() would likely
have communicated with the app_server all the time, since the origin bit
was needlessly invalidated, so some speedup should be achieved
* this should fix ticket #98
Modified: haiku/trunk/headers/os/interface/View.h
===================================================================
--- haiku/trunk/headers/os/interface/View.h 2007-08-12 09:05:48 UTC (rev 21899)
+++ haiku/trunk/headers/os/interface/View.h 2007-08-12 09:52:25 UTC (rev 21900)
@@ -599,6 +599,13 @@
void _ResizeBy(int32 deltaWidth, int32 deltaHeight);
void _ParentResizedBy(int32 x, int32 y);
+ void _ConvertToScreen(BPoint* pt, bool checkLock) const;
+ void _ConvertFromScreen(BPoint* pt, bool checkLock) const;
+
+ void _ConvertToParent(BPoint* pt, bool checkLock) const;
+ void _ConvertFromParent(BPoint* pt, bool checkLock) const;
+
+
void _Activate(bool state);
void _Attach();
void _Detach();
Modified: haiku/trunk/src/kits/interface/View.cpp
===================================================================
--- haiku/trunk/src/kits/interface/View.cpp 2007-08-12 09:05:48 UTC (rev 21899)
+++ haiku/trunk/src/kits/interface/View.cpp 2007-08-12 09:52:25 UTC (rev 21900)
@@ -628,20 +628,24 @@
void
-BView::ConvertToParent(BPoint *point) const
+BView::_ConvertToParent(BPoint *point, bool checkLock) const
{
if (!fParent)
return;
- check_lock_no_pick();
+ if (checkLock)
+ check_lock_no_pick();
- // TODO: handle scale
+ // - our scrolling offset
+ // + our bounds location within the parent
+ point->x += -fBounds.left + fParentOffset.x;
+ point->y += -fBounds.top + fParentOffset.y;
+}
- // our local coordinate transformation
- *point -= Origin();
-
- // our bounds location within the parent
- *point += fParentOffset;
+void
+BView::ConvertToParent(BPoint *point) const
+{
+ _ConvertToParent(point, true);
}
@@ -655,20 +659,24 @@
void
-BView::ConvertFromParent(BPoint *point) const
+BView::_ConvertFromParent(BPoint *point, bool checkLock) const
{
if (!fParent)
return;
- check_lock_no_pick();
+ if (checkLock)
+ check_lock_no_pick();
- // TODO: handle scale
+ // - our bounds location within the parent
+ // + our scrolling offset
+ point->x += -fParentOffset.x + fBounds.left;
+ point->y += -fParentOffset.y + fBounds.top;
+}
- // our bounds location within the parent
- *point -= fParentOffset;
-
- // our local coordinate transformation
- *point += Origin();
+void
+BView::ConvertFromParent(BPoint *point) const
+{
+ _ConvertFromParent(point, true);
}
@@ -689,15 +697,10 @@
check_lock_no_pick();
- // TODO: handle scale
-
- BPoint origin = Origin();
-
- // our local coordinate transformation
- rect->OffsetBy(-origin.x, -origin.y);
-
- // our bounds location within the parent
- rect->OffsetBy(fParentOffset);
+ // - our scrolling offset
+ // + our bounds location within the parent
+ rect->OffsetBy(-fBounds.left + fParentOffset.x,
+ -fBounds.top + fParentOffset.y);
}
@@ -718,13 +721,10 @@
check_lock_no_pick();
- // TODO: handle scale
-
- // our bounds location within the parent
- rect->OffsetBy(-fParentOffset.x, -fParentOffset.y);
-
- // our local coordinate transformation
- rect->OffsetBy(Origin());
+ // - our bounds location within the parent
+ // + our scrolling offset
+ rect->OffsetBy(-fParentOffset.x + fBounds.left,
+ -fParentOffset.y + fBounds.top);
}
@@ -738,7 +738,7 @@
void
-BView::ConvertToScreen(BPoint *pt) const
+BView::_ConvertToScreen(BPoint *pt, bool checkLock) const
{
if (!fParent) {
if (fOwner)
@@ -747,13 +747,21 @@
return;
}
- do_owner_check_no_pick();
+ if (checkLock)
+ do_owner_check_no_pick();
- ConvertToParent(pt);
- fParent->ConvertToScreen(pt);
+ _ConvertToParent(pt, false);
+ fParent->_ConvertToScreen(pt, false);
}
+void
+BView::ConvertToScreen(BPoint *pt) const
+{
+ _ConvertToScreen(pt, true);
+}
+
+
BPoint
BView::ConvertToScreen(BPoint pt) const
{
@@ -764,7 +772,7 @@
void
-BView::ConvertFromScreen(BPoint *pt) const
+BView::_ConvertFromScreen(BPoint *pt, bool checkLock) const
{
if (!fParent) {
if (fOwner)
@@ -773,13 +781,20 @@
return;
}
- do_owner_check_no_pick();
+ if (checkLock)
+ do_owner_check_no_pick();
- ConvertFromParent(pt);
- fParent->ConvertFromScreen(pt);
+ _ConvertFromParent(pt, false);
+ fParent->_ConvertFromScreen(pt, false);
}
+void
+BView::ConvertFromScreen(BPoint *pt) const
+{
+ _ConvertFromScreen(pt, true);
+}
+
BPoint
BView::ConvertFromScreen(BPoint pt) const
{
@@ -976,6 +991,9 @@
&& x == fState->origin.x && y == fState->origin.y)
return;
+ fState->origin.x = x;
+ fState->origin.y = y;
+
if (do_owner_check()) {
fOwner->fLink->StartMessage(AS_LAYER_SET_ORIGIN);
fOwner->fLink->Attach<float>(x);
@@ -1539,7 +1557,7 @@
fOwner->fLink->Flush();
- fState->valid_flags &= ~(B_VIEW_FRAME_BIT | B_VIEW_ORIGIN_BIT);
+// fState->valid_flags &= ~B_VIEW_FRAME_BIT;
}
// we modify our bounds rectangle by deltaX/deltaY coord units hor/ver.
@@ -3572,7 +3590,7 @@
fOwner->fLink->Attach<float>(x);
fOwner->fLink->Attach<float>(y);
- fState->valid_flags |= B_VIEW_FRAME_BIT;
+// fState->valid_flags |= B_VIEW_FRAME_BIT;
_FlushIfNotInTransaction();
}
@@ -3600,7 +3618,7 @@
fOwner->fLink->Attach<float>(fBounds.right + deltaWidth);
fOwner->fLink->Attach<float>(fBounds.bottom + deltaHeight);
- fState->valid_flags |= B_VIEW_FRAME_BIT;
+// fState->valid_flags |= B_VIEW_FRAME_BIT;
_FlushIfNotInTransaction();
}
@@ -4652,17 +4670,17 @@
return;
fState->UpdateFrom(*fOwner->fLink);
- if (!fState->IsValid(B_VIEW_FRAME_BIT)) {
- fOwner->fLink->StartMessage(AS_LAYER_GET_COORD);
-
- status_t code;
- if (fOwner->fLink->FlushWithReply(code) == B_OK
- && code == B_OK) {
- fOwner->fLink->Read<BPoint>(&fParentOffset);
- fOwner->fLink->Read<BRect>(&fBounds);
- fState->valid_flags |= B_VIEW_FRAME_BIT;
- }
- }
+// if (!fState->IsValid(B_VIEW_FRAME_BIT)) {
+// fOwner->fLink->StartMessage(AS_LAYER_GET_COORD);
+//
+// status_t code;
+// if (fOwner->fLink->FlushWithReply(code) == B_OK
+// && code == B_OK) {
+// fOwner->fLink->Read<BPoint>(&fParentOffset);
+// fOwner->fLink->Read<BRect>(&fBounds);
+// fState->valid_flags |= B_VIEW_FRAME_BIT;
+// }
+// }
// update children as well
Modified: haiku/trunk/src/servers/app/ServerWindow.cpp
===================================================================
--- haiku/trunk/src/servers/app/ServerWindow.cpp 2007-08-12 09:05:48 UTC (rev 21899)
+++ haiku/trunk/src/servers/app/ServerWindow.cpp 2007-08-12 09:52:25 UTC (rev 21900)
@@ -1381,8 +1381,8 @@
STRACE(("ServerWindow %s: Message AS_LAYER_GET_COORD: ViewLayer: %s\n", Title(), fCurrentLayer->Name()));
fLink.StartMessage(B_OK);
// our offset in the parent -> will be originX and originY in BView
- fLink.Attach<float>(fCurrentLayer->Frame().left);
- fLink.Attach<float>(fCurrentLayer->Frame().top);
+ BPoint parentOffset = fCurrentLayer->Frame().LeftTop();
+ fLink.Attach<BPoint>(parentOffset);
fLink.Attach<BRect>(fCurrentLayer->Bounds());
fLink.Flush();
break;
@@ -1403,9 +1403,7 @@
{
STRACE(("ServerWindow %s: Message AS_LAYER_GET_ORIGIN: ViewLayer: %s\n", Title(), fCurrentLayer->Name()));
fLink.StartMessage(B_OK);
- // 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.Attach<BPoint>(fCurrentLayer->DrawingOrigin());
fLink.Flush();
break;
}
More information about the Haiku-commits
mailing list