mirror of https://github.com/OpenTTD/OpenTTD.git
Cleanup: [OSX] Remove cargo cult back-buffer alpha setting on show/hide and instead simply initialise the buffer on allocation.
This commit is contained in:
parent
a61a741683
commit
7bdaabf5f1
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 ] ];
|
||||
|
||||
|
@ -341,13 +336,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
|
||||
*/
|
||||
|
@ -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 ];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue