diff options
author | Michael Lutz <michi@icosahedron.de> | 2021-01-24 13:12:55 +0100 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2021-02-13 22:21:17 +0100 |
commit | 8ced72ab10b12a33ef5e71f8b346f63a0db0f862 (patch) | |
tree | b17e93ba9c7cd698a0d3bc2a6b6146cc06e612c5 /src/video/cocoa/cocoa_v.mm | |
parent | 13134f9d64fb873ab1ee0cca2cc4c4fa3c64a44a (diff) | |
download | openttd-8ced72ab10b12a33ef5e71f8b346f63a0db0f862.tar.xz |
Codechange: [OSX] Inline some functions that are used in only one place.
Diffstat (limited to 'src/video/cocoa/cocoa_v.mm')
-rw-r--r-- | src/video/cocoa/cocoa_v.mm | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/src/video/cocoa/cocoa_v.mm b/src/video/cocoa/cocoa_v.mm index 9e52cce01..3350e32b8 100644 --- a/src/video/cocoa/cocoa_v.mm +++ b/src/video/cocoa/cocoa_v.mm @@ -141,7 +141,7 @@ const char *VideoDriver_Cocoa::Start(const StringList &parm) return "The cocoa quartz subdriver only supports 8 and 32 bpp."; } - if (!this->ChangeResolution(width, height, bpp)) { + if (!this->SetVideoMode(width, height, bpp)) { Stop(); return "Could not create subdriver"; } @@ -195,9 +195,17 @@ void VideoDriver_Cocoa::MainLoop() */ bool VideoDriver_Cocoa::ChangeResolution(int w, int h) { - bool ret = this->ChangeResolution(w, h, BlitterFactory::GetCurrentBlitter()->GetScreenDepth()); - this->GameSizeChanged(); - return ret; + int old_width = this->window_width; + int old_height = this->window_height; + int old_bpp = this->buffer_depth; + + if (this->SetVideoMode(w, h, BlitterFactory::GetCurrentBlitter()->GetScreenDepth())) { + this->GameSizeChanged(); + return true; + } + + if (old_width != 0 && old_height != 0) this->SetVideoMode(old_width, old_height, old_bpp); + return false; } /** @@ -257,7 +265,7 @@ void VideoDriver_Cocoa::GameSizeChanged() _screen.width = this->window_width; _screen.height = this->window_height; _screen.pitch = this->window_width; - _screen.dst_ptr = this->GetPixelBuffer(); + _screen.dst_ptr = this->buffer_depth == 8 ? this->pixel_buffer : this->window_buffer; /* Store old window size if we entered fullscreen mode. */ bool fullscreen = this->IsFullscreen(); @@ -508,7 +516,7 @@ bool VideoDriver_Cocoa::SetVideoMode(int width, int height, int bpp) if (this->color_space == nullptr) this->color_space = CGColorSpaceCreateDeviceRGB(); if (this->color_space == nullptr) error("Could not get a valid colour space for drawing."); - bool ret = WindowResized(); + bool ret = this->WindowResized(); this->UpdatePalette(0, 256); this->setup = false; @@ -589,18 +597,6 @@ void VideoDriver_Cocoa::UpdatePalette(uint first_color, uint num_colors) this->num_dirty_rects = lengthof(this->dirty_rects); } -bool VideoDriver_Cocoa::ChangeResolution(int w, int h, int bpp) -{ - int old_width = this->window_width; - int old_height = this->window_height; - int old_bpp = this->buffer_depth; - - if (this->SetVideoMode(w, h, bpp)) return true; - if (old_width != 0 && old_height != 0) this->SetVideoMode(old_width, old_height, old_bpp); - - return false; -} - /* Convert local coordinate to window server (CoreGraphics) coordinate */ CGPoint VideoDriver_Cocoa::PrivateLocalToCG(NSPoint *p) { |