aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJorge Arellano Cid <jcid@dillo.org>2016-04-27 14:27:53 -0300
committerJorge Arellano Cid <jcid@dillo.org>2016-04-27 14:27:53 -0300
commit0c2eaee51fbaa734a72e5c4d2cf62881e7c45991 (patch)
tree3efab3d9b503931bcc66c16ac397a8167ef91a62
parent08fd62b0bf3bd21b1fc6f27bc3b1ceea1b57f773 (diff)
Reduce in half the redraws when scrolling.
Now there's a single fl_scroll() call for each scroll operation, instead of calling fl_scroll() and then draw(). The patch also fixes support for FL_DAMAGE_EXPOSE in FltkViewport::draw(). Test data: FL_DAMAGE_CHILD = 0x01, 1 FL_DAMAGE_EXPOSE = 0x02, 2 FL_DAMAGE_SCROLL = 0x04, 4 FL_DAMAGE_OVERLAY = 0x08, 8 FL_DAMAGE_USER1 = 0x10, 16 FL_DAMAGE_USER2 = 0x20, 32 FL_DAMAGE_ALL = 0x80 128 -----------------------------------------------------------------------------. | scroll: keys | focus click | Alt-Tab | unfocus| | or mousewheel | viewport | statusbar | unfocus | focus | click | -----------------------------------------------------------------------------| d4235 | 5,5 | 16 | | 128 |128,128,128| | d4529 | 5,5 | 16 | | 128 |128,128,128| | dpatch | 5 | 16 | | 128 |128,128,128| | -----------------------------------------------------------------------------' </pre> The first column means dillo version (hg rev). The second one the FLTK damage bits received by FltkViewport::draw() per scroll operation (also viewable at dillo's stdout). The other columns show excessive calls, but that's another bug that is not as relevant as scrolling now, so feel free to ignore them by now.
-rw-r--r--dw/fltkviewbase.cc2
-rw-r--r--dw/fltkviewport.cc35
-rw-r--r--dw/layout.cc1
3 files changed, 20 insertions, 18 deletions
diff --git a/dw/fltkviewbase.cc b/dw/fltkviewbase.cc
index 4778cd87..145d4136 100644
--- a/dw/fltkviewbase.cc
+++ b/dw/fltkviewbase.cc
@@ -434,7 +434,7 @@ void FltkViewBase::finishDrawing (core::Rectangle *area)
void FltkViewBase::queueDraw (core::Rectangle *area)
{
drawRegion.addRectangle (area);
- damage (FL_DAMAGE_USER1);
+ damage (FL_DAMAGE_USER1); // USER1 for buffered draw
}
void FltkViewBase::queueDrawTotal ()
diff --git a/dw/fltkviewport.cc b/dw/fltkviewport.cc
index 707c0bd7..e903e05f 100644
--- a/dw/fltkviewport.cc
+++ b/dw/fltkviewport.cc
@@ -193,34 +193,37 @@ void FltkViewport::draw_area (void *data, int x, int y, int w, int h)
}
fl_pop_clip();
-
}
+/*
+ * Draw the viewport.
+ *
+ * + Damage flags come in different ways, draw() should cope with them all.
+ * + FL_DAMAGE_CHILD can flag scroll bars or embedded FLTK widgets.
+ */
void FltkViewport::draw ()
{
int hdiff = vscrollbar->visible () ? SCROLLBAR_THICKNESS : 0;
int vdiff = hscrollbar->visible () ? SCROLLBAR_THICKNESS : 0;
int d = damage();
- if (d & FL_DAMAGE_SCROLL) {
- clear_damage (FL_DAMAGE_SCROLL);
+ MSG("FltkViewport::draw d=%d => ", d);
+ if (d == (FL_DAMAGE_SCROLL | FL_DAMAGE_CHILD)) {
fl_scroll(x(), y(), w() - hdiff, h() - vdiff,
-scrollDX, -scrollDY, draw_area, this);
- clear_damage (d & ~FL_DAMAGE_SCROLL);
- }
-
- if (d) {
+ MSG("fl_scroll()\n");
+ } else {
draw_area(this, x(), y(), w () - hdiff, h () - vdiff);
+ MSG("draw_area()\n");
+ }
- if (d == FL_DAMAGE_ALL || hscrollbar->damage ())
- draw_child (*hscrollbar);
- if (d == FL_DAMAGE_ALL || vscrollbar->damage ())
- draw_child (*vscrollbar);
-
- if (d == FL_DAMAGE_ALL && hdiff && vdiff) {
- fl_color(FL_BACKGROUND_COLOR);
- fl_rectf(x()+w()-hdiff, y()+h()-vdiff, hdiff, vdiff);
- }
+ if ((d & (FL_DAMAGE_ALL | FL_DAMAGE_EXPOSE)) || vscrollbar->damage ())
+ draw_child (*vscrollbar);
+ if ((d & (FL_DAMAGE_ALL | FL_DAMAGE_EXPOSE)) || hscrollbar->damage ())
+ draw_child (*hscrollbar);
+ if ((d & (FL_DAMAGE_ALL | FL_DAMAGE_EXPOSE)) && (hdiff && vdiff)) {
+ fl_color(FL_BACKGROUND_COLOR);
+ fl_rectf(x()+w()-hdiff, y()+h()-vdiff, hdiff, vdiff);
}
scrollDX = 0;
diff --git a/dw/layout.cc b/dw/layout.cc
index 3535d794..28633c85 100644
--- a/dw/layout.cc
+++ b/dw/layout.cc
@@ -931,7 +931,6 @@ void Layout::resizeIdle ()
// Tell the view about the new world size.
view->setCanvasSize (canvasWidth, canvasAscent, canvasDescent);
- // view->queueDrawTotal (false);
if (usesViewport) {
int currHThickness = currHScrollbarThickness();