File diff r24850:df6b081a960b → r24851:a41e925d9dc7
src/video/cocoa/cocoa_v.mm
Show inline comments
 
@@ -456,28 +456,28 @@ void VideoDriver_Cocoa::BlitIndexedToVie
 
	uint32       *dst   = (uint32*)this->window_buffer;
 
	uint          width = this->window_width;
 
	uint          pitch = this->window_pitch;
 

	
 
	for (int y = top; y < bottom; y++) {
 
		for (int x = left; x < right; x++) {
 
			dst[y * pitch + x] = pal[src[y * width + x]];
 
		}
 
	}
 
}
 

	
 
/**
 
 * Draw window.
 
 * Paint window.
 
 * @param force_update Whether to redraw unconditionally
 
 */
 
void VideoDriver_Cocoa::Draw(bool force_update)
 
void VideoDriver_Cocoa::Paint()
 
{
 
	PerformanceMeasurer framerate(PFE_VIDEO);
 

	
 
	/* Check if we need to do anything */
 
	if (this->num_dirty_rects == 0 || [ this->window isMiniaturized ]) return;
 

	
 
	if (this->num_dirty_rects >= lengthof(this->dirty_rects)) {
 
		this->num_dirty_rects = 1;
 
		this->dirty_rects[0].left = 0;
 
		this->dirty_rects[0].top = 0;
 
		this->dirty_rects[0].right = this->window_width;
 
		this->dirty_rects[0].bottom = this->window_height;
 
@@ -493,27 +493,26 @@ void VideoDriver_Cocoa::Draw(bool force_
 
				this->dirty_rects[i].right,
 
				this->dirty_rects[i].bottom
 
			);
 
		}
 

	
 
		NSRect dirtyrect;
 
		dirtyrect.origin.x = this->dirty_rects[i].left;
 
		dirtyrect.origin.y = this->window_height - this->dirty_rects[i].bottom;
 
		dirtyrect.size.width = this->dirty_rects[i].right - this->dirty_rects[i].left;
 
		dirtyrect.size.height = this->dirty_rects[i].bottom - this->dirty_rects[i].top;
 

	
 
		/* Normally drawRect will be automatically called by Mac OS X during next update cycle,
 
		 * and then blitting will occur. If force_update is true, it will be done right now. */
 
		 * and then blitting will occur. */
 
		[ this->cocoaview setNeedsDisplayInRect:[ this->cocoaview getVirtualRect:dirtyrect ] ];
 
		if (force_update) [ this->cocoaview displayIfNeeded ];
 
	}
 

	
 
	this->num_dirty_rects = 0;
 
}
 

	
 
/** Update the palette. */
 
void VideoDriver_Cocoa::UpdatePalette(uint first_color, uint num_colors)
 
{
 
	if (this->buffer_depth != 8) return;
 

	
 
	for (uint i = first_color; i < first_color + num_colors; i++) {
 
		uint32 clr = 0xff000000;
 
@@ -699,25 +698,25 @@ void VideoDriver_Cocoa::GameLoop()
 

	
 
			/* Prevent drawing when switching mode, as windows can be removed when they should still appear. */
 
			if (cur_ticks >= next_draw_tick && (_switch_mode == SM_NONE || HasModalProgress())) {
 
				next_draw_tick += this->GetDrawInterval();
 
				/* Avoid next_draw_tick getting behind more and more if it cannot keep up. */
 
				if (next_draw_tick < cur_ticks - ALLOWED_DRIFT * this->GetDrawInterval()) next_draw_tick = cur_ticks;
 

	
 
				this->InputLoop();
 
				::InputLoop();
 
				UpdateWindows();
 
				this->CheckPaletteAnim();
 

	
 
				this->Draw();
 
				this->Paint();
 
			}
 

	
 
			/* If we are not in fast-forward, create some time between calls to ease up CPU usage. */
 
			if (!_fast_forward || _pause_mode) {
 
				/* See how much time there is till we have to process the next event, and try to hit that as close as possible. */
 
				auto next_tick = std::min(next_draw_tick, next_game_tick);
 
				auto now = std::chrono::steady_clock::now();
 

	
 
				if (next_tick > now) {
 
					std::this_thread::sleep_for(next_tick - now);
 
				}
 
			}