1
0
Fork 0

Cleanup: [OSX] Remove cargo cult back-buffer alpha setting on show/hide and instead simply initialise the buffer on allocation.

pull/8458/head
Michael Lutz 2020-12-26 16:07:54 +01:00
parent a61a741683
commit 7bdaabf5f1
4 changed files with 10 additions and 34 deletions

View File

@ -180,9 +180,6 @@ public:
*/ */
virtual bool IsActive() = 0; virtual bool IsActive() = 0;
/** Makes the *game region* of the window 100% opaque. */
virtual void SetPortAlphaOpaque() { return; };
/** Whether the window was successfully resized /** Whether the window was successfully resized
* @return whether the window was successfully resized * @return whether the window was successfully resized
*/ */

View File

@ -370,8 +370,6 @@ public:
virtual bool IsActive() { return active; } virtual bool IsActive() { return active; }
void SetPortAlphaOpaque();
bool WindowResized(); bool WindowResized();
}; };
@ -771,19 +769,14 @@ bool WindowQuartzSubdriver::MouseIsInsideView(NSPoint *pt)
return [ cocoaview mouse:*pt inRect:[ this->cocoaview bounds ] ]; return [ cocoaview mouse:*pt inRect:[ this->cocoaview bounds ] ];
} }
/** Clear buffer to opaque black. */
/* This function makes the *game region* of the window 100% opaque. static void ClearWindowBuffer(uint32 *buffer, uint32 pitch, uint32 height)
* The genie effect uses the alpha component. Otherwise,
* it doesn't seem to matter what value it has.
*/
void WindowQuartzSubdriver::SetPortAlphaOpaque()
{ {
uint32 *pixels = (uint32*)this->window_buffer; uint32 fill = Colour(0, 0, 0).data;
uint32 pitch = this->window_width; for (uint32 y = 0; y < height; y++) {
for (uint32 x = 0; x < pitch; x++) {
for (int y = 0; y < this->window_height; y++) buffer[y * pitch + x] = fill;
for (int x = 0; x < this->window_width; x++) { }
pixels[y * pitch + x] |= 0xFF000000;
} }
} }
@ -798,7 +791,9 @@ bool WindowQuartzSubdriver::WindowResized()
/* Create Core Graphics Context */ /* Create Core Graphics Context */
free(this->window_buffer); 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); CGContextRelease(this->cgcontext);
this->cgcontext = CGBitmapContextCreate( this->cgcontext = CGBitmapContextCreate(

View File

@ -32,7 +32,6 @@ extern NSString *OTTDMainLaunchGameEngine;
- (void)display; - (void)display;
- (void)setFrame:(NSRect)frameRect display:(BOOL)flag; - (void)setFrame:(NSRect)frameRect display:(BOOL)flag;
- (void)appDidHide:(NSNotification*)note; - (void)appDidHide:(NSNotification*)note;
- (void)appWillUnhide:(NSNotification*)note;
- (void)appDidUnhide:(NSNotification*)note; - (void)appDidUnhide:(NSNotification*)note;
- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag; - (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag;
@end @end

View File

@ -291,9 +291,6 @@ void CocoaDialog(const char *title, const char *message, const char *buttonLabel
*/ */
- (void)miniaturize:(id)sender - (void)miniaturize:(id)sender
{ {
/* make the alpha channel opaque so anim won't have holes in it */
driver->SetPortAlphaOpaque();
/* window is hidden now */ /* window is hidden now */
driver->active = false; driver->active = false;
@ -308,8 +305,6 @@ void CocoaDialog(const char *title, const char *message, const char *buttonLabel
*/ */
- (void)display - (void)display
{ {
driver->SetPortAlphaOpaque();
/* save current visible surface */ /* save current visible surface */
[ self cacheImageInRect:[ driver->cocoaview frame ] ]; [ self cacheImageInRect:[ driver->cocoaview frame ] ];
@ -341,13 +336,6 @@ void CocoaDialog(const char *title, const char *message, const char *buttonLabel
{ {
driver->active = false; 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 * Unhide and restore display plane and re-activate driver
*/ */
@ -367,9 +355,6 @@ void CocoaDialog(const char *title, const char *message, const char *buttonLabel
[ [ NSNotificationCenter defaultCenter ] addObserver:self [ [ NSNotificationCenter defaultCenter ] addObserver:self
selector:@selector(appDidUnhide:) name:NSApplicationDidUnhideNotification object:NSApp ]; 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 ]; return [ super initWithContentRect:contentRect styleMask:styleMask backing:backingType defer:flag ];
} }