aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2015-09-21 12:53:08 +0200
committerSebastian Geerken <devnull@localhost>2015-09-21 12:53:08 +0200
commiteca6709dee327dca43673a4240537cdfedc590f8 (patch)
tree829c21c302774c0f095d83753c54f09e5cfed279
parentd5c28323ef77ec7a8827b528a9ba102ce07af91a (diff)
SRDOP: More cleanup for floats. (Code compiles, not more!)
-rw-r--r--dw/ooffloatsmgr.cc104
-rw-r--r--dw/ooffloatsmgr.hh38
2 files changed, 40 insertions, 102 deletions
diff --git a/dw/ooffloatsmgr.cc b/dw/ooffloatsmgr.cc
index 7166b770..dc89cce2 100644
--- a/dw/ooffloatsmgr.cc
+++ b/dw/ooffloatsmgr.cc
@@ -72,7 +72,7 @@ OOFFloatsMgr::Float::Float (OOFFloatsMgr *oofm, Widget *widget,
yReq = yReal = size.width = size.ascent = size.descent = 0;
dirty = sizeChangedSinceLastAllocation = true;
- indexGBList = indexCBList = -1;
+ index = -1;
// Sometimes a float with widget = NULL is created as a key; this
// is not interesting for RTFL.
@@ -111,10 +111,8 @@ void OOFFloatsMgr::Float::intoStringBuffer(StringBuffer *sb)
sb->append (")");
}
- sb->append (", indexGBList = ");
- sb->appendInt (indexGBList);
- sb->append (", indexCBList = ");
- sb->appendInt (indexCBList);
+ sb->append (", index = ");
+ sb->appendInt (index);
sb->append (", sideSpanningIndex = ");
sb->appendInt (sideSpanningIndex);
sb->append (", generatingBlock = ");
@@ -194,7 +192,7 @@ int OOFFloatsMgr::Float::ComparePosition::compare (Object *o1, Object *o2)
DBG_OBJ_ENTER_O ("border", 1, oofm,
"ComparePosition/compare", "(#%d, #%d) [refTB = %p]",
- fl1->getIndex (type), fl2->getIndex (type), refTB);
+ fl1->index, fl2->index, refTB);
if (refTB == fl1->generatingBlock && refTB == fl2->generatingBlock) {
DBG_OBJ_MSG_O ("border", 2, oofm, "refTB is generating both floats");
@@ -281,8 +279,8 @@ int OOFFloatsMgr::Float::CompareGBAndExtIndex::compare (Object *o1, Object *o2)
DBG_OBJ_ENTER_O ("border", 1, oofm, "CompareGBAndExtIndex::compare",
"#%d -> %p/%d, #%d -> %p/#%d",
- f1->getIndex (type), f1->generatingBlock, f1->externalIndex,
- f2->getIndex (type), f2->generatingBlock,
+ f1->index, f1->generatingBlock, f1->externalIndex,
+ f2->index, f2->generatingBlock,
f2->externalIndex);
if (f1->generatingBlock == f2->generatingBlock) {
@@ -338,8 +336,8 @@ int OOFFloatsMgr::SortedFloatsVector::findFloatIndex (OOFAwareWidget *lastGB,
lastGB, lastExtIndex);
Float key (oofm, NULL, lastGB, lastExtIndex);
- key.setIndex (type, -1); // for debugging
- Float::CompareGBAndExtIndex comparator (oofm, type);
+ key.index = -1; // for debugging
+ Float::CompareGBAndExtIndex comparator (oofm);
int i = bsearch (&key, false, &comparator);
// At position i is the next larger element, so element i should
@@ -383,8 +381,8 @@ int OOFFloatsMgr::SortedFloatsVector::find (OOFAwareWidget *textblock, int y,
Float key (oofm, NULL, NULL, 0);
key.generatingBlock = textblock;
key.yReal = y;
- key.setIndex (type, -1); // for debugging
- Float::ComparePosition comparator (oofm, textblock, type);
+ key.index = -1; // for debugging
+ Float::ComparePosition comparator (oofm, textblock);
int result = bsearch (&key, false, start, end, &comparator);
DBG_OBJ_MSGF_O ("border", 1, oofm, "=> result = %d", result);
@@ -409,7 +407,7 @@ int OOFFloatsMgr::SortedFloatsVector::findFirst (OOFAwareWidget *textblock,
DBG_OBJ_MSGF_O ("border", 2, oofm,
"%d: (%p, i = %d/%d, y = %d/%d, s = (%d * (%d + %d)), "
"%s, %s, ext = %d, GB = %p); widget at (%d, %d)",
- i, get(i)->getWidget (), get(i)->getIndex (type),
+ i, get(i)->getWidget (), get(i)->index,
get(i)->sideSpanningIndex, get(i)->yReq, get(i)->yReal,
get(i)->size.width, get(i)->size.ascent,
get(i)->size.descent,
@@ -465,7 +463,7 @@ int OOFFloatsMgr::SortedFloatsVector::findLastBeforeSideSpanningIndex
void OOFFloatsMgr::SortedFloatsVector::put (Float *vloat)
{
lout::container::typed::Vector<Float>::put (vloat);
- vloat->setIndex (type, size() - 1);
+ vloat->index = size() - 1;
}
OOFFloatsMgr::TBInfo::TBInfo (OOFFloatsMgr *oofm, OOFAwareWidget *textblock,
@@ -475,8 +473,8 @@ OOFFloatsMgr::TBInfo::TBInfo (OOFFloatsMgr *oofm, OOFAwareWidget *textblock,
this->parent = parent;
this->parentExtIndex = parentExtIndex;
- leftFloatsGB = new SortedFloatsVector (oofm, LEFT, GB);
- rightFloatsGB = new SortedFloatsVector (oofm, RIGHT, GB);
+ leftFloatsGB = new SortedFloatsVector (oofm, LEFT);
+ rightFloatsGB = new SortedFloatsVector (oofm, RIGHT);
wasAllocated = getWidget()->wasAllocated ();
allocation = *(getWidget()->getAllocation ());
@@ -505,8 +503,8 @@ OOFFloatsMgr::OOFFloatsMgr (OOFAwareWidget *container)
this->container = (OOFAwareWidget*)container;
- leftFloatsCB = new SortedFloatsVector (this, LEFT, CB);
- rightFloatsCB = new SortedFloatsVector (this, RIGHT, CB);
+ leftFloatsCB = new SortedFloatsVector (this, LEFT);
+ rightFloatsCB = new SortedFloatsVector (this, RIGHT);
DBG_OBJ_SET_NUM ("leftFloatsCB.size", leftFloatsCB->size());
DBG_OBJ_SET_NUM ("rightFloatsCB.size", rightFloatsCB->size());
@@ -580,10 +578,6 @@ void OOFFloatsMgr::sizeAllocateStart (OOFAwareWidget *caller,
containerWasAllocated = true;
containerAllocation = *allocation;
- // Move floats from GB lists to the one CB list.
- moveFromGBToCB (LEFT);
- moveFromGBToCB (RIGHT);
-
// These attributes are used to keep track which floats have
// been allocated (referring to leftFloatsCB and rightFloatsCB).
lastAllocatedLeftFloat = lastAllocatedRightFloat = -1;
@@ -783,45 +777,6 @@ bool OOFFloatsMgr::haveExtremesChanged (Side side)
return changed;
}
-void OOFFloatsMgr::moveFromGBToCB (Side side)
-{
- DBG_OBJ_ENTER ("oofm.resize", 0, "moveFromGBToCB", "%s",
- side == LEFT ? "LEFT" : "RIGHT");
-
- SortedFloatsVector *dest = side == LEFT ? leftFloatsCB : rightFloatsCB;
- int *floatsMark = side == LEFT ? &leftFloatsMark : &rightFloatsMark;
-
- for (int mark = 0; mark <= *floatsMark; mark++)
- for (lout::container::typed::Iterator<TBInfo> it = tbInfos->iterator ();
- it.hasNext (); ) {
- TBInfo *tbInfo = it.getNext ();
- SortedFloatsVector *src =
- side == LEFT ? tbInfo->leftFloatsGB : tbInfo->rightFloatsGB;
- for (int i = 0; i < src->size (); i++) {
- Float *vloat = src->get (i);
- // "vloat->indexCBList == -1": prevent copying the vloat twice.
- if (vloat->indexCBList == -1 && vloat->mark == mark) {
- dest->put (vloat);
- DBG_OBJ_MSGF ("oofm.resize", 1,
- "moving float %p (mark %d) to CB list\n",
- vloat->getWidget (), vloat->mark);
- DBG_OBJ_SET_NUM (side == LEFT ?
- "leftFloatsCB.size" : "rightFloatsCB.size",
- dest->size());
- DBG_OBJ_ARRATTRSET_PTR (side == LEFT ?
- "leftFloatsCB" : "rightFloatsCB",
- dest->size() - 1, "widget",
- vloat->getWidget ());
-
- }
- }
- }
-
- *floatsMark = 0;
-
- DBG_OBJ_LEAVE ();
-}
-
void OOFFloatsMgr::sizeAllocateFloats (Side side, int newLastAllocatedFloat)
{
SortedFloatsVector *list = side == LEFT ? leftFloatsCB : rightFloatsCB;
@@ -1183,10 +1138,9 @@ void OOFFloatsMgr::tellPosition1 (Widget *widget, int x, int y)
// tested; especially since searching and border calculation would
// be confused. For this reaspn, only the previous float is
// relevant. (Cf. below, collisions on the other side.)
- int index = vloat->getIndex (listSame->type), yRealNew;
- if (index >= 1 &&
- collidesV (vloat, listSame->get (index - 1), listSame->type,
- &yRealNew, false)) {
+ int yRealNew;
+ if (vloat->index >= 1 &&
+ collidesV (vloat, listSame->get (vloat->index - 1), &yRealNew)) {
vloat->yReal = yRealNew;
DBG_OBJ_SET_NUM_O (vloat->getWidget (), "<Float>.yReal", vloat->yReal);
}
@@ -1223,12 +1177,11 @@ void OOFFloatsMgr::tellPosition1 (Widget *widget, int x, int y)
// ...
for (bool foundColl = false;
!foundColl && oppFloatIndex >= 0 &&
- collidesV (vloat, listOpp->get (oppFloatIndex), listSame->type,
- &yRealNew, false);
+ collidesV (vloat, listOpp->get (oppFloatIndex), &yRealNew);
oppFloatIndex--) {
// ... but stop the loop as soon as the horizontal dimensions
// test is positive.
- if (collidesH (vloat, listOpp->get (oppFloatIndex), listSame->type)) {
+ if (collidesH (vloat, listOpp->get (oppFloatIndex))) {
vloat->yReal = yRealNew;
DBG_OBJ_SET_NUM_O (vloat->getWidget (), "<Float>.yReal", vloat->yReal);
foundColl = true;
@@ -1258,16 +1211,15 @@ void OOFFloatsMgr::tellIncompletePosition2 (Widget *generator, Widget *widget,
assertNotReached ();
}
-bool OOFFloatsMgr::collidesV (Float *vloat, Float *other, SFVType type,
- int *yReal, bool useAllocation)
+bool OOFFloatsMgr::collidesV (Float *vloat, Float *other, int *yReal)
{
// Only checks vertical (possible) collisions, and only refers to
// vloat->yReal; never to vloat->allocation->y, even when the GBs are
// different. Used only in tellPosition.
DBG_OBJ_ENTER ("resize.oofm", 0, "collidesV", "#%d [%p], #%d [%p], ...",
- vloat->getIndex (type), vloat->getWidget (),
- other->getIndex (type), other->getWidget ());
+ vloat->index, vloat->getWidget (), other->index,
+ other->getWidget ());
bool result;
@@ -1298,6 +1250,10 @@ bool OOFFloatsMgr::collidesV (Float *vloat, Float *other, SFVType type,
Allocation *gba = getAllocation (vloat->generatingBlock),
*flaOther = other->getWidget()->getAllocation ();
+ // TODO: The following comment is wrong after SRDOP. What is still
+ // relevant (especially in the second paragraph)? (Also, usage of
+ // allocation has to be reworked generally.)
+ //
// We distinguish two cases (by different values of useAllocation):
// (i) within tellPosition, GB allocation + yReal is used for the
// y position of the other float, while (ii) in checkAllocatedFloat-
@@ -1320,7 +1276,7 @@ bool OOFFloatsMgr::collidesV (Float *vloat, Float *other, SFVType type,
// case, corrected in sizeAllocateEnd, either because hasRelation-
// Changed returns true, or in checkAllocatedFloatCollisions.
- int otherFloatY = useAllocation ? flaOther->y :
+ int otherFloatY =
getAllocation(other->generatingBlock)->y + other->yReal;
int otherBottomGB =
otherFloatY + flaOther->ascent + flaOther->descent - gba->y;
@@ -1349,7 +1305,7 @@ bool OOFFloatsMgr::collidesV (Float *vloat, Float *other, SFVType type,
}
-bool OOFFloatsMgr::collidesH (Float *vloat, Float *other, SFVType type)
+bool OOFFloatsMgr::collidesH (Float *vloat, Float *other)
{
// Only checks horizontal collision. For a complete test, use
// collidesV (...) && collidesH (...).
diff --git a/dw/ooffloatsmgr.hh b/dw/ooffloatsmgr.hh
index 6394fdb9..250e849f 100644
--- a/dw/ooffloatsmgr.hh
+++ b/dw/ooffloatsmgr.hh
@@ -1,6 +1,7 @@
#ifndef __DW_OOFFLOATSMGR_HH__
#define __DW_OOFFLOATSMGR_HH__
+
#include "outofflowmgr.hh"
namespace dw {
@@ -20,7 +21,6 @@ class OOFFloatsMgr: public OutOfFlowMgr
private:
enum Side { LEFT, RIGHT };
- enum SFVType { GB, CB };
OOFAwareWidget *container;
@@ -65,12 +65,10 @@ private:
private:
OOFFloatsMgr *oofm;
OOFAwareWidget *refTB;
- SFVType type; // actually only used for debugging
public:
- ComparePosition (OOFFloatsMgr *oofm, OOFAwareWidget *refTB,
- SFVType type)
- { this->oofm = oofm; this->refTB = refTB; this->type = type; }
+ ComparePosition (OOFFloatsMgr *oofm, OOFAwareWidget *refTB)
+ { this->oofm = oofm; this->refTB = refTB; }
int compare(Object *o1, Object *o2);
};
@@ -84,22 +82,17 @@ private:
{
private:
OOFFloatsMgr *oofm;
- SFVType type; // actually only used for debugging
public:
- CompareGBAndExtIndex (OOFFloatsMgr *oofm, SFVType type)
- { this->oofm = oofm; this->type = type; }
+ CompareGBAndExtIndex (OOFFloatsMgr *oofm)
+ { this->oofm = oofm; }
int compare(Object *o1, Object *o2);
};
OOFAwareWidget *generatingBlock;
int externalIndex;
+ int index; // TODO Needed after SRDOP?
int yReq, yReal; // relative to generator, not container
- int indexGBList; /* Refers to TBInfo::leftFloatsGB or
- TBInfo::rightFloatsGB, respectively. -1
- initially. */
- int indexCBList; /* Refers to leftFloatsCB or rightFloatsCB,
- respectively. -1 initially. */
int sideSpanningIndex, mark;
core::Requisition size;
int cbLineBreakWidth; /* On which the calculation of relative sizes
@@ -120,12 +113,6 @@ private:
getWidget()->getAllocation()->descent; }
void updateAllocation ();
- inline int *getIndexRef (SFVType type) {
- return type == GB ? &indexGBList : &indexCBList; }
- inline int getIndex (SFVType type) { return *(getIndexRef (type)); }
- inline void setIndex (SFVType type, int value) {
- *(getIndexRef (type)) = value; }
-
void intoStringBuffer(lout::misc::StringBuffer *sb);
bool covers (OOFAwareWidget *textblock, int y, int h);
@@ -145,17 +132,14 @@ private:
*/
class SortedFloatsVector: private lout::container::typed::Vector<Float>
{
- public:
- SFVType type;
-
private:
OOFFloatsMgr *oofm;
Side side;
public:
- inline SortedFloatsVector (OOFFloatsMgr *oofm, Side side, SFVType type) :
+ inline SortedFloatsVector (OOFFloatsMgr *oofm, Side side) :
lout::container::typed::Vector<Float> (1, false)
- { this->oofm = oofm; this->side = side; this->type = type; }
+ { this->oofm = oofm; this->side = side; }
int findFloatIndex (OOFAwareWidget *lastGB, int lastExtIndex);
int find (OOFAwareWidget *textblock, int y, int start, int end);
@@ -262,7 +246,6 @@ private:
int diff);
Float *findFloatByWidget (core::Widget *widget);
- void moveFromGBToCB (Side side);
void sizeAllocateFloats (Side side, int newLastAllocatedFloat);
int getGBWidthForAllocation (Float *vloat);
int calcFloatX (Float *vloat, Side side, int gbX, int gbWidth);
@@ -276,9 +259,8 @@ private:
core::GettingWidgetAtPointContext
*context);
- bool collidesV (Float *vloat, Float *other, SFVType type, int *yReal,
- bool useAllocation);
- bool collidesH (Float *vloat, Float *other, SFVType type);
+ bool collidesV (Float *vloat, Float *other, int *yReal);
+ bool collidesH (Float *vloat, Float *other);
void getFloatsListsAndSide (Float *vloat, SortedFloatsVector **listSame,
SortedFloatsVector **listOpp, Side *side);