區別如下:
SDL_Flip() | 假如有設定SDL_DOUBLEBUF時,會直接呼叫Framebuffer Driver的fb_pan_display(),藉此快速刷屏,假如沒有設定,則執行SDL_UpdateRect() |
---|---|
SDL_UpdateRect() | 一個區塊慢慢複製(透過blitFunc()) |
(SDL 1.2.15)src/video/SDL_video.c
1105 int SDL_Flip(SDL_Surface *screen) ... 1147 if ( (screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) { 1148 SDL_VideoDevice *this = current_video; 1149 return(video->FlipHWSurface(this, SDL_VideoSurface)); 1150 } else { 1151 SDL_UpdateRect(screen, 0, 0, 0, 0); 1152 } 1153 return(0); 1154 }
(SDL 1.2.15)src/video/fbcon/SDL_fbvideo.c
1423 static int FB_FlipHWSurface(_THIS, SDL_Surface *surface) 1424 { 1425 if ( switched_away ) { 1426 return -2; /* no hardware access */ 1427 } 1428 1429 /* Wait for vertical retrace and then flip display */ 1430 cache_vinfo.yoffset = flip_page*surface->h; 1431 if ( FB_IsSurfaceBusy(this->screen) ) { 1432 FB_WaitBusySurfaces(this); 1433 } 1434 wait_vbl(this); 1435 if ( ioctl(console_fd, FBIOPAN_DISPLAY, &cache_vinfo) < 0 ) { 1436 SDL_SetError("ioctl(FBIOPAN_DISPLAY) failed"); 1437 return(-1); 1438 } 1439 flip_page = !flip_page; 1440 1441 surface->pixels = flip_address[flip_page]; 1442 return(0); 1443 } 1014 void SDL_UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h) 1015 { 1016 if ( screen ) { 1017 SDL_Rect rect; 1018 1019 /* Perform some checking */ 1020 if ( w == 0 ) 1021 w = screen->w; 1022 if ( h == 0 ) 1023 h = screen->h; 1024 if ( (int)(x+w) > screen->w ) 1025 return; 1026 if ( (int)(y+h) > screen->h ) 1027 return; 1028 1029 /* Fill the rectangle */ 1030 rect.x = (Sint16)x; 1031 rect.y = (Sint16)y; 1032 rect.w = (Uint16)w; 1033 rect.h = (Uint16)h; 1034 SDL_UpdateRects(screen, 1, &rect); 1035 } 1036 } 1037 void SDL_UpdateRects (SDL_Surface *screen, int numrects, SDL_Rect *rects) ... 1097 video->UpdateRects(this, numrects, rects); 1098 } 1099 } 1100 } 1183 this->UpdateRects = FB_DirectUpdate; 1496 static void FB_DirectUpdate(_THIS, int numrects, SDL_Rect *rects) ... 1600 blitFunc((Uint8 *) src_start, 1601 shadow_right_delta, 1602 shadow_down_delta, 1603 (Uint8 *) dst_start, 1604 physlinebytes, 1605 scr_x2 - scr_x1, 1606 scr_y2 - scr_y1); 1607 } 1608 }