summaryrefslogtreecommitdiff
path: root/src/video
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2020-12-26 16:07:54 +0100
committerMichael Lutz <michi@icosahedron.de>2021-01-03 13:25:32 +0100
commit7bdaabf5f126edd58f3ddb14c71bb4ed2230bf27 (patch)
tree0af7d9fa3fc41680be68fcb884f47e8b976e7617 /src/video
parenta61a7416836ec021f522720940265d2b67dedb08 (diff)
downloadopenttd-7bdaabf5f126edd58f3ddb14c71bb4ed2230bf27.tar.xz
Cleanup: [OSX] Remove cargo cult back-buffer alpha setting on show/hide and instead simply initialise the buffer on allocation.
Diffstat (limited to 'src/video')
-rw-r--r--src/video/cocoa/cocoa_v.h3
-rw-r--r--src/video/cocoa/cocoa_v.mm25
-rw-r--r--src/video/cocoa/cocoa_wnd.h1
-rw-r--r--src/video/cocoa/cocoa_wnd.mm15
4 files changed, 10 insertions, 34 deletions
diff --git a/src/video/cocoa/cocoa_v.h b/src/video/cocoa/cocoa_v.h
index 0944424e8..db970d979 100644
--- a/src/video/cocoa/cocoa_v.h
+++ b/src/video/cocoa/cocoa_v.h
@@ -180,9 +180,6 @@ public:
*/
virtual bool IsActive() = 0;
- /** Makes the *game region* of the window 100% opaque. */
- virtual void SetPortAlphaOpaque() { return; };
-
/** Whether the window was successfully resized
* @return whether the window was successfully resized
*/
diff --git a/src/video/cocoa/cocoa_v.mm b/src/video/cocoa/cocoa_v.mm
index aa9d57ecf..d8178699e 100644
--- a/src/video/cocoa/cocoa_v.mm
+++ b/src/video/cocoa/cocoa_v.mm
@@ -370,8 +370,6 @@ public:
virtual bool IsActive() { return active; }
-
- void SetPortAlphaOpaque();
bool WindowResized();
};
@@ -771,19 +769,14 @@ bool WindowQuartzSubdriver::MouseIsInsideView(NSPoint *pt)
return [ cocoaview mouse:*pt inRect:[ this->cocoaview bounds ] ];
}
-
-/* This function makes the *game region* of the window 100% opaque.
- * The genie effect uses the alpha component. Otherwise,
- * it doesn't seem to matter what value it has.
- */
-void WindowQuartzSubdriver::SetPortAlphaOpaque()
+/** Clear buffer to opaque black. */
+static void ClearWindowBuffer(uint32 *buffer, uint32 pitch, uint32 height)
{
- uint32 *pixels = (uint32*)this->window_buffer;
- uint32 pitch = this->window_width;
-
- for (int y = 0; y < this->window_height; y++)
- for (int x = 0; x < this->window_width; x++) {
- pixels[y * pitch + x] |= 0xFF000000;
+ uint32 fill = Colour(0, 0, 0).data;
+ for (uint32 y = 0; y < height; y++) {
+ for (uint32 x = 0; x < pitch; x++) {
+ buffer[y * pitch + x] = fill;
+ }
}
}
@@ -798,7 +791,9 @@ bool WindowQuartzSubdriver::WindowResized()
/* Create Core Graphics Context */
free(this->window_buffer);
- this->window_buffer = (uint32*)malloc(this->window_width * this->window_height * 4);
+ this->window_buffer = malloc(this->window_width * this->window_height * sizeof(uint32));
+ /* Initialize with opaque black. */
+ ClearWindowBuffer((uint32 *)this->window_buffer, this->window_width, this->window_height);
CGContextRelease(this->cgcontext);
this->cgcontext = CGBitmapContextCreate(
diff --git a/src/video/cocoa/cocoa_wnd.h b/src/video/cocoa/cocoa_wnd.h
index f395114db..506fbd294 100644
--- a/src/video/cocoa/cocoa_wnd.h
+++ b/src/video/cocoa/cocoa_wnd.h
@@ -32,7 +32,6 @@ extern NSString *OTTDMainLaunchGameEngine;
- (void)display;
- (void)setFrame:(NSRect)frameRect display:(BOOL)flag;
- (void)appDidHide:(NSNotification*)note;
-- (void)appWillUnhide:(NSNotification*)note;
- (void)appDidUnhide:(NSNotification*)note;
- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag;
@end
diff --git a/src/video/cocoa/cocoa_wnd.mm b/src/video/cocoa/cocoa_wnd.mm
index d9687ac4a..addf94ba3 100644
--- a/src/video/cocoa/cocoa_wnd.mm
+++ b/src/video/cocoa/cocoa_wnd.mm
@@ -291,9 +291,6 @@ void CocoaDialog(const char *title, const char *message, const char *buttonLabel
*/
- (void)miniaturize:(id)sender
{
- /* make the alpha channel opaque so anim won't have holes in it */
- driver->SetPortAlphaOpaque();
-
/* window is hidden now */
driver->active = false;
@@ -308,8 +305,6 @@ void CocoaDialog(const char *title, const char *message, const char *buttonLabel
*/
- (void)display
{
- driver->SetPortAlphaOpaque();
-
/* save current visible surface */
[ self cacheImageInRect:[ driver->cocoaview frame ] ];
@@ -342,13 +337,6 @@ void CocoaDialog(const char *title, const char *message, const char *buttonLabel
driver->active = false;
}
/**
- * Fade-in the application and restore display plane
- */
-- (void)appWillUnhide:(NSNotification*)note
-{
- driver->SetPortAlphaOpaque ();
-}
-/**
* Unhide and restore display plane and re-activate driver
*/
- (void)appDidUnhide:(NSNotification*)note
@@ -367,9 +355,6 @@ void CocoaDialog(const char *title, const char *message, const char *buttonLabel
[ [ NSNotificationCenter defaultCenter ] addObserver:self
selector:@selector(appDidUnhide:) name:NSApplicationDidUnhideNotification object:NSApp ];
- [ [ NSNotificationCenter defaultCenter ] addObserver:self
- selector:@selector(appWillUnhide:) name:NSApplicationWillUnhideNotification object:NSApp ];
-
return [ super initWithContentRect:contentRect styleMask:styleMask backing:backingType defer:flag ];
}