Cocoa Port: Vastly improve the ability to take screenshots of the NDS displays.

- The old Tools > Save Screenshot As has been replaced with the new Screenshot Capture Tool.
- The new Screenshot Capture Tool allows screenshots to be configured to render with the same layout features as a display view.
- Screenshot captures now both render and save to file on their own independent threads.
- Screenshots are now captured using the Take Screenshot button, and files are now automatically named based on ROM name and timestamp.
- All of these features means that users can now rapidly take screenshots with their own custom layouts, all with little to no slowdown to the emulation.
- Also do a bunch of code cleanup and refactoring as a side-effect of adding these new features.
This commit is contained in:
rogerman 2017-09-30 23:54:05 -07:00
parent 2c1360dec5
commit 059ea519bc
29 changed files with 6691 additions and 3015 deletions

File diff suppressed because it is too large Load Diff

View File

@ -110,7 +110,7 @@ struct ClientFrameInfo
}; };
typedef struct ClientFrameInfo ClientFrameInfo; typedef struct ClientFrameInfo ClientFrameInfo;
struct ClientDisplayViewProperties struct ClientDisplayPresenterProperties
{ {
ClientDisplayMode mode; ClientDisplayMode mode;
ClientDisplayLayout layout; ClientDisplayLayout layout;
@ -125,7 +125,7 @@ struct ClientDisplayViewProperties
double viewScale; double viewScale;
double gapDistance; double gapDistance;
}; };
typedef struct ClientDisplayViewProperties ClientDisplayViewProperties; typedef struct ClientDisplayPresenterProperties ClientDisplayPresenterProperties;
extern LUTValues *_LQ2xLUT; extern LUTValues *_LQ2xLUT;
extern LUTValues *_HQ2xLUT; extern LUTValues *_HQ2xLUT;
@ -133,15 +133,14 @@ extern LUTValues *_HQ3xLUT;
extern LUTValues *_HQ4xLUT; extern LUTValues *_HQ4xLUT;
void InitHQnxLUTs(); void InitHQnxLUTs();
class ClientDisplayView class ClientDisplayPresenter
{ {
private: private:
void __InstanceInit(const ClientDisplayViewProperties &props); void __InstanceInit(const ClientDisplayPresenterProperties &props);
protected: protected:
ClientDisplayViewProperties _renderProperty; ClientDisplayPresenterProperties _renderProperty;
ClientDisplayViewProperties _stagedProperty; ClientDisplayPresenterProperties _stagedProperty;
InitialTouchPressMap *_initialTouchInMajorDisplay;
GPUClientFetchObject *_fetchObject; GPUClientFetchObject *_fetchObject;
bool _useDeposterize; bool _useDeposterize;
@ -152,8 +151,6 @@ protected:
bool _isSelectedDisplayEnabled[2]; bool _isSelectedDisplayEnabled[2];
NDSDisplayID _selectedSourceForDisplay[2]; NDSDisplayID _selectedSourceForDisplay[2];
int64_t _displayViewID;
bool _useVerticalSync;
double _scaleFactor; double _scaleFactor;
double _hudObjectScale; double _hudObjectScale;
@ -184,9 +181,6 @@ protected:
std::string _hudInputString; std::string _hudInputString;
std::string _outHudString; std::string _outHudString;
bool _hudNeedsUpdate; bool _hudNeedsUpdate;
bool _viewNeedsFlush;
bool _allowViewUpdates;
bool _allowViewFlushes;
FT_Library _ftLibrary; FT_Library _ftLibrary;
const char *_lastFontFilePath; const char *_lastFontFilePath;
@ -215,26 +209,19 @@ protected:
virtual void _ResizeCPUPixelScaler(const VideoFilterTypeID filterID); virtual void _ResizeCPUPixelScaler(const VideoFilterTypeID filterID);
public: public:
ClientDisplayView(); ClientDisplayPresenter();
ClientDisplayView(const ClientDisplayViewProperties &props); ClientDisplayPresenter(const ClientDisplayPresenterProperties &props);
virtual ~ClientDisplayView(); virtual ~ClientDisplayPresenter();
virtual void Init(); virtual void Init();
int64_t GetDisplayViewID();
virtual void SetDisplayViewID(int64_t displayViewID);
virtual bool GetViewNeedsFlush();
bool GetUseVerticalSync() const;
virtual void SetUseVerticalSync(const bool useVerticalSync);
double GetScaleFactor() const; double GetScaleFactor() const;
virtual void SetScaleFactor(const double scaleFactor); virtual void SetScaleFactor(const double scaleFactor);
// NDS screen layout // NDS screen layout
const ClientDisplayViewProperties& GetViewProperties() const; const ClientDisplayPresenterProperties& GetPresenterProperties() const;
void CommitViewProperties(const ClientDisplayViewProperties &props); void CommitPresenterProperties(const ClientDisplayPresenterProperties &props);
virtual void SetupViewProperties(); virtual void SetupPresenterProperties();
double GetRotation() const; double GetRotation() const;
double GetViewScale() const; double GetViewScale() const;
@ -311,15 +298,9 @@ public:
const GPUClientFetchObject& GetFetchObject() const; const GPUClientFetchObject& GetFetchObject() const;
void SetFetchObject(GPUClientFetchObject *fetchObject); void SetFetchObject(GPUClientFetchObject *fetchObject);
bool GetAllowViewUpdates() const;
virtual void SetAllowViewUpdates(bool allowUpdates);
bool GetAllowViewFlushes() const;
virtual void SetAllowViewFlushes(bool allowFlushes);
virtual void LoadDisplays(); virtual void LoadDisplays();
virtual void ProcessDisplays(); virtual void ProcessDisplays();
virtual void UpdateView(); virtual void UpdateLayout();
virtual void FlushView();
virtual void FinishFrameAtIndex(const uint8_t bufferIndex); virtual void FinishFrameAtIndex(const uint8_t bufferIndex);
virtual void CopyFrameToBuffer(uint32_t *dstBuffer); virtual void CopyFrameToBuffer(uint32_t *dstBuffer);
@ -327,12 +308,6 @@ public:
// Emulator interface // Emulator interface
const NDSDisplayInfo& GetEmuDisplayInfo() const; const NDSDisplayInfo& GetEmuDisplayInfo() const;
void SetEmuDisplayInfo(const NDSDisplayInfo &ndsDisplayInfo); void SetEmuDisplayInfo(const NDSDisplayInfo &ndsDisplayInfo);
virtual void HandleEmulatorFrameEndEvent();
// Touch screen input handling
void GetNDSPoint(const int inputID, const bool isInitialTouchPress,
const double clientX, const double clientY,
u8 &outX, u8 &outY) const;
// Utility methods // Utility methods
static void ConvertNormalToTransformedBounds(const double scalar, static void ConvertNormalToTransformedBounds(const double scalar,
@ -342,25 +317,69 @@ public:
static double GetMaxScalarWithinBounds(const double normalBoundsWidth, const double normalBoundsHeight, static double GetMaxScalarWithinBounds(const double normalBoundsWidth, const double normalBoundsHeight,
const double keepInBoundsWidth, const double keepInBoundsHeight); const double keepInBoundsWidth, const double keepInBoundsHeight);
static void CalculateNormalSize(const ClientDisplayMode mode, const ClientDisplayLayout layout, const double gapScale,
double &outWidth, double &outHeight);
};
class ClientDisplayViewInterface
{
protected:
InitialTouchPressMap *_initialTouchInMajorDisplay;
int64_t _displayViewID;
bool _useVerticalSync;
bool _viewNeedsFlush;
bool _allowViewUpdates;
bool _allowViewFlushes;
public:
ClientDisplayViewInterface();
virtual ~ClientDisplayViewInterface();
int64_t GetDisplayViewID();
virtual void SetDisplayViewID(int64_t displayViewID);
virtual bool GetViewNeedsFlush();
virtual void SetViewNeedsFlush();
bool GetUseVerticalSync() const;
virtual void SetUseVerticalSync(const bool useVerticalSync);
// Client view interface
bool GetAllowViewUpdates() const;
virtual void SetAllowViewUpdates(bool allowUpdates);
bool GetAllowViewFlushes() const;
virtual void SetAllowViewFlushes(bool allowFlushes);
virtual void FlushView();
// Touch screen input handling
void GetNDSPoint(const ClientDisplayPresenterProperties &props,
const double logicalClientWidth, const double logicalClientHeight,
const int inputID, const bool isInitialTouchPress,
const double clientX, const double clientY,
uint8_t &outX, uint8_t &outY) const;
// Utility methods
static void ConvertClientToNormalPoint(const double normalBoundsWidth, const double normalBoundsHeight, static void ConvertClientToNormalPoint(const double normalBoundsWidth, const double normalBoundsHeight,
const double transformBoundsWidth, const double transformBoundsHeight, const double transformBoundsWidth, const double transformBoundsHeight,
const double scalar, const double scalar,
const double angleDegrees, const double angleDegrees,
double &inoutX, double &inoutY); double &inoutX, double &inoutY);
static void CalculateNormalSize(const ClientDisplayMode mode, const ClientDisplayLayout layout, const double gapScale,
double &outWidth, double &outHeight);
}; };
class ClientDisplay3DView : public ClientDisplayView class ClientDisplay3DPresenter : public ClientDisplayPresenter
{ {
private:
void __InstanceInit();
protected: protected:
bool _canFilterOnGPU; bool _canFilterOnGPU;
bool _willFilterOnGPU; bool _willFilterOnGPU;
bool _filtersPreferGPU; bool _filtersPreferGPU;
public: public:
ClientDisplay3DView(); ClientDisplay3DPresenter();
ClientDisplay3DPresenter(const ClientDisplayPresenterProperties &props);
bool CanFilterOnGPU() const; bool CanFilterOnGPU() const;
bool GetFiltersPreferGPU() const; bool GetFiltersPreferGPU() const;
@ -377,4 +396,34 @@ public:
void SetScreenTextureCoordinates(float w0, float h0, float w1, float h1, float *texCoordBufferPtr); void SetScreenTextureCoordinates(float w0, float h0, float w1, float h1, float *texCoordBufferPtr);
}; };
class ClientDisplayView : public ClientDisplayViewInterface
{
protected:
ClientDisplayPresenter *_presenter;
public:
ClientDisplayView();
ClientDisplayView(ClientDisplayPresenter *thePresenter);
virtual void Init();
ClientDisplayPresenter* GetPresenter();
void SetPresenter(ClientDisplayPresenter *thePresenter);
};
class ClientDisplay3DView : public ClientDisplayViewInterface
{
protected:
ClientDisplay3DPresenter *_presenter;
public:
ClientDisplay3DView();
ClientDisplay3DView(ClientDisplay3DPresenter *thePresenter);
virtual void Init();
ClientDisplay3DPresenter* Get3DPresenter();
void Set3DPresenter(ClientDisplay3DPresenter *thePresenter);
};
#endif // _CLIENT_DISPLAY_VIEW_H_ #endif // _CLIENT_DISPLAY_VIEW_H_

View File

@ -1048,6 +1048,9 @@
ABD10AEC1715FCDD00B5729D /* mic_ext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD10AE61715FCDD00B5729D /* mic_ext.cpp */; }; ABD10AEC1715FCDD00B5729D /* mic_ext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD10AE61715FCDD00B5729D /* mic_ext.cpp */; };
ABD10AED17160C9300B5729D /* ringbuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB1B9E601501A78000464647 /* ringbuffer.cpp */; }; ABD10AED17160C9300B5729D /* ringbuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB1B9E601501A78000464647 /* ringbuffer.cpp */; };
ABD10AEE17160CDD00B5729D /* cocoa_input.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABD104111346652500AF11D1 /* cocoa_input.mm */; }; ABD10AEE17160CDD00B5729D /* cocoa_input.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABD104111346652500AF11D1 /* cocoa_input.mm */; };
ABD1FBF11F7B7E7E00B4F648 /* MacScreenshotCaptureTool.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABD1FBF01F7B7E7E00B4F648 /* MacScreenshotCaptureTool.mm */; };
ABD1FBF21F7B7E7E00B4F648 /* MacScreenshotCaptureTool.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABD1FBF01F7B7E7E00B4F648 /* MacScreenshotCaptureTool.mm */; };
ABD1FBF31F7B7E7E00B4F648 /* MacScreenshotCaptureTool.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABD1FBF01F7B7E7E00B4F648 /* MacScreenshotCaptureTool.mm */; };
ABD1FED21345AC8400AF11D1 /* arm_instructions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD1FEA31345AC8400AF11D1 /* arm_instructions.cpp */; }; ABD1FED21345AC8400AF11D1 /* arm_instructions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD1FEA31345AC8400AF11D1 /* arm_instructions.cpp */; };
ABD1FED31345AC8400AF11D1 /* armcpu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD1FEA41345AC8400AF11D1 /* armcpu.cpp */; }; ABD1FED31345AC8400AF11D1 /* armcpu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD1FEA41345AC8400AF11D1 /* armcpu.cpp */; };
ABD1FED41345AC8400AF11D1 /* bios.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD1FEA51345AC8400AF11D1 /* bios.cpp */; }; ABD1FED41345AC8400AF11D1 /* bios.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD1FEA51345AC8400AF11D1 /* bios.cpp */; };
@ -1628,6 +1631,8 @@
ABD10AE41715FCDD00B5729D /* mic_ext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mic_ext.h; sourceTree = SOURCE_ROOT; }; ABD10AE41715FCDD00B5729D /* mic_ext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mic_ext.h; sourceTree = SOURCE_ROOT; };
ABD10AE51715FCDD00B5729D /* audiosamplegenerator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = audiosamplegenerator.cpp; sourceTree = SOURCE_ROOT; }; ABD10AE51715FCDD00B5729D /* audiosamplegenerator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = audiosamplegenerator.cpp; sourceTree = SOURCE_ROOT; };
ABD10AE61715FCDD00B5729D /* mic_ext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mic_ext.cpp; sourceTree = SOURCE_ROOT; }; ABD10AE61715FCDD00B5729D /* mic_ext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mic_ext.cpp; sourceTree = SOURCE_ROOT; };
ABD1FBF01F7B7E7E00B4F648 /* MacScreenshotCaptureTool.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MacScreenshotCaptureTool.mm; sourceTree = "<group>"; };
ABD1FBF41F7B7EA600B4F648 /* MacScreenshotCaptureTool.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MacScreenshotCaptureTool.h; sourceTree = "<group>"; };
ABD1FE6F1345AC8400AF11D1 /* armcpu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = armcpu.h; sourceTree = "<group>"; }; ABD1FE6F1345AC8400AF11D1 /* armcpu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = armcpu.h; sourceTree = "<group>"; };
ABD1FE701345AC8400AF11D1 /* bios.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bios.h; sourceTree = "<group>"; }; ABD1FE701345AC8400AF11D1 /* bios.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bios.h; sourceTree = "<group>"; };
ABD1FE711345AC8400AF11D1 /* bits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bits.h; sourceTree = "<group>"; }; ABD1FE711345AC8400AF11D1 /* bits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bits.h; sourceTree = "<group>"; };
@ -2433,6 +2438,7 @@
AB01005C170D07AF00D70FBE /* InputProfileController.h */, AB01005C170D07AF00D70FBE /* InputProfileController.h */,
AB3BF43F1E2628B6003E2B24 /* MacMetalDisplayView.h */, AB3BF43F1E2628B6003E2B24 /* MacMetalDisplayView.h */,
AB3BF4051E22FEA8003E2B24 /* MacOGLDisplayView.h */, AB3BF4051E22FEA8003E2B24 /* MacOGLDisplayView.h */,
ABD1FBF41F7B7EA600B4F648 /* MacScreenshotCaptureTool.h */,
AB3ACB7014C2361100D7D192 /* preferencesWindowDelegate.h */, AB3ACB7014C2361100D7D192 /* preferencesWindowDelegate.h */,
ABAF0A3F1A96E67200B95B75 /* RomInfoPanel.h */, ABAF0A3F1A96E67200B95B75 /* RomInfoPanel.h */,
AB564902186E6EBC002740F4 /* Slot2WindowDelegate.h */, AB564902186E6EBC002740F4 /* Slot2WindowDelegate.h */,
@ -2449,6 +2455,7 @@
AB01005D170D07B000D70FBE /* InputProfileController.mm */, AB01005D170D07B000D70FBE /* InputProfileController.mm */,
AB3BF43B1E26289E003E2B24 /* MacMetalDisplayView.mm */, AB3BF43B1E26289E003E2B24 /* MacMetalDisplayView.mm */,
AB3BF4011E22FE01003E2B24 /* MacOGLDisplayView.mm */, AB3BF4011E22FE01003E2B24 /* MacOGLDisplayView.mm */,
ABD1FBF01F7B7E7E00B4F648 /* MacScreenshotCaptureTool.mm */,
AB3ACB7114C2361100D7D192 /* preferencesWindowDelegate.mm */, AB3ACB7114C2361100D7D192 /* preferencesWindowDelegate.mm */,
ABAF0A401A96E67200B95B75 /* RomInfoPanel.mm */, ABAF0A401A96E67200B95B75 /* RomInfoPanel.mm */,
AB564903186E6EBC002740F4 /* Slot2WindowDelegate.mm */, AB564903186E6EBC002740F4 /* Slot2WindowDelegate.mm */,
@ -3814,6 +3821,7 @@
ABA7316F1BB51FDC00B26147 /* type1.c in Sources */, ABA7316F1BB51FDC00B26147 /* type1.c in Sources */,
ABD1FF5F1345ACBF00AF11D1 /* fatfile.cpp in Sources */, ABD1FF5F1345ACBF00AF11D1 /* fatfile.cpp in Sources */,
ABD1FEDF1345AC8400AF11D1 /* FIFO.cpp in Sources */, ABD1FEDF1345AC8400AF11D1 /* FIFO.cpp in Sources */,
ABD1FBF31F7B7E7E00B4F648 /* MacScreenshotCaptureTool.mm in Sources */,
ABAD3E7413AF1D6D00502E1E /* FIFOSampleBuffer.cpp in Sources */, ABAD3E7413AF1D6D00502E1E /* FIFOSampleBuffer.cpp in Sources */,
ABD1FF601345ACBF00AF11D1 /* file_allocation_table.cpp in Sources */, ABD1FF601345ACBF00AF11D1 /* file_allocation_table.cpp in Sources */,
AB2EE12D17D57ED500F68622 /* slot1_retail_mcrom_debug.cpp in Sources */, AB2EE12D17D57ED500F68622 /* slot1_retail_mcrom_debug.cpp in Sources */,
@ -4035,6 +4043,7 @@
AB796D0115CDCBA200C59155 /* dlditool.cpp in Sources */, AB796D0115CDCBA200C59155 /* dlditool.cpp in Sources */,
AB796D0215CDCBA200C59155 /* driver.cpp in Sources */, AB796D0215CDCBA200C59155 /* driver.cpp in Sources */,
AB796D0315CDCBA200C59155 /* emufat.cpp in Sources */, AB796D0315CDCBA200C59155 /* emufat.cpp in Sources */,
ABD1FBF11F7B7E7E00B4F648 /* MacScreenshotCaptureTool.mm in Sources */,
AB3BF4381E25D9AE003E2B24 /* DisplayViewCALayer.mm in Sources */, AB3BF4381E25D9AE003E2B24 /* DisplayViewCALayer.mm in Sources */,
AB564904186E6EBC002740F4 /* Slot2WindowDelegate.mm in Sources */, AB564904186E6EBC002740F4 /* Slot2WindowDelegate.mm in Sources */,
AB9038B217C5ED2200F410BD /* slot1_retail_mcrom.cpp in Sources */, AB9038B217C5ED2200F410BD /* slot1_retail_mcrom.cpp in Sources */,
@ -4385,6 +4394,7 @@
AB8F3CE81A53AC2600A80BF6 /* epx.cpp in Sources */, AB8F3CE81A53AC2600A80BF6 /* epx.cpp in Sources */,
AB8F3CE91A53AC2600A80BF6 /* hq2x.cpp in Sources */, AB8F3CE91A53AC2600A80BF6 /* hq2x.cpp in Sources */,
AB8F3CEA1A53AC2600A80BF6 /* hq4x.cpp in Sources */, AB8F3CEA1A53AC2600A80BF6 /* hq4x.cpp in Sources */,
ABD1FBF21F7B7E7E00B4F648 /* MacScreenshotCaptureTool.mm in Sources */,
AB8F3CEB1A53AC2600A80BF6 /* advanscene.cpp in Sources */, AB8F3CEB1A53AC2600A80BF6 /* advanscene.cpp in Sources */,
AB8F3CEC1A53AC2600A80BF6 /* lq2x.cpp in Sources */, AB8F3CEC1A53AC2600A80BF6 /* lq2x.cpp in Sources */,
AB8F3CED1A53AC2600A80BF6 /* xbrz.cpp in Sources */, AB8F3CED1A53AC2600A80BF6 /* xbrz.cpp in Sources */,

View File

@ -1227,6 +1227,11 @@
ABAAFBEB172122B6005DDDBE /* FileMigrationDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABAAFBE9172122B6005DDDBE /* FileMigrationDelegate.mm */; }; ABAAFBEB172122B6005DDDBE /* FileMigrationDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABAAFBE9172122B6005DDDBE /* FileMigrationDelegate.mm */; };
ABAAFBEC172122B6005DDDBE /* FileMigrationDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABAAFBE9172122B6005DDDBE /* FileMigrationDelegate.mm */; }; ABAAFBEC172122B6005DDDBE /* FileMigrationDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABAAFBE9172122B6005DDDBE /* FileMigrationDelegate.mm */; };
ABAAFBED172122B6005DDDBE /* FileMigrationDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABAAFBE9172122B6005DDDBE /* FileMigrationDelegate.mm */; }; ABAAFBED172122B6005DDDBE /* FileMigrationDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABAAFBE9172122B6005DDDBE /* FileMigrationDelegate.mm */; };
ABAB0AFF1F7C1BB70079EFD3 /* MacScreenshotCaptureTool.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABAB0AFE1F7C1BB70079EFD3 /* MacScreenshotCaptureTool.mm */; };
ABAB0B001F7C1BB70079EFD3 /* MacScreenshotCaptureTool.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABAB0AFE1F7C1BB70079EFD3 /* MacScreenshotCaptureTool.mm */; };
ABAB0B011F7C1BB70079EFD3 /* MacScreenshotCaptureTool.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABAB0AFE1F7C1BB70079EFD3 /* MacScreenshotCaptureTool.mm */; };
ABAB0B021F7C1BB70079EFD3 /* MacScreenshotCaptureTool.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABAB0AFE1F7C1BB70079EFD3 /* MacScreenshotCaptureTool.mm */; };
ABAB0B031F7C1BB70079EFD3 /* MacScreenshotCaptureTool.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABAB0AFE1F7C1BB70079EFD3 /* MacScreenshotCaptureTool.mm */; };
ABACB73A1AAC46B20066F429 /* Icon_MicrophoneDarkGreen_256x256.png in Resources */ = {isa = PBXBuildFile; fileRef = ABACB7391AAC46B20066F429 /* Icon_MicrophoneDarkGreen_256x256.png */; }; ABACB73A1AAC46B20066F429 /* Icon_MicrophoneDarkGreen_256x256.png in Resources */ = {isa = PBXBuildFile; fileRef = ABACB7391AAC46B20066F429 /* Icon_MicrophoneDarkGreen_256x256.png */; };
ABACB73B1AAC46B20066F429 /* Icon_MicrophoneDarkGreen_256x256.png in Resources */ = {isa = PBXBuildFile; fileRef = ABACB7391AAC46B20066F429 /* Icon_MicrophoneDarkGreen_256x256.png */; }; ABACB73B1AAC46B20066F429 /* Icon_MicrophoneDarkGreen_256x256.png in Resources */ = {isa = PBXBuildFile; fileRef = ABACB7391AAC46B20066F429 /* Icon_MicrophoneDarkGreen_256x256.png */; };
ABACB73C1AAC46B20066F429 /* Icon_MicrophoneDarkGreen_256x256.png in Resources */ = {isa = PBXBuildFile; fileRef = ABACB7391AAC46B20066F429 /* Icon_MicrophoneDarkGreen_256x256.png */; }; ABACB73C1AAC46B20066F429 /* Icon_MicrophoneDarkGreen_256x256.png in Resources */ = {isa = PBXBuildFile; fileRef = ABACB7391AAC46B20066F429 /* Icon_MicrophoneDarkGreen_256x256.png */; };
@ -1994,6 +1999,8 @@
ABAAEFFE1B22361800E1269D /* hq3x.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = hq3x.cpp; sourceTree = "<group>"; }; ABAAEFFE1B22361800E1269D /* hq3x.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = hq3x.cpp; sourceTree = "<group>"; };
ABAAFBE8172122B6005DDDBE /* FileMigrationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileMigrationDelegate.h; sourceTree = "<group>"; }; ABAAFBE8172122B6005DDDBE /* FileMigrationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileMigrationDelegate.h; sourceTree = "<group>"; };
ABAAFBE9172122B6005DDDBE /* FileMigrationDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FileMigrationDelegate.mm; sourceTree = "<group>"; }; ABAAFBE9172122B6005DDDBE /* FileMigrationDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FileMigrationDelegate.mm; sourceTree = "<group>"; };
ABAB0AFD1F7C1BB70079EFD3 /* MacScreenshotCaptureTool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacScreenshotCaptureTool.h; sourceTree = "<group>"; };
ABAB0AFE1F7C1BB70079EFD3 /* MacScreenshotCaptureTool.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MacScreenshotCaptureTool.mm; sourceTree = "<group>"; };
ABACB7391AAC46B20066F429 /* Icon_MicrophoneDarkGreen_256x256.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Icon_MicrophoneDarkGreen_256x256.png; path = images/Icon_MicrophoneDarkGreen_256x256.png; sourceTree = "<group>"; }; ABACB7391AAC46B20066F429 /* Icon_MicrophoneDarkGreen_256x256.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Icon_MicrophoneDarkGreen_256x256.png; path = images/Icon_MicrophoneDarkGreen_256x256.png; sourceTree = "<group>"; };
ABAD104915ACE7A00000EC47 /* DeSmuME (PPC).app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "DeSmuME (PPC).app"; sourceTree = BUILT_PRODUCTS_DIR; }; ABAD104915ACE7A00000EC47 /* DeSmuME (PPC).app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "DeSmuME (PPC).app"; sourceTree = BUILT_PRODUCTS_DIR; };
ABAE2F7918682B6C00C92F4F /* Slot2WindowDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Slot2WindowDelegate.h; sourceTree = "<group>"; }; ABAE2F7918682B6C00C92F4F /* Slot2WindowDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Slot2WindowDelegate.h; sourceTree = "<group>"; };
@ -3017,6 +3024,7 @@
AB3ACB6E14C2361100D7D192 /* inputPrefsView.h */, AB3ACB6E14C2361100D7D192 /* inputPrefsView.h */,
AB213D43170CB141006DDB0F /* InputProfileController.h */, AB213D43170CB141006DDB0F /* InputProfileController.h */,
AB3E690E1E231E9900D4CC75 /* MacOGLDisplayView.h */, AB3E690E1E231E9900D4CC75 /* MacOGLDisplayView.h */,
ABAB0AFD1F7C1BB70079EFD3 /* MacScreenshotCaptureTool.h */,
AB3ACB7014C2361100D7D192 /* preferencesWindowDelegate.h */, AB3ACB7014C2361100D7D192 /* preferencesWindowDelegate.h */,
ABC3DEBB1A96EA96009EC345 /* RomInfoPanel.h */, ABC3DEBB1A96EA96009EC345 /* RomInfoPanel.h */,
ABAE2F7918682B6C00C92F4F /* Slot2WindowDelegate.h */, ABAE2F7918682B6C00C92F4F /* Slot2WindowDelegate.h */,
@ -3031,6 +3039,7 @@
AB3ACB6F14C2361100D7D192 /* inputPrefsView.mm */, AB3ACB6F14C2361100D7D192 /* inputPrefsView.mm */,
AB213D44170CB141006DDB0F /* InputProfileController.mm */, AB213D44170CB141006DDB0F /* InputProfileController.mm */,
AB3E690F1E231E9900D4CC75 /* MacOGLDisplayView.mm */, AB3E690F1E231E9900D4CC75 /* MacOGLDisplayView.mm */,
ABAB0AFE1F7C1BB70079EFD3 /* MacScreenshotCaptureTool.mm */,
AB3ACB7114C2361100D7D192 /* preferencesWindowDelegate.mm */, AB3ACB7114C2361100D7D192 /* preferencesWindowDelegate.mm */,
ABC3DEBC1A96EA96009EC345 /* RomInfoPanel.mm */, ABC3DEBC1A96EA96009EC345 /* RomInfoPanel.mm */,
ABAE2F7A18682B6C00C92F4F /* Slot2WindowDelegate.mm */, ABAE2F7A18682B6C00C92F4F /* Slot2WindowDelegate.mm */,
@ -4617,6 +4626,7 @@
ABC04DA41F67A20500EA6ED7 /* ClientInputHandler.cpp in Sources */, ABC04DA41F67A20500EA6ED7 /* ClientInputHandler.cpp in Sources */,
ABC04DCB1F67A2AC00EA6ED7 /* macosx_10_5_compat.cpp in Sources */, ABC04DCB1F67A2AC00EA6ED7 /* macosx_10_5_compat.cpp in Sources */,
ABAFD2791F7110E6007705BD /* gdbstub.cpp in Sources */, ABAFD2791F7110E6007705BD /* gdbstub.cpp in Sources */,
ABAB0B001F7C1BB70079EFD3 /* MacScreenshotCaptureTool.mm in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -4805,6 +4815,7 @@
ABC04DA51F67A20500EA6ED7 /* ClientInputHandler.cpp in Sources */, ABC04DA51F67A20500EA6ED7 /* ClientInputHandler.cpp in Sources */,
ABC04DCC1F67A2AC00EA6ED7 /* macosx_10_5_compat.cpp in Sources */, ABC04DCC1F67A2AC00EA6ED7 /* macosx_10_5_compat.cpp in Sources */,
ABAFD2781F7110E5007705BD /* gdbstub.cpp in Sources */, ABAFD2781F7110E5007705BD /* gdbstub.cpp in Sources */,
ABAB0B011F7C1BB70079EFD3 /* MacScreenshotCaptureTool.mm in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -5023,6 +5034,7 @@
ABC04DA31F67A20500EA6ED7 /* ClientInputHandler.cpp in Sources */, ABC04DA31F67A20500EA6ED7 /* ClientInputHandler.cpp in Sources */,
ABC04DCA1F67A2AC00EA6ED7 /* macosx_10_5_compat.cpp in Sources */, ABC04DCA1F67A2AC00EA6ED7 /* macosx_10_5_compat.cpp in Sources */,
ABAFD2751F7110E4007705BD /* gdbstub.cpp in Sources */, ABAFD2751F7110E4007705BD /* gdbstub.cpp in Sources */,
ABAB0AFF1F7C1BB70079EFD3 /* MacScreenshotCaptureTool.mm in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -5241,6 +5253,7 @@
ABC04DA71F67A20500EA6ED7 /* ClientInputHandler.cpp in Sources */, ABC04DA71F67A20500EA6ED7 /* ClientInputHandler.cpp in Sources */,
ABC04DCE1F67A2AC00EA6ED7 /* macosx_10_5_compat.cpp in Sources */, ABC04DCE1F67A2AC00EA6ED7 /* macosx_10_5_compat.cpp in Sources */,
ABAFD2761F7110E4007705BD /* gdbstub.cpp in Sources */, ABAFD2761F7110E4007705BD /* gdbstub.cpp in Sources */,
ABAB0B031F7C1BB70079EFD3 /* MacScreenshotCaptureTool.mm in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -5429,6 +5442,7 @@
ABC04DA61F67A20500EA6ED7 /* ClientInputHandler.cpp in Sources */, ABC04DA61F67A20500EA6ED7 /* ClientInputHandler.cpp in Sources */,
ABC04DCD1F67A2AC00EA6ED7 /* macosx_10_5_compat.cpp in Sources */, ABC04DCD1F67A2AC00EA6ED7 /* macosx_10_5_compat.cpp in Sources */,
ABAFD2771F7110E5007705BD /* gdbstub.cpp in Sources */, ABAFD2771F7110E5007705BD /* gdbstub.cpp in Sources */,
ABAB0B021F7C1BB70079EFD3 /* MacScreenshotCaptureTool.mm in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };

View File

@ -752,6 +752,26 @@
<integer>0</integer> <integer>0</integer>
<key>RomInfoPanel_SectionViewState</key> <key>RomInfoPanel_SectionViewState</key>
<dict/> <dict/>
<key>ScreenshotCaptureTool_DirectoryPath</key>
<string>~/Pictures</string>
<key>ScreenshotCaptureTool_FileFormat</key>
<integer>0</integer>
<key>ScreenshotCaptureTool_DisplayMode</key>
<integer>2</integer>
<key>ScreenshotCaptureTool_DisplayRotation</key>
<integer>0</integer>
<key>ScreenshotCaptureTool_DisplaySeparation</key>
<integer>0</integer>
<key>ScreenshotCaptureTool_DisplayLayout</key>
<integer>0</integer>
<key>ScreenshotCaptureTool_DisplayOrder</key>
<integer>0</integer>
<key>ScreenshotCaptureTool_Deposterize</key>
<false/>
<key>ScreenshotCaptureTool_OutputFilter</key>
<integer>1</integer>
<key>ScreenshotCaptureTool_PixelScaler</key>
<integer>0</integer>
<key>Slot2_GBA_CartridgePath</key> <key>Slot2_GBA_CartridgePath</key>
<string></string> <string></string>
<key>Slot2_GBA_SRAMPath</key> <key>Slot2_GBA_SRAMPath</key>

View File

@ -5019,15 +5019,17 @@ void OGLClientFetchObject::_FetchCustomDisplayByID(const NDSDisplayID displayID,
OGLVideoOutput::OGLVideoOutput() OGLVideoOutput::OGLVideoOutput()
{ {
_contextInfo = NULL; _contextInfo = NULL;
_viewportWidth = GPU_FRAMEBUFFER_NATIVE_WIDTH;
_viewportHeight = GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2;
_needUpdateViewport = true; _needUpdateViewport = true;
_hasOGLPixelScaler = false; _hasOGLPixelScaler = false;
_layerList = new std::vector<OGLVideoLayer *>;
_layerList->reserve(8);
_texCPUFilterDstID[NDSDisplayID_Main] = 0; _texCPUFilterDstID[NDSDisplayID_Main] = 0;
_texCPUFilterDstID[NDSDisplayID_Touch] = 0; _texCPUFilterDstID[NDSDisplayID_Touch] = 0;
_fboFrameCopyID = 0; _fboFrameCopyID = 0;
_layerList = new std::vector<OGLVideoLayer *>;
_layerList->reserve(8);
} }
OGLVideoOutput::~OGLVideoOutput() OGLVideoOutput::~OGLVideoOutput()
@ -5073,12 +5075,12 @@ void OGLVideoOutput::_UpdateClientSize()
this->_needUpdateViewport = true; this->_needUpdateViewport = true;
this->GetHUDLayer()->SetNeedsUpdateVertices(); this->GetHUDLayer()->SetNeedsUpdateVertices();
this->ClientDisplay3DView::_UpdateClientSize(); this->ClientDisplay3DPresenter::_UpdateClientSize();
} }
void OGLVideoOutput::_UpdateViewScale() void OGLVideoOutput::_UpdateViewScale()
{ {
this->ClientDisplayView::_UpdateViewScale(); this->ClientDisplay3DPresenter::_UpdateViewScale();
for (size_t i = 0; i < _layerList->size(); i++) for (size_t i = 0; i < _layerList->size(); i++)
{ {
@ -5109,7 +5111,7 @@ void OGLVideoOutput::_ResizeCPUPixelScaler(const VideoFilterTypeID filterID)
glFinish(); glFinish();
this->ClientDisplay3DView::_ResizeCPUPixelScaler(filterID); this->ClientDisplay3DPresenter::_ResizeCPUPixelScaler(filterID);
glTextureRangeAPPLE(GL_TEXTURE_RECTANGLE_ARB, this->_vfMasterDstBufferSize, this->_vfMasterDstBuffer); glTextureRangeAPPLE(GL_TEXTURE_RECTANGLE_ARB, this->_vfMasterDstBufferSize, this->_vfMasterDstBuffer);
glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE); glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
@ -5199,7 +5201,7 @@ void OGLVideoOutput::SetOutputFilter(const OutputFilterTypeID filterID)
void OGLVideoOutput::SetPixelScaler(const VideoFilterTypeID filterID) void OGLVideoOutput::SetPixelScaler(const VideoFilterTypeID filterID)
{ {
this->ClientDisplay3DView::SetPixelScaler(filterID); this->ClientDisplay3DPresenter::SetPixelScaler(filterID);
this->_hasOGLPixelScaler = this->GetDisplayLayer()->SetGPUPixelScalerOGL(this->_pixelScaler); this->_hasOGLPixelScaler = this->GetDisplayLayer()->SetGPUPixelScalerOGL(this->_pixelScaler);
this->_willFilterOnGPU = (this->GetFiltersPreferGPU()) ? this->_hasOGLPixelScaler : false; this->_willFilterOnGPU = (this->GetFiltersPreferGPU()) ? this->_hasOGLPixelScaler : false;
@ -5213,7 +5215,7 @@ void OGLVideoOutput::CopyHUDFont(const FT_Face &fontFace, const size_t glyphSize
void OGLVideoOutput::SetHUDVisibility(const bool visibleState) void OGLVideoOutput::SetHUDVisibility(const bool visibleState)
{ {
this->GetHUDLayer()->SetVisibility(visibleState); this->GetHUDLayer()->SetVisibility(visibleState);
this->ClientDisplay3DView::SetHUDVisibility(visibleState); this->ClientDisplay3DPresenter::SetHUDVisibility(visibleState);
} }
void OGLVideoOutput::SetFiltersPreferGPU(const bool preferGPU) void OGLVideoOutput::SetFiltersPreferGPU(const bool preferGPU)
@ -5271,12 +5273,6 @@ void OGLVideoOutput::FinishFrameAtIndex(const uint8_t bufferIndex)
void OGLVideoOutput::CopyFrameToBuffer(uint32_t *dstBuffer) void OGLVideoOutput::CopyFrameToBuffer(uint32_t *dstBuffer)
{ {
for (size_t i = 0; i < _layerList->size(); i++)
{
OGLVideoLayer *theLayer = (*_layerList)[i];
theLayer->SetNeedsUpdateViewport();
}
GLuint texFrameCopyID = 0; GLuint texFrameCopyID = 0;
glGenTextures(1, &texFrameCopyID); glGenTextures(1, &texFrameCopyID);
@ -5290,6 +5286,7 @@ void OGLVideoOutput::CopyFrameToBuffer(uint32_t *dstBuffer)
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, this->_fboFrameCopyID); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, this->_fboFrameCopyID);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_ARB, texFrameCopyID, 0); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_ARB, texFrameCopyID, 0);
this->_needUpdateViewport = true;
this->RenderFrameOGL(true); this->RenderFrameOGL(true);
glReadPixels(0, 0, this->_renderProperty.clientWidth, this->_renderProperty.clientHeight, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, dstBuffer); glReadPixels(0, 0, this->_renderProperty.clientWidth, this->_renderProperty.clientHeight, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, dstBuffer);
@ -5297,11 +5294,7 @@ void OGLVideoOutput::CopyFrameToBuffer(uint32_t *dstBuffer)
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0); glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
glDeleteTextures(1, &texFrameCopyID); glDeleteTextures(1, &texFrameCopyID);
for (size_t i = 0; i < _layerList->size(); i++) this->_needUpdateViewport = true;
{
OGLVideoLayer *theLayer = (*_layerList)[i];
theLayer->SetNeedsUpdateViewport();
}
} }
void OGLVideoOutput::RenderFrameOGL(bool isRenderingFlipped) void OGLVideoOutput::RenderFrameOGL(bool isRenderingFlipped)
@ -5834,7 +5827,7 @@ void OGLImage::UploadTransformationOGL()
{ {
const double w = this->_viewportWidth; const double w = this->_viewportWidth;
const double h = this->_viewportHeight; const double h = this->_viewportHeight;
const GLdouble s = ClientDisplayView::GetMaxScalarWithinBounds(this->_normalWidth, this->_normalHeight, w, h); const GLdouble s = ClientDisplayPresenter::GetMaxScalarWithinBounds(this->_normalWidth, this->_normalHeight, w, h);
if (this->_canUseShaderOutput) if (this->_canUseShaderOutput)
{ {
@ -6560,7 +6553,7 @@ void OGLHUDLayer::RenderOGL(bool isRenderingFlipped)
if (this->_needUpdateViewport) if (this->_needUpdateViewport)
{ {
glUniform2f(this->_uniformViewSize, this->_output->GetViewProperties().clientWidth, this->_output->GetViewProperties().clientHeight); glUniform2f(this->_uniformViewSize, this->_output->GetPresenterProperties().clientWidth, this->_output->GetPresenterProperties().clientHeight);
glUniform1i(this->_uniformRenderFlipped, (isRenderingFlipped) ? GL_TRUE : GL_FALSE); glUniform1i(this->_uniformRenderFlipped, (isRenderingFlipped) ? GL_TRUE : GL_FALSE);
this->_needUpdateViewport = false; this->_needUpdateViewport = false;
} }
@ -6577,7 +6570,7 @@ void OGLHUDLayer::RenderOGL(bool isRenderingFlipped)
// First, draw the inputs. // First, draw the inputs.
if (this->_output->GetHUDShowInput()) if (this->_output->GetHUDShowInput())
{ {
const ClientDisplayViewProperties &cdv = this->_output->GetViewProperties(); const ClientDisplayPresenterProperties &cdv = this->_output->GetPresenterProperties();
if (this->_output->GetContextInfo()->IsShaderSupported()) if (this->_output->GetContextInfo()->IsShaderSupported())
{ {
@ -6776,7 +6769,7 @@ OGLDisplayLayer::~OGLDisplayLayer()
void OGLDisplayLayer::_UpdateRotationScaleOGL() void OGLDisplayLayer::_UpdateRotationScaleOGL()
{ {
const ClientDisplayViewProperties &cdv = this->_output->GetViewProperties(); const ClientDisplayPresenterProperties &cdv = this->_output->GetPresenterProperties();
const double r = cdv.rotation; const double r = cdv.rotation;
const double s = cdv.viewScale; const double s = cdv.viewScale;
@ -7140,7 +7133,7 @@ void OGLDisplayLayer::ProcessOGL()
{ {
const OGLClientFetchObject &fetchObj = (const OGLClientFetchObject &)this->_output->GetFetchObject(); const OGLClientFetchObject &fetchObj = (const OGLClientFetchObject &)this->_output->GetFetchObject();
const NDSDisplayInfo &emuDisplayInfo = this->_output->GetEmuDisplayInfo(); const NDSDisplayInfo &emuDisplayInfo = this->_output->GetEmuDisplayInfo();
const ClientDisplayMode mode = this->_output->GetViewProperties().mode; const ClientDisplayMode mode = this->_output->GetPresenterProperties().mode;
const NDSDisplayID selectedDisplaySource[2] = { this->_output->GetSelectedDisplaySourceForDisplay(NDSDisplayID_Main), this->_output->GetSelectedDisplaySourceForDisplay(NDSDisplayID_Touch) }; const NDSDisplayID selectedDisplaySource[2] = { this->_output->GetSelectedDisplaySourceForDisplay(NDSDisplayID_Main), this->_output->GetSelectedDisplaySourceForDisplay(NDSDisplayID_Touch) };
const bool didRenderNative[2] = { !emuDisplayInfo.didPerformCustomRender[selectedDisplaySource[NDSDisplayID_Main]], !emuDisplayInfo.didPerformCustomRender[selectedDisplaySource[NDSDisplayID_Touch]] }; const bool didRenderNative[2] = { !emuDisplayInfo.didPerformCustomRender[selectedDisplaySource[NDSDisplayID_Main]], !emuDisplayInfo.didPerformCustomRender[selectedDisplaySource[NDSDisplayID_Touch]] };
@ -7259,7 +7252,7 @@ void OGLDisplayLayer::RenderOGL(bool isRenderingFlipped)
this->_output->LockDisplayTextures(); this->_output->LockDisplayTextures();
glBindVertexArrayDESMUME(this->_vaoMainStatesID); glBindVertexArrayDESMUME(this->_vaoMainStatesID);
switch (this->_output->GetViewProperties().mode) switch (this->_output->GetPresenterProperties().mode)
{ {
case ClientDisplayMode_Main: case ClientDisplayMode_Main:
{ {
@ -7287,10 +7280,10 @@ void OGLDisplayLayer::RenderOGL(bool isRenderingFlipped)
case ClientDisplayMode_Dual: case ClientDisplayMode_Dual:
{ {
const NDSDisplayID majorDisplayID = (this->_output->GetViewProperties().order == ClientDisplayOrder_MainFirst) ? NDSDisplayID_Main : NDSDisplayID_Touch; const NDSDisplayID majorDisplayID = (this->_output->GetPresenterProperties().order == ClientDisplayOrder_MainFirst) ? NDSDisplayID_Main : NDSDisplayID_Touch;
const size_t majorDisplayVtx = (this->_output->GetViewProperties().order == ClientDisplayOrder_MainFirst) ? 8 : 12; const size_t majorDisplayVtx = (this->_output->GetPresenterProperties().order == ClientDisplayOrder_MainFirst) ? 8 : 12;
switch (this->_output->GetViewProperties().layout) switch (this->_output->GetPresenterProperties().layout)
{ {
case ClientDisplayLayout_Hybrid_2_1: case ClientDisplayLayout_Hybrid_2_1:
case ClientDisplayLayout_Hybrid_16_9: case ClientDisplayLayout_Hybrid_16_9:

View File

@ -373,7 +373,7 @@ public:
virtual void SetFetchBuffers(const NDSDisplayInfo &currentDisplayInfo); virtual void SetFetchBuffers(const NDSDisplayInfo &currentDisplayInfo);
}; };
class OGLVideoOutput : public ClientDisplay3DView class OGLVideoOutput : public ClientDisplay3DPresenter
{ {
protected: protected:
OGLContextInfo *_contextInfo; OGLContextInfo *_contextInfo;
@ -381,10 +381,12 @@ protected:
GLsizei _viewportHeight; GLsizei _viewportHeight;
bool _needUpdateViewport; bool _needUpdateViewport;
bool _hasOGLPixelScaler; bool _hasOGLPixelScaler;
std::vector<OGLVideoLayer *> *_layerList;
GLuint _texCPUFilterDstID[2]; GLuint _texCPUFilterDstID[2];
GLuint _fboFrameCopyID; GLuint _fboFrameCopyID;
std::vector<OGLVideoLayer *> *_layerList;
void _UpdateViewport(); void _UpdateViewport();
virtual void _UpdateNormalSize(); virtual void _UpdateNormalSize();

View File

@ -62,12 +62,10 @@ typedef std::map<CGDirectDisplayID, int64_t> DisplayLinkFlushTimeLimitMap;
@property (assign, nonatomic) GPUClientFetchObject *GPUFetchObject; @property (assign, nonatomic) GPUClientFetchObject *GPUFetchObject;
@property (readonly, nonatomic) volatile int32_t numberViewsUsingDirectToCPUFiltering; @property (readonly, nonatomic) volatile int32_t numberViewsUsingDirectToCPUFiltering;
- (const NDSDisplayInfo &) fetchDisplayInfoForIndex:(const u8)bufferIndex;
- (pthread_rwlock_t *) rwlockFramebufferAtIndex:(const u8)bufferIndex; - (pthread_rwlock_t *) rwlockFramebufferAtIndex:(const u8)bufferIndex;
- (void) setOutputList:(NSMutableArray *)theOutputList mutex:(pthread_mutex_t *)theMutex; - (void) setOutputList:(NSMutableArray *)theOutputList mutex:(pthread_mutex_t *)theMutex;
- (void) incrementViewsUsingDirectToCPUFiltering; - (void) incrementViewsUsingDirectToCPUFiltering;
- (void) decrementViewsUsingDirectToCPUFiltering; - (void) decrementViewsUsingDirectToCPUFiltering;
- (void) handleFetchFromBufferIndexAndPushVideo:(NSData *)indexData;
- (void) pushVideoDataToAllDisplayViews; - (void) pushVideoDataToAllDisplayViews;
- (void) finishAllDisplayViewsAtIndex:(const u8)bufferIndex; - (void) finishAllDisplayViewsAtIndex:(const u8)bufferIndex;
- (void) flushAllDisplaysOnDisplayLink:(CVDisplayLinkRef)displayLink timeStamp:(const CVTimeStamp *)timeStamp; - (void) flushAllDisplaysOnDisplayLink:(CVDisplayLinkRef)displayLink timeStamp:(const CVTimeStamp *)timeStamp;

View File

@ -950,19 +950,6 @@ public:
[super dealloc]; [super dealloc];
} }
- (void) handleFetchFromBufferIndexAndPushVideo:(NSData *)indexData
{
const NSInteger index = *(NSInteger *)[indexData bytes];
GPUFetchObject->FetchFromBufferIndex(index);
[self pushVideoDataToAllDisplayViews];
}
- (const NDSDisplayInfo &) fetchDisplayInfoForIndex:(const u8)bufferIndex
{
return GPUFetchObject->GetFetchDisplayInfoForBufferIndex(bufferIndex);
}
- (pthread_rwlock_t *) rwlockFramebufferAtIndex:(const u8)bufferIndex - (pthread_rwlock_t *) rwlockFramebufferAtIndex:(const u8)bufferIndex
{ {
return _rwlockFramebuffer[bufferIndex]; return _rwlockFramebuffer[bufferIndex];
@ -1035,8 +1022,8 @@ public:
{ {
if ([cdsOutput isKindOfClass:[CocoaDSDisplayVideo class]]) if ([cdsOutput isKindOfClass:[CocoaDSDisplayVideo class]])
{ {
ClientDisplay3DView *cdv = [(CocoaDSDisplayVideo *)cdsOutput clientDisplayView]; ClientDisplay3DView *cdv = [(CocoaDSDisplayVideo *)cdsOutput clientDisplay3DView];
cdv->FinishFrameAtIndex(bufferIndex); cdv->Get3DPresenter()->FinishFrameAtIndex(bufferIndex);
} }
} }
@ -1063,7 +1050,7 @@ public:
{ {
if ([(CocoaDSDisplayVideo *)cdsOutput currentDisplayID] == displayID) if ([(CocoaDSDisplayVideo *)cdsOutput currentDisplayID] == displayID)
{ {
ClientDisplay3DView *cdv = [(CocoaDSDisplayVideo *)cdsOutput clientDisplayView]; ClientDisplay3DView *cdv = [(CocoaDSDisplayVideo *)cdsOutput clientDisplay3DView];
if (cdv->GetViewNeedsFlush()) if (cdv->GetViewNeedsFlush())
{ {

View File

@ -38,7 +38,7 @@
#define NSSTRING_TITLE_SELECT_MPCF_DISK_IMAGE_PANEL NSLocalizedString(@"Select MPCF Disk Image", nil) #define NSSTRING_TITLE_SELECT_MPCF_DISK_IMAGE_PANEL NSLocalizedString(@"Select MPCF Disk Image", nil)
#define NSSTRING_TITLE_CHOOSE_GBA_CARTRIDGE_PANEL NSLocalizedString(@"Choose GBA Cartridge", nil) #define NSSTRING_TITLE_CHOOSE_GBA_CARTRIDGE_PANEL NSLocalizedString(@"Choose GBA Cartridge", nil)
#define NSSTRING_TITLE_CHOOSE_GBA_SRAM_PANEL NSLocalizedString(@"Choose GBA SRAM File", nil) #define NSSTRING_TITLE_CHOOSE_GBA_SRAM_PANEL NSLocalizedString(@"Choose GBA SRAM File", nil)
#define NSSTRING_TITLE_SAVE_SCREENSHOT_PANEL NSLocalizedString(@"Save Screenshot", nil) #define NSSTRING_TITLE_SAVE_SCREENSHOT_PANEL NSLocalizedString(@"Screenshot Save Location", nil)
#define NSSTRING_TITLE_EXECUTE_CONTROL NSLocalizedString(@"Execute", nil) #define NSSTRING_TITLE_EXECUTE_CONTROL NSLocalizedString(@"Execute", nil)
#define NSSTRING_TITLE_PAUSE_CONTROL NSLocalizedString(@"Pause", nil) #define NSSTRING_TITLE_PAUSE_CONTROL NSLocalizedString(@"Pause", nil)
@ -367,7 +367,6 @@ enum
MESSAGE_SET_SPU_INTERPOLATION_MODE, MESSAGE_SET_SPU_INTERPOLATION_MODE,
MESSAGE_SET_VOLUME, MESSAGE_SET_VOLUME,
MESSAGE_REQUEST_SCREENSHOT,
MESSAGE_COPY_TO_PASTEBOARD MESSAGE_COPY_TO_PASTEBOARD
}; };

View File

@ -116,7 +116,7 @@
@interface CocoaDSDisplayVideo : CocoaDSDisplay @interface CocoaDSDisplayVideo : CocoaDSDisplay
{ {
ClientDisplay3DView *_cdv; ClientDisplay3DView *_cdv;
ClientDisplayViewProperties _intermediateViewProps; ClientDisplayPresenterProperties _intermediateViewProps;
OSSpinLock spinlockViewProperties; OSSpinLock spinlockViewProperties;
OSSpinLock spinlockIsHUDVisible; OSSpinLock spinlockIsHUDVisible;
@ -129,7 +129,7 @@
OSSpinLock spinlockDisplayID; OSSpinLock spinlockDisplayID;
} }
@property (assign, nonatomic) ClientDisplay3DView *clientDisplayView; @property (assign, nonatomic, getter=clientDisplay3DView, setter=setClientDisplay3DView:) ClientDisplay3DView *_cdv;
@property (readonly, nonatomic) BOOL canFilterOnGPU; @property (readonly, nonatomic) BOOL canFilterOnGPU;
@property (readonly, nonatomic) BOOL willFilterOnGPU; @property (readonly, nonatomic) BOOL willFilterOnGPU;
@property (assign) BOOL isHUDVisible; @property (assign) BOOL isHUDVisible;
@ -158,7 +158,7 @@
@property (assign) NSInteger outputFilter; @property (assign) NSInteger outputFilter;
@property (assign) NSInteger pixelScaler; @property (assign) NSInteger pixelScaler;
- (void) commitViewProperties:(const ClientDisplayViewProperties &)viewProps; - (void) commitPresenterProperties:(const ClientDisplayPresenterProperties &)viewProps;
- (void) handleChangeViewProperties; - (void) handleChangeViewProperties;
- (void) handleReceiveGPUFrame; - (void) handleReceiveGPUFrame;
@ -166,12 +166,9 @@
- (void) handleReprocessRedraw; - (void) handleReprocessRedraw;
- (void) handleRedraw; - (void) handleRedraw;
- (void) handleCopyToPasteboard; - (void) handleCopyToPasteboard;
- (void) handleRequestScreenshot:(NSData *)fileURLStringData fileTypeData:(NSData *)fileTypeData;
- (void) setScaleFactor:(float)theScaleFactor; - (void) setScaleFactor:(float)theScaleFactor;
- (void) hudUpdate; - (void) hudUpdate;
- (NSImage *) copyImageFromView;
- (NSImage *) image; - (NSImage *) image;
- (NSBitmapImageRep *) bitmapImageRep;
@end @end

View File

@ -568,7 +568,7 @@
@implementation CocoaDSDisplayVideo @implementation CocoaDSDisplayVideo
@dynamic clientDisplayView; @synthesize _cdv;
@dynamic canFilterOnGPU; @dynamic canFilterOnGPU;
@dynamic willFilterOnGPU; @dynamic willFilterOnGPU;
@dynamic isHUDVisible; @dynamic isHUDVisible;
@ -625,17 +625,7 @@
[super dealloc]; [super dealloc];
} }
- (void) setClientDisplayView:(ClientDisplay3DView *)clientDisplayView - (void) commitPresenterProperties:(const ClientDisplayPresenterProperties &)viewProps
{
_cdv = clientDisplayView;
}
- (ClientDisplay3DView *) clientDisplayView
{
return _cdv;
}
- (void) commitViewProperties:(const ClientDisplayViewProperties &)viewProps
{ {
OSSpinLockLock(&spinlockViewProperties); OSSpinLockLock(&spinlockViewProperties);
_intermediateViewProps = viewProps; _intermediateViewProps = viewProps;
@ -646,25 +636,27 @@
- (BOOL) canFilterOnGPU - (BOOL) canFilterOnGPU
{ {
return (_cdv->CanFilterOnGPU()) ? YES : NO; return (_cdv->Get3DPresenter()->CanFilterOnGPU()) ? YES : NO;
} }
- (BOOL) willFilterOnGPU - (BOOL) willFilterOnGPU
{ {
return (_cdv->WillFilterOnGPU()) ? YES : NO; return (_cdv->Get3DPresenter()->WillFilterOnGPU()) ? YES : NO;
} }
- (void) setIsHUDVisible:(BOOL)theState - (void) setIsHUDVisible:(BOOL)theState
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
_cdv->SetHUDVisibility((theState) ? true : false); _cdv->Get3DPresenter()->SetHUDVisibility((theState) ? true : false);
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
_cdv->SetViewNeedsFlush();
} }
- (BOOL) isHUDVisible - (BOOL) isHUDVisible
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
const BOOL theState = (_cdv->GetHUDVisibility()) ? YES : NO; const BOOL theState = (_cdv->Get3DPresenter()->GetHUDVisibility()) ? YES : NO;
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
return theState; return theState;
@ -673,14 +665,16 @@
- (void) setIsHUDVideoFPSVisible:(BOOL)theState - (void) setIsHUDVideoFPSVisible:(BOOL)theState
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
_cdv->SetHUDShowVideoFPS((theState) ? true : false); _cdv->Get3DPresenter()->SetHUDShowVideoFPS((theState) ? true : false);
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
_cdv->SetViewNeedsFlush();
} }
- (BOOL) isHUDVideoFPSVisible - (BOOL) isHUDVideoFPSVisible
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
const BOOL theState = (_cdv->GetHUDShowVideoFPS()) ? YES : NO; const BOOL theState = (_cdv->Get3DPresenter()->GetHUDShowVideoFPS()) ? YES : NO;
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
return theState; return theState;
@ -689,14 +683,16 @@
- (void) setIsHUDRender3DFPSVisible:(BOOL)theState - (void) setIsHUDRender3DFPSVisible:(BOOL)theState
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
_cdv->SetHUDShowRender3DFPS((theState) ? true : false); _cdv->Get3DPresenter()->SetHUDShowRender3DFPS((theState) ? true : false);
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
_cdv->SetViewNeedsFlush();
} }
- (BOOL) isHUDRender3DFPSVisible - (BOOL) isHUDRender3DFPSVisible
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
const BOOL theState = (_cdv->GetHUDShowRender3DFPS()) ? YES : NO; const BOOL theState = (_cdv->Get3DPresenter()->GetHUDShowRender3DFPS()) ? YES : NO;
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
return theState; return theState;
@ -705,14 +701,16 @@
- (void) setIsHUDFrameIndexVisible:(BOOL)theState - (void) setIsHUDFrameIndexVisible:(BOOL)theState
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
_cdv->SetHUDShowFrameIndex((theState) ? true : false); _cdv->Get3DPresenter()->SetHUDShowFrameIndex((theState) ? true : false);
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
_cdv->SetViewNeedsFlush();
} }
- (BOOL) isHUDFrameIndexVisible - (BOOL) isHUDFrameIndexVisible
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
const BOOL theState = (_cdv->GetHUDShowFrameIndex()) ? YES : NO; const BOOL theState = (_cdv->Get3DPresenter()->GetHUDShowFrameIndex()) ? YES : NO;
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
return theState; return theState;
@ -721,14 +719,16 @@
- (void) setIsHUDLagFrameCountVisible:(BOOL)theState - (void) setIsHUDLagFrameCountVisible:(BOOL)theState
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
_cdv->SetHUDShowLagFrameCount((theState) ? true : false); _cdv->Get3DPresenter()->SetHUDShowLagFrameCount((theState) ? true : false);
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
_cdv->SetViewNeedsFlush();
} }
- (BOOL) isHUDLagFrameCountVisible - (BOOL) isHUDLagFrameCountVisible
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
const BOOL theState = (_cdv->GetHUDShowLagFrameCount()) ? YES : NO; const BOOL theState = (_cdv->Get3DPresenter()->GetHUDShowLagFrameCount()) ? YES : NO;
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
return theState; return theState;
@ -737,14 +737,16 @@
- (void) setIsHUDCPULoadAverageVisible:(BOOL)theState - (void) setIsHUDCPULoadAverageVisible:(BOOL)theState
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
_cdv->SetHUDShowCPULoadAverage((theState) ? true : false); _cdv->Get3DPresenter()->SetHUDShowCPULoadAverage((theState) ? true : false);
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
_cdv->SetViewNeedsFlush();
} }
- (BOOL) isHUDCPULoadAverageVisible - (BOOL) isHUDCPULoadAverageVisible
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
const BOOL theState = (_cdv->GetHUDShowCPULoadAverage()) ? YES : NO; const BOOL theState = (_cdv->Get3DPresenter()->GetHUDShowCPULoadAverage()) ? YES : NO;
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
return theState; return theState;
@ -753,14 +755,16 @@
- (void) setIsHUDRealTimeClockVisible:(BOOL)theState - (void) setIsHUDRealTimeClockVisible:(BOOL)theState
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
_cdv->SetHUDShowRTC((theState) ? true : false); _cdv->Get3DPresenter()->SetHUDShowRTC((theState) ? true : false);
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
_cdv->SetViewNeedsFlush();
} }
- (BOOL) isHUDRealTimeClockVisible - (BOOL) isHUDRealTimeClockVisible
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
const BOOL theState = (_cdv->GetHUDShowRTC()) ? YES : NO; const BOOL theState = (_cdv->Get3DPresenter()->GetHUDShowRTC()) ? YES : NO;
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
return theState; return theState;
@ -769,14 +773,16 @@
- (void) setIsHUDInputVisible:(BOOL)theState - (void) setIsHUDInputVisible:(BOOL)theState
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
_cdv->SetHUDShowInput((theState) ? true : false); _cdv->Get3DPresenter()->SetHUDShowInput((theState) ? true : false);
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
_cdv->SetViewNeedsFlush();
} }
- (BOOL) isHUDInputVisible - (BOOL) isHUDInputVisible
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
const BOOL theState = (_cdv->GetHUDShowInput()) ? YES : NO; const BOOL theState = (_cdv->Get3DPresenter()->GetHUDShowInput()) ? YES : NO;
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
return theState; return theState;
@ -785,14 +791,16 @@
- (void) setHudColorVideoFPS:(uint32_t)theColor - (void) setHudColorVideoFPS:(uint32_t)theColor
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
_cdv->SetHUDColorVideoFPS(theColor); _cdv->Get3DPresenter()->SetHUDColorVideoFPS(theColor);
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
_cdv->SetViewNeedsFlush();
} }
- (uint32_t) hudColorVideoFPS - (uint32_t) hudColorVideoFPS
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
const uint32_t color32 = _cdv->GetHUDColorVideoFPS(); const uint32_t color32 = _cdv->Get3DPresenter()->GetHUDColorVideoFPS();
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
return color32; return color32;
@ -801,14 +809,16 @@
- (void) setHudColorRender3DFPS:(uint32_t)theColor - (void) setHudColorRender3DFPS:(uint32_t)theColor
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
_cdv->SetHUDColorRender3DFPS(theColor); _cdv->Get3DPresenter()->SetHUDColorRender3DFPS(theColor);
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
_cdv->SetViewNeedsFlush();
} }
- (uint32_t) hudColorRender3DFPS - (uint32_t) hudColorRender3DFPS
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
const uint32_t color32 = _cdv->GetHUDColorRender3DFPS(); const uint32_t color32 = _cdv->Get3DPresenter()->GetHUDColorRender3DFPS();
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
return color32; return color32;
@ -817,14 +827,16 @@
- (void) setHudColorFrameIndex:(uint32_t)theColor - (void) setHudColorFrameIndex:(uint32_t)theColor
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
_cdv->SetHUDColorFrameIndex(theColor); _cdv->Get3DPresenter()->SetHUDColorFrameIndex(theColor);
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
_cdv->SetViewNeedsFlush();
} }
- (uint32_t) hudColorFrameIndex - (uint32_t) hudColorFrameIndex
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
const uint32_t color32 = _cdv->GetHUDColorFrameIndex(); const uint32_t color32 = _cdv->Get3DPresenter()->GetHUDColorFrameIndex();
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
return color32; return color32;
@ -833,14 +845,16 @@
- (void) setHudColorLagFrameCount:(uint32_t)theColor - (void) setHudColorLagFrameCount:(uint32_t)theColor
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
_cdv->SetHUDColorLagFrameCount(theColor); _cdv->Get3DPresenter()->SetHUDColorLagFrameCount(theColor);
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
_cdv->SetViewNeedsFlush();
} }
- (uint32_t) hudColorLagFrameCount - (uint32_t) hudColorLagFrameCount
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
const uint32_t color32 = _cdv->GetHUDColorLagFrameCount(); const uint32_t color32 = _cdv->Get3DPresenter()->GetHUDColorLagFrameCount();
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
return color32; return color32;
@ -849,14 +863,16 @@
- (void) setHudColorCPULoadAverage:(uint32_t)theColor - (void) setHudColorCPULoadAverage:(uint32_t)theColor
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
_cdv->SetHUDColorCPULoadAverage(theColor); _cdv->Get3DPresenter()->SetHUDColorCPULoadAverage(theColor);
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
_cdv->SetViewNeedsFlush();
} }
- (uint32_t) hudColorCPULoadAverage - (uint32_t) hudColorCPULoadAverage
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
const uint32_t color32 = _cdv->GetHUDColorCPULoadAverage(); const uint32_t color32 = _cdv->Get3DPresenter()->GetHUDColorCPULoadAverage();
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
return color32; return color32;
@ -865,14 +881,16 @@
- (void) setHudColorRTC:(uint32_t)theColor - (void) setHudColorRTC:(uint32_t)theColor
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
_cdv->SetHUDColorRTC(theColor); _cdv->Get3DPresenter()->SetHUDColorRTC(theColor);
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
_cdv->SetViewNeedsFlush();
} }
- (uint32_t) hudColorRTC - (uint32_t) hudColorRTC
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
const uint32_t color32 = _cdv->GetHUDColorRTC(); const uint32_t color32 = _cdv->Get3DPresenter()->GetHUDColorRTC();
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
return color32; return color32;
@ -881,14 +899,16 @@
- (void) setHudColorInputPendingAndApplied:(uint32_t)theColor - (void) setHudColorInputPendingAndApplied:(uint32_t)theColor
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
_cdv->SetHUDColorInputPendingAndApplied(theColor); _cdv->Get3DPresenter()->SetHUDColorInputPendingAndApplied(theColor);
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
_cdv->SetViewNeedsFlush();
} }
- (uint32_t) hudColorInputPendingAndApplied - (uint32_t) hudColorInputPendingAndApplied
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
const uint32_t color32 = _cdv->GetHUDColorInputPendingAndApplied(); const uint32_t color32 = _cdv->Get3DPresenter()->GetHUDColorInputPendingAndApplied();
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
return color32; return color32;
@ -897,14 +917,16 @@
- (void) setHudColorInputAppliedOnly:(uint32_t)theColor - (void) setHudColorInputAppliedOnly:(uint32_t)theColor
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
_cdv->SetHUDColorInputAppliedOnly(theColor); _cdv->Get3DPresenter()->SetHUDColorInputAppliedOnly(theColor);
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
_cdv->SetViewNeedsFlush();
} }
- (uint32_t) hudColorInputAppliedOnly - (uint32_t) hudColorInputAppliedOnly
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
const uint32_t color32 = _cdv->GetHUDColorInputAppliedOnly(); const uint32_t color32 = _cdv->Get3DPresenter()->GetHUDColorInputAppliedOnly();
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
return color32; return color32;
@ -913,14 +935,16 @@
- (void) setHudColorInputPendingOnly:(uint32_t)theColor - (void) setHudColorInputPendingOnly:(uint32_t)theColor
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
_cdv->SetHUDColorInputPendingOnly(theColor); _cdv->Get3DPresenter()->SetHUDColorInputPendingOnly(theColor);
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
_cdv->SetViewNeedsFlush();
} }
- (uint32_t) hudColorInputPendingOnly - (uint32_t) hudColorInputPendingOnly
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
const uint32_t color32 = _cdv->GetHUDColorInputPendingOnly(); const uint32_t color32 = _cdv->Get3DPresenter()->GetHUDColorInputPendingOnly();
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
return color32; return color32;
@ -929,14 +953,16 @@
- (void) setDisplayMainVideoSource:(NSInteger)displaySourceID - (void) setDisplayMainVideoSource:(NSInteger)displaySourceID
{ {
OSSpinLockLock(&spinlockDisplayVideoSource); OSSpinLockLock(&spinlockDisplayVideoSource);
_cdv->SetDisplayVideoSource(NDSDisplayID_Main, (ClientDisplaySource)displaySourceID); _cdv->Get3DPresenter()->SetDisplayVideoSource(NDSDisplayID_Main, (ClientDisplaySource)displaySourceID);
OSSpinLockUnlock(&spinlockDisplayVideoSource); OSSpinLockUnlock(&spinlockDisplayVideoSource);
_cdv->SetViewNeedsFlush();
} }
- (NSInteger) displayMainVideoSource - (NSInteger) displayMainVideoSource
{ {
OSSpinLockLock(&spinlockDisplayVideoSource); OSSpinLockLock(&spinlockDisplayVideoSource);
const NSInteger displayVideoSource = _cdv->GetDisplayVideoSource(NDSDisplayID_Main); const NSInteger displayVideoSource = _cdv->Get3DPresenter()->GetDisplayVideoSource(NDSDisplayID_Main);
OSSpinLockUnlock(&spinlockDisplayVideoSource); OSSpinLockUnlock(&spinlockDisplayVideoSource);
return displayVideoSource; return displayVideoSource;
@ -945,14 +971,16 @@
- (void) setDisplayTouchVideoSource:(NSInteger)displaySourceID - (void) setDisplayTouchVideoSource:(NSInteger)displaySourceID
{ {
OSSpinLockLock(&spinlockDisplayVideoSource); OSSpinLockLock(&spinlockDisplayVideoSource);
_cdv->SetDisplayVideoSource(NDSDisplayID_Touch, (ClientDisplaySource)displaySourceID); _cdv->Get3DPresenter()->SetDisplayVideoSource(NDSDisplayID_Touch, (ClientDisplaySource)displaySourceID);
OSSpinLockUnlock(&spinlockDisplayVideoSource); OSSpinLockUnlock(&spinlockDisplayVideoSource);
_cdv->SetViewNeedsFlush();
} }
- (NSInteger) displayTouchVideoSource - (NSInteger) displayTouchVideoSource
{ {
OSSpinLockLock(&spinlockDisplayVideoSource); OSSpinLockLock(&spinlockDisplayVideoSource);
const NSInteger displayVideoSource = _cdv->GetDisplayVideoSource(NDSDisplayID_Touch); const NSInteger displayVideoSource = _cdv->Get3DPresenter()->GetDisplayVideoSource(NDSDisplayID_Touch);
OSSpinLockUnlock(&spinlockDisplayVideoSource); OSSpinLockUnlock(&spinlockDisplayVideoSource);
return displayVideoSource; return displayVideoSource;
@ -993,14 +1021,14 @@
- (void) setVideoFiltersPreferGPU:(BOOL)theState - (void) setVideoFiltersPreferGPU:(BOOL)theState
{ {
OSSpinLockLock(&spinlockVideoFiltersPreferGPU); OSSpinLockLock(&spinlockVideoFiltersPreferGPU);
_cdv->SetFiltersPreferGPU((theState) ? true : false); _cdv->Get3DPresenter()->SetFiltersPreferGPU((theState) ? true : false);
OSSpinLockUnlock(&spinlockVideoFiltersPreferGPU); OSSpinLockUnlock(&spinlockVideoFiltersPreferGPU);
} }
- (BOOL) videoFiltersPreferGPU - (BOOL) videoFiltersPreferGPU
{ {
OSSpinLockLock(&spinlockVideoFiltersPreferGPU); OSSpinLockLock(&spinlockVideoFiltersPreferGPU);
const BOOL theState = (_cdv->GetFiltersPreferGPU()) ? YES : NO; const BOOL theState = (_cdv->Get3DPresenter()->GetFiltersPreferGPU()) ? YES : NO;
OSSpinLockUnlock(&spinlockVideoFiltersPreferGPU); OSSpinLockUnlock(&spinlockVideoFiltersPreferGPU);
return theState; return theState;
@ -1009,14 +1037,14 @@
- (void) setSourceDeposterize:(BOOL)theState - (void) setSourceDeposterize:(BOOL)theState
{ {
OSSpinLockLock(&spinlockSourceDeposterize); OSSpinLockLock(&spinlockSourceDeposterize);
_cdv->SetSourceDeposterize((theState) ? true : false); _cdv->Get3DPresenter()->SetSourceDeposterize((theState) ? true : false);
OSSpinLockUnlock(&spinlockSourceDeposterize); OSSpinLockUnlock(&spinlockSourceDeposterize);
} }
- (BOOL) sourceDeposterize - (BOOL) sourceDeposterize
{ {
OSSpinLockLock(&spinlockSourceDeposterize); OSSpinLockLock(&spinlockSourceDeposterize);
const BOOL theState = (_cdv->GetSourceDeposterize()) ? YES : NO; const BOOL theState = (_cdv->Get3DPresenter()->GetSourceDeposterize()) ? YES : NO;
OSSpinLockUnlock(&spinlockSourceDeposterize); OSSpinLockUnlock(&spinlockSourceDeposterize);
return theState; return theState;
@ -1025,14 +1053,14 @@
- (void) setOutputFilter:(NSInteger)filterID - (void) setOutputFilter:(NSInteger)filterID
{ {
OSSpinLockLock(&spinlockOutputFilter); OSSpinLockLock(&spinlockOutputFilter);
_cdv->SetOutputFilter((OutputFilterTypeID)filterID); _cdv->Get3DPresenter()->SetOutputFilter((OutputFilterTypeID)filterID);
OSSpinLockUnlock(&spinlockOutputFilter); OSSpinLockUnlock(&spinlockOutputFilter);
} }
- (NSInteger) outputFilter - (NSInteger) outputFilter
{ {
OSSpinLockLock(&spinlockOutputFilter); OSSpinLockLock(&spinlockOutputFilter);
const NSInteger filterID = _cdv->GetOutputFilter(); const NSInteger filterID = _cdv->Get3DPresenter()->GetOutputFilter();
OSSpinLockUnlock(&spinlockOutputFilter); OSSpinLockUnlock(&spinlockOutputFilter);
return filterID; return filterID;
@ -1041,14 +1069,14 @@
- (void) setPixelScaler:(NSInteger)filterID - (void) setPixelScaler:(NSInteger)filterID
{ {
OSSpinLockLock(&spinlockPixelScaler); OSSpinLockLock(&spinlockPixelScaler);
_cdv->SetPixelScaler((VideoFilterTypeID)filterID); _cdv->Get3DPresenter()->SetPixelScaler((VideoFilterTypeID)filterID);
OSSpinLockUnlock(&spinlockPixelScaler); OSSpinLockUnlock(&spinlockPixelScaler);
} }
- (NSInteger) pixelScaler - (NSInteger) pixelScaler
{ {
OSSpinLockLock(&spinlockPixelScaler); OSSpinLockLock(&spinlockPixelScaler);
const NSInteger filterID = _cdv->GetPixelScaler(); const NSInteger filterID = _cdv->Get3DPresenter()->GetPixelScaler();
OSSpinLockUnlock(&spinlockPixelScaler); OSSpinLockUnlock(&spinlockPixelScaler);
return filterID; return filterID;
@ -1057,7 +1085,6 @@
- (void)handlePortMessage:(NSPortMessage *)portMessage - (void)handlePortMessage:(NSPortMessage *)portMessage
{ {
NSInteger message = (NSInteger)[portMessage msgid]; NSInteger message = (NSInteger)[portMessage msgid];
NSArray *messageComponents = [portMessage components];
switch (message) switch (message)
{ {
@ -1081,10 +1108,6 @@
[self handleCopyToPasteboard]; [self handleCopyToPasteboard];
break; break;
case MESSAGE_REQUEST_SCREENSHOT:
[self handleRequestScreenshot:[messageComponents objectAtIndex:0] fileTypeData:[messageComponents objectAtIndex:1]];
break;
default: default:
[super handlePortMessage:portMessage]; [super handlePortMessage:portMessage];
break; break;
@ -1095,52 +1118,53 @@
{ {
[super handleEmuFrameProcessed]; [super handleEmuFrameProcessed];
[self hudUpdate]; [self hudUpdate];
_cdv->HandleEmulatorFrameEndEvent(); _cdv->SetViewNeedsFlush();
} }
- (void) handleChangeViewProperties - (void) handleChangeViewProperties
{ {
OSSpinLockLock(&spinlockViewProperties); OSSpinLockLock(&spinlockViewProperties);
_cdv->CommitViewProperties(_intermediateViewProps); _cdv->Get3DPresenter()->CommitPresenterProperties(_intermediateViewProps);
OSSpinLockUnlock(&spinlockViewProperties); OSSpinLockUnlock(&spinlockViewProperties);
_cdv->SetupViewProperties(); _cdv->Get3DPresenter()->SetupPresenterProperties();
_cdv->SetViewNeedsFlush();
} }
- (void) handleReceiveGPUFrame - (void) handleReceiveGPUFrame
{ {
[super handleReceiveGPUFrame]; [super handleReceiveGPUFrame];
_cdv->LoadDisplays(); _cdv->Get3DPresenter()->LoadDisplays();
_cdv->ProcessDisplays(); _cdv->Get3DPresenter()->ProcessDisplays();
} }
- (void) handleReloadReprocessRedraw - (void) handleReloadReprocessRedraw
{ {
GPUClientFetchObject &fetchObjMutable = (GPUClientFetchObject &)_cdv->GetFetchObject(); GPUClientFetchObject &fetchObjMutable = (GPUClientFetchObject &)_cdv->Get3DPresenter()->GetFetchObject();
const u8 bufferIndex = fetchObjMutable.GetLastFetchIndex(); const u8 bufferIndex = fetchObjMutable.GetLastFetchIndex();
fetchObjMutable.FetchFromBufferIndex(bufferIndex); fetchObjMutable.FetchFromBufferIndex(bufferIndex);
_cdv->LoadDisplays(); _cdv->Get3DPresenter()->LoadDisplays();
_cdv->ProcessDisplays(); _cdv->Get3DPresenter()->ProcessDisplays();
[self handleEmuFrameProcessed]; [self handleEmuFrameProcessed];
} }
- (void) handleReprocessRedraw - (void) handleReprocessRedraw
{ {
_cdv->ProcessDisplays(); _cdv->Get3DPresenter()->ProcessDisplays();
_cdv->UpdateView(); _cdv->SetViewNeedsFlush();
} }
- (void) handleRedraw - (void) handleRedraw
{ {
_cdv->UpdateView(); _cdv->SetViewNeedsFlush();
} }
- (void) handleCopyToPasteboard - (void) handleCopyToPasteboard
{ {
NSImage *screenshot = [self copyImageFromView]; NSImage *screenshot = [self image];
if (screenshot == nil) if (screenshot == nil)
{ {
return; return;
@ -1151,28 +1175,10 @@
[pboard setData:[screenshot TIFFRepresentationUsingCompression:NSTIFFCompressionLZW factor:1.0f] forType:NSTIFFPboardType]; [pboard setData:[screenshot TIFFRepresentationUsingCompression:NSTIFFCompressionLZW factor:1.0f] forType:NSTIFFPboardType];
} }
- (void) handleRequestScreenshot:(NSData *)fileURLStringData fileTypeData:(NSData *)fileTypeData
{
NSString *fileURLString = [[NSString alloc] initWithData:fileURLStringData encoding:NSUTF8StringEncoding];
NSURL *fileURL = [NSURL URLWithString:fileURLString];
NSBitmapImageFileType fileType = *(NSBitmapImageFileType *)[fileTypeData bytes];
NSDictionary *userInfo = [[NSDictionary alloc] initWithObjectsAndKeys:
fileURL, @"fileURL",
[NSNumber numberWithInteger:(NSInteger)fileType], @"fileType",
[self image], @"screenshotImage",
nil];
[[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"org.desmume.DeSmuME.requestScreenshotDidFinish" object:self userInfo:userInfo];
[userInfo release];
[fileURLString release];
}
- (void) setScaleFactor:(float)theScaleFactor - (void) setScaleFactor:(float)theScaleFactor
{ {
OSSpinLockLock(&spinlockIsHUDVisible); OSSpinLockLock(&spinlockIsHUDVisible);
_cdv->SetScaleFactor(theScaleFactor); _cdv->Get3DPresenter()->SetScaleFactor(theScaleFactor);
OSSpinLockUnlock(&spinlockIsHUDVisible); OSSpinLockUnlock(&spinlockIsHUDVisible);
} }
@ -1184,13 +1190,13 @@
OSSpinLockUnlock(&spinlockReceivedFrameIndex); OSSpinLockUnlock(&spinlockReceivedFrameIndex);
OSSpinLockLock(&spinlockNDSFrameInfo); OSSpinLockLock(&spinlockNDSFrameInfo);
_cdv->SetHUDInfo(clientFrameInfo, _ndsFrameInfo); _cdv->Get3DPresenter()->SetHUDInfo(clientFrameInfo, _ndsFrameInfo);
OSSpinLockUnlock(&spinlockNDSFrameInfo); OSSpinLockUnlock(&spinlockNDSFrameInfo);
} }
- (NSImage *) copyImageFromView - (NSImage *) image
{ {
NSSize viewSize = NSMakeSize(_cdv->GetViewProperties().clientWidth, _cdv->GetViewProperties().clientHeight); NSSize viewSize = NSMakeSize(_cdv->Get3DPresenter()->GetPresenterProperties().clientWidth, _cdv->Get3DPresenter()->GetPresenterProperties().clientHeight);
NSUInteger w = viewSize.width; NSUInteger w = viewSize.width;
NSUInteger h = viewSize.height; NSUInteger h = viewSize.height;
@ -1218,7 +1224,7 @@
return newImage; return newImage;
} }
_cdv->CopyFrameToBuffer((uint32_t *)[newImageRep bitmapData]); _cdv->Get3DPresenter()->CopyFrameToBuffer((uint32_t *)[newImageRep bitmapData]);
// Attach the rendered frame to the NSImageRep // Attach the rendered frame to the NSImageRep
[newImage addRepresentation:newImageRep]; [newImage addRepresentation:newImageRep];
@ -1226,86 +1232,4 @@
return [newImage autorelease]; return [newImage autorelease];
} }
- (NSImage *) image
{
pthread_rwlock_rdlock(self.rwlockProducer);
NSSize displaySize = NSMakeSize((CGFloat)GPU->GetCustomFramebufferWidth(), (_cdv->GetMode() == ClientDisplayMode_Dual) ? (CGFloat)(GPU->GetCustomFramebufferHeight() * 2): (CGFloat)GPU->GetCustomFramebufferHeight());
pthread_rwlock_unlock(self.rwlockProducer);
NSImage *newImage = [[NSImage alloc] initWithSize:displaySize];
if (newImage == nil)
{
return newImage;
}
// Render the frame in an NSBitmapImageRep
NSBitmapImageRep *newImageRep = [self bitmapImageRep];
if (newImageRep == nil)
{
[newImage release];
newImage = nil;
return newImage;
}
// Attach the rendered frame to the NSImageRep
[newImage addRepresentation:newImageRep];
return [newImage autorelease];
}
- (NSBitmapImageRep *) bitmapImageRep
{
GPUClientFetchObject &fetchObjMutable = (GPUClientFetchObject &)_cdv->GetFetchObject();
NDSDisplayInfo &displayInfoMutable = (NDSDisplayInfo &)fetchObjMutable.GetFetchDisplayInfoForBufferIndex(fetchObjMutable.GetLastFetchIndex());
NSUInteger w = (NSUInteger)displayInfoMutable.customWidth;
NSUInteger h = (_cdv->GetMode() == ClientDisplayMode_Dual) ? (NSUInteger)(displayInfoMutable.customHeight * 2) : (NSUInteger)displayInfoMutable.customHeight;
NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
pixelsWide:w
pixelsHigh:h
bitsPerSample:8
samplesPerPixel:4
hasAlpha:YES
isPlanar:NO
colorSpaceName:NSCalibratedRGBColorSpace
bytesPerRow:w * 4
bitsPerPixel:32];
if (imageRep == nil)
{
return imageRep;
}
void *displayBuffer = displayInfoMutable.masterCustomBuffer;
uint32_t *bitmapData = (uint32_t *)[imageRep bitmapData];
pthread_rwlock_wrlock(self.rwlockProducer);
GPU->PostprocessDisplay(NDSDisplayID_Main, displayInfoMutable);
GPU->PostprocessDisplay(NDSDisplayID_Touch, displayInfoMutable);
GPU->ResolveDisplayToCustomFramebuffer(NDSDisplayID_Main, displayInfoMutable);
GPU->ResolveDisplayToCustomFramebuffer(NDSDisplayID_Touch, displayInfoMutable);
if (displayInfoMutable.pixelBytes == 2)
{
ColorspaceConvertBuffer555To8888Opaque<false, true>((u16 *)displayBuffer, bitmapData, (w * h));
}
else if (displayInfoMutable.pixelBytes == 4)
{
memcpy(bitmapData, displayBuffer, w * h * sizeof(uint32_t));
}
pthread_rwlock_unlock(self.rwlockProducer);
#ifdef MSB_FIRST
for (size_t i = 0; i < w * h; i++)
{
bitmapData[i] = LE_TO_LOCAL_32(bitmapData[i]);
}
#endif
return [imageRep autorelease];
}
@end @end

View File

@ -22,15 +22,17 @@
#import <QuartzCore/QuartzCore.h> #import <QuartzCore/QuartzCore.h>
#import "InputManager.h" #import "InputManager.h"
#import "../ClientDisplayView.h"
@class CocoaDSDisplayVideo; @class CocoaDSDisplayVideo;
@class MacClientSharedObject; @class MacClientSharedObject;
class ClientDisplay3DView; class MacDisplayLayeredView;
@protocol DisplayViewCALayer <NSObject> @protocol DisplayViewCALayer <NSObject>
@required @required
- (ClientDisplay3DView *) clientDisplay3DView;
@property (assign, nonatomic, getter=clientDisplayView, setter=setClientDisplayView:) MacDisplayLayeredView *_cdv;
@end @end
@ -39,7 +41,7 @@ class ClientDisplay3DView;
@required @required
@property (retain) InputManager *inputManager; @property (retain) InputManager *inputManager;
@property (retain) CocoaDSDisplayVideo *cdsVideoOutput; @property (retain) CocoaDSDisplayVideo *cdsVideoOutput;
@property (readonly, nonatomic) ClientDisplay3DView *clientDisplay3DView; @property (readonly, nonatomic) MacDisplayLayeredView *clientDisplayView;
@property (readonly) BOOL canUseShaderBasedFilters; @property (readonly) BOOL canUseShaderBasedFilters;
@property (assign, nonatomic) BOOL allowViewUpdates; @property (assign, nonatomic) BOOL allowViewUpdates;
@property (assign) BOOL isHUDVisible; @property (assign) BOOL isHUDVisible;
@ -68,34 +70,43 @@ class ClientDisplay3DView;
@property (assign) NSInteger pixelScaler; @property (assign) NSInteger pixelScaler;
- (void) setupLayer; - (void) setupLayer;
- (void) requestScreenshot:(NSURL *)fileURL fileType:(NSBitmapImageFileType)fileType;
@end @end
class DisplayViewCALayerInterface class MacDisplayPresenterInterface
{ {
private: protected:
NSView *_nsView;
CALayer<DisplayViewCALayer> *_frontendLayer;
bool _willRenderToCALayer;
MacClientSharedObject *_sharedData; MacClientSharedObject *_sharedData;
public: public:
DisplayViewCALayerInterface(); MacDisplayPresenterInterface();
MacDisplayPresenterInterface(MacClientSharedObject *sharedObject);
MacClientSharedObject* GetSharedData();
virtual void SetSharedData(MacClientSharedObject *sharedObject);
};
class MacDisplayLayeredView : public ClientDisplay3DView
{
private:
void __InstanceInit();
protected:
NSView *_nsView;
CALayer<DisplayViewCALayer> *_caLayer;
bool _willRenderToCALayer;
public:
MacDisplayLayeredView();
MacDisplayLayeredView(ClientDisplay3DPresenter *thePresenter);
NSView* GetNSView() const; NSView* GetNSView() const;
void SetNSView(NSView *theView); void SetNSView(NSView *theView);
CALayer<DisplayViewCALayer>* GetFrontendLayer() const; CALayer<DisplayViewCALayer>* GetCALayer() const;
void SetFrontendLayer(CALayer<DisplayViewCALayer> *layer);
void CALayerDisplay();
bool GetRenderToCALayer() const; bool GetRenderToCALayer() const;
void SetRenderToCALayer(const bool renderToLayer); void SetRenderToCALayer(const bool renderToLayer);
MacClientSharedObject* GetSharedData();
void SetSharedData(MacClientSharedObject *sharedObject);
}; };
#endif // _DISPLAYVIEWCALAYER_H #endif // _DISPLAYVIEWCALAYER_H

View File

@ -18,55 +18,66 @@
#import "DisplayViewCALayer.h" #import "DisplayViewCALayer.h"
#import "../cocoa_GPU.h" #import "../cocoa_GPU.h"
DisplayViewCALayerInterface::DisplayViewCALayerInterface() MacDisplayPresenterInterface::MacDisplayPresenterInterface()
{ {
_nsView = nil;
_frontendLayer = nil;
_sharedData = nil; _sharedData = nil;
_willRenderToCALayer = false;
} }
NSView* DisplayViewCALayerInterface::GetNSView() const MacDisplayPresenterInterface::MacDisplayPresenterInterface(MacClientSharedObject *sharedObject)
{ {
return this->_nsView; _sharedData = sharedObject;
} }
void DisplayViewCALayerInterface::SetNSView(NSView *theView) MacClientSharedObject* MacDisplayPresenterInterface::GetSharedData()
{
this->_nsView = theView;
}
CALayer<DisplayViewCALayer>* DisplayViewCALayerInterface::GetFrontendLayer() const
{
return this->_frontendLayer;
}
void DisplayViewCALayerInterface::SetFrontendLayer(CALayer<DisplayViewCALayer> *layer)
{
this->_frontendLayer = layer;
}
void DisplayViewCALayerInterface::CALayerDisplay()
{
[this->_frontendLayer setNeedsDisplay];
}
bool DisplayViewCALayerInterface::GetRenderToCALayer() const
{
return this->_willRenderToCALayer;
}
void DisplayViewCALayerInterface::SetRenderToCALayer(const bool renderToLayer)
{
this->_willRenderToCALayer = renderToLayer;
}
MacClientSharedObject* DisplayViewCALayerInterface::GetSharedData()
{ {
return this->_sharedData; return this->_sharedData;
} }
void DisplayViewCALayerInterface::SetSharedData(MacClientSharedObject *sharedObject) void MacDisplayPresenterInterface::SetSharedData(MacClientSharedObject *sharedObject)
{ {
this->_sharedData = sharedObject; this->_sharedData = sharedObject;
} }
#pragma mark -
MacDisplayLayeredView::MacDisplayLayeredView()
{
__InstanceInit();
}
MacDisplayLayeredView::MacDisplayLayeredView(ClientDisplay3DPresenter *thePresenter) : ClientDisplay3DView(thePresenter)
{
__InstanceInit();
}
void MacDisplayLayeredView::__InstanceInit()
{
_nsView = nil;
_caLayer = nil;
_willRenderToCALayer = false;
}
NSView* MacDisplayLayeredView::GetNSView() const
{
return this->_nsView;
}
void MacDisplayLayeredView::SetNSView(NSView *theView)
{
this->_nsView = theView;
}
CALayer<DisplayViewCALayer>* MacDisplayLayeredView::GetCALayer() const
{
return this->_caLayer;
}
bool MacDisplayLayeredView::GetRenderToCALayer() const
{
return this->_willRenderToCALayer;
}
void MacDisplayLayeredView::SetRenderToCALayer(const bool renderToLayer)
{
this->_willRenderToCALayer = renderToLayer;
}

View File

@ -42,7 +42,7 @@ class OGLVideoOutput;
{ {
InputManager *inputManager; InputManager *inputManager;
CocoaDSDisplayVideo *cdsVideoOutput; CocoaDSDisplayVideo *cdsVideoOutput;
CALayer *localLayer; CALayer<DisplayViewCALayer> *localLayer;
NSOpenGLContext *localOGLContext; NSOpenGLContext *localOGLContext;
} }
@ -59,8 +59,7 @@ class OGLVideoOutput;
{ {
NSObject *dummyObject; NSObject *dummyObject;
ClientDisplayViewProperties _localViewProps; ClientDisplayPresenterProperties _localViewProps;
NSView *saveScreenshotPanelAccessoryView;
NSView *outputVolumeControlView; NSView *outputVolumeControlView;
NSView *microphoneGainControlView; NSView *microphoneGainControlView;
NSMenuItem *outputVolumeMenuItem; NSMenuItem *outputVolumeMenuItem;
@ -73,8 +72,6 @@ class OGLVideoOutput;
NSScreen *assignedScreen; NSScreen *assignedScreen;
NSWindow *masterWindow; NSWindow *masterWindow;
NSInteger screenshotFileFormat;
NSSize _minDisplayViewSize; NSSize _minDisplayViewSize;
BOOL _isMinSizeNormal; BOOL _isMinSizeNormal;
NSUInteger _statusBarHeight; NSUInteger _statusBarHeight;
@ -89,7 +86,6 @@ class OGLVideoOutput;
@property (readonly) IBOutlet NSObject *dummyObject; @property (readonly) IBOutlet NSObject *dummyObject;
@property (readonly) IBOutlet NSView *saveScreenshotPanelAccessoryView;
@property (readonly) IBOutlet NSView *outputVolumeControlView; @property (readonly) IBOutlet NSView *outputVolumeControlView;
@property (readonly) IBOutlet NSView *microphoneGainControlView; @property (readonly) IBOutlet NSView *microphoneGainControlView;
@property (readonly) IBOutlet NSMenuItem *outputVolumeMenuItem; @property (readonly) IBOutlet NSMenuItem *outputVolumeMenuItem;
@ -109,13 +105,12 @@ class OGLVideoOutput;
@property (assign, nonatomic) double displayGap; @property (assign, nonatomic) double displayGap;
@property (assign, nonatomic) double displayScale; @property (assign, nonatomic) double displayScale;
@property (assign, nonatomic) double displayRotation; @property (assign, nonatomic) double displayRotation;
@property (assign) NSInteger screenshotFileFormat;
@property (assign) BOOL isMinSizeNormal; @property (assign) BOOL isMinSizeNormal;
@property (assign) BOOL isShowingStatusBar; @property (assign) BOOL isShowingStatusBar;
- (id)initWithWindowNibName:(NSString *)windowNibName emuControlDelegate:(EmuControllerDelegate *)theEmuController; - (id)initWithWindowNibName:(NSString *)windowNibName emuControlDelegate:(EmuControllerDelegate *)theEmuController;
- (ClientDisplayViewProperties &) localViewProperties; - (ClientDisplayPresenterProperties &) localViewProperties;
- (void) setVideoPropertiesWithoutUpdateUsingPreferGPU:(BOOL)preferGPU - (void) setVideoPropertiesWithoutUpdateUsingPreferGPU:(BOOL)preferGPU
sourceDeposterize:(BOOL)useDeposterize sourceDeposterize:(BOOL)useDeposterize
outputFilter:(NSInteger)outputFilterID outputFilter:(NSInteger)outputFilterID
@ -150,7 +145,6 @@ class OGLVideoOutput;
- (IBAction) reset:(id)sender; - (IBAction) reset:(id)sender;
- (IBAction) changeCoreSpeed:(id)sender; - (IBAction) changeCoreSpeed:(id)sender;
- (IBAction) openRom:(id)sender; - (IBAction) openRom:(id)sender;
- (IBAction) saveScreenshotAs:(id)sender;
// View Menu // View Menu
- (IBAction) changeScale:(id)sender; - (IBAction) changeScale:(id)sender;

View File

@ -52,7 +52,6 @@
@synthesize assignedScreen; @synthesize assignedScreen;
@synthesize masterWindow; @synthesize masterWindow;
@synthesize view; @synthesize view;
@synthesize saveScreenshotPanelAccessoryView;
@synthesize outputVolumeControlView; @synthesize outputVolumeControlView;
@synthesize microphoneGainControlView; @synthesize microphoneGainControlView;
@synthesize outputVolumeMenuItem; @synthesize outputVolumeMenuItem;
@ -67,7 +66,6 @@
@dynamic displayOrientation; @dynamic displayOrientation;
@dynamic displayOrder; @dynamic displayOrder;
@dynamic displayGap; @dynamic displayGap;
@synthesize screenshotFileFormat;
@dynamic isMinSizeNormal; @dynamic isMinSizeNormal;
@dynamic isShowingStatusBar; @dynamic isShowingStatusBar;
@ -92,7 +90,6 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
emuControl = [theEmuController retain]; emuControl = [theEmuController retain];
assignedScreen = nil; assignedScreen = nil;
masterWindow = nil; masterWindow = nil;
screenshotFileFormat = NSTIFFFileType;
// These need to be initialized first since there are dependencies on these. // These need to be initialized first since there are dependencies on these.
_localViewProps.normalWidth = GPU_FRAMEBUFFER_NATIVE_WIDTH; _localViewProps.normalWidth = GPU_FRAMEBUFFER_NATIVE_WIDTH;
@ -118,11 +115,6 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
_masterWindowFrame = NSMakeRect(0.0, 0.0, _localViewProps.clientWidth, _localViewProps.clientHeight + _localViewProps.gapDistance); _masterWindowFrame = NSMakeRect(0.0, 0.0, _localViewProps.clientWidth, _localViewProps.clientHeight + _localViewProps.gapDistance);
_masterStatusBarState = NO; _masterStatusBarState = NO;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(saveScreenshotAsFinish:)
name:@"org.desmume.DeSmuME.requestScreenshotDidFinish"
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(respondToScreenChange:) selector:@selector(respondToScreenChange:)
name:@"NSApplicationDidChangeScreenParametersNotification" name:@"NSApplicationDidChangeScreenParametersNotification"
@ -192,7 +184,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
if ([self isFullScreen]) if ([self isFullScreen])
{ {
[[[self view] cdsVideoOutput] commitViewProperties:_localViewProps]; [[[self view] cdsVideoOutput] commitPresenterProperties:_localViewProps];
} }
else else
{ {
@ -207,7 +199,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
// display view to update itself. // display view to update itself.
if (oldBounds.width == newBounds.width && oldBounds.height == newBounds.height) if (oldBounds.width == newBounds.width && oldBounds.height == newBounds.height)
{ {
[[[self view] cdsVideoOutput] commitViewProperties:_localViewProps]; [[[self view] cdsVideoOutput] commitPresenterProperties:_localViewProps];
} }
} }
} }
@ -223,7 +215,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
( ((_localViewProps.mode == ClientDisplayMode_Main) || (_localViewProps.mode == ClientDisplayMode_Touch)) && (displayModeID == ClientDisplayMode_Dual) ); ( ((_localViewProps.mode == ClientDisplayMode_Main) || (_localViewProps.mode == ClientDisplayMode_Touch)) && (displayModeID == ClientDisplayMode_Dual) );
_localViewProps.mode = (ClientDisplayMode)displayModeID; _localViewProps.mode = (ClientDisplayMode)displayModeID;
ClientDisplayView::CalculateNormalSize((ClientDisplayMode)displayModeID, (ClientDisplayLayout)[self displayOrientation], [self displayGap], _localViewProps.normalWidth, _localViewProps.normalHeight); ClientDisplayPresenter::CalculateNormalSize((ClientDisplayMode)displayModeID, (ClientDisplayLayout)[self displayOrientation], [self displayGap], _localViewProps.normalWidth, _localViewProps.normalHeight);
[self setIsMinSizeNormal:[self isMinSizeNormal]]; [self setIsMinSizeNormal:[self isMinSizeNormal]];
if (![self isFullScreen] && willModeChangeSize) if (![self isFullScreen] && willModeChangeSize)
@ -232,7 +224,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
} }
else else
{ {
[[[self view] cdsVideoOutput] commitViewProperties:_localViewProps]; [[[self view] cdsVideoOutput] commitPresenterProperties:_localViewProps];
} }
} }
@ -245,14 +237,14 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
{ {
_localViewProps.layout = (ClientDisplayLayout)theOrientation; _localViewProps.layout = (ClientDisplayLayout)theOrientation;
ClientDisplayView::CalculateNormalSize((ClientDisplayMode)[self displayMode], (ClientDisplayLayout)theOrientation, [self displayGap], _localViewProps.normalWidth, _localViewProps.normalHeight); ClientDisplayPresenter::CalculateNormalSize((ClientDisplayMode)[self displayMode], (ClientDisplayLayout)theOrientation, [self displayGap], _localViewProps.normalWidth, _localViewProps.normalHeight);
[self setIsMinSizeNormal:[self isMinSizeNormal]]; [self setIsMinSizeNormal:[self isMinSizeNormal]];
if ([self displayMode] == ClientDisplayMode_Dual) if ([self displayMode] == ClientDisplayMode_Dual)
{ {
if ([self isFullScreen]) if ([self isFullScreen])
{ {
[[[self view] cdsVideoOutput] commitViewProperties:_localViewProps]; [[[self view] cdsVideoOutput] commitPresenterProperties:_localViewProps];
} }
else else
{ {
@ -269,7 +261,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
- (void) setDisplayOrder:(NSInteger)theOrder - (void) setDisplayOrder:(NSInteger)theOrder
{ {
_localViewProps.order = (ClientDisplayOrder)theOrder; _localViewProps.order = (ClientDisplayOrder)theOrder;
[[[self view] cdsVideoOutput] commitViewProperties:_localViewProps]; [[[self view] cdsVideoOutput] commitPresenterProperties:_localViewProps];
} }
- (NSInteger) displayOrder - (NSInteger) displayOrder
@ -280,7 +272,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
- (void) setDisplayGap:(double)gapScalar - (void) setDisplayGap:(double)gapScalar
{ {
_localViewProps.gapScale = gapScalar; _localViewProps.gapScale = gapScalar;
ClientDisplayView::CalculateNormalSize((ClientDisplayMode)[self displayMode], (ClientDisplayLayout)[self displayOrientation], gapScalar, _localViewProps.normalWidth, _localViewProps.normalHeight); ClientDisplayPresenter::CalculateNormalSize((ClientDisplayMode)[self displayMode], (ClientDisplayLayout)[self displayOrientation], gapScalar, _localViewProps.normalWidth, _localViewProps.normalHeight);
[self setIsMinSizeNormal:[self isMinSizeNormal]]; [self setIsMinSizeNormal:[self isMinSizeNormal]];
if ([self displayMode] == ClientDisplayMode_Dual) if ([self displayMode] == ClientDisplayMode_Dual)
@ -296,7 +288,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
case ClientDisplayLayout_Hybrid_16_9: case ClientDisplayLayout_Hybrid_16_9:
case ClientDisplayLayout_Hybrid_16_10: case ClientDisplayLayout_Hybrid_16_10:
default: default:
[[[self view] cdsVideoOutput] commitViewProperties:_localViewProps]; [[[self view] cdsVideoOutput] commitPresenterProperties:_localViewProps];
break; break;
} }
} }
@ -306,7 +298,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
{ {
case ClientDisplayLayout_Hybrid_16_9: case ClientDisplayLayout_Hybrid_16_9:
case ClientDisplayLayout_Hybrid_16_10: case ClientDisplayLayout_Hybrid_16_10:
[[[self view] cdsVideoOutput] commitViewProperties:_localViewProps]; [[[self view] cdsVideoOutput] commitPresenterProperties:_localViewProps];
break; break;
case ClientDisplayLayout_Horizontal: case ClientDisplayLayout_Horizontal:
@ -341,7 +333,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
// Set the minimum content size, keeping the display rotation in mind. // Set the minimum content size, keeping the display rotation in mind.
double transformedMinWidth = _minDisplayViewSize.width; double transformedMinWidth = _minDisplayViewSize.width;
double transformedMinHeight = _minDisplayViewSize.height; double transformedMinHeight = _minDisplayViewSize.height;
ClientDisplayView::ConvertNormalToTransformedBounds(1.0, _localViewProps.rotation, transformedMinWidth, transformedMinHeight); ClientDisplayPresenter::ConvertNormalToTransformedBounds(1.0, _localViewProps.rotation, transformedMinWidth, transformedMinHeight);
[[self window] setContentMinSize:NSMakeSize(transformedMinWidth, transformedMinHeight + _statusBarHeight)]; [[self window] setContentMinSize:NSMakeSize(transformedMinWidth, transformedMinHeight + _statusBarHeight)];
} }
@ -393,7 +385,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
#pragma mark Class Methods #pragma mark Class Methods
- (ClientDisplayViewProperties &) localViewProperties - (ClientDisplayPresenterProperties &) localViewProperties
{ {
return _localViewProps; return _localViewProps;
} }
@ -429,7 +421,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
_localViewProps.gapDistance = DS_DISPLAY_UNSCALED_GAP * gapScale; _localViewProps.gapDistance = DS_DISPLAY_UNSCALED_GAP * gapScale;
_localViewProps.rotation = 360.0 - _localRotation; _localViewProps.rotation = 360.0 - _localRotation;
ClientDisplayView::CalculateNormalSize(mode, layout, gapScale, _localViewProps.normalWidth, _localViewProps.normalHeight); ClientDisplayPresenter::CalculateNormalSize(mode, layout, gapScale, _localViewProps.normalWidth, _localViewProps.normalHeight);
// Set the minimum content size. // Set the minimum content size.
_isMinSizeNormal = isMinSizeNormal; _isMinSizeNormal = isMinSizeNormal;
@ -444,7 +436,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
double transformedMinWidth = _minDisplayViewSize.width; double transformedMinWidth = _minDisplayViewSize.width;
double transformedMinHeight = _minDisplayViewSize.height; double transformedMinHeight = _minDisplayViewSize.height;
ClientDisplayView::ConvertNormalToTransformedBounds(1.0, _localViewProps.rotation, transformedMinWidth, transformedMinHeight); ClientDisplayPresenter::ConvertNormalToTransformedBounds(1.0, _localViewProps.rotation, transformedMinWidth, transformedMinHeight);
[[self window] setContentMinSize:NSMakeSize(transformedMinWidth, transformedMinHeight + _statusBarHeight)]; [[self window] setContentMinSize:NSMakeSize(transformedMinWidth, transformedMinHeight + _statusBarHeight)];
// Set the client size and resize the window. // Set the client size and resize the window.
@ -458,7 +450,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
// window size changed or not. // window size changed or not.
if (oldBounds.width == newBounds.width && oldBounds.height == newBounds.height) if (oldBounds.width == newBounds.width && oldBounds.height == newBounds.height)
{ {
[[[self view] cdsVideoOutput] commitViewProperties:_localViewProps]; [[[self view] cdsVideoOutput] commitPresenterProperties:_localViewProps];
} }
} }
@ -529,7 +521,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
// Get the maximum scalar size within drawBounds. // Get the maximum scalar size within drawBounds.
double checkWidth = _localViewProps.normalWidth; double checkWidth = _localViewProps.normalWidth;
double checkHeight = _localViewProps.normalHeight; double checkHeight = _localViewProps.normalHeight;
ClientDisplayView::ConvertNormalToTransformedBounds(1.0, _localViewProps.rotation, checkWidth, checkHeight); ClientDisplayPresenter::ConvertNormalToTransformedBounds(1.0, _localViewProps.rotation, checkWidth, checkHeight);
const double maxViewScaleInHostScreen = [self maxViewScaleInHostScreen:checkWidth height:checkHeight]; const double maxViewScaleInHostScreen = [self maxViewScaleInHostScreen:checkWidth height:checkHeight];
if (_localViewScale > maxViewScaleInHostScreen) if (_localViewScale > maxViewScaleInHostScreen)
@ -540,7 +532,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
// Get the new bounds for the window's content view based on the transformed draw bounds. // Get the new bounds for the window's content view based on the transformed draw bounds.
double transformedWidth = _localViewProps.normalWidth; double transformedWidth = _localViewProps.normalWidth;
double transformedHeight = _localViewProps.normalHeight; double transformedHeight = _localViewProps.normalHeight;
ClientDisplayView::ConvertNormalToTransformedBounds(_localViewScale, _localViewProps.rotation, transformedWidth, transformedHeight); ClientDisplayPresenter::ConvertNormalToTransformedBounds(_localViewScale, _localViewProps.rotation, transformedWidth, transformedHeight);
// Get the center of the content view in screen coordinates. // Get the center of the content view in screen coordinates.
const NSRect windowContentRect = [[masterWindow contentView] bounds]; const NSRect windowContentRect = [[masterWindow contentView] bounds];
@ -573,29 +565,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
const NSRect windowFrame = [[self window] frameRectForContentRect:NSMakeRect(0.0, 0.0, contentBoundsWidth, contentBoundsHeight + _statusBarHeight)]; const NSRect windowFrame = [[self window] frameRectForContentRect:NSMakeRect(0.0, 0.0, contentBoundsWidth, contentBoundsHeight + _statusBarHeight)];
const NSSize visibleScreenBounds = { (screenFrame.size.width - (windowFrame.size.width - contentBoundsWidth)), (screenFrame.size.height - (windowFrame.size.height - contentBoundsHeight)) }; const NSSize visibleScreenBounds = { (screenFrame.size.width - (windowFrame.size.width - contentBoundsWidth)), (screenFrame.size.height - (windowFrame.size.height - contentBoundsHeight)) };
return ClientDisplayView::GetMaxScalarWithinBounds(contentBoundsWidth, contentBoundsHeight, visibleScreenBounds.width, visibleScreenBounds.height); return ClientDisplayPresenter::GetMaxScalarWithinBounds(contentBoundsWidth, contentBoundsHeight, visibleScreenBounds.width, visibleScreenBounds.height);
}
- (void) saveScreenshotAsFinish:(NSNotification *)aNotification
{
NSURL *fileURL = (NSURL *)[[aNotification userInfo] valueForKey:@"fileURL"];
NSBitmapImageFileType fileType = (NSBitmapImageFileType)[(NSNumber *)[[aNotification userInfo] valueForKey:@"fileType"] integerValue];
NSImage *screenshotImage = (NSImage *)[[aNotification userInfo] valueForKey:@"screenshotImage"];
const BOOL fileSaved = [CocoaDSFile saveScreenshot:fileURL bitmapData:(NSBitmapImageRep *)[[screenshotImage representations] objectAtIndex:0] fileType:fileType];
if (!fileSaved)
{
NSAlert *theAlert = [[NSAlert alloc] init];
[theAlert setMessageText:NSSTRING_ALERT_SCREENSHOT_FAILED_TITLE];
[theAlert setInformativeText:NSSTRING_ALERT_SCREENSHOT_FAILED_MESSAGE];
[theAlert setAlertStyle:NSCriticalAlertStyle];
[theAlert runModal];
[theAlert release];
}
[emuControl restoreCoreState];
} }
- (void) enterFullScreen - (void) enterFullScreen
@ -681,7 +651,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
CGDirectDisplayID displayID = [idNumber unsignedIntValue]; CGDirectDisplayID displayID = [idNumber unsignedIntValue];
[[[self view] cdsVideoOutput] setCurrentDisplayID:displayID]; [[[self view] cdsVideoOutput] setCurrentDisplayID:displayID];
[[[self view] cdsVideoOutput] clientDisplayView]->UpdateView(); [[[self view] cdsVideoOutput] clientDisplay3DView]->SetViewNeedsFlush();
} }
- (void) respondToScreenChange:(NSNotification *)aNotification - (void) respondToScreenChange:(NSNotification *)aNotification
@ -797,7 +767,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
// Set the minimum content size, keeping the display rotation in mind. // Set the minimum content size, keeping the display rotation in mind.
double transformedMinWidth = _minDisplayViewSize.width; double transformedMinWidth = _minDisplayViewSize.width;
double transformedMinHeight = _minDisplayViewSize.height; double transformedMinHeight = _minDisplayViewSize.height;
ClientDisplayView::ConvertNormalToTransformedBounds(1.0, _localViewProps.rotation, transformedMinWidth, transformedMinHeight); ClientDisplayPresenter::ConvertNormalToTransformedBounds(1.0, _localViewProps.rotation, transformedMinWidth, transformedMinHeight);
transformedMinHeight += _statusBarHeight; transformedMinHeight += _statusBarHeight;
// Resize the window if it's smaller than the minimum content size. // Resize the window if it's smaller than the minimum content size.
@ -870,26 +840,6 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
[emuControl openRom:sender]; [emuControl openRom:sender];
} }
- (IBAction) saveScreenshotAs:(id)sender
{
[emuControl pauseCore];
NSSavePanel *panel = [NSSavePanel savePanel];
[panel setCanCreateDirectories:YES];
[panel setTitle:NSSTRING_TITLE_SAVE_SCREENSHOT_PANEL];
[panel setAccessoryView:saveScreenshotPanelAccessoryView];
const NSInteger buttonClicked = [panel runModal];
if(buttonClicked == NSOKButton)
{
[view requestScreenshot:[panel URL] fileType:(NSBitmapImageFileType)[self screenshotFileFormat]];
}
else
{
[emuControl restoreCoreState];
}
}
- (IBAction) changeScale:(id)sender - (IBAction) changeScale:(id)sender
{ {
[self setDisplayScale:(double)[CocoaDSUtil getIBActionSenderTag:sender] / 100.0]; [self setDisplayScale:(double)[CocoaDSUtil getIBActionSenderTag:sender] / 100.0];
@ -1324,11 +1274,12 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
// Set up the video output thread. // Set up the video output thread.
CocoaDSDisplayVideo *newDisplayOutput = [[[CocoaDSDisplayVideo alloc] init] autorelease]; CocoaDSDisplayVideo *newDisplayOutput = [[[CocoaDSDisplayVideo alloc] init] autorelease];
[newDisplayOutput setClientDisplayView:[newView clientDisplay3DView]]; ClientDisplay3DView *cdv = [newView clientDisplayView];
[newDisplayOutput setClientDisplay3DView:cdv];
ClientDisplayView *cdv = [newDisplayOutput clientDisplayView];
NSString *fontPath = [[NSBundle mainBundle] pathForResource:@"SourceSansPro-Bold" ofType:@"otf"]; NSString *fontPath = [[NSBundle mainBundle] pathForResource:@"SourceSansPro-Bold" ofType:@"otf"];
cdv->SetHUDFontPath([fontPath cStringUsingEncoding:NSUTF8StringEncoding]); cdv->Get3DPresenter()->SetHUDFontPath([fontPath cStringUsingEncoding:NSUTF8StringEncoding]);
if (scaleFactor != 1.0f) if (scaleFactor != 1.0f)
{ {
@ -1336,7 +1287,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
} }
else else
{ {
cdv->LoadHUDFont(); cdv->Get3DPresenter()->LoadHUDFont();
} }
[newView setCdsVideoOutput:newDisplayOutput]; [newView setCdsVideoOutput:newDisplayOutput];
@ -1390,9 +1341,9 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
// Find the maximum scalar we can use for the display view, bounded by the content Rect. // Find the maximum scalar we can use for the display view, bounded by the content Rect.
double checkWidth = _localViewProps.normalWidth; double checkWidth = _localViewProps.normalWidth;
double checkHeight = _localViewProps.normalHeight; double checkHeight = _localViewProps.normalHeight;
ClientDisplayView::ConvertNormalToTransformedBounds(1.0, _localViewProps.rotation, checkWidth, checkHeight); ClientDisplayPresenter::ConvertNormalToTransformedBounds(1.0, _localViewProps.rotation, checkWidth, checkHeight);
const NSSize contentBounds = NSMakeSize(contentRect.size.width, contentRect.size.height - _statusBarHeight); const NSSize contentBounds = NSMakeSize(contentRect.size.width, contentRect.size.height - _statusBarHeight);
_localViewScale = ClientDisplayView::GetMaxScalarWithinBounds(checkWidth, checkHeight, contentBounds.width, contentBounds.height); _localViewScale = ClientDisplayPresenter::GetMaxScalarWithinBounds(checkWidth, checkHeight, contentBounds.width, contentBounds.height);
// Make a new content Rect with our max scalar, and convert it back to a frame Rect. // Make a new content Rect with our max scalar, and convert it back to a frame Rect.
const NSRect finalContentRect = NSMakeRect(0.0f, 0.0f, checkWidth * _localViewScale, (checkHeight * _localViewScale) + _statusBarHeight); const NSRect finalContentRect = NSMakeRect(0.0f, 0.0f, checkWidth * _localViewScale, (checkHeight * _localViewScale) + _statusBarHeight);
@ -1445,9 +1396,9 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
// Find the maximum scalar we can use for the display view, bounded by the content Rect. // Find the maximum scalar we can use for the display view, bounded by the content Rect.
double checkWidth = _localViewProps.normalWidth; double checkWidth = _localViewProps.normalWidth;
double checkHeight = _localViewProps.normalHeight; double checkHeight = _localViewProps.normalHeight;
ClientDisplayView::ConvertNormalToTransformedBounds(1.0, _localViewProps.rotation, checkWidth, checkHeight); ClientDisplayPresenter::ConvertNormalToTransformedBounds(1.0, _localViewProps.rotation, checkWidth, checkHeight);
const NSSize contentBounds = NSMakeSize(contentRect.size.width, contentRect.size.height - _statusBarHeight); const NSSize contentBounds = NSMakeSize(contentRect.size.width, contentRect.size.height - _statusBarHeight);
const double maxS = ClientDisplayView::GetMaxScalarWithinBounds(checkWidth, checkHeight, contentBounds.width, contentBounds.height); const double maxS = ClientDisplayPresenter::GetMaxScalarWithinBounds(checkWidth, checkHeight, contentBounds.width, contentBounds.height);
// Make a new content Rect with our max scalar, and convert it back to a frame Rect. // Make a new content Rect with our max scalar, and convert it back to a frame Rect.
const NSRect finalContentRect = NSMakeRect(0.0f, 0.0f, checkWidth * maxS, (checkHeight * maxS) + _statusBarHeight); const NSRect finalContentRect = NSMakeRect(0.0f, 0.0f, checkWidth * maxS, (checkHeight * maxS) + _statusBarHeight);
@ -1640,7 +1591,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
@synthesize inputManager; @synthesize inputManager;
@synthesize cdsVideoOutput; @synthesize cdsVideoOutput;
@dynamic clientDisplay3DView; @dynamic clientDisplayView;
@dynamic canUseShaderBasedFilters; @dynamic canUseShaderBasedFilters;
@dynamic allowViewUpdates; @dynamic allowViewUpdates;
@dynamic isHUDVisible; @dynamic isHUDVisible;
@ -1725,8 +1676,8 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
{ {
BOOL isHandled = NO; BOOL isHandled = NO;
DisplayWindowController *windowController = (DisplayWindowController *)[[self window] delegate]; DisplayWindowController *windowController = (DisplayWindowController *)[[self window] delegate];
ClientDisplayView *cdv = [(id<DisplayViewCALayer>)localLayer clientDisplay3DView]; MacDisplayLayeredView *cdv = [localLayer clientDisplayView];
const ClientDisplayMode displayMode = cdv->GetMode(); const ClientDisplayMode displayMode = cdv->Get3DPresenter()->GetMode();
// Convert the clicked location from window coordinates, to view coordinates, // Convert the clicked location from window coordinates, to view coordinates,
// and finally to DS touchscreen coordinates. // and finally to DS touchscreen coordinates.
@ -1736,12 +1687,17 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
if (displayMode != ClientDisplayMode_Main) if (displayMode != ClientDisplayMode_Main)
{ {
const ClientDisplayPresenterProperties &props = cdv->Get3DPresenter()->GetPresenterProperties();
const double scaleFactor = cdv->Get3DPresenter()->GetScaleFactor();
const NSEventType eventType = [theEvent type]; const NSEventType eventType = [theEvent type];
const bool isInitialMouseDown = (eventType == NSLeftMouseDown) || (eventType == NSRightMouseDown) || (eventType == NSOtherMouseDown); const bool isInitialMouseDown = (eventType == NSLeftMouseDown) || (eventType == NSRightMouseDown) || (eventType == NSOtherMouseDown);
// Convert the clicked location from window coordinates, to view coordinates, and finally to NDS touchscreen coordinates. // Convert the clicked location from window coordinates, to view coordinates, and finally to NDS touchscreen coordinates.
const NSPoint clientLoc = [self convertPoint:[theEvent locationInWindow] fromView:nil]; const NSPoint clientLoc = [self convertPoint:[theEvent locationInWindow] fromView:nil];
cdv->GetNDSPoint((int)buttonNumber, isInitialMouseDown, clientLoc.x, clientLoc.y, x, y);
cdv->GetNDSPoint(props,
props.clientWidth * scaleFactor, props.clientHeight * scaleFactor,
(int)buttonNumber, isInitialMouseDown, clientLoc.x, clientLoc.y, x, y);
} }
MacInputDevicePropertiesEncoder *inputEncoder = [inputManager inputEncoder]; MacInputDevicePropertiesEncoder *inputEncoder = [inputManager inputEncoder];
@ -1759,9 +1715,9 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
#pragma mark CocoaDisplayView Protocol #pragma mark CocoaDisplayView Protocol
- (ClientDisplay3DView *) clientDisplay3DView - (MacDisplayLayeredView *) clientDisplayView
{ {
return [(id<DisplayViewCALayer>)localLayer clientDisplay3DView]; return [localLayer clientDisplayView];
} }
- (BOOL) canUseShaderBasedFilters - (BOOL) canUseShaderBasedFilters
@ -1771,12 +1727,12 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
- (BOOL) allowViewUpdates - (BOOL) allowViewUpdates
{ {
return ([self clientDisplay3DView]->GetAllowViewUpdates()) ? YES : NO; return ([self clientDisplayView]->GetAllowViewUpdates()) ? YES : NO;
} }
- (void) setAllowViewUpdates:(BOOL)allowUpdates - (void) setAllowViewUpdates:(BOOL)allowUpdates
{ {
[self clientDisplay3DView]->SetAllowViewUpdates((allowUpdates) ? true : false); [self clientDisplayView]->SetAllowViewUpdates((allowUpdates) ? true : false);
} }
- (void) setIsHUDVisible:(BOOL)theState - (void) setIsHUDVisible:(BOOL)theState
@ -2031,9 +1987,9 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
{ {
[macSharedData decrementViewsUsingDirectToCPUFiltering]; [macSharedData decrementViewsUsingDirectToCPUFiltering];
} }
[CocoaDSUtil messageSendOneWay:[[self cdsVideoOutput] receivePort] msgID:MESSAGE_RELOAD_REPROCESS_REDRAW];
} }
[CocoaDSUtil messageSendOneWay:[[self cdsVideoOutput] receivePort] msgID:MESSAGE_REPROCESS_AND_REDRAW];
} }
- (BOOL) sourceDeposterize - (BOOL) sourceDeposterize
@ -2073,9 +2029,9 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
{ {
[macSharedData decrementViewsUsingDirectToCPUFiltering]; [macSharedData decrementViewsUsingDirectToCPUFiltering];
} }
[CocoaDSUtil messageSendOneWay:[[self cdsVideoOutput] receivePort] msgID:MESSAGE_RELOAD_REPROCESS_REDRAW];
} }
[CocoaDSUtil messageSendOneWay:[[self cdsVideoOutput] receivePort] msgID:MESSAGE_REPROCESS_AND_REDRAW];
} }
- (NSInteger) pixelScaler - (NSInteger) pixelScaler
@ -2088,39 +2044,30 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
DisplayWindowController *windowController = (DisplayWindowController *)[[self window] delegate]; DisplayWindowController *windowController = (DisplayWindowController *)[[self window] delegate];
CocoaDSCore *cdsCore = (CocoaDSCore *)[[[windowController emuControl] cdsCoreController] content]; CocoaDSCore *cdsCore = (CocoaDSCore *)[[[windowController emuControl] cdsCoreController] content];
CocoaDSGPU *cdsGPU = [cdsCore cdsGPU]; CocoaDSGPU *cdsGPU = [cdsCore cdsGPU];
MacClientSharedObject *macSharedData = [cdsGPU sharedData];
BOOL isMetalLayer = NO; BOOL isMetalLayer = NO;
#ifdef ENABLE_APPLE_METAL #ifdef ENABLE_APPLE_METAL
MacClientSharedObject *macSharedData = [cdsGPU sharedData];
if ((macSharedData != nil) && [macSharedData isKindOfClass:[MetalDisplayViewSharedData class]]) if ((macSharedData != nil) && [macSharedData isKindOfClass:[MetalDisplayViewSharedData class]])
{ {
localLayer = [[DisplayViewMetalLayer alloc] init]; if ([(MetalDisplayViewSharedData *)macSharedData device] != nil)
[(DisplayViewMetalLayer *)localLayer setSharedData:(MetalDisplayViewSharedData *)macSharedData];
MacMetalDisplayView *macMTLCDV = (MacMetalDisplayView *)[(id<DisplayViewCALayer>)localLayer clientDisplay3DView];
macMTLCDV->SetFetchObject([cdsGPU fetchObject]);
macMTLCDV->Init();
macMTLCDV->SetNSView(self);
macMTLCDV->SetSharedData([cdsGPU sharedData]);
if ([(DisplayViewMetalLayer *)localLayer device] == nil)
{ {
[localLayer release]; MacMetalDisplayView *macMTLCDV = new MacMetalDisplayView(macSharedData);
localLayer = nil; macMTLCDV->SetNSView(self);
macMTLCDV->Init();
localLayer = macMTLCDV->GetCALayer();
isMetalLayer = YES;
} }
isMetalLayer = YES;
} }
else
#endif #endif
if (localLayer == nil)
{ {
localLayer = [[DisplayViewOpenGLLayer alloc] init]; MacOGLDisplayView *macOGLCDV = new MacOGLDisplayView(macSharedData);
MacOGLDisplayView *macOGLCDV = (MacOGLDisplayView *)[(id<DisplayViewCALayer>)localLayer clientDisplay3DView];
macOGLCDV->SetFetchObject([cdsGPU fetchObject]);
macOGLCDV->Init();
macOGLCDV->SetNSView(self); macOGLCDV->SetNSView(self);
macOGLCDV->SetSharedData([cdsGPU sharedData]); macOGLCDV->Init();
localLayer = macOGLCDV->GetCALayer();
// For macOS 10.8 Mountain Lion and later, we can use the CAOpenGLLayer directly. But for // For macOS 10.8 Mountain Lion and later, we can use the CAOpenGLLayer directly. But for
// earlier versions of macOS, using the CALayer directly will cause too many strange issues, // earlier versions of macOS, using the CALayer directly will cause too many strange issues,
@ -2137,13 +2084,13 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
[self setWantsBestResolutionOpenGLSurface:YES]; [self setWantsBestResolutionOpenGLSurface:YES];
} }
#endif #endif
localOGLContext = macOGLCDV->GetNSContext(); localOGLContext = ((MacOGLDisplayPresenter *)macOGLCDV->Get3DPresenter())->GetNSContext();
[localOGLContext retain]; [localOGLContext retain];
} }
} }
ClientDisplay3DView *cdv = [(id<DisplayViewCALayer>)localLayer clientDisplay3DView]; MacDisplayLayeredView *cdv = [localLayer clientDisplayView];
cdv->UpdateView(); cdv->Get3DPresenter()->UpdateLayout();
if (localOGLContext != nil) if (localOGLContext != nil)
{ {
@ -2174,19 +2121,6 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
} }
} }
- (void) requestScreenshot:(NSURL *)fileURL fileType:(NSBitmapImageFileType)fileType
{
NSString *fileURLString = [fileURL absoluteString];
NSData *fileURLStringData = [fileURLString dataUsingEncoding:NSUTF8StringEncoding];
NSData *bitmapImageFileTypeData = [[NSData alloc] initWithBytes:&fileType length:sizeof(NSBitmapImageFileType)];
NSArray *messageComponents = [[NSArray alloc] initWithObjects:fileURLStringData, bitmapImageFileTypeData, nil];
[CocoaDSUtil messageSendOneWayWithMessageComponents:[[self cdsVideoOutput] receivePort] msgID:MESSAGE_REQUEST_SCREENSHOT array:messageComponents];
[bitmapImageFileTypeData release];
[messageComponents release];
}
#pragma mark InputHIDManagerTarget Protocol #pragma mark InputHIDManagerTarget Protocol
- (BOOL) handleHIDQueue:(IOHIDQueueRef)hidQueue hidManager:(InputHIDManager *)hidManager - (BOOL) handleHIDQueue:(IOHIDQueueRef)hidQueue hidManager:(InputHIDManager *)hidManager
{ {
@ -2261,12 +2195,12 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
- (void)updateLayer - (void)updateLayer
{ {
[self clientDisplay3DView]->FlushView(); [self clientDisplayView]->FlushView();
} }
- (void)drawRect:(NSRect)dirtyRect - (void)drawRect:(NSRect)dirtyRect
{ {
[self clientDisplay3DView]->FlushView(); [self clientDisplayView]->FlushView();
} }
- (void)setFrame:(NSRect)rect - (void)setFrame:(NSRect)rect
@ -2277,7 +2211,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
if (rect.size.width != oldFrame.size.width || rect.size.height != oldFrame.size.height) if (rect.size.width != oldFrame.size.width || rect.size.height != oldFrame.size.height)
{ {
DisplayWindowController *windowController = (DisplayWindowController *)[[self window] delegate]; DisplayWindowController *windowController = (DisplayWindowController *)[[self window] delegate];
ClientDisplayViewProperties &props = [windowController localViewProperties]; ClientDisplayPresenterProperties &props = [windowController localViewProperties];
NSRect newViewportRect = rect; NSRect newViewportRect = rect;
#if defined(MAC_OS_X_VERSION_10_7) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7) #if defined(MAC_OS_X_VERSION_10_7) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7)
@ -2290,11 +2224,11 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
// Calculate the view scale for the given client size. // Calculate the view scale for the given client size.
double checkWidth = props.normalWidth; double checkWidth = props.normalWidth;
double checkHeight = props.normalHeight; double checkHeight = props.normalHeight;
ClientDisplayView::ConvertNormalToTransformedBounds(1.0, props.rotation, checkWidth, checkHeight); ClientDisplayPresenter::ConvertNormalToTransformedBounds(1.0, props.rotation, checkWidth, checkHeight);
props.clientWidth = newViewportRect.size.width; props.clientWidth = newViewportRect.size.width;
props.clientHeight = newViewportRect.size.height; props.clientHeight = newViewportRect.size.height;
props.viewScale = ClientDisplayView::GetMaxScalarWithinBounds(checkWidth, checkHeight, props.clientWidth, props.clientHeight); props.viewScale = ClientDisplayPresenter::GetMaxScalarWithinBounds(checkWidth, checkHeight, props.clientWidth, props.clientHeight);
if (localOGLContext != nil) if (localOGLContext != nil)
{ {
@ -2311,7 +2245,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
} }
#endif #endif
[[self cdsVideoOutput] commitViewProperties:props]; [[self cdsVideoOutput] commitPresenterProperties:props];
} }
} }

View File

@ -28,6 +28,8 @@
@class CocoaDSCheatManager; @class CocoaDSCheatManager;
@class CheatWindowDelegate; @class CheatWindowDelegate;
@class DisplayWindowController; @class DisplayWindowController;
@class RomInfoPanel;
@class MacScreenshotCaptureToolDelegate;
class AudioSampleBlockGenerator; class AudioSampleBlockGenerator;
@interface EmuControllerDelegate : NSObject <NSUserInterfaceValidations, CocoaDSControllerDelegate> @interface EmuControllerDelegate : NSObject <NSUserInterfaceValidations, CocoaDSControllerDelegate>
@ -41,15 +43,19 @@ class AudioSampleBlockGenerator;
CocoaDSCheatManager *dummyCheatList; CocoaDSCheatManager *dummyCheatList;
CheatWindowDelegate *cheatWindowDelegate; CheatWindowDelegate *cheatWindowDelegate;
MacScreenshotCaptureToolDelegate *screenshotCaptureToolDelegate;
NSObjectController *firmwarePanelController; NSObjectController *firmwarePanelController;
NSObjectController *romInfoPanelController; NSObjectController *romInfoPanelController;
NSObjectController *cdsCoreController; NSObjectController *cdsCoreController;
NSObjectController *cdsSoundController; NSObjectController *cdsSoundController;
NSObjectController *cheatWindowController; NSObjectController *cheatWindowController;
NSObjectController *slot2WindowController; NSObjectController *slot2WindowController;
NSArrayController *inputDeviceListController;
NSArrayController *cheatListController; NSArrayController *cheatListController;
NSArrayController *cheatDatabaseController; NSArrayController *cheatDatabaseController;
RomInfoPanel *romInfoPanel;
NSWindow *displayRotationPanel; NSWindow *displayRotationPanel;
NSWindow *displaySeparationPanel; NSWindow *displaySeparationPanel;
NSWindow *displayVideoSettingsPanel; NSWindow *displayVideoSettingsPanel;
@ -116,15 +122,19 @@ class AudioSampleBlockGenerator;
@property (retain) CocoaDSCheatManager *cdsCheats; @property (retain) CocoaDSCheatManager *cdsCheats;
@property (readonly) IBOutlet CheatWindowDelegate *cheatWindowDelegate; @property (readonly) IBOutlet CheatWindowDelegate *cheatWindowDelegate;
@property (readonly) IBOutlet MacScreenshotCaptureToolDelegate *screenshotCaptureToolDelegate;
@property (readonly) IBOutlet NSObjectController *firmwarePanelController; @property (readonly) IBOutlet NSObjectController *firmwarePanelController;
@property (readonly) IBOutlet NSObjectController *romInfoPanelController; @property (readonly) IBOutlet NSObjectController *romInfoPanelController;
@property (readonly) IBOutlet NSObjectController *cdsCoreController; @property (readonly) IBOutlet NSObjectController *cdsCoreController;
@property (readonly) IBOutlet NSObjectController *cdsSoundController; @property (readonly) IBOutlet NSObjectController *cdsSoundController;
@property (readonly) IBOutlet NSObjectController *cheatWindowController; @property (readonly) IBOutlet NSObjectController *cheatWindowController;
@property (readonly) IBOutlet NSObjectController *slot2WindowController; @property (readonly) IBOutlet NSObjectController *slot2WindowController;
@property (readonly) IBOutlet NSArrayController *inputDeviceListController;
@property (readonly) IBOutlet NSArrayController *cheatListController; @property (readonly) IBOutlet NSArrayController *cheatListController;
@property (readonly) IBOutlet NSArrayController *cheatDatabaseController; @property (readonly) IBOutlet NSArrayController *cheatDatabaseController;
@property (readonly) IBOutlet RomInfoPanel *romInfoPanel;
@property (readonly) IBOutlet NSWindow *displayRotationPanel; @property (readonly) IBOutlet NSWindow *displayRotationPanel;
@property (readonly) IBOutlet NSWindow *displaySeparationPanel; @property (readonly) IBOutlet NSWindow *displaySeparationPanel;
@property (readonly) IBOutlet NSWindow *displayVideoSettingsPanel; @property (readonly) IBOutlet NSWindow *displayVideoSettingsPanel;
@ -278,6 +288,10 @@ class AudioSampleBlockGenerator;
- (void) updateAllWindowTitles; - (void) updateAllWindowTitles;
- (void) updateDisplayPanelTitles; - (void) updateDisplayPanelTitles;
- (void) setupUserDefaults; - (void) appInit;
- (void) readUserDefaults;
- (void) writeUserDefaults;
- (void) restoreDisplayWindowStates;
- (void) saveDisplayWindowStates;
@end @end

View File

@ -20,6 +20,7 @@
#import "InputManager.h" #import "InputManager.h"
#import "cheatWindowDelegate.h" #import "cheatWindowDelegate.h"
#import "Slot2WindowDelegate.h" #import "Slot2WindowDelegate.h"
#import "MacScreenshotCaptureTool.h"
#import "cocoa_globals.h" #import "cocoa_globals.h"
#import "cocoa_cheat.h" #import "cocoa_cheat.h"
@ -42,6 +43,7 @@
@synthesize cdsCheats; @synthesize cdsCheats;
@synthesize cheatWindowDelegate; @synthesize cheatWindowDelegate;
@synthesize screenshotCaptureToolDelegate;
@synthesize firmwarePanelController; @synthesize firmwarePanelController;
@synthesize romInfoPanelController; @synthesize romInfoPanelController;
@synthesize cdsCoreController; @synthesize cdsCoreController;
@ -50,6 +52,9 @@
@synthesize cheatListController; @synthesize cheatListController;
@synthesize cheatDatabaseController; @synthesize cheatDatabaseController;
@synthesize slot2WindowController; @synthesize slot2WindowController;
@synthesize inputDeviceListController;
@synthesize romInfoPanel;
@synthesize displayRotationPanel; @synthesize displayRotationPanel;
@synthesize displaySeparationPanel; @synthesize displaySeparationPanel;
@ -1029,7 +1034,7 @@
if ([[windowController view] isHUDInputVisible]) if ([[windowController view] isHUDInputVisible])
{ {
[[windowController view] clientDisplay3DView]->UpdateView(); [[windowController view] clientDisplayView]->SetViewNeedsFlush();
} }
} }
} }
@ -1054,7 +1059,7 @@
if ([[windowController view] isHUDInputVisible]) if ([[windowController view] isHUDInputVisible])
{ {
[[windowController view] clientDisplay3DView]->UpdateView(); [[windowController view] clientDisplayView]->SetViewNeedsFlush();
} }
} }
} }
@ -1078,7 +1083,7 @@
if ([[windowController view] isHUDInputVisible]) if ([[windowController view] isHUDInputVisible])
{ {
[[windowController view] clientDisplay3DView]->UpdateView(); [[windowController view] clientDisplayView]->SetViewNeedsFlush();
} }
} }
} }
@ -1808,6 +1813,7 @@
// Update the UI to indicate that a ROM has indeed been loaded. // Update the UI to indicate that a ROM has indeed been loaded.
[self updateAllWindowTitles]; [self updateAllWindowTitles];
[screenshotCaptureToolDelegate setRomName:[currentRom internalName]];
for (DisplayWindowController *windowController in windowList) for (DisplayWindowController *windowController in windowList)
{ {
@ -1889,6 +1895,7 @@
// Update the UI to indicate that the ROM has finished unloading. // Update the UI to indicate that the ROM has finished unloading.
[self updateAllWindowTitles]; [self updateAllWindowTitles];
[screenshotCaptureToolDelegate setRomName:[currentRom internalName]];
[[cdsCore cdsGPU] clearWithColor:0x8000]; [[cdsCore cdsGPU] clearWithColor:0x8000];
for (DisplayWindowController *windowController in windowList) for (DisplayWindowController *windowController in windowList)
@ -2245,9 +2252,37 @@
} }
} }
- (void) setupUserDefaults - (void) appInit
{
[romInfoPanelController setContent:[CocoaDSRom romNotLoadedBindings]];
[cheatWindowController setContent:[cheatWindowDelegate bindings]];
// Update the SLOT-2 device list.
Slot2WindowDelegate *slot2WindowDelegate = (Slot2WindowDelegate *)[slot2WindowController content];
[slot2WindowDelegate update];
[slot2WindowDelegate setHidManager:[inputManager hidManager]];
[slot2WindowDelegate setAutoSelectedDeviceText:[[slot2WindowDelegate deviceManager] autoSelectedDeviceName]];
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
[screenshotCaptureToolDelegate setSharedData:[[cdsCore cdsGPU] sharedData]];
}
- (void) readUserDefaults
{ {
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content]; CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
Slot2WindowDelegate *slot2WindowDelegate = (Slot2WindowDelegate *)[slot2WindowController content];
// Set up the user's default input settings.
NSDictionary *userMappings = [[NSUserDefaults standardUserDefaults] dictionaryForKey:@"Input_ControllerMappings"];
if (userMappings == nil)
{
NSDictionary *defaultKeyMappingsDict = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"DefaultKeyMappings" ofType:@"plist"]];
NSArray *internalDefaultProfilesList = (NSArray *)[defaultKeyMappingsDict valueForKey:@"DefaultInputProfiles"];
userMappings = [(NSDictionary *)[internalDefaultProfilesList objectAtIndex:0] valueForKey:@"Mappings"];
}
[inputManager setMappingsWithMappings:userMappings];
[[inputManager hidManager] setDeviceListController:inputDeviceListController];
// Set the microphone settings per user preferences. // Set the microphone settings per user preferences.
[[cdsCore cdsController] setHardwareMicMute:[[NSUserDefaults standardUserDefaults] boolForKey:@"Microphone_HardwareMicMute"]]; [[cdsCore cdsController] setHardwareMicMute:[[NSUserDefaults standardUserDefaults] boolForKey:@"Microphone_HardwareMicMute"]];
@ -2279,6 +2314,227 @@
// Set the stylus options per user preferences. // Set the stylus options per user preferences.
[[cdsCore cdsController] setStylusPressure:[[NSUserDefaults standardUserDefaults] integerForKey:@"Emulation_StylusPressure"]]; [[cdsCore cdsController] setStylusPressure:[[NSUserDefaults standardUserDefaults] integerForKey:@"Emulation_StylusPressure"]];
// Set up the default SLOT-2 device.
[slot2WindowDelegate setupUserDefaults];
// Set up the ROM Info panel.
[romInfoPanel setupUserDefaults];
// Set up the screenshot capture tool defaults.
[screenshotCaptureToolDelegate readUserDefaults];
}
- (void) writeUserDefaults
{
[romInfoPanel writeDefaults];
[screenshotCaptureToolDelegate writeUserDefaults];
}
- (void) restoreDisplayWindowStates
{
NSArray *windowPropertiesList = [[NSUserDefaults standardUserDefaults] arrayForKey:@"General_DisplayWindowRestorableStates"];
const BOOL willRestoreWindows = [[NSUserDefaults standardUserDefaults] boolForKey:@"General_WillRestoreDisplayWindows"];
if (!willRestoreWindows || windowPropertiesList == nil || [windowPropertiesList count] < 1)
{
// If no windows were saved for restoring (the user probably closed all windows before
// app termination), then simply create a new display window per user defaults.
[self newDisplayWindow:self];
}
else
{
for (NSDictionary *windowProperties in windowPropertiesList)
{
DisplayWindowController *windowController = [[DisplayWindowController alloc] initWithWindowNibName:@"DisplayWindow" emuControlDelegate:self];
if (windowController == nil)
{
continue;
}
const NSInteger displayMode = ([windowProperties objectForKey:@"displayMode"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"displayMode"] integerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"DisplayView_Mode"];
const double displayScale = ([windowProperties objectForKey:@"displayScale"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"displayScale"] doubleValue] : ([[NSUserDefaults standardUserDefaults] doubleForKey:@"DisplayView_Size"] / 100.0);
const double displayRotation = ([windowProperties objectForKey:@"displayRotation"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"displayRotation"] doubleValue] : [[NSUserDefaults standardUserDefaults] doubleForKey:@"DisplayView_Rotation"];
const NSInteger displayOrientation = ([windowProperties objectForKey:@"displayOrientation"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"displayOrientation"] integerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"DisplayViewCombo_Orientation"];
const NSInteger displayOrder = ([windowProperties objectForKey:@"displayOrder"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"displayOrder"] integerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"DisplayViewCombo_Order"];
const double displayGap = ([windowProperties objectForKey:@"displayGap"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"displayGap"] doubleValue] : ([[NSUserDefaults standardUserDefaults] doubleForKey:@"DisplayViewCombo_Gap"] / 100.0);
const NSInteger displayMainSource = ([windowProperties objectForKey:@"displayMainVideoSource"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"displayMainVideoSource"] integerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"DisplayView_DisplayMainVideoSource"];
const NSInteger displayTouchSource = ([windowProperties objectForKey:@"displayTouchVideoSource"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"displayTouchVideoSource"] integerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"DisplayView_DisplayTouchVideoSource"];
const BOOL videoFiltersPreferGPU = ([windowProperties objectForKey:@"videoFiltersPreferGPU"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"videoFiltersPreferGPU"] boolValue] : [[NSUserDefaults standardUserDefaults] boolForKey:@"DisplayView_FiltersPreferGPU"];
const BOOL videoSourceDeposterize = ([windowProperties objectForKey:@"videoSourceDeposterize"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"videoSourceDeposterize"] boolValue] : [[NSUserDefaults standardUserDefaults] boolForKey:@"DisplayView_Deposterize"];
const NSInteger videoPixelScaler = ([windowProperties objectForKey:@"videoFilterType"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"videoFilterType"] integerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"DisplayView_VideoFilter"];
const NSInteger videoOutputFilter = ([windowProperties objectForKey:@"videoOutputFilter"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"videoOutputFilter"] integerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"DisplayView_OutputFilter"];
const BOOL hudEnable = ([windowProperties objectForKey:@"hudEnable"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudEnable"] boolValue] : [[NSUserDefaults standardUserDefaults] boolForKey:@"DisplayView_EnableHUD"];
const BOOL hudShowVideoFPS = ([windowProperties objectForKey:@"hudShowVideoFPS"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudShowVideoFPS"] boolValue] : [[NSUserDefaults standardUserDefaults] boolForKey:@"HUD_ShowVideoFPS"];
const BOOL hudShowRender3DFPS = ([windowProperties objectForKey:@"hudShowRender3DFPS"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudShowRender3DFPS"] boolValue] : [[NSUserDefaults standardUserDefaults] boolForKey:@"HUD_ShowRender3DFPS"];
const BOOL hudShowFrameIndex = ([windowProperties objectForKey:@"hudShowFrameIndex"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudShowFrameIndex"] boolValue] : [[NSUserDefaults standardUserDefaults] boolForKey:@"HUD_ShowFrameIndex"];
const BOOL hudShowLagFrameCount = ([windowProperties objectForKey:@"hudShowLagFrameCount"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudShowLagFrameCount"] boolValue] : [[NSUserDefaults standardUserDefaults] boolForKey:@"HUD_ShowLagFrameCount"];
const BOOL hudShowCPULoadAverage = ([windowProperties objectForKey:@"hudShowCPULoadAverage"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudShowCPULoadAverage"] boolValue] : [[NSUserDefaults standardUserDefaults] boolForKey:@"HUD_ShowCPULoadAverage"];
const BOOL hudShowRTC = ([windowProperties objectForKey:@"hudShowRTC"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudShowRTC"] boolValue] : [[NSUserDefaults standardUserDefaults] boolForKey:@"HUD_ShowRTC"];
const BOOL hudShowInput = ([windowProperties objectForKey:@"hudShowInput"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudShowInput"] boolValue] : [[NSUserDefaults standardUserDefaults] boolForKey:@"HUD_ShowInput"];
const NSUInteger hudColorVideoFPS = ([windowProperties objectForKey:@"hudColorVideoFPS"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudColorVideoFPS"] unsignedIntegerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"HUD_Color_VideoFPS"];
const NSUInteger hudColorRender3DFPS = ([windowProperties objectForKey:@"hudColorRender3DFPS"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudColorRender3DFPS"] unsignedIntegerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"HUD_Color_Render3DFPS"];
const NSUInteger hudColorFrameIndex = ([windowProperties objectForKey:@"hudColorFrameIndex"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudColorFrameIndex"] unsignedIntegerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"HUD_Color_FrameIndex"];
const NSUInteger hudColorLagFrameCount = ([windowProperties objectForKey:@"hudColorLagFrameCount"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudColorLagFrameCount"] unsignedIntegerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"HUD_Color_LagFrameCount"];
const NSUInteger hudColorCPULoadAverage = ([windowProperties objectForKey:@"hudColorCPULoadAverage"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudColorCPULoadAverage"] unsignedIntegerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"HUD_Color_CPULoadAverage"];
const NSUInteger hudColorRTC = ([windowProperties objectForKey:@"hudColorRTC"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudColorRTC"] unsignedIntegerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"HUD_Color_RTC"];
const NSUInteger hudColorInputPendingAndApplied = ([windowProperties objectForKey:@"hudColorInputPendingAndApplied"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudColorInputPendingAndApplied"] unsignedIntegerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"HUD_Color_Input_PendingAndApplied"];
const NSUInteger hudColorInputAppliedOnly = ([windowProperties objectForKey:@"hudColorInputAppliedOnly"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudColorInputAppliedOnly"] unsignedIntegerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"HUD_Color_Input_AppliedOnly"];
const NSUInteger hudColorInputPendingOnly = ([windowProperties objectForKey:@"hudColorInputPendingOnly"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudColorInputPendingOnly"] unsignedIntegerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"HUD_Color_Input_PendingOnly"];
const BOOL useVerticalSync = ([windowProperties objectForKey:@"useVerticalSync"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"useVerticalSync"] boolValue] : YES;
const BOOL isMinSizeNormal = ([windowProperties objectForKey:@"isMinSizeNormal"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"isMinSizeNormal"] boolValue] : YES;
const BOOL isShowingStatusBar = ([windowProperties objectForKey:@"isShowingStatusBar"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"isShowingStatusBar"] boolValue] : [[NSUserDefaults standardUserDefaults] boolForKey:@"DisplayView_ShowStatusBar"];
const BOOL isInFullScreenMode = ([windowProperties objectForKey:@"isInFullScreenMode"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"isInFullScreenMode"] boolValue] : NO;
const NSUInteger screenIndex = ([windowProperties objectForKey:@"screenIndex"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"screenIndex"] unsignedIntegerValue] : 0;
NSString *windowFrameStr = (NSString *)[windowProperties valueForKey:@"windowFrame"];
int frameX = 0;
int frameY = 0;
int frameWidth = 256;
int frameHeight = 192*2;
const char *frameCStr = [windowFrameStr cStringUsingEncoding:NSUTF8StringEncoding];
sscanf(frameCStr, "%i %i %i %i", &frameX, &frameY, &frameWidth, &frameHeight);
// Force the window to load now so that we can overwrite its internal defaults with the user's defaults.
[windowController window];
[windowController setDisplayMode:(ClientDisplayMode)displayMode
viewScale:displayScale
rotation:displayRotation
layout:(ClientDisplayLayout)displayOrientation
order:(ClientDisplayOrder)displayOrder
gapScale:displayGap
isMinSizeNormal:isMinSizeNormal
isShowingStatusBar:isShowingStatusBar];
[[windowController view] setDisplayMainVideoSource:displayMainSource];
[[windowController view] setDisplayTouchVideoSource:displayTouchSource];
[windowController setVideoPropertiesWithoutUpdateUsingPreferGPU:videoFiltersPreferGPU
sourceDeposterize:videoSourceDeposterize
outputFilter:videoOutputFilter
pixelScaler:videoPixelScaler];
[[windowController view] setUseVerticalSync:useVerticalSync];
[[windowController view] setIsHUDVisible:hudEnable];
[[windowController view] setIsHUDVideoFPSVisible:hudShowVideoFPS];
[[windowController view] setIsHUDRender3DFPSVisible:hudShowRender3DFPS];
[[windowController view] setIsHUDFrameIndexVisible:hudShowFrameIndex];
[[windowController view] setIsHUDLagFrameCountVisible:hudShowLagFrameCount];
[[windowController view] setIsHUDCPULoadAverageVisible:hudShowCPULoadAverage];
[[windowController view] setIsHUDRealTimeClockVisible:hudShowRTC];
[[windowController view] setIsHUDInputVisible:hudShowInput];
[[windowController view] setHudColorVideoFPS:[CocoaDSUtil NSColorFromRGBA8888:(uint32_t)hudColorVideoFPS]];
[[windowController view] setHudColorRender3DFPS:[CocoaDSUtil NSColorFromRGBA8888:(uint32_t)hudColorRender3DFPS]];
[[windowController view] setHudColorFrameIndex:[CocoaDSUtil NSColorFromRGBA8888:(uint32_t)hudColorFrameIndex]];
[[windowController view] setHudColorLagFrameCount:[CocoaDSUtil NSColorFromRGBA8888:(uint32_t)hudColorLagFrameCount]];
[[windowController view] setHudColorCPULoadAverage:[CocoaDSUtil NSColorFromRGBA8888:(uint32_t)hudColorCPULoadAverage]];
[[windowController view] setHudColorRTC:[CocoaDSUtil NSColorFromRGBA8888:(uint32_t)hudColorRTC]];
[[windowController view] setHudColorInputPendingAndApplied:[CocoaDSUtil NSColorFromRGBA8888:(uint32_t)hudColorInputPendingAndApplied]];
[[windowController view] setHudColorInputAppliedOnly:[CocoaDSUtil NSColorFromRGBA8888:(uint32_t)hudColorInputAppliedOnly]];
[[windowController view] setHudColorInputPendingOnly:[CocoaDSUtil NSColorFromRGBA8888:(uint32_t)hudColorInputPendingOnly]];
[[windowController masterWindow] setFrameOrigin:NSMakePoint(frameX, frameY)];
// If this is the last window in the list, make this window key and main.
// Otherwise, just order the window to the front so that the windows will
// stack in a deterministic order.
[[windowController view] setAllowViewUpdates:YES];
[[[windowController view] cdsVideoOutput] handleReloadReprocessRedraw];
if (windowProperties == [windowPropertiesList lastObject])
{
[[windowController window] makeKeyAndOrderFront:self];
[[windowController window] makeMainWindow];
}
else
{
[[windowController window] orderFront:self];
}
// 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,
// since the user's screen configuration could change in between app launches,
// and since we don't want a window to go full screen on the wrong screen.
if (isInFullScreenMode &&
([[NSScreen screens] indexOfObject:[[windowController window] screen]] == screenIndex))
{
[windowController toggleFullScreenDisplay:self];
}
}
}
}
- (void) saveDisplayWindowStates
{
const BOOL willRestoreWindows = [[NSUserDefaults standardUserDefaults] boolForKey:@"General_WillRestoreDisplayWindows"];
if (willRestoreWindows && [windowList count] > 0)
{
NSMutableArray *windowPropertiesList = [NSMutableArray arrayWithCapacity:[windowList count]];
for (DisplayWindowController *windowController in windowList)
{
const NSUInteger screenIndex = [[NSScreen screens] indexOfObject:[[windowController masterWindow] screen]];
const NSRect windowFrame = [windowController masterWindowFrame];
NSString *windowFrameStr = [NSString stringWithFormat:@"%i %i %i %i",
(int)windowFrame.origin.x, (int)windowFrame.origin.y, (int)windowFrame.size.width, (int)windowFrame.size.height];
NSDictionary *windowProperties = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInteger:[windowController displayMode]], @"displayMode",
[NSNumber numberWithDouble:[windowController masterWindowScale]], @"displayScale",
[NSNumber numberWithDouble:[windowController displayRotation]], @"displayRotation",
[NSNumber numberWithInteger:[[windowController view] displayMainVideoSource]], @"displayMainVideoSource",
[NSNumber numberWithInteger:[[windowController view] displayTouchVideoSource]], @"displayTouchVideoSource",
[NSNumber numberWithInteger:[windowController displayOrientation]], @"displayOrientation",
[NSNumber numberWithInteger:[windowController displayOrder]], @"displayOrder",
[NSNumber numberWithDouble:[windowController displayGap]], @"displayGap",
[NSNumber numberWithBool:[[windowController view] videoFiltersPreferGPU]], @"videoFiltersPreferGPU",
[NSNumber numberWithInteger:[[windowController view] pixelScaler]], @"videoFilterType",
[NSNumber numberWithInteger:[[windowController view] outputFilter]], @"videoOutputFilter",
[NSNumber numberWithBool:[[windowController view] sourceDeposterize]], @"videoSourceDeposterize",
[NSNumber numberWithBool:[[windowController view] useVerticalSync]], @"useVerticalSync",
[NSNumber numberWithBool:[[windowController view] isHUDVisible]], @"hudEnable",
[NSNumber numberWithBool:[[windowController view] isHUDVideoFPSVisible]], @"hudShowVideoFPS",
[NSNumber numberWithBool:[[windowController view] isHUDRender3DFPSVisible]], @"hudShowRender3DFPS",
[NSNumber numberWithBool:[[windowController view] isHUDFrameIndexVisible]], @"hudShowFrameIndex",
[NSNumber numberWithBool:[[windowController view] isHUDLagFrameCountVisible]], @"hudShowLagFrameCount",
[NSNumber numberWithBool:[[windowController view] isHUDCPULoadAverageVisible]], @"hudShowCPULoadAverage",
[NSNumber numberWithBool:[[windowController view] isHUDRealTimeClockVisible]], @"hudShowRTC",
[NSNumber numberWithBool:[[windowController view] isHUDInputVisible]], @"hudShowInput",
[NSNumber numberWithUnsignedInteger:[CocoaDSUtil RGBA8888FromNSColor:[[windowController view] hudColorVideoFPS]]], @"hudColorVideoFPS",
[NSNumber numberWithUnsignedInteger:[CocoaDSUtil RGBA8888FromNSColor:[[windowController view] hudColorRender3DFPS]]], @"hudColorRender3DFPS",
[NSNumber numberWithUnsignedInteger:[CocoaDSUtil RGBA8888FromNSColor:[[windowController view] hudColorFrameIndex]]], @"hudColorFrameIndex",
[NSNumber numberWithUnsignedInteger:[CocoaDSUtil RGBA8888FromNSColor:[[windowController view] hudColorLagFrameCount]]], @"hudColorLagFrameCount",
[NSNumber numberWithUnsignedInteger:[CocoaDSUtil RGBA8888FromNSColor:[[windowController view] hudColorCPULoadAverage]]], @"hudColorCPULoadAverage",
[NSNumber numberWithUnsignedInteger:[CocoaDSUtil RGBA8888FromNSColor:[[windowController view] hudColorRTC]]], @"hudColorRTC",
[NSNumber numberWithUnsignedInteger:[CocoaDSUtil RGBA8888FromNSColor:[[windowController view] hudColorInputPendingAndApplied]]], @"hudColorInputPendingAndApplied",
[NSNumber numberWithUnsignedInteger:[CocoaDSUtil RGBA8888FromNSColor:[[windowController view] hudColorInputAppliedOnly]]], @"hudColorInputAppliedOnly",
[NSNumber numberWithUnsignedInteger:[CocoaDSUtil RGBA8888FromNSColor:[[windowController view] hudColorInputPendingOnly]]], @"hudColorInputPendingOnly",
[NSNumber numberWithBool:[windowController isMinSizeNormal]], @"isMinSizeNormal",
[NSNumber numberWithBool:[windowController masterStatusBarState]], @"isShowingStatusBar",
[NSNumber numberWithBool:[windowController isFullScreen]], @"isInFullScreenMode",
[NSNumber numberWithUnsignedInteger:screenIndex], @"screenIndex",
windowFrameStr, @"windowFrame",
nil];
[windowPropertiesList addObject:windowProperties];
}
[[NSUserDefaults standardUserDefaults] setObject:windowPropertiesList forKey:@"General_DisplayWindowRestorableStates"];
}
else
{
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"General_DisplayWindowRestorableStates"];
}
} }
#pragma mark NSUserInterfaceValidations Protocol #pragma mark NSUserInterfaceValidations Protocol

View File

@ -31,6 +31,7 @@
#endif #endif
class MacMetalFetchObject; class MacMetalFetchObject;
class MacMetalDisplayPresenter;
class MacMetalDisplayView; class MacMetalDisplayView;
struct DisplayViewShaderProperties struct DisplayViewShaderProperties
@ -155,16 +156,17 @@ typedef DisplayViewShaderProperties DisplayViewShaderProperties;
@end @end
@interface DisplayViewMetalLayer : CAMetalLayer <DisplayViewCALayer> @interface MacMetalDisplayPresenterObject : NSObject
{ {
MacMetalDisplayView *_cdv; ClientDisplay3DPresenter *cdp;
MetalDisplayViewSharedData *sharedData; MetalDisplayViewSharedData *sharedData;
MTLRenderPassDescriptor *_outputRenderPassDesc; MTLRenderPassDescriptor *_outputRenderPassDesc;
MTLRenderPassColorAttachmentDescriptor *colorAttachment0Desc; MTLRenderPassColorAttachmentDescriptor *colorAttachment0Desc;
id<MTLComputePipelineState> pixelScalePipeline; id<MTLComputePipelineState> pixelScalePipeline;
id<MTLRenderPipelineState> displayOutputPipeline; id<MTLRenderPipelineState> outputRGBAPipeline;
id<MTLRenderPipelineState> displayRGBAOutputPipeline; id<MTLRenderPipelineState> outputDrawablePipeline;
MTLPixelFormat drawableFormat;
id<MTLBuffer> _cdvPropertiesBuffer; id<MTLBuffer> _cdvPropertiesBuffer;
id<MTLBuffer> _displayVtxPositionBuffer; id<MTLBuffer> _displayVtxPositionBuffer;
@ -202,11 +204,15 @@ typedef DisplayViewShaderProperties DisplayViewShaderProperties;
size_t _hudTouchLineLength; size_t _hudTouchLineLength;
} }
@property (readonly, nonatomic) ClientDisplay3DPresenter *cdp;
@property (assign, nonatomic) MetalDisplayViewSharedData *sharedData; @property (assign, nonatomic) MetalDisplayViewSharedData *sharedData;
@property (readonly, nonatomic) MTLRenderPassColorAttachmentDescriptor *colorAttachment0Desc; @property (readonly, nonatomic) MTLRenderPassColorAttachmentDescriptor *colorAttachment0Desc;
@property (readonly, nonatomic) pthread_mutex_t *mutexDisplayTextureUpdate;
@property (readonly, nonatomic) pthread_mutex_t *mutexBufferUpdate;
@property (retain) id<MTLComputePipelineState> pixelScalePipeline; @property (retain) id<MTLComputePipelineState> pixelScalePipeline;
@property (retain) id<MTLRenderPipelineState> displayOutputPipeline; @property (retain) id<MTLRenderPipelineState> outputRGBAPipeline;
@property (retain) id<MTLRenderPipelineState> displayRGBAOutputPipeline; @property (retain) id<MTLRenderPipelineState> outputDrawablePipeline;
@property (assign) MTLPixelFormat drawableFormat;
@property (retain) id<MTLBuffer> bufCPUFilterSrcMain; @property (retain) id<MTLBuffer> bufCPUFilterSrcMain;
@property (retain) id<MTLBuffer> bufCPUFilterSrcTouch; @property (retain) id<MTLBuffer> bufCPUFilterSrcTouch;
@property (retain) id<MTLBuffer> bufCPUFilterDstMain; @property (retain) id<MTLBuffer> bufCPUFilterDstMain;
@ -221,17 +227,31 @@ typedef DisplayViewShaderProperties DisplayViewShaderProperties;
@property (assign, nonatomic) VideoFilterTypeID pixelScaler; @property (assign, nonatomic) VideoFilterTypeID pixelScaler;
@property (assign, nonatomic) OutputFilterTypeID outputFilter; @property (assign, nonatomic) OutputFilterTypeID outputFilter;
- (id) initWithDisplayPresenter:(MacMetalDisplayPresenter *)thePresenter;
- (id<MTLCommandBuffer>) newCommandBuffer; - (id<MTLCommandBuffer>) newCommandBuffer;
- (void) setupLayer; - (void) setup;
- (void) resizeCPUPixelScalerUsingFilterID:(const VideoFilterTypeID)filterID; - (void) resizeCPUPixelScalerUsingFilterID:(const VideoFilterTypeID)filterID;
- (void) copyHUDFontUsingFace:(const FT_Face &)fontFace size:(const size_t)glyphSize tileSize:(const size_t)glyphTileSize info:(GlyphInfo *)glyphInfo; - (void) copyHUDFontUsingFace:(const FT_Face &)fontFace size:(const size_t)glyphSize tileSize:(const size_t)glyphTileSize info:(GlyphInfo *)glyphInfo;
- (void) processDisplays; - (void) processDisplays;
- (void) updateRenderBuffers; - (void) updateRenderBuffers;
- (void) renderForCommandBuffer:(id<MTLCommandBuffer>)cb - (void) renderForCommandBuffer:(id<MTLCommandBuffer>)cb
displayPipelineState:(id<MTLRenderPipelineState>)displayPipelineState outputPipelineState:(id<MTLRenderPipelineState>)outputPipelineState
hudPipelineState:(id<MTLRenderPipelineState>)hudPipelineState; hudPipelineState:(id<MTLRenderPipelineState>)hudPipelineState;
- (void) renderAndDownloadToBuffer:(uint32_t *)dstBuffer; - (void) renderToBuffer:(uint32_t *)dstBuffer;
- (void) renderAndFlushDrawable;
@end
@interface DisplayViewMetalLayer : CAMetalLayer<DisplayViewCALayer>
{
MacDisplayLayeredView *_cdv;
MacMetalDisplayPresenterObject *presenterObject;
}
@property (readonly, nonatomic) MacMetalDisplayPresenterObject *presenterObject;
- (id) initWithDisplayPresenterObject:(MacMetalDisplayPresenterObject *)thePresenterObject;
- (void) setupLayer;
- (void) renderToDrawable;
@end @end
@ -260,11 +280,14 @@ public:
#pragma mark - #pragma mark -
class MacMetalDisplayView : public ClientDisplay3DView, public DisplayViewCALayerInterface class MacMetalDisplayPresenter : public ClientDisplay3DPresenter, public MacDisplayPresenterInterface
{ {
private:
void __InstanceInit(MacClientSharedObject *sharedObject);
protected: protected:
pthread_mutex_t *_mutexProcessPtr; MacMetalDisplayPresenterObject *_presenterObject;
OSSpinLock _spinlockViewNeedsFlush; pthread_mutex_t _mutexProcessPtr;
virtual void _UpdateNormalSize(); virtual void _UpdateNormalSize();
virtual void _UpdateOrder(); virtual void _UpdateOrder();
@ -273,17 +296,17 @@ protected:
virtual void _UpdateViewScale(); virtual void _UpdateViewScale();
virtual void _LoadNativeDisplayByID(const NDSDisplayID displayID); virtual void _LoadNativeDisplayByID(const NDSDisplayID displayID);
virtual void _ResizeCPUPixelScaler(const VideoFilterTypeID filterID); virtual void _ResizeCPUPixelScaler(const VideoFilterTypeID filterID);
public:
MacMetalDisplayView();
virtual ~MacMetalDisplayView();
pthread_mutex_t* GetMutexProcessPtr() const; public:
MacMetalDisplayPresenter();
MacMetalDisplayPresenter(MacClientSharedObject *sharedObject);
virtual ~MacMetalDisplayPresenter();
MacMetalDisplayPresenterObject* GetPresenterObject() const;
pthread_mutex_t* GetMutexProcessPtr();
virtual void Init(); virtual void Init();
virtual bool GetViewNeedsFlush(); virtual void SetSharedData(MacClientSharedObject *sharedObject);
virtual void SetAllowViewFlushes(bool allowFlushes);
virtual void CopyHUDFont(const FT_Face &fontFace, const size_t glyphSize, const size_t glyphTileSize, GlyphInfo *glyphInfo); virtual void CopyHUDFont(const FT_Face &fontFace, const size_t glyphSize, const size_t glyphTileSize, GlyphInfo *glyphInfo);
// NDS screen filters // NDS screen filters
@ -293,12 +316,35 @@ public:
// Client view interface // Client view interface
virtual void ProcessDisplays(); virtual void ProcessDisplays();
virtual void UpdateView(); virtual void UpdateLayout();
virtual void FlushView();
virtual void CopyFrameToBuffer(uint32_t *dstBuffer); virtual void CopyFrameToBuffer(uint32_t *dstBuffer);
}; };
class MacMetalDisplayView : public MacDisplayLayeredView
{
private:
void __InstanceInit(MacClientSharedObject *sharedObject);
protected:
OSSpinLock _spinlockViewNeedsFlush;
public:
MacMetalDisplayView();
MacMetalDisplayView(MacClientSharedObject *sharedObject);
virtual ~MacMetalDisplayView();
virtual void Init();
virtual bool GetViewNeedsFlush();
virtual void SetViewNeedsFlush();
virtual void SetAllowViewFlushes(bool allowFlushes);
// Client view interface
virtual void FlushView();
};
#pragma mark - #pragma mark -
void SetupHQnxLUTs_Metal(id<MTLDevice> &device, id<MTLTexture> &texLQ2xLUT, id<MTLTexture> &texHQ2xLUT, id<MTLTexture> &texHQ3xLUT, id<MTLTexture> &texHQ4xLUT); void SetupHQnxLUTs_Metal(id<MTLDevice> &device, id<MTLTexture> &texLQ2xLUT, id<MTLTexture> &texHQ2xLUT, id<MTLTexture> &texHQ3xLUT, id<MTLTexture> &texHQ4xLUT);
void DeleteHQnxLUTs_Metal(id<MTLTexture> &texLQ2xLUT, id<MTLTexture> &texHQ2xLUT, id<MTLTexture> &texHQ3xLUT, id<MTLTexture> &texHQ4xLUT); void DeleteHQnxLUTs_Metal(id<MTLTexture> &texLQ2xLUT, id<MTLTexture> &texHQ2xLUT, id<MTLTexture> &texHQ3xLUT, id<MTLTexture> &texHQ4xLUT);

View File

@ -39,8 +39,9 @@ class MacOGLDisplayView;
@interface DisplayViewOpenGLLayer : CAOpenGLLayer <DisplayViewCALayer> @interface DisplayViewOpenGLLayer : CAOpenGLLayer <DisplayViewCALayer>
{ {
MacOGLDisplayView *_cdv; MacDisplayLayeredView *_cdv;
} }
@end @end
class MacOGLClientFetchObject : public OGLClientFetchObject class MacOGLClientFetchObject : public OGLClientFetchObject
@ -61,19 +62,21 @@ public:
virtual void FetchFromBufferIndex(const u8 index); virtual void FetchFromBufferIndex(const u8 index);
}; };
class MacOGLDisplayView : public OGLVideoOutput, public DisplayViewCALayerInterface class MacOGLDisplayPresenter : public OGLVideoOutput, public MacDisplayPresenterInterface
{ {
private:
void __InstanceInit(MacClientSharedObject *sharedObject);
protected: protected:
NSOpenGLContext *_nsContext; NSOpenGLContext *_nsContext;
NSOpenGLPixelFormat *_nsPixelFormat; NSOpenGLPixelFormat *_nsPixelFormat;
CGLContextObj _context; CGLContextObj _context;
CGLPixelFormatObj _pixelFormat; CGLPixelFormatObj _pixelFormat;
OSSpinLock _spinlockViewNeedsFlush;
public: public:
void operator delete(void *ptr); void operator delete(void *ptr);
MacOGLDisplayView(); MacOGLDisplayPresenter();
MacOGLDisplayPresenter(MacClientSharedObject *sharedObject);
virtual void Init(); virtual void Init();
@ -82,12 +85,7 @@ public:
CGLPixelFormatObj GetPixelFormat() const; CGLPixelFormatObj GetPixelFormat() const;
CGLContextObj GetContext() const; CGLContextObj GetContext() const;
virtual bool GetViewNeedsFlush();
virtual void SetAllowViewFlushes(bool allowFlushes);
virtual void LoadHUDFont(); virtual void LoadHUDFont();
virtual void SetUseVerticalSync(const bool useVerticalSync);
virtual void SetScaleFactor(const double scaleFactor); virtual void SetScaleFactor(const double scaleFactor);
// NDS screen filters // NDS screen filters
@ -98,12 +96,34 @@ public:
// Client view interface // Client view interface
virtual void LoadDisplays(); virtual void LoadDisplays();
virtual void ProcessDisplays(); virtual void ProcessDisplays();
virtual void UpdateView();
virtual void FlushView();
virtual void CopyFrameToBuffer(uint32_t *dstBuffer); virtual void CopyFrameToBuffer(uint32_t *dstBuffer);
virtual void FinishFrameAtIndex(const uint8_t bufferIndex); virtual void FinishFrameAtIndex(const uint8_t bufferIndex);
virtual void LockDisplayTextures(); virtual void LockDisplayTextures();
virtual void UnlockDisplayTextures(); virtual void UnlockDisplayTextures();
}; };
class MacOGLDisplayView : public MacDisplayLayeredView
{
private:
void __InstanceInit(MacClientSharedObject *sharedObject);
protected:
OSSpinLock _spinlockViewNeedsFlush;
public:
MacOGLDisplayView();
MacOGLDisplayView(MacClientSharedObject *sharedObject);
virtual ~MacOGLDisplayView();
virtual bool GetViewNeedsFlush();
virtual void SetViewNeedsFlush();
virtual void SetAllowViewFlushes(bool allowFlushes);
virtual void SetUseVerticalSync(const bool useVerticalSync);
// Client view interface
virtual void FlushView();
};
#endif // _MAC_OGLDISPLAYOUTPUT_H_ #endif // _MAC_OGLDISPLAYOUTPUT_H_

View File

@ -21,6 +21,8 @@
@implementation DisplayViewOpenGLLayer @implementation DisplayViewOpenGLLayer
@synthesize _cdv;
- (id)init - (id)init
{ {
self = [super init]; self = [super init];
@ -29,8 +31,7 @@
return nil; return nil;
} }
_cdv = new MacOGLDisplayView(); _cdv = NULL;
_cdv->SetFrontendLayer(self);
[self setBounds:CGRectMake(0.0f, 0.0f, (float)GPU_FRAMEBUFFER_NATIVE_WIDTH, (float)GPU_FRAMEBUFFER_NATIVE_HEIGHT)]; [self setBounds:CGRectMake(0.0f, 0.0f, (float)GPU_FRAMEBUFFER_NATIVE_WIDTH, (float)GPU_FRAMEBUFFER_NATIVE_HEIGHT)];
[self setAsynchronous:NO]; [self setAsynchronous:NO];
@ -39,21 +40,9 @@
return self; return self;
} }
- (void)dealloc
{
delete _cdv;
[super dealloc];
}
- (OGLContextInfo *) contextInfo - (OGLContextInfo *) contextInfo
{ {
return _cdv->GetContextInfo(); return ((MacOGLDisplayPresenter *)(_cdv->Get3DPresenter()))->GetContextInfo();
}
- (ClientDisplay3DView *)clientDisplay3DView
{
return _cdv;
} }
- (BOOL)isAsynchronous - (BOOL)isAsynchronous
@ -63,19 +52,19 @@
- (CGLPixelFormatObj)copyCGLPixelFormatForDisplayMask:(uint32_t)mask - (CGLPixelFormatObj)copyCGLPixelFormatForDisplayMask:(uint32_t)mask
{ {
return _cdv->GetPixelFormat(); return ((MacOGLDisplayPresenter *)(_cdv->Get3DPresenter()))->GetPixelFormat();
} }
- (CGLContextObj)copyCGLContextForPixelFormat:(CGLPixelFormatObj)pixelFormat - (CGLContextObj)copyCGLContextForPixelFormat:(CGLPixelFormatObj)pixelFormat
{ {
return _cdv->GetContext(); return ((MacOGLDisplayPresenter *)(_cdv->Get3DPresenter()))->GetContext();
} }
- (void)drawInCGLContext:(CGLContextObj)glContext pixelFormat:(CGLPixelFormatObj)pixelFormat forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp - (void)drawInCGLContext:(CGLContextObj)glContext pixelFormat:(CGLPixelFormatObj)pixelFormat forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp
{ {
CGLSetCurrentContext(glContext); CGLSetCurrentContext(glContext);
CGLLockContext(glContext); CGLLockContext(glContext);
_cdv->RenderFrameOGL(false); ((MacOGLDisplayPresenter *)(_cdv->Get3DPresenter()))->RenderFrameOGL(false);
[super drawInCGLContext:glContext pixelFormat:pixelFormat forLayerTime:timeInterval displayTime:timeStamp]; [super drawInCGLContext:glContext pixelFormat:pixelFormat forLayerTime:timeInterval displayTime:timeStamp];
CGLUnlockContext(glContext); CGLUnlockContext(glContext);
} }
@ -214,18 +203,18 @@ void MacOGLClientFetchObject::FetchFromBufferIndex(const u8 index)
#pragma mark - #pragma mark -
void MacOGLDisplayView::operator delete(void *ptr) void MacOGLDisplayPresenter::operator delete(void *ptr)
{ {
CGLContextObj context = ((MacOGLDisplayView *)ptr)->GetContext(); CGLContextObj context = ((MacOGLDisplayPresenter *)ptr)->GetContext();
if (context != NULL) if (context != NULL)
{ {
OGLContextInfo *contextInfo = ((MacOGLDisplayView *)ptr)->GetContextInfo(); OGLContextInfo *contextInfo = ((MacOGLDisplayPresenter *)ptr)->GetContextInfo();
CGLContextObj prevContext = CGLGetCurrentContext(); CGLContextObj prevContext = CGLGetCurrentContext();
CGLSetCurrentContext(context); CGLSetCurrentContext(context);
[((MacOGLDisplayView *)ptr)->GetNSContext() release]; [((MacOGLDisplayPresenter *)ptr)->GetNSContext() release];
[((MacOGLDisplayView *)ptr)->GetNSPixelFormat() release]; [((MacOGLDisplayPresenter *)ptr)->GetNSPixelFormat() release];
delete contextInfo; delete contextInfo;
::operator delete(ptr); ::operator delete(ptr);
@ -233,7 +222,17 @@ void MacOGLDisplayView::operator delete(void *ptr)
} }
} }
MacOGLDisplayView::MacOGLDisplayView() MacOGLDisplayPresenter::MacOGLDisplayPresenter()
{
__InstanceInit(nil);
}
MacOGLDisplayPresenter::MacOGLDisplayPresenter(MacClientSharedObject *sharedObject) : MacDisplayPresenterInterface(sharedObject)
{
__InstanceInit(sharedObject);
}
void MacOGLDisplayPresenter::__InstanceInit(MacClientSharedObject *sharedObject)
{ {
// Initialize the OpenGL context. // Initialize the OpenGL context.
// //
@ -241,7 +240,6 @@ MacOGLDisplayView::MacOGLDisplayView()
// [NSOpenGLContext CGLContextObj] is available on macOS 10.5 Leopard, but // [NSOpenGLContext CGLContextObj] is available on macOS 10.5 Leopard, but
// [NSOpenGLContext initWithCGLContextObj:] is only available on macOS 10.6 // [NSOpenGLContext initWithCGLContextObj:] is only available on macOS 10.6
// Snow Leopard. // Snow Leopard.
bool useContext_3_2 = false;
NSOpenGLPixelFormatAttribute attributes[] = { NSOpenGLPixelFormatAttribute attributes[] = {
NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute)24, NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute)24,
NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute)8, NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute)8,
@ -255,7 +253,7 @@ MacOGLDisplayView::MacOGLDisplayView()
#ifdef _OGLDISPLAYOUTPUT_3_2_H_ #ifdef _OGLDISPLAYOUTPUT_3_2_H_
// If we can support a 3.2 Core Profile context, then request that in our // If we can support a 3.2 Core Profile context, then request that in our
// pixel format attributes. // pixel format attributes.
useContext_3_2 = IsOSXVersionSupported(10, 7, 0); bool useContext_3_2 = IsOSXVersionSupported(10, 7, 0);
if (useContext_3_2) if (useContext_3_2)
{ {
attributes[9] = NSOpenGLPFAOpenGLProfile; attributes[9] = NSOpenGLPFAOpenGLProfile;
@ -277,11 +275,14 @@ MacOGLDisplayView::MacOGLDisplayView()
_nsContext = nil; _nsContext = nil;
_context = nil; _context = nil;
_allowViewUpdates = false;
_spinlockViewNeedsFlush = OS_SPINLOCK_INIT; if (sharedObject != nil)
{
SetFetchObject([sharedObject GPUFetchObject]);
}
} }
void MacOGLDisplayView::Init() void MacOGLDisplayPresenter::Init()
{ {
this->_nsContext = [[NSOpenGLContext alloc] initWithFormat:this->_nsPixelFormat this->_nsContext = [[NSOpenGLContext alloc] initWithFormat:this->_nsPixelFormat
shareContext:((MacOGLClientFetchObject *)this->_fetchObject)->GetNSContext()]; shareContext:((MacOGLClientFetchObject *)this->_fetchObject)->GetNSContext()];
@ -308,26 +309,146 @@ void MacOGLDisplayView::Init()
CGLSetCurrentContext(prevContext); CGLSetCurrentContext(prevContext);
} }
NSOpenGLPixelFormat* MacOGLDisplayView::GetNSPixelFormat() const NSOpenGLPixelFormat* MacOGLDisplayPresenter::GetNSPixelFormat() const
{ {
return this->_nsPixelFormat; return this->_nsPixelFormat;
} }
NSOpenGLContext* MacOGLDisplayView::GetNSContext() const NSOpenGLContext* MacOGLDisplayPresenter::GetNSContext() const
{ {
return this->_nsContext; return this->_nsContext;
} }
CGLPixelFormatObj MacOGLDisplayView::GetPixelFormat() const CGLPixelFormatObj MacOGLDisplayPresenter::GetPixelFormat() const
{ {
return this->_pixelFormat; return this->_pixelFormat;
} }
CGLContextObj MacOGLDisplayView::GetContext() const CGLContextObj MacOGLDisplayPresenter::GetContext() const
{ {
return this->_context; return this->_context;
} }
void MacOGLDisplayPresenter::LoadHUDFont()
{
CGLLockContext(this->_context);
CGLSetCurrentContext(this->_context);
this->OGLVideoOutput::LoadHUDFont();
CGLUnlockContext(this->_context);
}
void MacOGLDisplayPresenter::SetScaleFactor(const double scaleFactor)
{
CGLLockContext(this->_context);
CGLSetCurrentContext(this->_context);
this->OGLVideoOutput::SetScaleFactor(scaleFactor);
CGLUnlockContext(this->_context);
}
void MacOGLDisplayPresenter::SetFiltersPreferGPU(const bool preferGPU)
{
CGLLockContext(this->_context);
CGLSetCurrentContext(this->_context);
this->OGLVideoOutput::SetFiltersPreferGPU(preferGPU);
CGLUnlockContext(this->_context);
}
void MacOGLDisplayPresenter::SetOutputFilter(const OutputFilterTypeID filterID)
{
CGLLockContext(this->_context);
CGLSetCurrentContext(this->_context);
this->OGLVideoOutput::SetOutputFilter(filterID);
CGLUnlockContext(this->_context);
}
void MacOGLDisplayPresenter::SetPixelScaler(const VideoFilterTypeID filterID)
{
CGLLockContext(this->_context);
CGLSetCurrentContext(this->_context);
this->OGLVideoOutput::SetPixelScaler(filterID);
CGLUnlockContext(this->_context);
}
// NDS GPU Interface
void MacOGLDisplayPresenter::LoadDisplays()
{
CGLLockContext(this->_context);
CGLSetCurrentContext(this->_context);
this->OGLVideoOutput::LoadDisplays();
CGLUnlockContext(this->_context);
}
void MacOGLDisplayPresenter::ProcessDisplays()
{
CGLLockContext(this->_context);
CGLSetCurrentContext(this->_context);
this->OGLVideoOutput::ProcessDisplays();
CGLUnlockContext(this->_context);
}
void MacOGLDisplayPresenter::CopyFrameToBuffer(uint32_t *dstBuffer)
{
CGLLockContext(this->_context);
CGLSetCurrentContext(this->_context);
this->OGLVideoOutput::CopyFrameToBuffer(dstBuffer);
CGLUnlockContext(this->_context);
}
void MacOGLDisplayPresenter::FinishFrameAtIndex(const uint8_t bufferIndex)
{
CGLLockContext(this->_context);
CGLSetCurrentContext(this->_context);
this->OGLVideoOutput::FinishFrameAtIndex(bufferIndex);
CGLUnlockContext(this->_context);
}
void MacOGLDisplayPresenter::LockDisplayTextures()
{
const GPUClientFetchObject &fetchObj = this->GetFetchObject();
const u8 bufferIndex = this->_emuDisplayInfo.bufferIndex;
MacClientSharedObject *sharedViewObject = (MacClientSharedObject *)fetchObj.GetClientData();
pthread_rwlock_rdlock([sharedViewObject rwlockFramebufferAtIndex:bufferIndex]);
}
void MacOGLDisplayPresenter::UnlockDisplayTextures()
{
const GPUClientFetchObject &fetchObj = this->GetFetchObject();
const u8 bufferIndex = this->_emuDisplayInfo.bufferIndex;
MacClientSharedObject *sharedViewObject = (MacClientSharedObject *)fetchObj.GetClientData();
pthread_rwlock_unlock([sharedViewObject rwlockFramebufferAtIndex:bufferIndex]);
}
#pragma mark -
MacOGLDisplayView::MacOGLDisplayView()
{
__InstanceInit(nil);
}
MacOGLDisplayView::MacOGLDisplayView(MacClientSharedObject *sharedObject)
{
__InstanceInit(sharedObject);
}
MacOGLDisplayView::~MacOGLDisplayView()
{
[this->_caLayer release];
}
void MacOGLDisplayView::__InstanceInit(MacClientSharedObject *sharedObject)
{
_allowViewUpdates = false;
_spinlockViewNeedsFlush = OS_SPINLOCK_INIT;
MacOGLDisplayPresenter *newOpenGLPresenter = new MacOGLDisplayPresenter(sharedObject);
_presenter = newOpenGLPresenter;
_caLayer = [[DisplayViewOpenGLLayer alloc] init];
[_caLayer setClientDisplayView:this];
}
bool MacOGLDisplayView::GetViewNeedsFlush() bool MacOGLDisplayView::GetViewNeedsFlush()
{ {
OSSpinLockLock(&this->_spinlockViewNeedsFlush); OSSpinLockLock(&this->_spinlockViewNeedsFlush);
@ -337,88 +458,9 @@ bool MacOGLDisplayView::GetViewNeedsFlush()
return viewNeedsFlush; return viewNeedsFlush;
} }
void MacOGLDisplayView::SetAllowViewFlushes(bool allowFlushes) void MacOGLDisplayView::SetViewNeedsFlush()
{ {
CGDirectDisplayID displayID = (CGDirectDisplayID)this->GetDisplayViewID(); if (!this->_allowViewUpdates || (this->_presenter == nil) || (this->GetNSView() == nil))
MacClientSharedObject *sharedData = this->GetSharedData();
if (![sharedData isDisplayLinkRunningUsingID:displayID])
{
[sharedData displayLinkStartUsingID:displayID];
}
}
void MacOGLDisplayView::LoadHUDFont()
{
CGLLockContext(this->_context);
CGLSetCurrentContext(this->_context);
this->OGLVideoOutput::LoadHUDFont();
CGLUnlockContext(this->_context);
}
void MacOGLDisplayView::SetUseVerticalSync(const bool useVerticalSync)
{
const GLint swapInt = (useVerticalSync) ? 1 : 0;
CGLLockContext(this->_context);
CGLSetCurrentContext(this->_context);
CGLSetParameter(this->_context, kCGLCPSwapInterval, &swapInt);
this->OGLVideoOutput::SetUseVerticalSync(useVerticalSync);
CGLUnlockContext(this->_context);
}
void MacOGLDisplayView::SetScaleFactor(const double scaleFactor)
{
CGLLockContext(this->_context);
CGLSetCurrentContext(this->_context);
this->OGLVideoOutput::SetScaleFactor(scaleFactor);
CGLUnlockContext(this->_context);
}
void MacOGLDisplayView::SetFiltersPreferGPU(const bool preferGPU)
{
CGLLockContext(this->_context);
CGLSetCurrentContext(this->_context);
this->OGLVideoOutput::SetFiltersPreferGPU(preferGPU);
CGLUnlockContext(this->_context);
}
void MacOGLDisplayView::SetOutputFilter(const OutputFilterTypeID filterID)
{
CGLLockContext(this->_context);
CGLSetCurrentContext(this->_context);
this->OGLVideoOutput::SetOutputFilter(filterID);
CGLUnlockContext(this->_context);
}
void MacOGLDisplayView::SetPixelScaler(const VideoFilterTypeID filterID)
{
CGLLockContext(this->_context);
CGLSetCurrentContext(this->_context);
this->OGLVideoOutput::SetPixelScaler(filterID);
CGLUnlockContext(this->_context);
}
// NDS GPU Interface
void MacOGLDisplayView::LoadDisplays()
{
CGLLockContext(this->_context);
CGLSetCurrentContext(this->_context);
this->OGLVideoOutput::LoadDisplays();
CGLUnlockContext(this->_context);
}
void MacOGLDisplayView::ProcessDisplays()
{
CGLLockContext(this->_context);
CGLSetCurrentContext(this->_context);
this->OGLVideoOutput::ProcessDisplays();
CGLUnlockContext(this->_context);
}
void MacOGLDisplayView::UpdateView()
{
if (!this->_allowViewUpdates || (this->GetNSView() == nil))
{ {
return; return;
} }
@ -439,49 +481,40 @@ void MacOGLDisplayView::UpdateView()
} }
} }
void MacOGLDisplayView::SetAllowViewFlushes(bool allowFlushes)
{
CGDirectDisplayID displayID = (CGDirectDisplayID)this->GetDisplayViewID();
MacClientSharedObject *sharedData = ((MacOGLDisplayPresenter *)this->_presenter)->GetSharedData();
if (![sharedData isDisplayLinkRunningUsingID:displayID])
{
[sharedData displayLinkStartUsingID:displayID];
}
}
void MacOGLDisplayView::SetUseVerticalSync(const bool useVerticalSync)
{
CGLContextObj context = ((MacOGLDisplayPresenter *)this->_presenter)->GetContext();
const GLint swapInt = (useVerticalSync) ? 1 : 0;
CGLLockContext(context);
CGLSetCurrentContext(context);
CGLSetParameter(context, kCGLCPSwapInterval, &swapInt);
MacDisplayLayeredView::SetUseVerticalSync(useVerticalSync);
CGLUnlockContext(context);
}
void MacOGLDisplayView::FlushView() void MacOGLDisplayView::FlushView()
{ {
OSSpinLockLock(&this->_spinlockViewNeedsFlush); OSSpinLockLock(&this->_spinlockViewNeedsFlush);
this->_viewNeedsFlush = false; this->_viewNeedsFlush = false;
OSSpinLockUnlock(&this->_spinlockViewNeedsFlush); OSSpinLockUnlock(&this->_spinlockViewNeedsFlush);
CGLLockContext(this->_context); CGLContextObj context = ((MacOGLDisplayPresenter *)this->_presenter)->GetContext();
CGLSetCurrentContext(this->_context);
this->RenderFrameOGL(false);
CGLFlushDrawable(this->_context);
CGLUnlockContext(this->_context);
}
void MacOGLDisplayView::CopyFrameToBuffer(uint32_t *dstBuffer)
{
CGLLockContext(this->_context);
CGLSetCurrentContext(this->_context);
this->OGLVideoOutput::CopyFrameToBuffer(dstBuffer);
CGLUnlockContext(this->_context);
}
void MacOGLDisplayView::FinishFrameAtIndex(const uint8_t bufferIndex)
{
CGLLockContext(this->_context);
CGLSetCurrentContext(this->_context);
this->OGLVideoOutput::FinishFrameAtIndex(bufferIndex);
CGLUnlockContext(this->_context);
}
void MacOGLDisplayView::LockDisplayTextures()
{
const GPUClientFetchObject &fetchObj = this->GetFetchObject();
const u8 bufferIndex = this->_emuDisplayInfo.bufferIndex;
MacClientSharedObject *sharedViewObject = (MacClientSharedObject *)fetchObj.GetClientData();
pthread_rwlock_rdlock([sharedViewObject rwlockFramebufferAtIndex:bufferIndex]); CGLLockContext(context);
} CGLSetCurrentContext(context);
((MacOGLDisplayPresenter *)this->_presenter)->RenderFrameOGL(false);
void MacOGLDisplayView::UnlockDisplayTextures() CGLFlushDrawable(context);
{ CGLUnlockContext(context);
const GPUClientFetchObject &fetchObj = this->GetFetchObject();
const u8 bufferIndex = this->_emuDisplayInfo.bufferIndex;
MacClientSharedObject *sharedViewObject = (MacClientSharedObject *)fetchObj.GetClientData();
pthread_rwlock_unlock([sharedViewObject rwlockFramebufferAtIndex:bufferIndex]);
} }

View File

@ -0,0 +1,97 @@
/*
Copyright (C) 2017 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
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _MAC_SCREENSHOTCAPTURETOOL_H_
#define _MAC_SCREENSHOTCAPTURETOOL_H_
#import <Cocoa/Cocoa.h>
#include <string>
#include "../ClientDisplayView.h"
#ifdef BOOL
#undef BOOL
#endif
@class MacClientSharedObject;
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
@interface MacScreenshotCaptureToolDelegate : NSObject <NSWindowDelegate>
#else
@interface MacScreenshotCaptureToolDelegate : NSObject
#endif
{
NSWindow *window;
MacClientSharedObject *sharedData;
NSString *saveDirectoryPath;
NSString *romName;
NSBitmapFormat fileFormat;
NSInteger displayMode;
NSInteger displayLayout;
NSInteger displayOrder;
NSInteger displaySeparation;
NSInteger displayRotation;
BOOL useDeposterize;
NSInteger outputFilterID;
NSInteger pixelScalerID;
}
@property (readonly) IBOutlet NSWindow *window;
@property (retain) MacClientSharedObject *sharedData;
@property (copy) NSString *saveDirectoryPath;
@property (copy) NSString *romName;
@property (assign) NSBitmapFormat fileFormat;
@property (assign) NSInteger displayMode;
@property (assign) NSInteger displayLayout;
@property (assign) NSInteger displayOrder;
@property (assign) NSInteger displaySeparation;
@property (assign) NSInteger displayRotation;
@property (assign) BOOL useDeposterize;
@property (assign) NSInteger outputFilterID;
@property (assign) NSInteger pixelScalerID;
- (IBAction) chooseDirectoryPath:(id)sender;
- (IBAction) takeScreenshot:(id)sender;
- (void) chooseDirectoryPathDidEnd:(NSOpenPanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo;
- (void) readUserDefaults;
- (void) writeUserDefaults;
@end
class MacScreenshotCaptureToolParams
{
public:
MacClientSharedObject *sharedData;
NSBitmapImageFileType fileFormat;
std::string savePath;
std::string romName;
bool useDeposterize;
OutputFilterTypeID outputFilterID;
VideoFilterTypeID pixelScalerID;
ClientDisplayPresenterProperties cdpProperty;
};
static void* RunFileWriteThread(void *arg);
#endif // _MAC_SCREENSHOTCAPTURETOOL_H_

View File

@ -0,0 +1,346 @@
/*
Copyright (C) 2017 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
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
#include <pthread.h>
#import "../cocoa_file.h"
#import "../cocoa_GPU.h"
#import "../cocoa_globals.h"
#import "MacScreenshotCaptureTool.h"
#import "MacOGLDisplayView.h"
#ifdef ENABLE_APPLE_METAL
#include "MacMetalDisplayView.h"
#endif
@implementation MacScreenshotCaptureToolDelegate
@synthesize window;
@synthesize sharedData;
@synthesize saveDirectoryPath;
@synthesize romName;
@synthesize fileFormat;
@synthesize displayMode;
@synthesize displayLayout;
@synthesize displayOrder;
@synthesize displaySeparation;
@synthesize displayRotation;
@synthesize useDeposterize;
@synthesize outputFilterID;
@synthesize pixelScalerID;
- (id)init
{
self = [super init];
if(self == nil)
{
return nil;
}
sharedData = nil;
saveDirectoryPath = nil;
romName = @"No_ROM_loaded";
return self;
}
- (void)dealloc
{
[self setSharedData:nil];
[self setSaveDirectoryPath:nil];
[self setRomName:nil];
[super dealloc];
}
- (IBAction) chooseDirectoryPath:(id)sender
{
NSOpenPanel *panel = [NSOpenPanel openPanel];
[panel setCanCreateDirectories:YES];
[panel setCanChooseDirectories:YES];
[panel setCanChooseFiles:NO];
[panel setResolvesAliases:YES];
[panel setAllowsMultipleSelection:NO];
[panel setTitle:NSSTRING_TITLE_SAVE_SCREENSHOT_PANEL];
#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_5
[panel beginSheetModalForWindow:[self window]
completionHandler:^(NSInteger result) {
[self chooseDirectoryPathDidEnd:panel returnCode:result contextInfo:nil];
} ];
#else
[panel beginSheetForDirectory:nil
file:nil
types:nil
modalForWindow:[self window]
modalDelegate:self
didEndSelector:@selector(chooseDirectoryPathDidEnd:returnCode:contextInfo:)
contextInfo:nil];
#endif
}
- (IBAction) takeScreenshot:(id)sender
{
NSString *savePath = [self saveDirectoryPath];
if ( (savePath != nil) && ([savePath length] > 0) )
{
savePath = [savePath stringByExpandingTildeInPath];
}
else
{
[self chooseDirectoryPath:self];
}
NSFileManager *fileManager = [[NSFileManager alloc] init];
BOOL isDirectoryFound = [fileManager createDirectoryAtPath:savePath withIntermediateDirectories:YES attributes:nil error:nil];
[fileManager release];
if (!isDirectoryFound)
{
[self chooseDirectoryPath:self];
isDirectoryFound = [fileManager createDirectoryAtPath:savePath withIntermediateDirectories:YES attributes:nil error:nil];
if (!isDirectoryFound)
{
// This was the last chance for the user to try to get a working writable directory.
// If the directory is still invalid, then just bail.
return;
}
}
// Note: We're allocating the parameter's memory block here, but we will be freeing it once we copy it in the detached thread.
MacScreenshotCaptureToolParams *param = new MacScreenshotCaptureToolParams;
param->sharedData = [self sharedData];
param->fileFormat = (NSBitmapImageFileType)[self fileFormat];
param->savePath = std::string([savePath cStringUsingEncoding:NSUTF8StringEncoding]);
param->romName = std::string([romName cStringUsingEncoding:NSUTF8StringEncoding]);
param->useDeposterize = [self useDeposterize] ? true : false;
param->outputFilterID = (OutputFilterTypeID)[self outputFilterID];
param->pixelScalerID = (VideoFilterTypeID)[self pixelScalerID];
param->cdpProperty.mode = (ClientDisplayMode)[self displayMode];
param->cdpProperty.layout = (ClientDisplayLayout)[self displayLayout];
param->cdpProperty.order = (ClientDisplayOrder)[self displayOrder];
param->cdpProperty.gapScale = (float)[self displaySeparation] / 100.0f;
param->cdpProperty.rotation = (float)[self displayRotation];
pthread_t fileWriteThread;
pthread_attr_t fileWriteThreadAttr;
pthread_attr_init(&fileWriteThreadAttr);
pthread_attr_setdetachstate(&fileWriteThreadAttr, PTHREAD_CREATE_DETACHED);
pthread_create(&fileWriteThread, &fileWriteThreadAttr, &RunFileWriteThread, param);
pthread_attr_destroy(&fileWriteThreadAttr);
}
- (void) chooseDirectoryPathDidEnd:(NSOpenPanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
{
[sheet orderOut:self];
if (returnCode == NSCancelButton)
{
return;
}
NSURL *selectedFileURL = [[sheet URLs] lastObject]; //hopefully also the first object
if(selectedFileURL == nil)
{
return;
}
[self setSaveDirectoryPath:[selectedFileURL path]];
}
- (void) readUserDefaults
{
[self setSaveDirectoryPath:[[NSUserDefaults standardUserDefaults] stringForKey:@"ScreenshotCaptureTool_DirectoryPath"]];
[self setFileFormat:[[NSUserDefaults standardUserDefaults] integerForKey:@"ScreenshotCaptureTool_FileFormat"]];
[self setUseDeposterize:[[NSUserDefaults standardUserDefaults] boolForKey:@"ScreenshotCaptureTool_Deposterize"]];
[self setOutputFilterID:[[NSUserDefaults standardUserDefaults] integerForKey:@"ScreenshotCaptureTool_OutputFilter"]];
[self setPixelScalerID:[[NSUserDefaults standardUserDefaults] integerForKey:@"ScreenshotCaptureTool_PixelScaler"]];
[self setDisplayMode:[[NSUserDefaults standardUserDefaults] integerForKey:@"ScreenshotCaptureTool_DisplayMode"]];
[self setDisplayLayout:[[NSUserDefaults standardUserDefaults] integerForKey:@"ScreenshotCaptureTool_DisplayLayout"]];
[self setDisplayOrder:[[NSUserDefaults standardUserDefaults] integerForKey:@"ScreenshotCaptureTool_DisplayOrder"]];
[self setDisplaySeparation:[[NSUserDefaults standardUserDefaults] integerForKey:@"ScreenshotCaptureTool_DisplaySeparation"]];
[self setDisplayRotation:[[NSUserDefaults standardUserDefaults] integerForKey:@"ScreenshotCaptureTool_DisplayRotation"]];
}
- (void) writeUserDefaults
{
[[NSUserDefaults standardUserDefaults] setObject:[self saveDirectoryPath] forKey:@"ScreenshotCaptureTool_DirectoryPath"];
[[NSUserDefaults standardUserDefaults] setInteger:[self fileFormat] forKey:@"ScreenshotCaptureTool_FileFormat"];
[[NSUserDefaults standardUserDefaults] setBool:[self useDeposterize] forKey:@"ScreenshotCaptureTool_Deposterize"];
[[NSUserDefaults standardUserDefaults] setInteger:[self outputFilterID] forKey:@"ScreenshotCaptureTool_OutputFilter"];
[[NSUserDefaults standardUserDefaults] setInteger:[self pixelScalerID] forKey:@"ScreenshotCaptureTool_PixelScaler"];
[[NSUserDefaults standardUserDefaults] setInteger:[self displayMode] forKey:@"ScreenshotCaptureTool_DisplayMode"];
[[NSUserDefaults standardUserDefaults] setInteger:[self displayLayout] forKey:@"ScreenshotCaptureTool_DisplayLayout"];
[[NSUserDefaults standardUserDefaults] setInteger:[self displayOrder] forKey:@"ScreenshotCaptureTool_DisplayOrder"];
[[NSUserDefaults standardUserDefaults] setInteger:[self displaySeparation] forKey:@"ScreenshotCaptureTool_DisplaySeparation"];
[[NSUserDefaults standardUserDefaults] setInteger:[self displayRotation] forKey:@"ScreenshotCaptureTool_DisplayRotation"];
}
@end
static void* RunFileWriteThread(void *arg)
{
// Copy the rendering properties from the calling thread.
MacScreenshotCaptureToolParams *inParams = (MacScreenshotCaptureToolParams *)arg;
MacScreenshotCaptureToolParams param;
param.sharedData = inParams->sharedData;
param.fileFormat = inParams->fileFormat;
param.savePath = inParams->savePath;
param.romName = inParams->romName;
param.useDeposterize = inParams->useDeposterize;
param.outputFilterID = inParams->outputFilterID;
param.pixelScalerID = inParams->pixelScalerID;
param.cdpProperty.mode = inParams->cdpProperty.mode;
param.cdpProperty.layout = inParams->cdpProperty.layout;
param.cdpProperty.order = inParams->cdpProperty.order;
param.cdpProperty.gapScale = inParams->cdpProperty.gapScale;
param.cdpProperty.rotation = inParams->cdpProperty.rotation;
delete inParams;
inParams = NULL;
// Do a few sanity checks before proceeding.
if (param.sharedData == nil)
{
return NULL;
}
GPUClientFetchObject *fetchObject = [param.sharedData GPUFetchObject];
if (fetchObject == NULL)
{
return NULL;
}
const NDSDisplayInfo &displayInfo = fetchObject->GetFetchDisplayInfoForBufferIndex( fetchObject->GetLastFetchIndex() );
if ( (displayInfo.renderedWidth[NDSDisplayID_Main] == 0) || (displayInfo.renderedHeight[NDSDisplayID_Main] == 0) ||
(displayInfo.renderedWidth[NDSDisplayID_Touch] == 0) || (displayInfo.renderedHeight[NDSDisplayID_Touch] == 0) )
{
return NULL;
}
// Set up the rendering properties.
ClientDisplayPresenter::CalculateNormalSize(param.cdpProperty.mode, param.cdpProperty.layout, param.cdpProperty.gapScale, param.cdpProperty.normalWidth, param.cdpProperty.normalHeight);
double transformedWidth = param.cdpProperty.normalWidth;
double transformedHeight = param.cdpProperty.normalHeight;
param.cdpProperty.viewScale = (double)displayInfo.customWidth / (double)GPU_FRAMEBUFFER_NATIVE_WIDTH;
ClientDisplayPresenter::ConvertNormalToTransformedBounds(param.cdpProperty.viewScale, param.cdpProperty.rotation, transformedWidth, transformedHeight);
param.cdpProperty.clientWidth = transformedWidth;
param.cdpProperty.clientHeight = transformedHeight;
param.cdpProperty.gapDistance = (double)DS_DISPLAY_UNSCALED_GAP * param.cdpProperty.gapScale;
// Render the frame to an NSBitmapImageRep.
NSAutoreleasePool *autoreleasePool = [[NSAutoreleasePool alloc] init];
NSUInteger w = param.cdpProperty.clientWidth;
NSUInteger h = param.cdpProperty.clientHeight;
NSBitmapImageRep *newImageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
pixelsWide:w
pixelsHigh:h
bitsPerSample:8
samplesPerPixel:4
hasAlpha:YES
isPlanar:NO
colorSpaceName:NSCalibratedRGBColorSpace
bytesPerRow:w * 4
bitsPerPixel:32];
if (newImageRep == nil)
{
[autoreleasePool release];
return NULL;
}
ClientDisplay3DPresenter *cdp = NULL;
bool filtersPreferGPU = true;
#ifdef ENABLE_APPLE_METAL
if ([param.sharedData isKindOfClass:[MetalDisplayViewSharedData class]])
{
if ([(MetalDisplayViewSharedData *)param.sharedData device] == nil)
{
[newImageRep release];
[autoreleasePool release];
return NULL;
}
cdp = new MacMetalDisplayPresenter(param.sharedData);
}
else
#endif
{
cdp = new MacOGLDisplayPresenter(param.sharedData);
filtersPreferGPU = false; // Just in case we're capturing the screenshot on an older GPU, perform the filtering on the CPU to avoid potential issues.
}
cdp->Init();
cdp->SetFiltersPreferGPU(filtersPreferGPU);
cdp->SetHUDVisibility(false);
cdp->CommitPresenterProperties(param.cdpProperty);
cdp->SetupPresenterProperties();
cdp->SetSourceDeposterize(param.useDeposterize);
if ( (cdp->GetViewScale() > 0.999) && (cdp->GetViewScale() < 1.001) )
{
// Special case stuff for when capturing the screenshot at the native resolution.
if ( (param.cdpProperty.layout == ClientDisplayLayout_Vertical) || (param.cdpProperty.layout == ClientDisplayLayout_Horizontal) )
{
cdp->SetOutputFilter(OutputFilterTypeID_NearestNeighbor);
}
else
{
cdp->SetOutputFilter(param.outputFilterID);
}
}
else
{
// For custom-sized resolutions, apply all the filters as normal.
cdp->SetPixelScaler(param.pixelScalerID);
cdp->SetOutputFilter(param.outputFilterID);
}
cdp->LoadDisplays();
cdp->ProcessDisplays();
cdp->UpdateLayout();
cdp->CopyFrameToBuffer((uint32_t *)[newImageRep bitmapData]);
// Write the file.
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyyMMdd_HH-mm-ss.SSS "];
NSString *fileName = [[dateFormatter stringFromDate:[NSDate date]] stringByAppendingString:[NSString stringWithCString:param.romName.c_str() encoding:NSUTF8StringEncoding]];
[dateFormatter release];
NSString *savePath = [NSString stringWithCString:param.savePath.c_str() encoding:NSUTF8StringEncoding];
NSURL *fileURL = [NSURL fileURLWithPath:[savePath stringByAppendingPathComponent:fileName]];
[CocoaDSFile saveScreenshot:fileURL bitmapData:newImageRep fileType:param.fileFormat];
// Clean up.
delete cdp;
[newImageRep release];
[autoreleasePool release];
return NULL;
}

View File

@ -19,9 +19,7 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
@class InputPrefsView; @class InputPrefsView;
@class InputManager;
@class FileMigrationDelegate; @class FileMigrationDelegate;
@class RomInfoPanel;
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5 #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
@ -34,21 +32,12 @@
NSObjectController *aboutWindowController; NSObjectController *aboutWindowController;
NSObjectController *emuControlController; NSObjectController *emuControlController;
NSObjectController *cdsSoundController;
NSObjectController *romInfoPanelController;
NSObjectController *prefWindowController; NSObjectController *prefWindowController;
NSObjectController *cheatWindowController;
NSObjectController *cdsCoreController; NSObjectController *cdsCoreController;
NSArrayController *inputDeviceListController;
FileMigrationDelegate *migrationDelegate; FileMigrationDelegate *migrationDelegate;
InputManager *inputManager;
RomInfoPanel *romInfoPanel;
NSWindow *prefWindow; NSWindow *prefWindow;
NSWindow *troubleshootingWindow; NSWindow *troubleshootingWindow;
NSWindow *cheatListWindow;
NSWindow *slot2Window;
NSView *prefGeneralView;
InputPrefsView *inputPrefsView; InputPrefsView *inputPrefsView;
NSMenu *mLoadStateSlot; NSMenu *mLoadStateSlot;
@ -62,23 +51,14 @@
@property (readonly) IBOutlet NSObjectController *aboutWindowController; @property (readonly) IBOutlet NSObjectController *aboutWindowController;
@property (readonly) IBOutlet NSObjectController *emuControlController; @property (readonly) IBOutlet NSObjectController *emuControlController;
@property (readonly) IBOutlet NSObjectController *cdsSoundController;
@property (readonly) IBOutlet NSObjectController *romInfoPanelController;
@property (readonly) IBOutlet NSObjectController *prefWindowController; @property (readonly) IBOutlet NSObjectController *prefWindowController;
@property (readonly) IBOutlet NSObjectController *cheatWindowController;
@property (readonly) IBOutlet NSObjectController *cdsCoreController; @property (readonly) IBOutlet NSObjectController *cdsCoreController;
@property (readonly) IBOutlet NSArrayController *inputDeviceListController;
@property (readonly) IBOutlet FileMigrationDelegate *migrationDelegate; @property (readonly) IBOutlet FileMigrationDelegate *migrationDelegate;
@property (readonly) IBOutlet InputManager *inputManager;
@property (readonly) IBOutlet NSWindow *prefWindow; @property (readonly) IBOutlet NSWindow *prefWindow;
@property (readonly) IBOutlet NSWindow *troubleshootingWindow; @property (readonly) IBOutlet NSWindow *troubleshootingWindow;
@property (readonly) IBOutlet NSWindow *cheatListWindow;
@property (readonly) IBOutlet NSWindow *slot2Window;
@property (readonly) IBOutlet NSView *prefGeneralView;
@property (readonly) IBOutlet NSMenu *mLoadStateSlot; @property (readonly) IBOutlet NSMenu *mLoadStateSlot;
@property (readonly) IBOutlet NSMenu *mSaveStateSlot; @property (readonly) IBOutlet NSMenu *mSaveStateSlot;
@property (readonly) IBOutlet InputPrefsView *inputPrefsView; @property (readonly) IBOutlet InputPrefsView *inputPrefsView;
@property (readonly) IBOutlet RomInfoPanel *romInfoPanel;
@property (assign) BOOL isAppRunningOnIntel; @property (assign) BOOL isAppRunningOnIntel;
@property (assign) BOOL isDeveloperPlusBuild; @property (assign) BOOL isDeveloperPlusBuild;
@ -91,7 +71,5 @@
- (void) setupSlotMenuItems; - (void) setupSlotMenuItems;
- (NSMenuItem *) addSlotMenuItem:(NSMenu *)menu slotNumber:(NSUInteger)slotNumber; - (NSMenuItem *) addSlotMenuItem:(NSMenu *)menu slotNumber:(NSUInteger)slotNumber;
- (void) setupUserDefaults; - (void) setupUserDefaults;
- (void) restoreDisplayWindowStates;
- (void) saveDisplayWindowStates;
@end @end

View File

@ -20,8 +20,6 @@
#import "DisplayWindowController.h" #import "DisplayWindowController.h"
#import "EmuControllerDelegate.h" #import "EmuControllerDelegate.h"
#import "FileMigrationDelegate.h" #import "FileMigrationDelegate.h"
#import "RomInfoPanel.h"
#import "Slot2WindowDelegate.h"
#import "preferencesWindowDelegate.h" #import "preferencesWindowDelegate.h"
#import "troubleshootingWindowDelegate.h" #import "troubleshootingWindowDelegate.h"
#import "cheatWindowDelegate.h" #import "cheatWindowDelegate.h"
@ -43,23 +41,14 @@
@dynamic dummyObject; @dynamic dummyObject;
@synthesize prefWindow; @synthesize prefWindow;
@synthesize troubleshootingWindow; @synthesize troubleshootingWindow;
@synthesize cheatListWindow;
@synthesize slot2Window;
@synthesize prefGeneralView;
@synthesize mLoadStateSlot; @synthesize mLoadStateSlot;
@synthesize mSaveStateSlot; @synthesize mSaveStateSlot;
@synthesize inputPrefsView; @synthesize inputPrefsView;
@synthesize aboutWindowController; @synthesize aboutWindowController;
@synthesize emuControlController; @synthesize emuControlController;
@synthesize cdsSoundController;
@synthesize romInfoPanelController;
@synthesize prefWindowController; @synthesize prefWindowController;
@synthesize cdsCoreController; @synthesize cdsCoreController;
@synthesize inputDeviceListController;
@synthesize cheatWindowController;
@synthesize migrationDelegate; @synthesize migrationDelegate;
@synthesize inputManager;
@synthesize romInfoPanel;
@synthesize isAppRunningOnIntel; @synthesize isAppRunningOnIntel;
@synthesize isDeveloperPlusBuild; @synthesize isDeveloperPlusBuild;
@ -136,8 +125,6 @@
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)[emuControlController content]; EmuControllerDelegate *emuControl = (EmuControllerDelegate *)[emuControlController content];
PreferencesWindowDelegate *prefWindowDelegate = (PreferencesWindowDelegate *)[prefWindow delegate]; PreferencesWindowDelegate *prefWindowDelegate = (PreferencesWindowDelegate *)[prefWindow delegate];
CheatWindowDelegate *cheatWindowDelegate = (CheatWindowDelegate *)[cheatListWindow delegate];
Slot2WindowDelegate *slot2WindowDelegate = (Slot2WindowDelegate *)[slot2Window delegate];
// Create the needed directories in Application Support if they haven't already // Create the needed directories in Application Support if they haven't already
// been created. // been created.
@ -149,6 +136,14 @@
[CocoaDSFile setupAllFilePaths]; [CocoaDSFile setupAllFilePaths];
// On macOS v10.13 and later, some unwanted menu items will show up in the View menu.
// Disable automatic window tabbing for all NSWindows in order to rid ourselves of
// these unwanted menu items.
if ([[NSWindow class] respondsToSelector:@selector(setAllowsAutomaticWindowTabbing:)])
{
[NSWindow setAllowsAutomaticWindowTabbing:NO];
}
// Setup the About window. // Setup the About window.
NSString *descriptionStr = [[[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"] stringByAppendingString:@" "] stringByAppendingString:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]]; NSString *descriptionStr = [[[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"] stringByAppendingString:@" "] stringByAppendingString:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]];
descriptionStr = [[descriptionStr stringByAppendingString:@"\n"] stringByAppendingString:@STRING_DESMUME_SHORT_DESCRIPTION]; descriptionStr = [[descriptionStr stringByAppendingString:@"\n"] stringByAppendingString:@STRING_DESMUME_SHORT_DESCRIPTION];
@ -193,16 +188,11 @@
[newCore addOutput:newSpeaker]; [newCore addOutput:newSpeaker];
[emuControl setCdsSpeaker:newSpeaker]; [emuControl setCdsSpeaker:newSpeaker];
// Update the SLOT-2 device list after the emulation core is initialized.
[slot2WindowDelegate update];
[slot2WindowDelegate setHidManager:[inputManager hidManager]];
[slot2WindowDelegate setAutoSelectedDeviceText:[[slot2WindowDelegate deviceManager] autoSelectedDeviceName]];
// Set up all the object controllers. // Set up all the object controllers.
[cdsCoreController setContent:newCore]; [cdsCoreController setContent:newCore];
[romInfoPanelController setContent:[CocoaDSRom romNotLoadedBindings]];
[prefWindowController setContent:[prefWindowDelegate bindings]]; [prefWindowController setContent:[prefWindowDelegate bindings]];
[cheatWindowController setContent:[cheatWindowDelegate bindings]];
[emuControl appInit];
} }
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
@ -241,7 +231,7 @@
// Bring the application to the front // Bring the application to the front
[NSApp activateIgnoringOtherApps:YES]; [NSApp activateIgnoringOtherApps:YES];
[self restoreDisplayWindowStates]; [emuControl restoreDisplayWindowStates];
// Load a new ROM on launch per user preferences. // Load a new ROM on launch per user preferences.
if ([[NSUserDefaults standardUserDefaults] objectForKey:@"General_AutoloadROMOnLaunch"] != nil) if ([[NSUserDefaults standardUserDefaults] objectForKey:@"General_AutoloadROMOnLaunch"] != nil)
@ -337,8 +327,9 @@
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content]; CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
// Save some settings to user defaults before app termination // Save some settings to user defaults before app termination
[self saveDisplayWindowStates]; [emuControl saveDisplayWindowStates];
[romInfoPanel writeDefaults]; [emuControl writeUserDefaults];
[[NSUserDefaults standardUserDefaults] setBool:[[cdsCore cdsController] hardwareMicMute] forKey:@"Microphone_HardwareMicMute"]; [[NSUserDefaults standardUserDefaults] setBool:[[cdsCore cdsController] hardwareMicMute] forKey:@"Microphone_HardwareMicMute"];
[[NSUserDefaults standardUserDefaults] setDouble:[emuControl currentVolumeValue] forKey:@"Sound_Volume"]; [[NSUserDefaults standardUserDefaults] setDouble:[emuControl currentVolumeValue] forKey:@"Sound_Volume"];
[[NSUserDefaults standardUserDefaults] setDouble:[emuControl lastSetSpeedScalar] forKey:@"CoreControl_SpeedScalar"]; [[NSUserDefaults standardUserDefaults] setDouble:[emuControl lastSetSpeedScalar] forKey:@"CoreControl_SpeedScalar"];
@ -428,7 +419,6 @@
{ {
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)[emuControlController content]; EmuControllerDelegate *emuControl = (EmuControllerDelegate *)[emuControlController content];
PreferencesWindowDelegate *prefWindowDelegate = [prefWindow delegate]; PreferencesWindowDelegate *prefWindowDelegate = [prefWindow delegate];
Slot2WindowDelegate *slot2WindowDelegate = (Slot2WindowDelegate *)[slot2Window delegate];
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content]; CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
// Set the emulation flags. // Set the emulation flags.
@ -520,244 +510,11 @@
[cdsCore setGdbStubPortARM7:0]; [cdsCore setGdbStubPortARM7:0];
#endif #endif
// Set up the user's default input settings. // Set up the rest of the emulation-related user defaults.
NSDictionary *userMappings = [[NSUserDefaults standardUserDefaults] dictionaryForKey:@"Input_ControllerMappings"]; [emuControl readUserDefaults];
if (userMappings == nil)
{
NSDictionary *defaultKeyMappingsDict = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"DefaultKeyMappings" ofType:@"plist"]];
NSArray *internalDefaultProfilesList = (NSArray *)[defaultKeyMappingsDict valueForKey:@"DefaultInputProfiles"];
userMappings = [(NSDictionary *)[internalDefaultProfilesList objectAtIndex:0] valueForKey:@"Mappings"];
}
[inputManager setMappingsWithMappings:userMappings];
[[inputManager hidManager] setDeviceListController:inputDeviceListController];
// Set up the ROM Info panel.
[romInfoPanel setupUserDefaults];
// Set up the preferences window. // Set up the preferences window.
[prefWindowDelegate setupUserDefaults]; [prefWindowDelegate setupUserDefaults];
// Set up the default SLOT-2 device.
[slot2WindowDelegate setupUserDefaults];
// Set up the rest of the emulation-related user defaults.
[emuControl setupUserDefaults];
}
- (void) restoreDisplayWindowStates
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)[emuControlController content];
NSArray *windowPropertiesList = [[NSUserDefaults standardUserDefaults] arrayForKey:@"General_DisplayWindowRestorableStates"];
const BOOL willRestoreWindows = [[NSUserDefaults standardUserDefaults] boolForKey:@"General_WillRestoreDisplayWindows"];
if (!willRestoreWindows || windowPropertiesList == nil || [windowPropertiesList count] < 1)
{
// If no windows were saved for restoring (the user probably closed all windows before
// app termination), then simply create a new display window per user defaults.
[emuControl newDisplayWindow:self];
}
else
{
for (NSDictionary *windowProperties in windowPropertiesList)
{
DisplayWindowController *windowController = [[DisplayWindowController alloc] initWithWindowNibName:@"DisplayWindow" emuControlDelegate:emuControl];
if (windowController == nil)
{
continue;
}
const NSInteger displayMode = ([windowProperties objectForKey:@"displayMode"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"displayMode"] integerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"DisplayView_Mode"];
const double displayScale = ([windowProperties objectForKey:@"displayScale"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"displayScale"] doubleValue] : ([[NSUserDefaults standardUserDefaults] doubleForKey:@"DisplayView_Size"] / 100.0);
const double displayRotation = ([windowProperties objectForKey:@"displayRotation"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"displayRotation"] doubleValue] : [[NSUserDefaults standardUserDefaults] doubleForKey:@"DisplayView_Rotation"];
const NSInteger displayOrientation = ([windowProperties objectForKey:@"displayOrientation"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"displayOrientation"] integerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"DisplayViewCombo_Orientation"];
const NSInteger displayOrder = ([windowProperties objectForKey:@"displayOrder"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"displayOrder"] integerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"DisplayViewCombo_Order"];
const double displayGap = ([windowProperties objectForKey:@"displayGap"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"displayGap"] doubleValue] : ([[NSUserDefaults standardUserDefaults] doubleForKey:@"DisplayViewCombo_Gap"] / 100.0);
const NSInteger displayMainSource = ([windowProperties objectForKey:@"displayMainVideoSource"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"displayMainVideoSource"] integerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"DisplayView_DisplayMainVideoSource"];
const NSInteger displayTouchSource = ([windowProperties objectForKey:@"displayTouchVideoSource"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"displayTouchVideoSource"] integerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"DisplayView_DisplayTouchVideoSource"];
const BOOL videoFiltersPreferGPU = ([windowProperties objectForKey:@"videoFiltersPreferGPU"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"videoFiltersPreferGPU"] boolValue] : [[NSUserDefaults standardUserDefaults] boolForKey:@"DisplayView_FiltersPreferGPU"];
const BOOL videoSourceDeposterize = ([windowProperties objectForKey:@"videoSourceDeposterize"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"videoSourceDeposterize"] boolValue] : [[NSUserDefaults standardUserDefaults] boolForKey:@"DisplayView_Deposterize"];
const NSInteger videoPixelScaler = ([windowProperties objectForKey:@"videoFilterType"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"videoFilterType"] integerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"DisplayView_VideoFilter"];
const NSInteger videoOutputFilter = ([windowProperties objectForKey:@"videoOutputFilter"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"videoOutputFilter"] integerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"DisplayView_OutputFilter"];
const BOOL hudEnable = ([windowProperties objectForKey:@"hudEnable"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudEnable"] boolValue] : [[NSUserDefaults standardUserDefaults] boolForKey:@"DisplayView_EnableHUD"];
const BOOL hudShowVideoFPS = ([windowProperties objectForKey:@"hudShowVideoFPS"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudShowVideoFPS"] boolValue] : [[NSUserDefaults standardUserDefaults] boolForKey:@"HUD_ShowVideoFPS"];
const BOOL hudShowRender3DFPS = ([windowProperties objectForKey:@"hudShowRender3DFPS"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudShowRender3DFPS"] boolValue] : [[NSUserDefaults standardUserDefaults] boolForKey:@"HUD_ShowRender3DFPS"];
const BOOL hudShowFrameIndex = ([windowProperties objectForKey:@"hudShowFrameIndex"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudShowFrameIndex"] boolValue] : [[NSUserDefaults standardUserDefaults] boolForKey:@"HUD_ShowFrameIndex"];
const BOOL hudShowLagFrameCount = ([windowProperties objectForKey:@"hudShowLagFrameCount"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudShowLagFrameCount"] boolValue] : [[NSUserDefaults standardUserDefaults] boolForKey:@"HUD_ShowLagFrameCount"];
const BOOL hudShowCPULoadAverage = ([windowProperties objectForKey:@"hudShowCPULoadAverage"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudShowCPULoadAverage"] boolValue] : [[NSUserDefaults standardUserDefaults] boolForKey:@"HUD_ShowCPULoadAverage"];
const BOOL hudShowRTC = ([windowProperties objectForKey:@"hudShowRTC"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudShowRTC"] boolValue] : [[NSUserDefaults standardUserDefaults] boolForKey:@"HUD_ShowRTC"];
const BOOL hudShowInput = ([windowProperties objectForKey:@"hudShowInput"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudShowInput"] boolValue] : [[NSUserDefaults standardUserDefaults] boolForKey:@"HUD_ShowInput"];
const NSUInteger hudColorVideoFPS = ([windowProperties objectForKey:@"hudColorVideoFPS"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudColorVideoFPS"] unsignedIntegerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"HUD_Color_VideoFPS"];
const NSUInteger hudColorRender3DFPS = ([windowProperties objectForKey:@"hudColorRender3DFPS"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudColorRender3DFPS"] unsignedIntegerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"HUD_Color_Render3DFPS"];
const NSUInteger hudColorFrameIndex = ([windowProperties objectForKey:@"hudColorFrameIndex"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudColorFrameIndex"] unsignedIntegerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"HUD_Color_FrameIndex"];
const NSUInteger hudColorLagFrameCount = ([windowProperties objectForKey:@"hudColorLagFrameCount"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudColorLagFrameCount"] unsignedIntegerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"HUD_Color_LagFrameCount"];
const NSUInteger hudColorCPULoadAverage = ([windowProperties objectForKey:@"hudColorCPULoadAverage"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudColorCPULoadAverage"] unsignedIntegerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"HUD_Color_CPULoadAverage"];
const NSUInteger hudColorRTC = ([windowProperties objectForKey:@"hudColorRTC"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudColorRTC"] unsignedIntegerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"HUD_Color_RTC"];
const NSUInteger hudColorInputPendingAndApplied = ([windowProperties objectForKey:@"hudColorInputPendingAndApplied"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudColorInputPendingAndApplied"] unsignedIntegerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"HUD_Color_Input_PendingAndApplied"];
const NSUInteger hudColorInputAppliedOnly = ([windowProperties objectForKey:@"hudColorInputAppliedOnly"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudColorInputAppliedOnly"] unsignedIntegerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"HUD_Color_Input_AppliedOnly"];
const NSUInteger hudColorInputPendingOnly = ([windowProperties objectForKey:@"hudColorInputPendingOnly"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"hudColorInputPendingOnly"] unsignedIntegerValue] : [[NSUserDefaults standardUserDefaults] integerForKey:@"HUD_Color_Input_PendingOnly"];
const NSInteger screenshotFileFormat = ([windowProperties objectForKey:@"screenshotFileFormat"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"screenshotFileFormat"] integerValue] : NSTIFFFileType;
const BOOL useVerticalSync = ([windowProperties objectForKey:@"useVerticalSync"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"useVerticalSync"] boolValue] : YES;
const BOOL isMinSizeNormal = ([windowProperties objectForKey:@"isMinSizeNormal"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"isMinSizeNormal"] boolValue] : YES;
const BOOL isShowingStatusBar = ([windowProperties objectForKey:@"isShowingStatusBar"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"isShowingStatusBar"] boolValue] : [[NSUserDefaults standardUserDefaults] boolForKey:@"DisplayView_ShowStatusBar"];
const BOOL isInFullScreenMode = ([windowProperties objectForKey:@"isInFullScreenMode"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"isInFullScreenMode"] boolValue] : NO;
const NSUInteger screenIndex = ([windowProperties objectForKey:@"screenIndex"] != nil) ? [(NSNumber *)[windowProperties valueForKey:@"screenIndex"] unsignedIntegerValue] : 0;
NSString *windowFrameStr = (NSString *)[windowProperties valueForKey:@"windowFrame"];
int frameX = 0;
int frameY = 0;
int frameWidth = 256;
int frameHeight = 192*2;
const char *frameCStr = [windowFrameStr cStringUsingEncoding:NSUTF8StringEncoding];
sscanf(frameCStr, "%i %i %i %i", &frameX, &frameY, &frameWidth, &frameHeight);
// Force the window to load now so that we can overwrite its internal defaults with the user's defaults.
[windowController window];
[windowController setDisplayMode:(ClientDisplayMode)displayMode
viewScale:displayScale
rotation:displayRotation
layout:(ClientDisplayLayout)displayOrientation
order:(ClientDisplayOrder)displayOrder
gapScale:displayGap
isMinSizeNormal:isMinSizeNormal
isShowingStatusBar:isShowingStatusBar];
[[windowController view] setDisplayMainVideoSource:displayMainSource];
[[windowController view] setDisplayTouchVideoSource:displayTouchSource];
[windowController setVideoPropertiesWithoutUpdateUsingPreferGPU:videoFiltersPreferGPU
sourceDeposterize:videoSourceDeposterize
outputFilter:videoOutputFilter
pixelScaler:videoPixelScaler];
[windowController setScreenshotFileFormat:screenshotFileFormat];
[[windowController view] setUseVerticalSync:useVerticalSync];
[[windowController view] setIsHUDVisible:hudEnable];
[[windowController view] setIsHUDVideoFPSVisible:hudShowVideoFPS];
[[windowController view] setIsHUDRender3DFPSVisible:hudShowRender3DFPS];
[[windowController view] setIsHUDFrameIndexVisible:hudShowFrameIndex];
[[windowController view] setIsHUDLagFrameCountVisible:hudShowLagFrameCount];
[[windowController view] setIsHUDCPULoadAverageVisible:hudShowCPULoadAverage];
[[windowController view] setIsHUDRealTimeClockVisible:hudShowRTC];
[[windowController view] setIsHUDInputVisible:hudShowInput];
[[windowController view] setHudColorVideoFPS:[CocoaDSUtil NSColorFromRGBA8888:(uint32_t)hudColorVideoFPS]];
[[windowController view] setHudColorRender3DFPS:[CocoaDSUtil NSColorFromRGBA8888:(uint32_t)hudColorRender3DFPS]];
[[windowController view] setHudColorFrameIndex:[CocoaDSUtil NSColorFromRGBA8888:(uint32_t)hudColorFrameIndex]];
[[windowController view] setHudColorLagFrameCount:[CocoaDSUtil NSColorFromRGBA8888:(uint32_t)hudColorLagFrameCount]];
[[windowController view] setHudColorCPULoadAverage:[CocoaDSUtil NSColorFromRGBA8888:(uint32_t)hudColorCPULoadAverage]];
[[windowController view] setHudColorRTC:[CocoaDSUtil NSColorFromRGBA8888:(uint32_t)hudColorRTC]];
[[windowController view] setHudColorInputPendingAndApplied:[CocoaDSUtil NSColorFromRGBA8888:(uint32_t)hudColorInputPendingAndApplied]];
[[windowController view] setHudColorInputAppliedOnly:[CocoaDSUtil NSColorFromRGBA8888:(uint32_t)hudColorInputAppliedOnly]];
[[windowController view] setHudColorInputPendingOnly:[CocoaDSUtil NSColorFromRGBA8888:(uint32_t)hudColorInputPendingOnly]];
[[windowController masterWindow] setFrameOrigin:NSMakePoint(frameX, frameY)];
// If this is the last window in the list, make this window key and main.
// Otherwise, just order the window to the front so that the windows will
// stack in a deterministic order.
[[windowController view] setAllowViewUpdates:YES];
[[[windowController view] cdsVideoOutput] handleReloadReprocessRedraw];
if (windowProperties == [windowPropertiesList lastObject])
{
[[windowController window] makeKeyAndOrderFront:self];
[[windowController window] makeMainWindow];
}
else
{
[[windowController window] orderFront:self];
}
// 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,
// since the user's screen configuration could change in between app launches,
// and since we don't want a window to go full screen on the wrong screen.
if (isInFullScreenMode &&
([[NSScreen screens] indexOfObject:[[windowController window] screen]] == screenIndex))
{
[windowController toggleFullScreenDisplay:self];
}
}
}
}
- (void) saveDisplayWindowStates
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)[emuControlController content];
NSArray *windowList = [emuControl windowList];
const BOOL willRestoreWindows = [[NSUserDefaults standardUserDefaults] boolForKey:@"General_WillRestoreDisplayWindows"];
if (willRestoreWindows && [windowList count] > 0)
{
NSMutableArray *windowPropertiesList = [NSMutableArray arrayWithCapacity:[windowList count]];
for (DisplayWindowController *windowController in windowList)
{
const NSUInteger screenIndex = [[NSScreen screens] indexOfObject:[[windowController masterWindow] screen]];
const NSRect windowFrame = [windowController masterWindowFrame];
NSString *windowFrameStr = [NSString stringWithFormat:@"%i %i %i %i",
(int)windowFrame.origin.x, (int)windowFrame.origin.y, (int)windowFrame.size.width, (int)windowFrame.size.height];
NSDictionary *windowProperties = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInteger:[windowController displayMode]], @"displayMode",
[NSNumber numberWithDouble:[windowController masterWindowScale]], @"displayScale",
[NSNumber numberWithDouble:[windowController displayRotation]], @"displayRotation",
[NSNumber numberWithInteger:[[windowController view] displayMainVideoSource]], @"displayMainVideoSource",
[NSNumber numberWithInteger:[[windowController view] displayTouchVideoSource]], @"displayTouchVideoSource",
[NSNumber numberWithInteger:[windowController displayOrientation]], @"displayOrientation",
[NSNumber numberWithInteger:[windowController displayOrder]], @"displayOrder",
[NSNumber numberWithDouble:[windowController displayGap]], @"displayGap",
[NSNumber numberWithBool:[[windowController view] videoFiltersPreferGPU]], @"videoFiltersPreferGPU",
[NSNumber numberWithInteger:[[windowController view] pixelScaler]], @"videoFilterType",
[NSNumber numberWithInteger:[windowController screenshotFileFormat]], @"screenshotFileFormat",
[NSNumber numberWithInteger:[[windowController view] outputFilter]], @"videoOutputFilter",
[NSNumber numberWithBool:[[windowController view] sourceDeposterize]], @"videoSourceDeposterize",
[NSNumber numberWithBool:[[windowController view] useVerticalSync]], @"useVerticalSync",
[NSNumber numberWithBool:[[windowController view] isHUDVisible]], @"hudEnable",
[NSNumber numberWithBool:[[windowController view] isHUDVideoFPSVisible]], @"hudShowVideoFPS",
[NSNumber numberWithBool:[[windowController view] isHUDRender3DFPSVisible]], @"hudShowRender3DFPS",
[NSNumber numberWithBool:[[windowController view] isHUDFrameIndexVisible]], @"hudShowFrameIndex",
[NSNumber numberWithBool:[[windowController view] isHUDLagFrameCountVisible]], @"hudShowLagFrameCount",
[NSNumber numberWithBool:[[windowController view] isHUDCPULoadAverageVisible]], @"hudShowCPULoadAverage",
[NSNumber numberWithBool:[[windowController view] isHUDRealTimeClockVisible]], @"hudShowRTC",
[NSNumber numberWithBool:[[windowController view] isHUDInputVisible]], @"hudShowInput",
[NSNumber numberWithUnsignedInteger:[CocoaDSUtil RGBA8888FromNSColor:[[windowController view] hudColorVideoFPS]]], @"hudColorVideoFPS",
[NSNumber numberWithUnsignedInteger:[CocoaDSUtil RGBA8888FromNSColor:[[windowController view] hudColorRender3DFPS]]], @"hudColorRender3DFPS",
[NSNumber numberWithUnsignedInteger:[CocoaDSUtil RGBA8888FromNSColor:[[windowController view] hudColorFrameIndex]]], @"hudColorFrameIndex",
[NSNumber numberWithUnsignedInteger:[CocoaDSUtil RGBA8888FromNSColor:[[windowController view] hudColorLagFrameCount]]], @"hudColorLagFrameCount",
[NSNumber numberWithUnsignedInteger:[CocoaDSUtil RGBA8888FromNSColor:[[windowController view] hudColorCPULoadAverage]]], @"hudColorCPULoadAverage",
[NSNumber numberWithUnsignedInteger:[CocoaDSUtil RGBA8888FromNSColor:[[windowController view] hudColorRTC]]], @"hudColorRTC",
[NSNumber numberWithUnsignedInteger:[CocoaDSUtil RGBA8888FromNSColor:[[windowController view] hudColorInputPendingAndApplied]]], @"hudColorInputPendingAndApplied",
[NSNumber numberWithUnsignedInteger:[CocoaDSUtil RGBA8888FromNSColor:[[windowController view] hudColorInputAppliedOnly]]], @"hudColorInputAppliedOnly",
[NSNumber numberWithUnsignedInteger:[CocoaDSUtil RGBA8888FromNSColor:[[windowController view] hudColorInputPendingOnly]]], @"hudColorInputPendingOnly",
[NSNumber numberWithBool:[windowController isMinSizeNormal]], @"isMinSizeNormal",
[NSNumber numberWithBool:[windowController masterStatusBarState]], @"isShowingStatusBar",
[NSNumber numberWithBool:[windowController isFullScreen]], @"isInFullScreenMode",
[NSNumber numberWithUnsignedInteger:screenIndex], @"screenIndex",
windowFrameStr, @"windowFrame",
nil];
// TODO: Show HUD Input.
//[NSNumber numberWithBool:[[windowController view] isHUDInputVisible]], @"hudShowInput",
[windowPropertiesList addObject:windowProperties];
}
[[NSUserDefaults standardUserDefaults] setObject:windowPropertiesList forKey:@"General_DisplayWindowRestorableStates"];
}
else
{
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"General_DisplayWindowRestorableStates"];
}
} }
@end @end