From 81772f1906e8d37149119f4136e6dca86f08e0d2 Mon Sep 17 00:00:00 2001 From: rogerman Date: Wed, 21 Jan 2015 02:15:38 +0000 Subject: [PATCH] Cocoa Port: - Oops! Missed some files that should've been committed in r5083. (Regression from r5083.) --- .../userinterface/DisplayWindowController.h | 4 +-- .../userinterface/DisplayWindowController.mm | 32 ++++++++----------- .../userinterface/EmuControllerDelegate.mm | 23 +++++-------- .../src/cocoa/userinterface/appDelegate.mm | 9 +----- 4 files changed, 24 insertions(+), 44 deletions(-) diff --git a/desmume/src/cocoa/userinterface/DisplayWindowController.h b/desmume/src/cocoa/userinterface/DisplayWindowController.h index e0c13826a..b605d03f4 100644 --- a/desmume/src/cocoa/userinterface/DisplayWindowController.h +++ b/desmume/src/cocoa/userinterface/DisplayWindowController.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 DeSmuME team + Copyright (C) 2013-2015 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -65,8 +65,6 @@ class OGLVideoOutput; - (NSPoint) convertPointToDS:(NSPoint)clickLoc; - (BOOL) handleKeyPress:(NSEvent *)theEvent keyPressed:(BOOL)keyPressed; - (BOOL) handleMouseButton:(NSEvent *)theEvent buttonPressed:(BOOL)buttonPressed; -- (void) clearToBlack; -- (void) clearToWhite; - (void) requestScreenshot:(NSURL *)fileURL fileType:(NSBitmapImageFileType)fileType; @end diff --git a/desmume/src/cocoa/userinterface/DisplayWindowController.mm b/desmume/src/cocoa/userinterface/DisplayWindowController.mm index 29e7f31c0..ec96293b2 100644 --- a/desmume/src/cocoa/userinterface/DisplayWindowController.mm +++ b/desmume/src/cocoa/userinterface/DisplayWindowController.mm @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2014 DeSmuME team + Copyright (C) 2013-2015 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1079,6 +1079,9 @@ static std::tr1::unordered_map _screenMap cdsVideoOutput = [[CocoaDSDisplayVideo alloc] init]; [cdsVideoOutput setDelegate:view]; + // Add the video thread to the output list. + [emuControl addOutputToCore:cdsVideoOutput]; + [NSThread detachNewThreadSelector:@selector(runThread:) toTarget:cdsVideoOutput withObject:nil]; while ([cdsVideoOutput thread] == nil) { @@ -1087,9 +1090,6 @@ static std::tr1::unordered_map _screenMap // Setup default values per user preferences. [self setupUserDefaults]; - - // Add the video thread to the output list. - [emuControl addOutputToCore:cdsVideoOutput]; } - (void)windowDidBecomeMain:(NSNotification *)notification @@ -1598,18 +1598,6 @@ static std::tr1::unordered_map _screenMap return isHandled; } -- (void) clearToBlack -{ - DisplayWindowController *windowController = (DisplayWindowController *)[[self window] delegate]; - [CocoaDSUtil messageSendOneWay:[[windowController cdsVideoOutput] receivePort] msgID:MESSAGE_SET_VIEW_TO_BLACK]; -} - -- (void) clearToWhite -{ - DisplayWindowController *windowController = (DisplayWindowController *)[[self window] delegate]; - [CocoaDSUtil messageSendOneWay:[[windowController cdsVideoOutput] receivePort] msgID:MESSAGE_SET_VIEW_TO_WHITE]; -} - - (void) requestScreenshot:(NSURL *)fileURL fileType:(NSBitmapImageFileType)fileType { NSString *fileURLString = [fileURL absoluteString]; @@ -1771,7 +1759,7 @@ static std::tr1::unordered_map _screenMap // No init needed, so do nothing. } -- (void)doProcessVideoFrame:(const void *)videoFrameData displayMode:(const NSInteger)frameDisplayMode width:(const NSInteger)frameWidth height:(const NSInteger)frameHeight +- (void)doLoadVideoFrame:(const void *)videoFrameData displayMode:(const NSInteger)frameDisplayMode width:(const NSInteger)frameWidth height:(const NSInteger)frameHeight { OGLDisplayLayer *display = oglv->GetDisplayLayer(); @@ -1782,7 +1770,15 @@ static std::tr1::unordered_map _screenMap CGLLockContext(cglDisplayContext); CGLSetCurrentContext(cglDisplayContext); - oglv->ProcessOGL((uint16_t *)videoFrameData, frameWidth, frameHeight); + display->LoadFrameOGL((uint16_t *)videoFrameData, frameWidth, frameHeight); + CGLUnlockContext(cglDisplayContext); +} + +- (void)doProcessVideoFrame +{ + CGLLockContext(cglDisplayContext); + CGLSetCurrentContext(cglDisplayContext); + oglv->ProcessOGL(); [self drawVideoFrame]; CGLUnlockContext(cglDisplayContext); } diff --git a/desmume/src/cocoa/userinterface/EmuControllerDelegate.mm b/desmume/src/cocoa/userinterface/EmuControllerDelegate.mm index 98a741ff0..027ca9883 100644 --- a/desmume/src/cocoa/userinterface/EmuControllerDelegate.mm +++ b/desmume/src/cocoa/userinterface/EmuControllerDelegate.mm @@ -314,14 +314,7 @@ { DisplayWindowController *newWindowController = [[DisplayWindowController alloc] initWithWindowNibName:@"DisplayWindow" emuControlDelegate:self]; - if ([self currentRom] == nil) - { - [[newWindowController view] clearToBlack]; - } - else - { - [[newWindowController view] setNeedsDisplay:YES]; - } + [CocoaDSUtil messageSendOneWay:[[newWindowController cdsVideoOutput] receivePort] msgID:MESSAGE_REPROCESS_AND_REDRAW]; [[newWindowController window] makeKeyAndOrderFront:self]; [[newWindowController window] makeMainWindow]; @@ -1441,12 +1434,10 @@ } [cdsCore reset]; - if ([cdsCore coreState] == CORESTATE_PAUSE) + + for (DisplayWindowController *windowController in windowList) { - for (DisplayWindowController *windowController in windowList) - { - [[windowController view] clearToWhite]; - } + [CocoaDSUtil messageSendOneWay:[[windowController cdsVideoOutput] receivePort] msgID:MESSAGE_REPROCESS_AND_REDRAW]; } [self setStatusText:NSSTRING_STATUS_EMULATOR_RESET]; @@ -1747,9 +1738,10 @@ // Update the UI to indicate that a ROM has indeed been loaded. [self updateAllWindowTitles]; + GPU_FillScreenWithBGRA5551(0xFFFF); for (DisplayWindowController *windowController in windowList) { - [[windowController view] clearToWhite]; + [CocoaDSUtil messageSendOneWay:[[windowController cdsVideoOutput] receivePort] msgID:MESSAGE_REPROCESS_AND_REDRAW]; } [self setStatusText:NSSTRING_STATUS_ROM_LOADED]; @@ -1824,9 +1816,10 @@ // Update the UI to indicate that the ROM has finished unloading. [self updateAllWindowTitles]; + GPU_FillScreenWithBGRA5551(0x8000); for (DisplayWindowController *windowController in windowList) { - [[windowController view] clearToBlack]; + [CocoaDSUtil messageSendOneWay:[[windowController cdsVideoOutput] receivePort] msgID:MESSAGE_REPROCESS_AND_REDRAW]; } [self setStatusText:NSSTRING_STATUS_ROM_UNLOADED]; diff --git a/desmume/src/cocoa/userinterface/appDelegate.mm b/desmume/src/cocoa/userinterface/appDelegate.mm index eda17e6df..09ba320fa 100644 --- a/desmume/src/cocoa/userinterface/appDelegate.mm +++ b/desmume/src/cocoa/userinterface/appDelegate.mm @@ -683,14 +683,7 @@ } // Draw the display view now so that we guarantee that its drawn at least once. - if ([emuControl currentRom] == nil) - { - [[windowController view] clearToBlack]; - } - else - { - [[windowController view] setNeedsDisplay:YES]; - } + [CocoaDSUtil messageSendOneWay:[[windowController cdsVideoOutput] receivePort] msgID:MESSAGE_REPROCESS_AND_REDRAW]; // If this window is set to full screen mode, its associated screen index must // exist. If not, this window will not enter full screen mode. This is necessary,