Skip to content

Commit

Permalink
Flag TurtleSpace as "dirty" when the backing store changes so we can …
Browse files Browse the repository at this point in the history
…only do

 something in putToScreen() if there's been a change since the last time.
  • Loading branch information
icculus committed Feb 23, 2007
1 parent c5c691d commit 43aaa06
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/toby_wxwidgets.cpp
Expand Up @@ -72,6 +72,7 @@ class TurtleSpace : public wxWindow
int backingH; // height of backing store (changes on startRun()).
wxBitmap *backing;
wxMemoryDC *backingDC;
bool dirty;
DECLARE_EVENT_TABLE()
};

Expand Down Expand Up @@ -423,8 +424,12 @@ wxBitmap *TurtleSpace::getBacking() const

void TurtleSpace::putToScreen()
{
this->Refresh(false);
this->Update(); // force repaint.
if (this->dirty)
{
this->Refresh(false);
this->Update(); // force repaint.
this->dirty = false;
} // if
} // TurtleSpace::putToScreen


Expand Down Expand Up @@ -462,6 +467,7 @@ void TurtleSpace::drawLine(lua_Number x1, lua_Number y1,
wxMemoryDC *dc = this->getBackingDC();
if (dc != NULL)
{
this->dirty = true;
this->scaleXY(x1, y1);
this->scaleXY(x2, y2);
dc->SetPen(wxPen(wxColour(r, g, b)));
Expand All @@ -479,6 +485,7 @@ bool TurtleSpace::drawString(lua_Number x, lua_Number y, const wxString &str,
wxMemoryDC *dc = this->getBackingDC();
if (dc != NULL)
{
this->dirty = true;
this->scaleXY(x, y);
const wxColour color(r, g, b);
dc->SetTextForeground(color);
Expand All @@ -497,7 +504,9 @@ void TurtleSpace::drawTurtle(const Turtle *turtle, void *data)
int xoff = 0;
int yoff = 0;

if (data != NULL) // not the backing store? Clip it.
if (data == NULL)
this->dirty = true;
else // not the backing store? Clip it.
{
this->calcOffset(xoff, yoff);
this->clipDC(dc, xoff, yoff);
Expand Down Expand Up @@ -552,6 +561,7 @@ void TurtleSpace::cleanup(int r, int g, int b, bool force)

if (dc != NULL)
{
this->dirty = true;
dc->SetBackground(wxBrush(wxColour(r, g, b)));
dc->Clear();
} // if
Expand Down

0 comments on commit 43aaa06

Please sign in to comment.