Changeset - r24777:a92c16aa9298
[Not reviewed]
master
0 1 0
Michael Lutz - 3 years ago 2021-02-06 19:23:53
michi@icosahedron.de
Codechange: [OSX] Align backing buffer pitch for a tiny bit performance.
1 file changed with 12 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/video/cocoa/cocoa_v.mm
Show inline comments
 
@@ -109,6 +109,7 @@ VideoDriver_Cocoa::VideoDriver_Cocoa()
 
{
 
	this->window_width  = 0;
 
	this->window_height = 0;
 
	this->window_pitch  = 0;
 
	this->buffer_depth  = 0;
 
	this->window_buffer = nullptr;
 
	this->pixel_buffer  = nullptr;
 
@@ -315,9 +316,9 @@ bool VideoDriver_Cocoa::IsFullscreen()
 
void VideoDriver_Cocoa::GameSizeChanged()
 
{
 
	/* Tell the game that the resolution has changed */
 
	_screen.width = this->window_width;
 
	_screen.height = this->window_height;
 
	_screen.pitch = this->window_width;
 
	_screen.width   = this->window_width;
 
	_screen.height  = this->window_height;
 
	_screen.pitch   = this->buffer_depth == 8 ? this->window_width : this->window_pitch;
 
	_screen.dst_ptr = this->buffer_depth == 8 ? this->pixel_buffer : this->window_buffer;
 

	
 
	/* Store old window size if we entered fullscreen mode. */
 
@@ -448,7 +449,7 @@ void VideoDriver_Cocoa::BlitIndexedToVie
 
	const uint8  *src   = (uint8*)this->pixel_buffer;
 
	uint32       *dst   = (uint32*)this->window_buffer;
 
	uint          width = this->window_width;
 
	uint          pitch = this->window_width;
 
	uint          pitch = this->window_pitch;
 

	
 
	for (int y = top; y < bottom; y++) {
 
		for (int x = left; x < right; x++) {
 
@@ -538,13 +539,14 @@ void VideoDriver_Cocoa::AllocateBackingS
 

	
 
	this->window_width = (int)newframe.size.width;
 
	this->window_height = (int)newframe.size.height;
 
	this->window_pitch = Align(this->window_width, 16 / sizeof(uint32)); // Quartz likes lines that are multiple of 16-byte.
 
	this->buffer_depth = BlitterFactory::GetCurrentBlitter()->GetScreenDepth();
 

	
 
	/* Create Core Graphics Context */
 
	free(this->window_buffer);
 
	this->window_buffer = malloc(this->window_width * this->window_height * sizeof(uint32));
 
	this->window_buffer = malloc(this->window_pitch * this->window_height * sizeof(uint32));
 
	/* Initialize with opaque black. */
 
	ClearWindowBuffer((uint32 *)this->window_buffer, this->window_width, this->window_height);
 
	ClearWindowBuffer((uint32 *)this->window_buffer, this->window_pitch, this->window_height);
 

	
 
	CGContextRelease(this->cgcontext);
 
	this->cgcontext = CGBitmapContextCreate(
 
@@ -552,7 +554,7 @@ void VideoDriver_Cocoa::AllocateBackingS
 
		this->window_width,        // width
 
		this->window_height,       // height
 
		8,                         // bits per component
 
		this->window_width * 4,    // bytes per row
 
		this->window_pitch * 4,    // bytes per row
 
		this->color_space,         // color space
 
		kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host
 
	);
 
@@ -566,6 +568,9 @@ void VideoDriver_Cocoa::AllocateBackingS
 
		free(this->pixel_buffer);
 
		this->pixel_buffer = malloc(this->window_width * this->window_height);
 
		if (this->pixel_buffer == nullptr) usererror("Out of memory allocating pixel buffer");
 
	} else {
 
		free(this->pixel_buffer);
 
		this->pixel_buffer = nullptr;
 
	}
 

	
 
	/* Redraw screen */
0 comments (0 inline, 0 general)