From a3dd14380f910615d937098c8c7d44ed976cafac Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 7 Dec 2009 17:34:04 +0000 Subject: use SDL blit method to accelerate copy operations svn path=/trunk/libnsfb/; revision=9720 --- src/frontend_sdl.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src') diff --git a/src/frontend_sdl.c b/src/frontend_sdl.c index b3c3f87..cc73f43 100644 --- a/src/frontend_sdl.c +++ b/src/frontend_sdl.c @@ -375,6 +375,46 @@ set_palette(nsfb_t *nsfb) } +static bool +sdlcopy(nsfb_t *nsfb, nsfb_bbox_t *srcbox, nsfb_bbox_t *dstbox) +{ + SDL_Rect src; + SDL_Rect dst; + SDL_Surface *sdl_screen = nsfb->frontend_priv; + nsfb_bbox_t allbox; + struct nsfb_cursor_s *cursor = nsfb->cursor; + + nsfb_plot_add_rect(srcbox, dstbox, &allbox); + + if ((cursor != NULL) && + (cursor->plotted == true) && + (nsfb_plot_bbox_intersect(&allbox, &cursor->loc))) { + nsfb_cursor_clear(nsfb, cursor); + } + + src.x = srcbox->x0; + src.y = srcbox->y0; + src.w = srcbox->x1 - srcbox->x0; + src.h = srcbox->y1 - srcbox->y0; + + dst.x = dstbox->x0; + dst.y = dstbox->y0; + dst.w = dstbox->x1 - dstbox->x0; + dst.h = dstbox->y1 - dstbox->y0; + + SDL_BlitSurface(sdl_screen, &src, sdl_screen , &dst); + + if ((cursor != NULL) && + (cursor->plotted == false)) { + nsfb_cursor_plot(nsfb, cursor); + } + + SDL_UpdateRect(sdl_screen, dst.x, dst.y, dst.w, dst.h); + + return true; + +} + static int sdl_set_geometry(nsfb_t *nsfb, int width, int height, int bpp) { if (nsfb->frontend_priv != NULL) @@ -387,6 +427,8 @@ static int sdl_set_geometry(nsfb_t *nsfb, int width, int height, int bpp) /* select default sw plotters for bpp */ select_plotters(nsfb); + nsfb->plotter_fns->copy = sdlcopy; + return 0; } -- cgit v1.2.3