1 |
//====================================================================== |
/* |
2 |
// Copyright (C) 2002 Daniel Heck |
* Copyright (C) 2002,2003 Daniel Heck |
3 |
// |
* |
4 |
// This program is free software; you can redistribute it and/or |
* This program is free software; you can redistribute it and/or |
5 |
// modify it under the terms of the GNU General Public License |
* modify it under the terms of the GNU General Public License |
6 |
// as published by the Free Software Foundation; either version 2 |
* as published by the Free Software Foundation; either version 2 |
7 |
// of the License, or (at your option) any later version. |
* of the License, or (at your option) any later version. |
8 |
// |
* |
9 |
// This program is distributed in the hope that it will be useful, |
* This program is distributed in the hope that it will be useful, |
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 |
// GNU General Public License for more details. |
* GNU General Public License for more details. |
13 |
// |
* |
14 |
// You should have received a copy of the GNU General Public License along |
* You should have received a copy of the GNU General Public License along |
15 |
// with this program; if not, write to the Free Software Foundation, Inc., |
* with this program; if not, write to the Free Software Foundation, Inc., |
16 |
// 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. |
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. |
17 |
//====================================================================== |
* |
18 |
|
* $Id$ |
19 |
|
*/ |
20 |
#include "video.hh" |
#include "video.hh" |
21 |
#include "error.hh" |
#include "error.hh" |
22 |
#include "geom.hh" |
#include "geom.hh" |
23 |
#include "tools.hh" |
#include "tools.hh" |
24 |
|
#include "sdl.hh" |
25 |
|
|
26 |
#include "SDL_image.h" |
#include "SDL_image.h" |
27 |
#include "SDL_syswm.h" |
#include "SDL_syswm.h" |
29 |
#include <cassert> |
#include <cassert> |
30 |
#include <string> |
#include <string> |
31 |
#include <memory> |
#include <memory> |
32 |
|
#include <cstdio> |
33 |
|
|
34 |
using namespace std; |
using namespace std; |
35 |
using namespace px; |
using namespace px; |
233 |
void |
void |
234 |
px::Screen::update_rect(const Rect& r) |
px::Screen::update_rect(const Rect& r) |
235 |
{ |
{ |
236 |
if (m_dirtyrects.size() < 40) |
if (m_dirtyrects.size() < 200) |
237 |
m_dirtyrects.push_back(r); |
m_dirtyrects.push_back(r); |
238 |
else |
else |
239 |
update_all(); |
update_all(); |
251 |
if (update_all_p) { |
if (update_all_p) { |
252 |
SDL_UpdateRect(get_surface(), 0, 0, 0, 0); // update everything |
SDL_UpdateRect(get_surface(), 0, 0, 0, 0); // update everything |
253 |
update_all_p=false; |
update_all_p=false; |
254 |
|
printf("updating complete screen\n"); |
255 |
} |
} |
256 |
else if (!m_dirtyrects.empty()) { |
else if (!m_dirtyrects.empty()) { |
257 |
m_dirtyrects.intersect(Rect(0, 0, width(), height())); |
m_dirtyrects.intersect(Rect(0, 0, width(), height())); |
258 |
|
|
259 |
RectList::iterator i; |
vector<SDL_Rect> rects(m_dirtyrects.size()); |
260 |
for (i=m_dirtyrects.begin(); i != m_dirtyrects.end(); ++i) |
|
261 |
SDL_UpdateRect(get_surface(), i->x, i->y, i->w, i->h); |
RectList::iterator j=m_dirtyrects.begin();; |
262 |
|
// for (i=m_dirtyrects.begin(); i != m_dirtyrects.end(); ++i) |
263 |
|
for (unsigned i=0; i<rects.size(); ++i, ++j) |
264 |
|
sdl::fill_rect (rects[i], *j); |
265 |
|
// RectList::iterator i; |
266 |
|
// for (i=m_dirtyrects.begin(); i != m_dirtyrects.end(); ++i) |
267 |
|
SDL_UpdateRects(get_surface(), rects.size(), &rects[0]); |
268 |
|
//i->x, i->y, i->w, i->h); |
269 |
} |
} |
270 |
m_dirtyrects.clear(); |
m_dirtyrects.clear(); |
271 |
} |
} |