diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2009-09-01 22:02:28 +0200 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2009-09-01 22:02:28 +0200 |
commit | 1eeb793701bc01670d22454f81ad5312bf8fa013 (patch) | |
tree | 99c0f82436aeb4158ac05ffc153fca2de7fd4a85 /dw | |
parent | 652a25919942438b6145dc9db672ad6c6b477306 (diff) |
further reduce size of rectangles before drawing
Make currently exposed area available in FltkViewBase and use it to
clip rectangles to the required size before drawing them.
We can use the same mechanism to limit drawImage() calls instead of
doing it in dw/image.cc as currently done.
Diffstat (limited to 'dw')
-rw-r--r-- | dw/fltkviewbase.cc | 5 | ||||
-rw-r--r-- | dw/fltkviewbase.hh | 19 |
2 files changed, 16 insertions, 8 deletions
diff --git a/dw/fltkviewbase.cc b/dw/fltkviewbase.cc index 1d82a661..89253179 100644 --- a/dw/fltkviewbase.cc +++ b/dw/fltkviewbase.cc @@ -48,6 +48,7 @@ FltkViewBase::FltkViewBase (int x, int y, int w, int h, const char *label): canvasHeight = 1; bgColor = WHITE; mouse_x = mouse_y = 0; + exposeArea = NULL; if (backBuffer == NULL) { backBuffer = new Image (); } @@ -129,6 +130,8 @@ void FltkViewBase::draw (const core::Rectangle *rect, viewRect.w (), viewRect.h ()); + exposeArea = &viewRect; + if (type == DRAW_BUFFERED && backBuffer && !backBufferInUse) { backBufferInUse = true; { @@ -160,6 +163,8 @@ void FltkViewBase::draw (const core::Rectangle *rect, fillrect (viewRect); theLayout->expose (this, &r); } + + exposeArea = NULL; } } diff --git a/dw/fltkviewbase.hh b/dw/fltkviewbase.hh index c502d2f7..fb3f2fe1 100644 --- a/dw/fltkviewbase.hh +++ b/dw/fltkviewbase.hh @@ -20,20 +20,23 @@ private: int bgColor; core::Region drawRegion; + ::fltk::Rectangle *exposeArea; static ::fltk::Image *backBuffer; static bool backBufferInUse; void draw (const core::Rectangle *rect, DrawType type); void drawChildWidgets (); inline void clipPoint (int *x, int *y) { - if (*x < 0) - *x = 0; - if (*x > w ()) - *x = w (); - if (*y < 0) - *y = 0; - if (*y > h ()) - *y = h (); + if (exposeArea) { + if (*x < exposeArea->x ()) + *x = exposeArea->x (); + if (*x > exposeArea->r ()) + *x = exposeArea->r (); + if (*y < exposeArea->y ()) + *y = exposeArea->y (); + if (*y > exposeArea->b ()) + *y = exposeArea->b (); + } } protected: |