aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2016-06-20 21:44:36 +0200
committerSebastian Geerken <devnull@localhost>2016-06-20 21:44:36 +0200
commit94c2d21c5c035fa056481ea6e6743f83ea651e78 (patch)
treebf04218bbe467fb81d265093e1469365f084d5ec
parent1d4da1af1d51e2b2de907c46666e05ef866a9300 (diff)
Incremental resizing for OOFFloatsMgr.
-rw-r--r--devdoc/dw-miscellaneous.doc6
-rw-r--r--dw/ooffloatsmgr.cc56
-rw-r--r--dw/ooffloatsmgr.hh1
-rw-r--r--dw/textblock.cc13
4 files changed, 43 insertions, 33 deletions
diff --git a/devdoc/dw-miscellaneous.doc b/devdoc/dw-miscellaneous.doc
index dc282354..faaf2fa8 100644
--- a/devdoc/dw-miscellaneous.doc
+++ b/devdoc/dw-miscellaneous.doc
@@ -51,6 +51,11 @@ Widget sizes
Relation between dw::core::Widget::markSizeChange and dw::core::Widget::queueResize
------------------------------------------------------------------------------------
+The following comment should be re-evaluated. Implementing incremental resizing
+for dw::oof::OOFFloatsMgr seems to fix the performance problems, but this should
+be examined further.
+
+<div style="text-decoration: line-through; color: #606060">
dw::oof::OOFFloatsMgr::markSizeChange (called from
dw::Textblock::markSizeChange) calls dw::oof::OOFAwareWidget::updateReference,
whose implementation dw::Textblock::updateReference calls
@@ -77,5 +82,6 @@ You may change the numner (20), or examine smaller cases with
<a href="http://home.gna.org/rtfl/">RTFL</a>:
(for i in $(seq 1 3); do echo '<div style="float:left"><div></div>'; done) > tmp.html; src/dillo tmp.html | rtfl-objview -OM -A "*" -a resize -a resize.oofm
+</div>
*/
diff --git a/dw/ooffloatsmgr.cc b/dw/ooffloatsmgr.cc
index 84b2f6ff..0d701b0b 100644
--- a/dw/ooffloatsmgr.cc
+++ b/dw/ooffloatsmgr.cc
@@ -340,6 +340,9 @@ OOFFloatsMgr::OOFFloatsMgr (OOFAwareWidget *container, int oofmIndex)
leftFloatsMark = rightFloatsMark = 0;
lastLeftTBIndex = lastRightTBIndex = 0;
+ floatRef = -1;
+ DBG_OBJ_SET_NUM ("floatRef", floatRef);
+
containerAllocation = *(container->getAllocation());
addWidgetInFlow (this->container, NULL, 0);
@@ -633,32 +636,40 @@ void OOFFloatsMgr::markSizeChange (int ref)
{
DBG_OBJ_ENTER ("resize.oofm", 0, "markSizeChange", "%d", ref);
- Float *vloat;
+ // We implement "incremental resizing" (kind of), by remembering the largest
+ // value for "ref", in "floatRef". It is reset again in getSize(), which is
+ // called by sizeRequest().
+ if (floatRef == -1 || ref > floatRef) {
+ Float *vloat;
- if (isSubRefLeftFloat (ref))
- vloat = leftFloats->get (getFloatIndexFromSubRef (ref));
- else if (isSubRefRightFloat (ref))
- vloat = rightFloats->get (getFloatIndexFromSubRef (ref));
- else {
- assertNotReached();
- vloat = NULL; // compiler happiness
- }
+ if (isSubRefLeftFloat (ref))
+ vloat = leftFloats->get (getFloatIndexFromSubRef (ref));
+ else if (isSubRefRightFloat (ref))
+ vloat = rightFloats->get (getFloatIndexFromSubRef (ref));
+ else {
+ assertNotReached();
+ vloat = NULL; // compiler happiness
+ }
- vloat->dirty = true;
- DBG_OBJ_SET_BOOL_O (vloat->getWidget (), "<Float>.dirty", vloat->dirty);
+ vloat->dirty = true;
+ DBG_OBJ_SET_BOOL_O (vloat->getWidget (), "<Float>.dirty", vloat->dirty);
- assert (vloat->getWidget()->getWidgetReference() != NULL);
+ assert (vloat->getWidget()->getWidgetReference() != NULL);
- int first = getOOFAwareWidget(vloat->generator)->index;
- DBG_OBJ_MSGF ("resize.oofm", 1, "updating from %d", first);
-
- tbInfos->get(first)->getOOFAwareWidget()
- ->updateReference (vloat->getWidget()->getWidgetReference()
- ->parentRef);
-
- for (int i = first + 1; i < tbInfos->size(); i++)
- tbInfos->get(i)->getOOFAwareWidget()->updateReference(0);
+ int first = getOOFAwareWidget(vloat->generator)->index;
+ DBG_OBJ_MSGF ("resize.oofm", 1, "updating from %d", first);
+
+ tbInfos->get(first)->getOOFAwareWidget()
+ ->updateReference (vloat->getWidget()->getWidgetReference()
+ ->parentRef);
+
+ for (int i = first + 1; i < tbInfos->size(); i++)
+ tbInfos->get(i)->getOOFAwareWidget()->updateReference(0);
+ floatRef = ref;
+ DBG_OBJ_SET_NUM ("floatRef", floatRef);
+ }
+
DBG_OBJ_LEAVE ();
}
@@ -925,6 +936,9 @@ void OOFFloatsMgr::getSize (Requisition *cbReq, int *oofWidth, int *oofHeight)
*oofHeight =
max (oofHeightLeft, oofHeightRight) + container->boxRestHeight ();
+ floatRef = -1;
+ DBG_OBJ_SET_NUM ("floatRef", floatRef);
+
DBG_OBJ_MSGF ("resize.oofm", 1,
"=> (l: %d, r: %d => %d) * (l: %d, r: %d => %d)",
oofWidthtLeft, oofWidthRight, *oofWidth, oofHeightLeft,
diff --git a/dw/ooffloatsmgr.hh b/dw/ooffloatsmgr.hh
index 87cdc866..c342f4a7 100644
--- a/dw/ooffloatsmgr.hh
+++ b/dw/ooffloatsmgr.hh
@@ -164,6 +164,7 @@ private:
TBInfo> *tbInfosByOOFAwareWidget;
int lastLeftTBIndex, lastRightTBIndex, leftFloatsMark, rightFloatsMark;
+ int floatRef;
void moveExternalIndices (lout::container::typed::Vector<Float> *list,
int oldStartIndex, int diff);
diff --git a/dw/textblock.cc b/dw/textblock.cc
index 700c748b..f0bfb3d8 100644
--- a/dw/textblock.cc
+++ b/dw/textblock.cc
@@ -3035,18 +3035,7 @@ void Textblock::queueDrawRange (int index1, int index2)
void Textblock::updateReference (int ref)
{
- // The condition "(lines->size () > 0)" prevents CPU hogging in some cases,
- // see devdoc/dw-miscellaneous.doc, "Relation between
- // dw::core::Widget::markSizeChange and dw::core::Widget::queueResize".
- //
- // This condition is safe, since an implementation of
- // dw::oof::OOFAwareWidget::updateReference should only affect content in
- // flow, not widgets out of flow, like floats.
-
- if (lines->size () > 0)
- queueResize (ref, false);
-
- // TODO: "if (words->size () > 0)" has to be considered.
+ queueResize (ref, false);
}
void Textblock::widgetRefSizeChanged (int externalIndex)