summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2021-02-11 22:54:43 +0100
committerMichael Lutz <michi@icosahedron.de>2021-02-13 22:21:17 +0100
commit13134f9d64fb873ab1ee0cca2cc4c4fa3c64a44a (patch)
tree67a7e7778cbb442a738de701c0ecf6bc225156a5 /src
parent88f6c7a9f353c3e78f30ddeaaeef91694af4d189 (diff)
downloadopenttd-13134f9d64fb873ab1ee0cca2cc4c4fa3c64a44a.tar.xz
Codechange: [OSX] Replace #define with modern code.
Diffstat (limited to 'src')
-rw-r--r--src/video/cocoa/cocoa_v.h5
-rw-r--r--src/video/cocoa/cocoa_v.mm12
2 files changed, 9 insertions, 8 deletions
diff --git a/src/video/cocoa/cocoa_v.h b/src/video/cocoa/cocoa_v.h
index adeadd3be..70adb18b5 100644
--- a/src/video/cocoa/cocoa_v.h
+++ b/src/video/cocoa/cocoa_v.h
@@ -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:
diff --git a/src/video/cocoa/cocoa_v.mm b/src/video/cocoa/cocoa_v.mm
index 9d1fe3782..9e52cce01 100644
--- a/src/video/cocoa/cocoa_v.mm
+++ b/src/video/cocoa/cocoa_v.mm
@@ -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(const StringList &parm)
*/
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_update)
/* 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_update)
}
/* 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(uint first_color, uint num_colors)
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;
}