Changeset - r24765:2c3933a09d54
[Not reviewed]
master
0 2 0
Michael Lutz - 3 years ago 2021-02-11 21:54:43
michi@icosahedron.de
Codechange: [OSX] Replace #define with modern code.
2 files changed with 9 insertions and 8 deletions:
0 comments (0 inline, 0 general)
src/video/cocoa/cocoa_v.h
Show inline comments
 
@@ -32,9 +32,10 @@ private:
 
	void *pixel_buffer;   ///< used for direct pixel access
 
	void *window_buffer;  ///< Colour translation from palette to screen
 

	
 
#	define MAX_DIRTY_RECTS 100
 
	static const int MAX_DIRTY_RECTS = 100;
 

	
 
	Rect dirty_rects[MAX_DIRTY_RECTS]; ///< dirty rectangles
 
	int num_dirty_rects = MAX_DIRTY_RECTS;  ///< Number of dirty rectangles
 
	uint num_dirty_rects;  ///< Number of dirty rectangles
 
	uint32 palette[256];  ///< Colour Palette
 

	
 
public:
src/video/cocoa/cocoa_v.mm
Show inline comments
 
@@ -92,7 +92,7 @@ VideoDriver_Cocoa::VideoDriver_Cocoa()
 
	this->color_space = nullptr;
 
	this->cgcontext   = nullptr;
 

	
 
	this->num_dirty_rects = MAX_DIRTY_RECTS;
 
	this->num_dirty_rects = lengthof(this->dirty_rects);
 
}
 

	
 
/**
 
@@ -164,7 +164,7 @@ const char *VideoDriver_Cocoa::Start(con
 
 */
 
void VideoDriver_Cocoa::MakeDirty(int left, int top, int width, int height)
 
{
 
	if (this->num_dirty_rects < MAX_DIRTY_RECTS) {
 
	if (this->num_dirty_rects < lengthof(this->dirty_rects)) {
 
		dirty_rects[this->num_dirty_rects].left = left;
 
		dirty_rects[this->num_dirty_rects].top = top;
 
		dirty_rects[this->num_dirty_rects].right = left + width;
 
@@ -539,7 +539,7 @@ void VideoDriver_Cocoa::Draw(bool force_
 
	/* Check if we need to do anything */
 
	if (this->num_dirty_rects == 0 || [ this->window isMiniaturized ]) return;
 

	
 
	if (this->num_dirty_rects >= MAX_DIRTY_RECTS) {
 
	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;
 
@@ -548,7 +548,7 @@ void VideoDriver_Cocoa::Draw(bool force_
 
	}
 

	
 
	/* Build the region of dirty rectangles */
 
	for (int i = 0; i < this->num_dirty_rects; i++) {
 
	for (uint i = 0; i < this->num_dirty_rects; i++) {
 
		/* We only need to blit in indexed mode since in 32bpp mode the game draws directly to the image. */
 
		if (this->buffer_depth == 8) {
 
			BlitIndexedToView32(
 
@@ -586,7 +586,7 @@ void VideoDriver_Cocoa::UpdatePalette(ui
 
		this->palette[i] = clr;
 
	}
 

	
 
	this->num_dirty_rects = MAX_DIRTY_RECTS;
 
	this->num_dirty_rects = lengthof(this->dirty_rects);
 
}
 

	
 
bool VideoDriver_Cocoa::ChangeResolution(int w, int h, int bpp)
 
@@ -692,7 +692,7 @@ bool VideoDriver_Cocoa::WindowResized()
 
	this->GameSizeChanged();
 

	
 
	/* Redraw screen */
 
	this->num_dirty_rects = MAX_DIRTY_RECTS;
 
	this->num_dirty_rects = lengthof(this->dirty_rects);
 

	
 
	return true;
 
}
0 comments (0 inline, 0 general)