summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2006-02-24 22:05:20 +0000
committerbjarni <bjarni@openttd.org>2006-02-24 22:05:20 +0000
commitaa3e439a68345566865291b97b089ae9cb78e8c0 (patch)
tree09a7fbf0a7ae161b875d2afb23baf5d393e31f16
parentaf9463187b968e749d3680f214063df631b5cc44 (diff)
downloadopenttd-aa3e439a68345566865291b97b089ae9cb78e8c0.tar.xz
(svn r3670) -Codechange: [OSX] rewrote a part of the cocoa video driver to speed it up by 1000% in fullscreen
rewrote QZ_DrawScreen to only redraw dirty rectangles (instead of everything) This reduce the OpenTTD time spent on this function from 75% to 6,7% (in main menu) Note: window mode is unaffected by this commit Note: the mouse pointer can now leave artefacts in debug mode
-rw-r--r--video/cocoa_v.m34
1 files changed, 31 insertions, 3 deletions
diff --git a/video/cocoa_v.m b/video/cocoa_v.m
index 0daffd8f1..654b5a9fb 100644
--- a/video/cocoa_v.m
+++ b/video/cocoa_v.m
@@ -1470,15 +1470,43 @@ static void QZ_DrawScreen(void)
uint width;
uint pitch;
uint y;
-
- QZ_WaitForVerticalBlank();
+ uint num_dirty_rects;
+ uint length_drawn;
+ uint left;
+ uint i;
src = _cocoa_video_data.pixels;
dst = (uint8*)_cocoa_video_data.realpixels;
height = _cocoa_video_data.height;
width = _cocoa_video_data.width;
pitch = _cocoa_video_data.pitch;
- for (y = 0; y < height; y++) memcpy(dst + y * pitch, src + y * width, width);
+ num_dirty_rects = _cocoa_video_data.num_dirty_rects;
+
+ /* Check if we need to do anything */
+ if (_cocoa_video_data.num_dirty_rects == 0 ) {
+ return;
+ }
+
+ if (num_dirty_rects >= MAX_DIRTY_RECTS) {
+ num_dirty_rects = 1;
+ _cocoa_video_data.dirty_rects[0].left = 0;
+ _cocoa_video_data.dirty_rects[0].top = 0;
+ _cocoa_video_data.dirty_rects[0].right = _cocoa_video_data.width;
+ _cocoa_video_data.dirty_rects[0].bottom = _cocoa_video_data.height;
+ }
+
+ QZ_WaitForVerticalBlank();
+ /* Build the region of dirty rectangles */
+ for (i = 0; i < num_dirty_rects; i++) {
+
+ y = _cocoa_video_data.dirty_rects[i].top;
+ left = _cocoa_video_data.dirty_rects[i].left;
+ length_drawn = _cocoa_video_data.dirty_rects[i].right - left + 1;
+ height = _cocoa_video_data.dirty_rects[i].bottom;
+ for (; y <= height; y++) memcpy(dst + y * pitch + left, src + y * width +left, length_drawn);
+ }
+
+ _cocoa_video_data.num_dirty_rects = 0;
}
static int QZ_ListFullscreenModes(OTTDPoint* mode_list, int max_modes)