[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3798 - trunk/pingus/src/display
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3798 - trunk/pingus/src/display |
Date: |
Sat, 12 Jul 2008 09:40:02 +0200 |
Author: grumbel
Date: 2008-07-12 09:40:01 +0200 (Sat, 12 Jul 2008)
New Revision: 3798
Modified:
trunk/pingus/src/display/delta_framebuffer.cpp
trunk/pingus/src/display/sdl_framebuffer.cpp
trunk/pingus/src/display/sdl_framebuffer.hpp
Log:
Use SDL_UpdateRects instead of SDL_UpdateRect
Modified: trunk/pingus/src/display/delta_framebuffer.cpp
===================================================================
--- trunk/pingus/src/display/delta_framebuffer.cpp 2008-07-12 06:11:32 UTC
(rev 3797)
+++ trunk/pingus/src/display/delta_framebuffer.cpp 2008-07-12 07:40:01 UTC
(rev 3798)
@@ -15,6 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <iostream>
+#include "../math.hpp"
#include "sdl_framebuffer.hpp"
#include "delta_framebuffer.hpp"
@@ -27,8 +28,13 @@
fb.draw_surface(surface, rect, pos);
}
- Rect get_region() const {
- return Rect(pos, rect.get_size());
+ SDL_Rect get_region() const {
+ SDL_Rect sdl_rect;
+ sdl_rect.x = pos.x;
+ sdl_rect.y = pos.y;
+ sdl_rect.w = rect.get_width();
+ sdl_rect.h = rect.get_height();
+ return sdl_rect;
}
};
@@ -58,7 +64,7 @@
void render(SDLFramebuffer& fb, DrawOpBuffer& frontbuffer)
{
- std::vector<Rect> update_rects;
+ std::vector<SDL_Rect> update_rects;
// Find all regions that need updating
for(DrawOps::iterator i = draw_obs.begin(); i != draw_obs.end(); ++i)
@@ -69,18 +75,29 @@
if (!has_op(*i))
update_rects.push_back(i->get_region());
+ // Clip things to the screen
+ Size screen_size = fb.get_size();
+ for(std::vector<SDL_Rect>::iterator i = update_rects.begin(); i !=
update_rects.end(); ++i)
+ {
+ i->w = Math::clamp(0, int(i->w), Math::max(0, screen_size.width -
i->x));
+ i->h = Math::clamp(0, int(i->h), Math::max(0, screen_size.height -
i->y));
+
+ i->x = Math::clamp(0, int(i->x), screen_size.width);
+ i->y = Math::clamp(0, int(i->y), screen_size.height);
+ }
+
// Merge rectangles
// Update all regions that need update
- for(std::vector<Rect>::iterator i = update_rects.begin(); i !=
update_rects.end(); ++i)
+ for(std::vector<SDL_Rect>::iterator i = update_rects.begin(); i !=
update_rects.end(); ++i)
{
- fb.push_cliprect(*i);
+ fb.push_cliprect(Rect(Vector2i(i->x, i->y), Size(i->w, i->h)));
for(DrawOps::iterator j = draw_obs.begin(); j != draw_obs.end(); ++j)
j->render(fb);
fb.pop_cliprect();
-
- fb.update_rect(*i);
}
+
+ fb.update_rects(update_rects);
}
void add(const SurfaceDrawOp& op) {
Modified: trunk/pingus/src/display/sdl_framebuffer.cpp
===================================================================
--- trunk/pingus/src/display/sdl_framebuffer.cpp 2008-07-12 06:11:32 UTC
(rev 3797)
+++ trunk/pingus/src/display/sdl_framebuffer.cpp 2008-07-12 07:40:01 UTC
(rev 3798)
@@ -376,14 +376,9 @@
}
void
-SDLFramebuffer::update_rect(const Rect& rect_)
+SDLFramebuffer::update_rects(const std::vector<SDL_Rect>& rects)
{
- Rect rect(Math::clamp(0, rect_.left, screen->w),
- Math::clamp(0, rect_.top, screen->h),
- Math::clamp(0, rect_.right, screen->w),
- Math::clamp(0, rect_.bottom, screen->h));
-
- SDL_UpdateRect(screen, rect.left, rect.top, rect.get_width(),
rect.get_height());
+ SDL_UpdateRects(screen, rects.size(),
const_cast<SDL_Rect*>(&*rects.begin()));
}
Size
Modified: trunk/pingus/src/display/sdl_framebuffer.hpp
===================================================================
--- trunk/pingus/src/display/sdl_framebuffer.hpp 2008-07-12 06:11:32 UTC
(rev 3797)
+++ trunk/pingus/src/display/sdl_framebuffer.hpp 2008-07-12 07:40:01 UTC
(rev 3798)
@@ -36,7 +36,7 @@
void set_video_mode(int width, int height, bool fullscreen);
void flip();
- void update_rect(const Rect& rect);
+ void update_rects(const std::vector<SDL_Rect>& rects);
void push_cliprect(const Rect&);
void pop_cliprect();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3798 - trunk/pingus/src/display,
grumbel at BerliOS <=