Cocoa Port: Even more display view refactoring work.
- Move Mac-specific OpenGL code to its own file. - Eliminate the CocoaDSDisplayDelegate and CocoaDSDisplayVideoDelegate protocols. Instead, call ClientDisplay3DView class methods directly.
This commit is contained in:
parent
a5b4df2038
commit
91f2bb9ee5
|
@ -45,8 +45,13 @@ ClientDisplayView::ClientDisplayView(const ClientDisplayViewProperties &props)
|
|||
ClientDisplayView::~ClientDisplayView()
|
||||
{
|
||||
delete _initialTouchInMajorDisplay;
|
||||
_initialTouchInMajorDisplay = NULL;
|
||||
|
||||
FT_Done_FreeType(this->_ftLibrary);
|
||||
if (this->_ftLibrary != NULL)
|
||||
{
|
||||
FT_Done_FreeType(this->_ftLibrary);
|
||||
this->_ftLibrary = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void ClientDisplayView::__InstanceInit(const ClientDisplayViewProperties &props)
|
||||
|
@ -318,6 +323,11 @@ void ClientDisplayView::SetPixelScaler(const VideoFilterTypeID filterID)
|
|||
// HUD appearance
|
||||
void ClientDisplayView::SetHUDFontUsingPath(const char *filePath)
|
||||
{
|
||||
if (filePath == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FT_Face fontFace;
|
||||
FT_Error error = FT_Err_Ok;
|
||||
|
||||
|
|
|
@ -182,7 +182,7 @@ public:
|
|||
virtual void SetPixelScaler(const VideoFilterTypeID filterID);
|
||||
|
||||
// HUD appearance
|
||||
void SetHUDFontUsingPath(const char *filePath);
|
||||
virtual void SetHUDFontUsingPath(const char *filePath);
|
||||
virtual void CopyHUDFont(const FT_Face &fontFace, const size_t glyphSize, const size_t glyphTileSize, GlyphInfo *glyphInfo);
|
||||
virtual void SetHUDInfo(const NDSFrameInfo &frameInfo);
|
||||
|
||||
|
@ -267,7 +267,7 @@ public:
|
|||
void SetHUDTextureCoordinates(float *texCoordBufferPtr);
|
||||
void SetScreenVertices(float *vtxBufferPtr);
|
||||
void SetScreenTextureCoordinates(float w0, float h0, float w1, float h1, float *texCoordBufferPtr);
|
||||
|
||||
|
||||
virtual void UpdateView() = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -137,6 +137,9 @@
|
|||
AB3ACC4014C24D5400D7D192 /* COPYING in Resources */ = {isa = PBXBuildFile; fileRef = AB3ACC3A14C24D5400D7D192 /* COPYING */; };
|
||||
AB3ACC4114C24D5400D7D192 /* README in Resources */ = {isa = PBXBuildFile; fileRef = AB3ACC3B14C24D5400D7D192 /* README */; };
|
||||
AB3ACC4314C24D5400D7D192 /* README.MAC in Resources */ = {isa = PBXBuildFile; fileRef = AB3ACC3D14C24D5400D7D192 /* README.MAC */; };
|
||||
AB3BF4021E22FE01003E2B24 /* MacOGLDisplayView.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3BF4011E22FE01003E2B24 /* MacOGLDisplayView.mm */; };
|
||||
AB3BF4031E22FE01003E2B24 /* MacOGLDisplayView.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3BF4011E22FE01003E2B24 /* MacOGLDisplayView.mm */; };
|
||||
AB3BF4041E22FE01003E2B24 /* MacOGLDisplayView.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3BF4011E22FE01003E2B24 /* MacOGLDisplayView.mm */; };
|
||||
AB3E34C9134AF4500056477A /* cocoa_output.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3E34C8134AF4500056477A /* cocoa_output.mm */; };
|
||||
AB40562A169F5DBB0016AC3E /* assembler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB405600169F5DBB0016AC3E /* assembler.cpp */; };
|
||||
AB40562B169F5DBB0016AC3E /* assembler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB405600169F5DBB0016AC3E /* assembler.cpp */; };
|
||||
|
@ -1347,6 +1350,8 @@
|
|||
AB3ACC3A14C24D5400D7D192 /* COPYING */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = COPYING; path = ../../../COPYING; sourceTree = SOURCE_ROOT; };
|
||||
AB3ACC3B14C24D5400D7D192 /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = README; path = ../../../README; sourceTree = SOURCE_ROOT; };
|
||||
AB3ACC3D14C24D5400D7D192 /* README.MAC */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = README.MAC; path = ../../../README.MAC; sourceTree = SOURCE_ROOT; };
|
||||
AB3BF4011E22FE01003E2B24 /* MacOGLDisplayView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MacOGLDisplayView.mm; sourceTree = "<group>"; };
|
||||
AB3BF4051E22FEA8003E2B24 /* MacOGLDisplayView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MacOGLDisplayView.h; sourceTree = "<group>"; };
|
||||
AB3E34C7134AF4500056477A /* cocoa_output.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cocoa_output.h; sourceTree = "<group>"; };
|
||||
AB3E34C8134AF4500056477A /* cocoa_output.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = cocoa_output.mm; sourceTree = "<group>"; };
|
||||
AB4055ED169F59380016AC3E /* AsmJit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AsmJit.h; sourceTree = "<group>"; };
|
||||
|
@ -2370,6 +2375,7 @@
|
|||
AB29B32F16D4BEBF000EF671 /* InputManager.h */,
|
||||
AB3ACB6E14C2361100D7D192 /* inputPrefsView.h */,
|
||||
AB01005C170D07AF00D70FBE /* InputProfileController.h */,
|
||||
AB3BF4051E22FEA8003E2B24 /* MacOGLDisplayView.h */,
|
||||
AB3ACB7014C2361100D7D192 /* preferencesWindowDelegate.h */,
|
||||
ABAF0A3F1A96E67200B95B75 /* RomInfoPanel.h */,
|
||||
AB564902186E6EBC002740F4 /* Slot2WindowDelegate.h */,
|
||||
|
@ -2382,6 +2388,7 @@
|
|||
AB29B33016D4BEBF000EF671 /* InputManager.mm */,
|
||||
AB3ACB6F14C2361100D7D192 /* inputPrefsView.mm */,
|
||||
AB01005D170D07B000D70FBE /* InputProfileController.mm */,
|
||||
AB3BF4011E22FE01003E2B24 /* MacOGLDisplayView.mm */,
|
||||
AB3ACB7114C2361100D7D192 /* preferencesWindowDelegate.mm */,
|
||||
ABAF0A401A96E67200B95B75 /* RomInfoPanel.mm */,
|
||||
AB564903186E6EBC002740F4 /* Slot2WindowDelegate.mm */,
|
||||
|
@ -3839,6 +3846,7 @@
|
|||
ABA6574B14511EC90077E5E9 /* cocoa_cheat.mm in Sources */,
|
||||
ABD1041D1346652500AF11D1 /* cocoa_core.mm in Sources */,
|
||||
AB58F32D1364F44B0074C376 /* cocoa_file.mm in Sources */,
|
||||
AB3BF4041E22FE01003E2B24 /* MacOGLDisplayView.mm in Sources */,
|
||||
ABE7F53E13EE1C7900FD3A71 /* cocoa_firmware.mm in Sources */,
|
||||
ABD1041C1346652500AF11D1 /* cocoa_input.mm in Sources */,
|
||||
AB3E34C9134AF4500056477A /* cocoa_output.mm in Sources */,
|
||||
|
@ -3983,6 +3991,7 @@
|
|||
AB796D0F15CDCBA200C59155 /* GPU.cpp in Sources */,
|
||||
ABADF11B1DEA4CF700A142B1 /* features_cpu.c in Sources */,
|
||||
AB9038AF17C5ED2200F410BD /* slot1_retail_auto.cpp in Sources */,
|
||||
AB3BF4021E22FE01003E2B24 /* MacOGLDisplayView.mm in Sources */,
|
||||
AB796D1115CDCBA200C59155 /* guid.cpp in Sources */,
|
||||
ABFEA8191BB4EC1000B08C25 /* ftfntfmt.c in Sources */,
|
||||
AB796D1215CDCBA200C59155 /* header.cpp in Sources */,
|
||||
|
@ -4183,6 +4192,7 @@
|
|||
ABA7316D1BB51FDC00B26147 /* psaux.c in Sources */,
|
||||
AB8F3C7E1A53AC2600A80BF6 /* cpu_detect_x86_gcc.cpp in Sources */,
|
||||
AB8F3C7F1A53AC2600A80BF6 /* crc.cpp in Sources */,
|
||||
AB3BF4031E22FE01003E2B24 /* MacOGLDisplayView.mm in Sources */,
|
||||
AB8F3C801A53AC2600A80BF6 /* datetime.cpp in Sources */,
|
||||
AB8F3C811A53AC2600A80BF6 /* debug.cpp in Sources */,
|
||||
AB8F3C821A53AC2600A80BF6 /* decrypt.cpp in Sources */,
|
||||
|
|
|
@ -757,6 +757,11 @@
|
|||
AB3ACC4614C24D5400D7D192 /* COPYING in Resources */ = {isa = PBXBuildFile; fileRef = AB3ACC3A14C24D5400D7D192 /* COPYING */; };
|
||||
AB3ACC4714C24D5400D7D192 /* README in Resources */ = {isa = PBXBuildFile; fileRef = AB3ACC3B14C24D5400D7D192 /* README */; };
|
||||
AB3ACC4914C24D5400D7D192 /* README.MAC in Resources */ = {isa = PBXBuildFile; fileRef = AB3ACC3D14C24D5400D7D192 /* README.MAC */; };
|
||||
AB3E69101E231E9900D4CC75 /* MacOGLDisplayView.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3E690F1E231E9900D4CC75 /* MacOGLDisplayView.mm */; };
|
||||
AB3E69111E231E9900D4CC75 /* MacOGLDisplayView.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3E690F1E231E9900D4CC75 /* MacOGLDisplayView.mm */; };
|
||||
AB3E69121E231E9900D4CC75 /* MacOGLDisplayView.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3E690F1E231E9900D4CC75 /* MacOGLDisplayView.mm */; };
|
||||
AB3E69131E231E9900D4CC75 /* MacOGLDisplayView.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3E690F1E231E9900D4CC75 /* MacOGLDisplayView.mm */; };
|
||||
AB3E69141E231E9900D4CC75 /* MacOGLDisplayView.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB3E690F1E231E9900D4CC75 /* MacOGLDisplayView.mm */; };
|
||||
AB43527217D5BA5E007417C8 /* slot1_retail_mcrom_debug.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB43527117D5BA5E007417C8 /* slot1_retail_mcrom_debug.cpp */; };
|
||||
AB43527317D5BA5E007417C8 /* slot1_retail_mcrom_debug.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB43527117D5BA5E007417C8 /* slot1_retail_mcrom_debug.cpp */; };
|
||||
AB43527417D5BA5E007417C8 /* slot1_retail_mcrom_debug.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB43527117D5BA5E007417C8 /* slot1_retail_mcrom_debug.cpp */; };
|
||||
|
@ -1874,6 +1879,8 @@
|
|||
AB3ACC3D14C24D5400D7D192 /* README.MAC */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = README.MAC; path = ../../../README.MAC; sourceTree = SOURCE_ROOT; };
|
||||
AB3E34C7134AF4500056477A /* cocoa_output.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cocoa_output.h; sourceTree = "<group>"; };
|
||||
AB3E34C8134AF4500056477A /* cocoa_output.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = cocoa_output.mm; sourceTree = "<group>"; };
|
||||
AB3E690E1E231E9900D4CC75 /* MacOGLDisplayView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacOGLDisplayView.h; sourceTree = "<group>"; };
|
||||
AB3E690F1E231E9900D4CC75 /* MacOGLDisplayView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MacOGLDisplayView.mm; sourceTree = "<group>"; };
|
||||
AB43527117D5BA5E007417C8 /* slot1_retail_mcrom_debug.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = slot1_retail_mcrom_debug.cpp; sourceTree = "<group>"; };
|
||||
AB43528517D5BA95007417C8 /* fsnitro.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fsnitro.h; sourceTree = "<group>"; };
|
||||
AB43528617D5BA95007417C8 /* fsnitro.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = fsnitro.cpp; sourceTree = "<group>"; };
|
||||
|
@ -2947,6 +2954,7 @@
|
|||
AB5A795616D5A56000ED84B7 /* InputManager.h */,
|
||||
AB3ACB6E14C2361100D7D192 /* inputPrefsView.h */,
|
||||
AB213D43170CB141006DDB0F /* InputProfileController.h */,
|
||||
AB3E690E1E231E9900D4CC75 /* MacOGLDisplayView.h */,
|
||||
AB3ACB7014C2361100D7D192 /* preferencesWindowDelegate.h */,
|
||||
ABC3DEBB1A96EA96009EC345 /* RomInfoPanel.h */,
|
||||
ABAE2F7918682B6C00C92F4F /* Slot2WindowDelegate.h */,
|
||||
|
@ -2959,6 +2967,7 @@
|
|||
AB5A795716D5A56000ED84B7 /* InputManager.mm */,
|
||||
AB3ACB6F14C2361100D7D192 /* inputPrefsView.mm */,
|
||||
AB213D44170CB141006DDB0F /* InputProfileController.mm */,
|
||||
AB3E690F1E231E9900D4CC75 /* MacOGLDisplayView.mm */,
|
||||
AB3ACB7114C2361100D7D192 /* preferencesWindowDelegate.mm */,
|
||||
ABC3DEBC1A96EA96009EC345 /* RomInfoPanel.mm */,
|
||||
ABAE2F7A18682B6C00C92F4F /* Slot2WindowDelegate.mm */,
|
||||
|
@ -4539,6 +4548,7 @@
|
|||
ABD21B631DE9010B001D2DFA /* features_cpu.c in Sources */,
|
||||
AB2C25081DEBFBD400706BFC /* encoding_utf.c in Sources */,
|
||||
AB0F13931E1B7C320075684F /* ClientDisplayView.cpp in Sources */,
|
||||
AB3E69111E231E9900D4CC75 /* MacOGLDisplayView.mm in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -4721,6 +4731,7 @@
|
|||
ABD21B641DE9010B001D2DFA /* features_cpu.c in Sources */,
|
||||
AB2C25091DEBFBD400706BFC /* encoding_utf.c in Sources */,
|
||||
AB0F13941E1B7C320075684F /* ClientDisplayView.cpp in Sources */,
|
||||
AB3E69121E231E9900D4CC75 /* MacOGLDisplayView.mm in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -4933,6 +4944,7 @@
|
|||
ABD21B621DE9010B001D2DFA /* features_cpu.c in Sources */,
|
||||
AB2C25071DEBFBD400706BFC /* encoding_utf.c in Sources */,
|
||||
AB0F13921E1B7C320075684F /* ClientDisplayView.cpp in Sources */,
|
||||
AB3E69101E231E9900D4CC75 /* MacOGLDisplayView.mm in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -5145,6 +5157,7 @@
|
|||
ABD21B661DE9010B001D2DFA /* features_cpu.c in Sources */,
|
||||
AB2C250B1DEBFBD400706BFC /* encoding_utf.c in Sources */,
|
||||
AB0F13961E1B7C320075684F /* ClientDisplayView.cpp in Sources */,
|
||||
AB3E69141E231E9900D4CC75 /* MacOGLDisplayView.mm in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -5327,6 +5340,7 @@
|
|||
ABD21B651DE9010B001D2DFA /* features_cpu.c in Sources */,
|
||||
AB2C250A1DEBFBD400706BFC /* encoding_utf.c in Sources */,
|
||||
AB0F13951E1B7C320075684F /* ClientDisplayView.cpp in Sources */,
|
||||
AB3E69131E231E9900D4CC75 /* MacOGLDisplayView.mm in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
@ -4917,13 +4917,19 @@ OGLVideoOutput::OGLVideoOutput()
|
|||
|
||||
OGLVideoOutput::~OGLVideoOutput()
|
||||
{
|
||||
for (size_t i = 0; i < _layerList->size(); i++)
|
||||
if (this->_layerList != NULL)
|
||||
{
|
||||
delete (*_layerList)[i];
|
||||
for (size_t i = 0; i < _layerList->size(); i++)
|
||||
{
|
||||
delete (*this->_layerList)[i];
|
||||
}
|
||||
|
||||
delete this->_layerList;
|
||||
this->_layerList = NULL;
|
||||
}
|
||||
|
||||
delete _layerList;
|
||||
delete _info;
|
||||
delete this->_info;
|
||||
this->_info = NULL;
|
||||
}
|
||||
|
||||
void OGLVideoOutput::_UpdateNormalSize()
|
||||
|
@ -6449,8 +6455,11 @@ void OGLHUDLayer::_UpdateVerticesOGL()
|
|||
|
||||
void OGLHUDLayer::UpdateViewportOGL()
|
||||
{
|
||||
glUseProgram(this->_program->GetProgramID());
|
||||
glUniform2f(this->_uniformViewSize, this->_output->GetViewProperties().clientWidth, this->_output->GetViewProperties().clientHeight);
|
||||
if (this->_output->GetInfo()->IsShaderSupported())
|
||||
{
|
||||
glUseProgram(this->_program->GetProgramID());
|
||||
glUniform2f(this->_uniformViewSize, this->_output->GetViewProperties().clientWidth, this->_output->GetViewProperties().clientHeight);
|
||||
}
|
||||
|
||||
this->_needUpdateVertices = true;
|
||||
};
|
||||
|
@ -7671,197 +7680,3 @@ void OGLDisplayLayer::FinishOGL()
|
|||
glFinishObjectAPPLE(GL_TEXTURE_RECTANGLE_ARB, (isUsingCPUPixelScaler) ? this->_texCPUFilterDstID[0] : ( (this->_isTexVideoInputDataNative[0]) ? this->_texVideoInputDataNativeID[0] : this->_texVideoInputDataCustomID[0]) );
|
||||
glFinishObjectAPPLE(GL_TEXTURE_RECTANGLE_ARB, (isUsingCPUPixelScaler) ? this->_texCPUFilterDstID[1] : ( (this->_isTexVideoInputDataNative[1]) ? this->_texVideoInputDataNativeID[1] : this->_texVideoInputDataCustomID[1]) );
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
MacOGLDisplayView::MacOGLDisplayView(CGLContextObj context)
|
||||
{
|
||||
this->_context = context;
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::_FrameRenderAndFlush()
|
||||
{
|
||||
this->FrameRender();
|
||||
CGLFlushDrawable(this->_context);
|
||||
}
|
||||
|
||||
CGLContextObj MacOGLDisplayView::GetContext() const
|
||||
{
|
||||
return this->_context;
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::SetContext(CGLContextObj context)
|
||||
{
|
||||
this->_context = context;
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::SetVideoBuffers(const uint32_t colorFormat,
|
||||
const void *videoBufferHead,
|
||||
const void *nativeBuffer0,
|
||||
const void *nativeBuffer1,
|
||||
const void *customBuffer0, const size_t customWidth0, const size_t customHeight0,
|
||||
const void *customBuffer1, const size_t customWidth1, const size_t customHeight1)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
|
||||
this->OGLVideoOutput::SetVideoBuffers(colorFormat,
|
||||
videoBufferHead,
|
||||
nativeBuffer0,
|
||||
nativeBuffer1,
|
||||
customBuffer0, customWidth0, customHeight0,
|
||||
customBuffer1, customWidth1, customHeight1);
|
||||
|
||||
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::SetupViewProperties()
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::SetupViewProperties();
|
||||
this->_FrameRenderAndFlush();
|
||||
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);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::SetHUDVisibility(const bool visibleState)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::SetHUDVisibility(visibleState);
|
||||
this->_FrameRenderAndFlush();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::SetHUDShowVideoFPS(const bool visibleState)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::SetHUDShowVideoFPS(visibleState);
|
||||
this->_FrameRenderAndFlush();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::SetHUDShowRender3DFPS(const bool visibleState)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::SetHUDShowRender3DFPS(visibleState);
|
||||
this->_FrameRenderAndFlush();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::SetHUDShowFrameIndex(const bool visibleState)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::SetHUDShowFrameIndex(visibleState);
|
||||
this->_FrameRenderAndFlush();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::SetHUDShowLagFrameCount(const bool visibleState)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::SetHUDShowLagFrameCount(visibleState);
|
||||
this->_FrameRenderAndFlush();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::SetHUDShowCPULoadAverage(const bool visibleState)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::SetHUDShowCPULoadAverage(visibleState);
|
||||
this->_FrameRenderAndFlush();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::SetHUDShowRTC(const bool visibleState)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::SetHUDShowRTC(visibleState);
|
||||
this->_FrameRenderAndFlush();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::FrameFinish()
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::FrameFinish();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::HandleGPUFrameEndEvent(const bool isMainSizeNative, const bool isTouchSizeNative)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->FrameLoadGPU(isMainSizeNative, isTouchSizeNative);
|
||||
this->FrameProcessGPU();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::HandleEmulatorFrameEndEvent(const NDSFrameInfo &frameInfo)
|
||||
{
|
||||
this->SetHUDInfo(frameInfo);
|
||||
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->FrameProcessHUD();
|
||||
this->_FrameRenderAndFlush();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::UpdateView()
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->_FrameRenderAndFlush();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
|
|
@ -437,50 +437,6 @@ public:
|
|||
virtual void FrameFinish();
|
||||
};
|
||||
|
||||
class MacOGLDisplayView : public OGLVideoOutput
|
||||
{
|
||||
protected:
|
||||
CGLContextObj _context;
|
||||
|
||||
void _FrameRenderAndFlush();
|
||||
|
||||
public:
|
||||
MacOGLDisplayView(CGLContextObj context);
|
||||
|
||||
CGLContextObj GetContext() const;
|
||||
void SetContext(CGLContextObj context);
|
||||
|
||||
virtual void SetVideoBuffers(const uint32_t colorFormat,
|
||||
const void *videoBufferHead,
|
||||
const void *nativeBuffer0,
|
||||
const void *nativeBuffer1,
|
||||
const void *customBuffer0, const size_t customWidth0, const size_t customHeight0,
|
||||
const void *customBuffer1, const size_t customWidth1, const size_t customHeight1);
|
||||
|
||||
virtual void SetUseVerticalSync(const bool useVerticalSync);
|
||||
virtual void SetScaleFactor(const double scaleFactor);
|
||||
|
||||
virtual void SetupViewProperties();
|
||||
|
||||
virtual void SetFiltersPreferGPU(const bool preferGPU);
|
||||
virtual void SetOutputFilter(const OutputFilterTypeID filterID);
|
||||
virtual void SetPixelScaler(const VideoFilterTypeID filterID);
|
||||
|
||||
virtual void SetHUDVisibility(const bool visibleState);
|
||||
virtual void SetHUDShowVideoFPS(const bool visibleState);
|
||||
virtual void SetHUDShowRender3DFPS(const bool visibleState);
|
||||
virtual void SetHUDShowFrameIndex(const bool visibleState);
|
||||
virtual void SetHUDShowLagFrameCount(const bool visibleState);
|
||||
virtual void SetHUDShowCPULoadAverage(const bool visibleState);
|
||||
virtual void SetHUDShowRTC(const bool visibleState);
|
||||
|
||||
virtual void FrameFinish();
|
||||
virtual void HandleGPUFrameEndEvent(const bool isMainSizeNative, const bool isTouchSizeNative);
|
||||
virtual void HandleEmulatorFrameEndEvent(const NDSFrameInfo &frameInfo);
|
||||
|
||||
virtual void UpdateView();
|
||||
};
|
||||
|
||||
OGLInfo* OGLInfoCreate_Legacy();
|
||||
|
||||
extern OGLInfo* (*OGLInfoCreate_Func)();
|
||||
|
|
|
@ -407,7 +407,7 @@ enum
|
|||
MESSAGE_RECEIVE_GPU_FRAME,
|
||||
MESSAGE_CHANGE_VIEW_PROPERTIES,
|
||||
MESSAGE_REDRAW_VIEW,
|
||||
MESSAGE_RELOAD_AND_REDRAW,
|
||||
MESSAGE_RELOAD_REPROCESS_REDRAW,
|
||||
MESSAGE_REPROCESS_AND_REDRAW,
|
||||
MESSAGE_SET_GPU_STATE_FLAGS,
|
||||
MESSAGE_SET_RENDER3D_METHOD,
|
||||
|
|
|
@ -95,45 +95,11 @@ struct NDSFrameInfo;
|
|||
|
||||
@class CocoaVideoFilter;
|
||||
|
||||
@protocol CocoaDSDisplayDelegate <NSObject>
|
||||
|
||||
@required
|
||||
- (void) doFinishFrame;
|
||||
- (void) doViewPropertiesChanged;
|
||||
|
||||
@end
|
||||
|
||||
@protocol CocoaDSDisplayVideoDelegate <CocoaDSDisplayDelegate>
|
||||
|
||||
@required
|
||||
- (void) doInitVideoOutput:(NSDictionary *)properties;
|
||||
|
||||
- (void) doSetVideoBuffersUsingFormat:(const uint32_t)colorFormat
|
||||
bufferHead:(const void *)videoBufferHead
|
||||
nativeBuffer0:(const void *)nativeBuffer0
|
||||
nativeBuffer1:(const void *)nativeBuffer1
|
||||
customBuffer0:(const void *)customBuffer0
|
||||
customWidth0:(const size_t)customWidth0
|
||||
customHeight0:(const size_t)customHeight0
|
||||
customBuffer1:(const void *)customBuffer1
|
||||
customWidth1:(const size_t)customWidth1
|
||||
customHeight1:(const size_t)customHeight1;
|
||||
|
||||
- (void) doLoadVideoFrameWithMainSizeNative:(bool)isMainSizeNative touchSizeNative:(bool)isTouchSizeNative;
|
||||
|
||||
- (void) doProcessVideoFrameWithInfo:(const NDSFrameInfo &)frameInfo;
|
||||
|
||||
@optional
|
||||
- (void) doRedraw;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface CocoaDSDisplay : CocoaDSOutput
|
||||
{
|
||||
id <CocoaDSDisplayDelegate> delegate;
|
||||
ClientDisplay3DView *_cdv;
|
||||
ClientDisplayViewProperties _intermediateViewProps;
|
||||
NSSize displaySize;
|
||||
ClientDisplayMode displayMode;
|
||||
|
||||
uint32_t _receivedFrameIndex;
|
||||
uint32_t _currentReceivedFrameIndex;
|
||||
|
@ -142,17 +108,19 @@ struct NDSFrameInfo;
|
|||
uint32_t _cpuLoadAvgARM9;
|
||||
uint32_t _cpuLoadAvgARM7;
|
||||
|
||||
OSSpinLock spinlockDisplayType;
|
||||
OSSpinLock spinlockReceivedFrameIndex;
|
||||
OSSpinLock spinlockCPULoadAverage;
|
||||
OSSpinLock spinlockViewProperties;
|
||||
}
|
||||
|
||||
@property (retain) id <CocoaDSDisplayDelegate> delegate;
|
||||
@property (assign, nonatomic) ClientDisplay3DView *clientDisplayView;
|
||||
@property (readonly) NSSize displaySize;
|
||||
@property (assign) ClientDisplayMode displayMode;
|
||||
|
||||
- (void) commitViewProperties:(const ClientDisplayViewProperties &)viewProps;
|
||||
|
||||
- (void) doReceiveGPUFrame;
|
||||
- (void) handleReceiveGPUFrame;
|
||||
- (void) handleChangeViewProperties;
|
||||
- (void) handleRequestScreenshot:(NSData *)fileURLStringData fileTypeData:(NSData *)fileTypeData;
|
||||
- (void) handleCopyToPasteboard;
|
||||
|
||||
|
@ -169,13 +137,35 @@ struct NDSFrameInfo;
|
|||
void *_videoBuffer;
|
||||
void *_nativeBuffer[2];
|
||||
void *_customBuffer[2];
|
||||
|
||||
OSSpinLock spinlockIsHUDVisible;
|
||||
OSSpinLock spinlockUseVerticalSync;
|
||||
OSSpinLock spinlockVideoFiltersPreferGPU;
|
||||
OSSpinLock spinlockOutputFilter;
|
||||
OSSpinLock spinlockSourceDeposterize;
|
||||
OSSpinLock spinlockPixelScaler;
|
||||
}
|
||||
|
||||
@property (readonly) BOOL canFilterOnGPU;
|
||||
@property (assign) BOOL isHUDVisible;
|
||||
@property (assign) BOOL isHUDVideoFPSVisible;
|
||||
@property (assign) BOOL isHUDRender3DFPSVisible;
|
||||
@property (assign) BOOL isHUDFrameIndexVisible;
|
||||
@property (assign) BOOL isHUDLagFrameCountVisible;
|
||||
@property (assign) BOOL isHUDCPULoadAverageVisible;
|
||||
@property (assign) BOOL isHUDRealTimeClockVisible;
|
||||
@property (assign) BOOL useVerticalSync;
|
||||
@property (assign) BOOL videoFiltersPreferGPU;
|
||||
@property (assign) BOOL sourceDeposterize;
|
||||
@property (assign) NSInteger outputFilter;
|
||||
@property (assign) NSInteger pixelScaler;
|
||||
|
||||
- (void) handleReceiveGPUFrame;
|
||||
- (void) handleRedrawView;
|
||||
- (void) handleReloadAndRedraw;
|
||||
- (void) handleReprocessAndRedraw;
|
||||
|
||||
- (void) resetVideoBuffers;
|
||||
- (void) setScaleFactor:(float)theScaleFactor;
|
||||
|
||||
@end
|
||||
|
|
|
@ -501,10 +501,8 @@
|
|||
|
||||
@implementation CocoaDSDisplay
|
||||
|
||||
@synthesize delegate;
|
||||
@dynamic clientDisplayView;
|
||||
@dynamic displaySize;
|
||||
@dynamic displayMode;
|
||||
|
||||
|
||||
- (id)init
|
||||
{
|
||||
|
@ -514,12 +512,11 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
spinlockDisplayType = OS_SPINLOCK_INIT;
|
||||
spinlockReceivedFrameIndex = OS_SPINLOCK_INIT;
|
||||
spinlockCPULoadAverage = OS_SPINLOCK_INIT;
|
||||
spinlockViewProperties = OS_SPINLOCK_INIT;
|
||||
|
||||
delegate = nil;
|
||||
displayMode = ClientDisplayMode_Dual;
|
||||
_cdv = NULL;
|
||||
|
||||
_receivedFrameIndex = 0;
|
||||
_currentReceivedFrameIndex = 0;
|
||||
|
@ -527,68 +524,43 @@
|
|||
|
||||
_cpuLoadAvgARM9 = 0;
|
||||
_cpuLoadAvgARM7 = 0;
|
||||
|
||||
[property setValue:[NSNumber numberWithInteger:displayMode] forKey:@"displayMode"];
|
||||
[property setValue:NSSTRING_DISPLAYMODE_MAIN forKey:@"displayModeString"];
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[self setDelegate:nil];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) setClientDisplayView:(ClientDisplay3DView *)clientDisplayView
|
||||
{
|
||||
_cdv = clientDisplayView;
|
||||
}
|
||||
|
||||
- (ClientDisplay3DView *) clientDisplayView
|
||||
{
|
||||
return _cdv;
|
||||
}
|
||||
|
||||
- (void) commitViewProperties:(const ClientDisplayViewProperties &)viewProps
|
||||
{
|
||||
OSSpinLockLock(&spinlockViewProperties);
|
||||
_intermediateViewProps = viewProps;
|
||||
OSSpinLockUnlock(&spinlockViewProperties);
|
||||
|
||||
[CocoaDSUtil messageSendOneWay:[self receivePort] msgID:MESSAGE_CHANGE_VIEW_PROPERTIES];
|
||||
}
|
||||
|
||||
- (NSSize) displaySize
|
||||
{
|
||||
pthread_rwlock_rdlock(self.rwlockProducer);
|
||||
NSSize size = NSMakeSize((CGFloat)GPU->GetCustomFramebufferWidth(), (displayMode == ClientDisplayMode_Dual) ? (CGFloat)(GPU->GetCustomFramebufferHeight() * 2): (CGFloat)GPU->GetCustomFramebufferHeight());
|
||||
NSSize size = NSMakeSize((CGFloat)GPU->GetCustomFramebufferWidth(), (_cdv->GetMode() == ClientDisplayMode_Dual) ? (CGFloat)(GPU->GetCustomFramebufferHeight() * 2): (CGFloat)GPU->GetCustomFramebufferHeight());
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
- (void) setDisplayMode:(ClientDisplayMode)displayModeID
|
||||
{
|
||||
NSString *newDispString = nil;
|
||||
|
||||
switch (displayModeID)
|
||||
{
|
||||
case ClientDisplayMode_Main:
|
||||
newDispString = NSSTRING_DISPLAYMODE_MAIN;
|
||||
break;
|
||||
|
||||
case ClientDisplayMode_Touch:
|
||||
newDispString = NSSTRING_DISPLAYMODE_TOUCH;
|
||||
break;
|
||||
|
||||
case ClientDisplayMode_Dual:
|
||||
newDispString = NSSTRING_DISPLAYMODE_DUAL;
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
OSSpinLockLock(&spinlockDisplayType);
|
||||
displayMode = displayModeID;
|
||||
[property setValue:[NSNumber numberWithInteger:displayModeID] forKey:@"displayMode"];
|
||||
[property setValue:newDispString forKey:@"displayModeString"];
|
||||
OSSpinLockUnlock(&spinlockDisplayType);
|
||||
}
|
||||
|
||||
- (ClientDisplayMode) displayMode
|
||||
{
|
||||
OSSpinLockLock(&spinlockDisplayType);
|
||||
ClientDisplayMode displayModeID = displayMode;
|
||||
OSSpinLockUnlock(&spinlockDisplayType);
|
||||
|
||||
return displayModeID;
|
||||
}
|
||||
|
||||
- (void) doReceiveGPUFrame
|
||||
{
|
||||
[CocoaDSUtil messageSendOneWay:self.receivePort msgID:MESSAGE_RECEIVE_GPU_FRAME];
|
||||
|
@ -632,7 +604,11 @@
|
|||
|
||||
- (void) handleChangeViewProperties
|
||||
{
|
||||
[(id<CocoaDSDisplayDelegate>)delegate doViewPropertiesChanged];
|
||||
OSSpinLockLock(&spinlockViewProperties);
|
||||
_cdv->CommitViewProperties(_intermediateViewProps);
|
||||
OSSpinLockUnlock(&spinlockViewProperties);
|
||||
|
||||
_cdv->SetupViewProperties();
|
||||
}
|
||||
|
||||
- (void) handleRequestScreenshot:(NSData *)fileURLStringData fileTypeData:(NSData *)fileTypeData
|
||||
|
@ -668,7 +644,7 @@
|
|||
|
||||
- (void) finishFrame
|
||||
{
|
||||
[(id<CocoaDSDisplayDelegate>)delegate doFinishFrame];
|
||||
_cdv->FrameFinish();
|
||||
}
|
||||
|
||||
- (void) takeFrameCount
|
||||
|
@ -713,10 +689,8 @@
|
|||
- (NSBitmapImageRep *) bitmapImageRep
|
||||
{
|
||||
const NDSDisplayInfo &dispInfo = GPU->GetDisplayInfo();
|
||||
const NSInteger dispMode = [self displayMode];
|
||||
|
||||
NSUInteger w = (NSUInteger)dispInfo.customWidth;
|
||||
NSUInteger h = (dispMode == ClientDisplayMode_Dual) ? (NSUInteger)(dispInfo.customHeight * 2) : (NSUInteger)dispInfo.customHeight;
|
||||
NSUInteger h = (_cdv->GetMode() == ClientDisplayMode_Dual) ? (NSUInteger)(dispInfo.customHeight * 2) : (NSUInteger)dispInfo.customHeight;
|
||||
|
||||
NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
|
||||
pixelsWide:w
|
||||
|
@ -768,6 +742,20 @@
|
|||
|
||||
@implementation CocoaDSDisplayVideo
|
||||
|
||||
@dynamic canFilterOnGPU;
|
||||
@dynamic isHUDVisible;
|
||||
@dynamic isHUDVideoFPSVisible;
|
||||
@dynamic isHUDRender3DFPSVisible;
|
||||
@dynamic isHUDFrameIndexVisible;
|
||||
@dynamic isHUDLagFrameCountVisible;
|
||||
@dynamic isHUDCPULoadAverageVisible;
|
||||
@dynamic isHUDRealTimeClockVisible;
|
||||
@dynamic useVerticalSync;
|
||||
@dynamic videoFiltersPreferGPU;
|
||||
@dynamic sourceDeposterize;
|
||||
@dynamic outputFilter;
|
||||
@dynamic pixelScaler;
|
||||
|
||||
- (id)init
|
||||
{
|
||||
self = [super init];
|
||||
|
@ -781,11 +769,14 @@
|
|||
_nativeBuffer[NDSDisplayID_Touch] = NULL;
|
||||
_customBuffer[NDSDisplayID_Main] = NULL;
|
||||
_customBuffer[NDSDisplayID_Touch] = NULL;
|
||||
[self resetVideoBuffers];
|
||||
|
||||
[property setValue:[NSNumber numberWithInteger:(NSInteger)VideoFilterTypeID_None] forKey:@"videoFilterType"];
|
||||
[property setValue:[CocoaVideoFilter typeStringByID:VideoFilterTypeID_None] forKey:@"videoFilterTypeString"];
|
||||
|
||||
spinlockIsHUDVisible = OS_SPINLOCK_INIT;
|
||||
spinlockUseVerticalSync = OS_SPINLOCK_INIT;
|
||||
spinlockVideoFiltersPreferGPU = OS_SPINLOCK_INIT;
|
||||
spinlockOutputFilter = OS_SPINLOCK_INIT;
|
||||
spinlockSourceDeposterize = OS_SPINLOCK_INIT;
|
||||
spinlockPixelScaler = OS_SPINLOCK_INIT;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -800,13 +791,201 @@
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) runThread:(id)object
|
||||
- (BOOL) canFilterOnGPU
|
||||
{
|
||||
NSAutoreleasePool *tempPool = [[NSAutoreleasePool alloc] init];
|
||||
[(id<CocoaDSDisplayVideoDelegate>)delegate doInitVideoOutput:self.property];
|
||||
[tempPool release];
|
||||
return (_cdv->CanFilterOnGPU()) ? YES : NO;
|
||||
}
|
||||
|
||||
- (void) setIsHUDVisible:(BOOL)theState
|
||||
{
|
||||
OSSpinLockLock(&spinlockIsHUDVisible);
|
||||
_cdv->SetHUDVisibility((theState) ? true : false);
|
||||
OSSpinLockUnlock(&spinlockIsHUDVisible);
|
||||
}
|
||||
|
||||
- (BOOL) isHUDVisible
|
||||
{
|
||||
OSSpinLockLock(&spinlockIsHUDVisible);
|
||||
const BOOL theState = (_cdv->GetHUDVisibility()) ? YES : NO;
|
||||
OSSpinLockUnlock(&spinlockIsHUDVisible);
|
||||
|
||||
[super runThread:object];
|
||||
return theState;
|
||||
}
|
||||
|
||||
- (void) setIsHUDVideoFPSVisible:(BOOL)theState
|
||||
{
|
||||
OSSpinLockLock(&spinlockIsHUDVisible);
|
||||
_cdv->SetHUDShowVideoFPS((theState) ? true : false);
|
||||
OSSpinLockUnlock(&spinlockIsHUDVisible);
|
||||
}
|
||||
|
||||
- (BOOL) isHUDVideoFPSVisible
|
||||
{
|
||||
OSSpinLockLock(&spinlockIsHUDVisible);
|
||||
const BOOL theState = (_cdv->GetHUDShowVideoFPS()) ? YES : NO;
|
||||
OSSpinLockUnlock(&spinlockIsHUDVisible);
|
||||
|
||||
return theState;
|
||||
}
|
||||
|
||||
- (void) setIsHUDRender3DFPSVisible:(BOOL)theState
|
||||
{
|
||||
OSSpinLockLock(&spinlockIsHUDVisible);
|
||||
_cdv->SetHUDShowRender3DFPS((theState) ? true : false);
|
||||
OSSpinLockUnlock(&spinlockIsHUDVisible);
|
||||
}
|
||||
|
||||
- (BOOL) isHUDRender3DFPSVisible
|
||||
{
|
||||
OSSpinLockLock(&spinlockIsHUDVisible);
|
||||
const BOOL theState = (_cdv->GetHUDShowRender3DFPS()) ? YES : NO;
|
||||
OSSpinLockUnlock(&spinlockIsHUDVisible);
|
||||
|
||||
return theState;
|
||||
}
|
||||
|
||||
- (void) setIsHUDFrameIndexVisible:(BOOL)theState
|
||||
{
|
||||
OSSpinLockLock(&spinlockIsHUDVisible);
|
||||
_cdv->SetHUDShowFrameIndex((theState) ? true : false);
|
||||
OSSpinLockUnlock(&spinlockIsHUDVisible);
|
||||
}
|
||||
|
||||
- (BOOL) isHUDFrameIndexVisible
|
||||
{
|
||||
OSSpinLockLock(&spinlockIsHUDVisible);
|
||||
const BOOL theState = (_cdv->GetHUDShowFrameIndex()) ? YES : NO;
|
||||
OSSpinLockUnlock(&spinlockIsHUDVisible);
|
||||
|
||||
return theState;
|
||||
}
|
||||
|
||||
- (void) setIsHUDLagFrameCountVisible:(BOOL)theState
|
||||
{
|
||||
OSSpinLockLock(&spinlockIsHUDVisible);
|
||||
_cdv->SetHUDShowLagFrameCount((theState) ? true : false);
|
||||
OSSpinLockUnlock(&spinlockIsHUDVisible);
|
||||
}
|
||||
|
||||
- (BOOL) isHUDLagFrameCountVisible
|
||||
{
|
||||
OSSpinLockLock(&spinlockIsHUDVisible);
|
||||
const BOOL theState = (_cdv->GetHUDShowLagFrameCount()) ? YES : NO;
|
||||
OSSpinLockUnlock(&spinlockIsHUDVisible);
|
||||
|
||||
return theState;
|
||||
}
|
||||
|
||||
- (void) setIsHUDCPULoadAverageVisible:(BOOL)theState
|
||||
{
|
||||
OSSpinLockLock(&spinlockIsHUDVisible);
|
||||
_cdv->SetHUDShowCPULoadAverage((theState) ? true : false);
|
||||
OSSpinLockUnlock(&spinlockIsHUDVisible);
|
||||
}
|
||||
|
||||
- (BOOL) isHUDCPULoadAverageVisible
|
||||
{
|
||||
OSSpinLockLock(&spinlockIsHUDVisible);
|
||||
const BOOL theState = (_cdv->GetHUDShowCPULoadAverage()) ? YES : NO;
|
||||
OSSpinLockUnlock(&spinlockIsHUDVisible);
|
||||
|
||||
return theState;
|
||||
}
|
||||
|
||||
- (void) setIsHUDRealTimeClockVisible:(BOOL)theState
|
||||
{
|
||||
OSSpinLockLock(&spinlockIsHUDVisible);
|
||||
_cdv->SetHUDShowRTC((theState) ? true : false);
|
||||
OSSpinLockUnlock(&spinlockIsHUDVisible);
|
||||
}
|
||||
|
||||
- (BOOL) isHUDRealTimeClockVisible
|
||||
{
|
||||
OSSpinLockLock(&spinlockIsHUDVisible);
|
||||
const BOOL theState = (_cdv->GetHUDShowRTC()) ? YES : NO;
|
||||
OSSpinLockUnlock(&spinlockIsHUDVisible);
|
||||
|
||||
return theState;
|
||||
}
|
||||
|
||||
- (void) setUseVerticalSync:(BOOL)theState
|
||||
{
|
||||
OSSpinLockLock(&spinlockUseVerticalSync);
|
||||
_cdv->SetUseVerticalSync((theState) ? true : false);
|
||||
OSSpinLockUnlock(&spinlockUseVerticalSync);
|
||||
}
|
||||
|
||||
- (BOOL) useVerticalSync
|
||||
{
|
||||
OSSpinLockLock(&spinlockUseVerticalSync);
|
||||
const BOOL theState = (_cdv->GetUseVerticalSync()) ? YES : NO;
|
||||
OSSpinLockUnlock(&spinlockUseVerticalSync);
|
||||
|
||||
return theState;
|
||||
}
|
||||
|
||||
- (void) setVideoFiltersPreferGPU:(BOOL)theState
|
||||
{
|
||||
OSSpinLockLock(&spinlockVideoFiltersPreferGPU);
|
||||
_cdv->SetFiltersPreferGPU((theState) ? true : false);
|
||||
OSSpinLockUnlock(&spinlockVideoFiltersPreferGPU);
|
||||
}
|
||||
|
||||
- (BOOL) videoFiltersPreferGPU
|
||||
{
|
||||
OSSpinLockLock(&spinlockVideoFiltersPreferGPU);
|
||||
const BOOL theState = (_cdv->GetFiltersPreferGPU()) ? YES : NO;
|
||||
OSSpinLockUnlock(&spinlockVideoFiltersPreferGPU);
|
||||
|
||||
return theState;
|
||||
}
|
||||
|
||||
- (void) setSourceDeposterize:(BOOL)theState
|
||||
{
|
||||
OSSpinLockLock(&spinlockSourceDeposterize);
|
||||
_cdv->SetSourceDeposterize((theState) ? true : false);
|
||||
OSSpinLockUnlock(&spinlockSourceDeposterize);
|
||||
}
|
||||
|
||||
- (BOOL) sourceDeposterize
|
||||
{
|
||||
OSSpinLockLock(&spinlockSourceDeposterize);
|
||||
const BOOL theState = (_cdv->GetSourceDeposterize()) ? YES : NO;
|
||||
OSSpinLockUnlock(&spinlockSourceDeposterize);
|
||||
|
||||
return theState;
|
||||
}
|
||||
|
||||
- (void) setOutputFilter:(NSInteger)filterID
|
||||
{
|
||||
OSSpinLockLock(&spinlockOutputFilter);
|
||||
_cdv->SetOutputFilter((OutputFilterTypeID)filterID);
|
||||
OSSpinLockUnlock(&spinlockOutputFilter);
|
||||
}
|
||||
|
||||
- (NSInteger) outputFilter
|
||||
{
|
||||
OSSpinLockLock(&spinlockOutputFilter);
|
||||
const NSInteger filterID = _cdv->GetOutputFilter();
|
||||
OSSpinLockUnlock(&spinlockOutputFilter);
|
||||
|
||||
return filterID;
|
||||
}
|
||||
|
||||
- (void) setPixelScaler:(NSInteger)filterID
|
||||
{
|
||||
OSSpinLockLock(&spinlockPixelScaler);
|
||||
_cdv->SetPixelScaler((VideoFilterTypeID)filterID);
|
||||
OSSpinLockUnlock(&spinlockPixelScaler);
|
||||
}
|
||||
|
||||
- (NSInteger) pixelScaler
|
||||
{
|
||||
OSSpinLockLock(&spinlockPixelScaler);
|
||||
const NSInteger filterID = _cdv->GetPixelScaler();
|
||||
OSSpinLockUnlock(&spinlockPixelScaler);
|
||||
|
||||
return filterID;
|
||||
}
|
||||
|
||||
- (void)handlePortMessage:(NSPortMessage *)portMessage
|
||||
|
@ -815,7 +994,7 @@
|
|||
|
||||
switch (message)
|
||||
{
|
||||
case MESSAGE_RELOAD_AND_REDRAW:
|
||||
case MESSAGE_RELOAD_REPROCESS_REDRAW:
|
||||
[self handleReloadAndRedraw];
|
||||
break;
|
||||
|
||||
|
@ -853,7 +1032,7 @@
|
|||
|
||||
rtcGetTimeAsString(frameInfo.rtcString);
|
||||
|
||||
[(id<CocoaDSDisplayVideoDelegate>)delegate doProcessVideoFrameWithInfo:frameInfo];
|
||||
_cdv->HandleEmulatorFrameEndEvent(frameInfo);
|
||||
}
|
||||
|
||||
- (void) handleReceiveGPUFrame
|
||||
|
@ -891,17 +1070,12 @@
|
|||
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
|
||||
[(id<CocoaDSDisplayVideoDelegate>)delegate doLoadVideoFrameWithMainSizeNative:isMainSizeNative touchSizeNative:isTouchSizeNative];
|
||||
_cdv->HandleGPUFrameEndEvent(isMainSizeNative, isTouchSizeNative);
|
||||
}
|
||||
|
||||
- (void) handleRedrawView
|
||||
{
|
||||
if (delegate == nil || ![delegate respondsToSelector:@selector(doRedraw)])
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
[(id<CocoaDSDisplayVideoDelegate>)delegate doRedraw];
|
||||
_cdv->UpdateView();
|
||||
}
|
||||
|
||||
- (void) handleReloadAndRedraw
|
||||
|
@ -922,16 +1096,16 @@
|
|||
void *oldVideoBuffer = _videoBuffer;
|
||||
uint8_t *newVideoBuffer = (uint8_t *)malloc_alignedCacheLine( ((GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT) + (dispInfo.customWidth * dispInfo.customHeight)) * 2 * dispInfo.pixelBytes );
|
||||
|
||||
[(id<CocoaDSDisplayVideoDelegate>)delegate doSetVideoBuffersUsingFormat:dispInfo.colorFormat
|
||||
bufferHead:newVideoBuffer
|
||||
nativeBuffer0:newVideoBuffer
|
||||
nativeBuffer1:newVideoBuffer + (GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * dispInfo.pixelBytes)
|
||||
customBuffer0:newVideoBuffer + (GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2 * dispInfo.pixelBytes)
|
||||
customWidth0:dispInfo.customWidth
|
||||
customHeight0:dispInfo.customHeight
|
||||
customBuffer1:newVideoBuffer + (GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2 * dispInfo.pixelBytes) + (dispInfo.customWidth * dispInfo.customHeight * dispInfo.pixelBytes)
|
||||
customWidth1:dispInfo.customWidth
|
||||
customHeight1:dispInfo.customHeight];
|
||||
_cdv->SetVideoBuffers(dispInfo.colorFormat,
|
||||
newVideoBuffer,
|
||||
newVideoBuffer,
|
||||
newVideoBuffer + (GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * dispInfo.pixelBytes),
|
||||
newVideoBuffer + (GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2 * dispInfo.pixelBytes),
|
||||
dispInfo.customWidth,
|
||||
dispInfo.customHeight,
|
||||
newVideoBuffer + (GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2 * dispInfo.pixelBytes) + (dispInfo.customWidth * dispInfo.customHeight * dispInfo.pixelBytes),
|
||||
dispInfo.customWidth,
|
||||
dispInfo.customHeight);
|
||||
|
||||
_videoBuffer = newVideoBuffer;
|
||||
_nativeBuffer[NDSDisplayID_Main] = newVideoBuffer;
|
||||
|
@ -942,4 +1116,11 @@
|
|||
free_aligned(oldVideoBuffer);
|
||||
}
|
||||
|
||||
- (void) setScaleFactor:(float)theScaleFactor
|
||||
{
|
||||
OSSpinLockLock(&spinlockIsHUDVisible);
|
||||
_cdv->SetScaleFactor(theScaleFactor);
|
||||
OSSpinLockUnlock(&spinlockIsHUDVisible);
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -35,27 +35,18 @@ class OGLVideoOutput;
|
|||
{ }
|
||||
@end
|
||||
|
||||
@interface DisplayView : NSView <CocoaDSDisplayVideoDelegate, InputHIDManagerTarget>
|
||||
@interface DisplayView : NSView <InputHIDManagerTarget>
|
||||
{
|
||||
InputManager *inputManager;
|
||||
CocoaDSDisplayVideo *cdsVideoOutput;
|
||||
ClientDisplay3DView *_cdv;
|
||||
ClientDisplayViewProperties _intermediateViewProps;
|
||||
|
||||
OSSpinLock spinlockIsHUDVisible;
|
||||
OSSpinLock spinlockUseVerticalSync;
|
||||
OSSpinLock spinlockVideoFiltersPreferGPU;
|
||||
OSSpinLock spinlockOutputFilter;
|
||||
OSSpinLock spinlockSourceDeposterize;
|
||||
OSSpinLock spinlockPixelScaler;
|
||||
|
||||
OSSpinLock spinlockViewProperties;
|
||||
|
||||
// OpenGL context
|
||||
NSOpenGLContext *context;
|
||||
CGLContextObj cglDisplayContext;
|
||||
NSOpenGLContext *localContext;
|
||||
}
|
||||
|
||||
@property (retain) InputManager *inputManager;
|
||||
@property (retain) CocoaDSDisplayVideo *cdsVideoOutput;
|
||||
@property (readonly, nonatomic) ClientDisplay3DView *clientDisplay3DView;
|
||||
@property (readonly) BOOL canUseShaderBasedFilters;
|
||||
@property (assign) BOOL isHUDVisible;
|
||||
@property (assign) BOOL isHUDVideoFPSVisible;
|
||||
|
@ -70,8 +61,6 @@ class OGLVideoOutput;
|
|||
@property (assign) NSInteger outputFilter;
|
||||
@property (assign) NSInteger pixelScaler;
|
||||
|
||||
- (void) setScaleFactor:(float)theScaleFactor;
|
||||
- (void) commitViewProperties:(const ClientDisplayViewProperties &)viewProps;
|
||||
- (BOOL) handleKeyPress:(NSEvent *)theEvent keyPressed:(BOOL)keyPressed;
|
||||
- (BOOL) handleMouseButton:(NSEvent *)theEvent buttonPressed:(BOOL)buttonPressed;
|
||||
- (void) requestScreenshot:(NSURL *)fileURL fileType:(NSBitmapImageFileType)fileType;
|
||||
|
@ -127,7 +116,7 @@ class OGLVideoOutput;
|
|||
@property (readonly) IBOutlet NSButton *microphoneMuteButton;
|
||||
|
||||
@property (retain) EmuControllerDelegate *emuControl;
|
||||
@property (assign) CocoaDSDisplayVideo *cdsVideoOutput;
|
||||
@property (retain) CocoaDSDisplayVideo *cdsVideoOutput;
|
||||
@property (assign) NSScreen *assignedScreen;
|
||||
@property (retain) NSWindow *masterWindow;
|
||||
|
||||
|
|
|
@ -26,11 +26,7 @@
|
|||
#import "cocoa_videofilter.h"
|
||||
#import "cocoa_util.h"
|
||||
|
||||
#ifdef MAC_OS_X_VERSION_10_7
|
||||
#include "OGLDisplayOutput_3_2.h"
|
||||
#else
|
||||
#include "OGLDisplayOutput.h"
|
||||
#endif
|
||||
#include "MacOGLDisplayView.h"
|
||||
|
||||
#include <Carbon/Carbon.h>
|
||||
|
||||
|
@ -140,6 +136,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
|
|||
[self setEmuControl:nil];
|
||||
[self setAssignedScreen:nil];
|
||||
[self setMasterWindow:nil];
|
||||
[self setCdsVideoOutput:nil];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
@ -194,7 +191,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
|
|||
|
||||
if ([self isFullScreen])
|
||||
{
|
||||
[view commitViewProperties:_localViewProps];
|
||||
[[self cdsVideoOutput] commitViewProperties:_localViewProps];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -209,7 +206,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
|
|||
// display view to update itself.
|
||||
if (oldBounds.width == newBounds.width && oldBounds.height == newBounds.height)
|
||||
{
|
||||
[view commitViewProperties:_localViewProps];
|
||||
[[self cdsVideoOutput] commitViewProperties:_localViewProps];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -234,7 +231,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
|
|||
}
|
||||
else
|
||||
{
|
||||
[view commitViewProperties:_localViewProps];
|
||||
[[self cdsVideoOutput] commitViewProperties:_localViewProps];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,7 +251,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
|
|||
{
|
||||
if ([self isFullScreen])
|
||||
{
|
||||
[view commitViewProperties:_localViewProps];
|
||||
[[self cdsVideoOutput] commitViewProperties:_localViewProps];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -271,7 +268,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
|
|||
- (void) setDisplayOrder:(NSInteger)theOrder
|
||||
{
|
||||
_localViewProps.order = (ClientDisplayOrder)theOrder;
|
||||
[view commitViewProperties:_localViewProps];
|
||||
[[self cdsVideoOutput] commitViewProperties:_localViewProps];
|
||||
}
|
||||
|
||||
- (NSInteger) displayOrder
|
||||
|
@ -298,7 +295,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
|
|||
case ClientDisplayLayout_Hybrid_16_9:
|
||||
case ClientDisplayLayout_Hybrid_16_10:
|
||||
default:
|
||||
[view commitViewProperties:_localViewProps];
|
||||
[[self cdsVideoOutput] commitViewProperties:_localViewProps];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -308,7 +305,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
|
|||
{
|
||||
case ClientDisplayLayout_Hybrid_16_9:
|
||||
case ClientDisplayLayout_Hybrid_16_10:
|
||||
[view commitViewProperties:_localViewProps];
|
||||
[[self cdsVideoOutput] commitViewProperties:_localViewProps];
|
||||
break;
|
||||
|
||||
case ClientDisplayLayout_Horizontal:
|
||||
|
@ -331,7 +328,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
|
|||
- (void) setVideoFiltersPreferGPU:(BOOL)theState
|
||||
{
|
||||
[[self view] setVideoFiltersPreferGPU:theState];
|
||||
[CocoaDSUtil messageSendOneWay:[[self cdsVideoOutput] receivePort] msgID:MESSAGE_RELOAD_AND_REDRAW];
|
||||
[CocoaDSUtil messageSendOneWay:[[self cdsVideoOutput] receivePort] msgID:MESSAGE_RELOAD_REPROCESS_REDRAW];
|
||||
}
|
||||
|
||||
- (BOOL) videoFiltersPreferGPU
|
||||
|
@ -342,7 +339,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
|
|||
- (void) setVideoSourceDeposterize:(BOOL)theState
|
||||
{
|
||||
[[self view] setSourceDeposterize:theState];
|
||||
[CocoaDSUtil messageSendOneWay:[[self cdsVideoOutput] receivePort] msgID:MESSAGE_RELOAD_AND_REDRAW];
|
||||
[CocoaDSUtil messageSendOneWay:[[self cdsVideoOutput] receivePort] msgID:MESSAGE_RELOAD_REPROCESS_REDRAW];
|
||||
}
|
||||
|
||||
- (BOOL) videoSourceDeposterize
|
||||
|
@ -364,7 +361,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
|
|||
- (void) setVideoPixelScaler:(NSInteger)filterID
|
||||
{
|
||||
[[self view] setPixelScaler:filterID];
|
||||
[CocoaDSUtil messageSendOneWay:[[self cdsVideoOutput] receivePort] msgID:MESSAGE_RELOAD_AND_REDRAW];
|
||||
[CocoaDSUtil messageSendOneWay:[[self cdsVideoOutput] receivePort] msgID:MESSAGE_RELOAD_REPROCESS_REDRAW];
|
||||
}
|
||||
|
||||
- (NSInteger) videoPixelScaler
|
||||
|
@ -504,7 +501,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
|
|||
// window size changed or not.
|
||||
if (oldBounds.width == newBounds.width && oldBounds.height == newBounds.height)
|
||||
{
|
||||
[view commitViewProperties:_localViewProps];
|
||||
[[self cdsVideoOutput] commitViewProperties:_localViewProps];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1276,22 +1273,24 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
|
|||
scaleFactor = [[self window] backingScaleFactor];
|
||||
}
|
||||
#endif
|
||||
[view setScaleFactor:scaleFactor];
|
||||
|
||||
// Set up some custom UI elements.
|
||||
[microphoneGainMenuItem setView:microphoneGainControlView];
|
||||
[outputVolumeMenuItem setView:outputVolumeControlView];
|
||||
|
||||
// Set up the video output thread.
|
||||
cdsVideoOutput = [[CocoaDSDisplayVideo alloc] init];
|
||||
[cdsVideoOutput setDelegate:view];
|
||||
[cdsVideoOutput resetVideoBuffers];
|
||||
CocoaDSDisplayVideo *newDisplayOutput = [[CocoaDSDisplayVideo alloc] init];
|
||||
[newDisplayOutput setClientDisplayView:[view clientDisplay3DView]];
|
||||
[newDisplayOutput setScaleFactor:scaleFactor];
|
||||
[newDisplayOutput resetVideoBuffers];
|
||||
[self setCdsVideoOutput:newDisplayOutput];
|
||||
[view setCdsVideoOutput:newDisplayOutput];
|
||||
|
||||
// Add the video thread to the output list.
|
||||
[emuControl addOutputToCore:cdsVideoOutput];
|
||||
[emuControl addOutputToCore:newDisplayOutput];
|
||||
|
||||
[NSThread detachNewThreadSelector:@selector(runThread:) toTarget:cdsVideoOutput withObject:nil];
|
||||
while ([cdsVideoOutput thread] == nil)
|
||||
[NSThread detachNewThreadSelector:@selector(runThread:) toTarget:newDisplayOutput withObject:nil];
|
||||
while ([newDisplayOutput thread] == nil)
|
||||
{
|
||||
[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.01]];
|
||||
}
|
||||
|
@ -1375,8 +1374,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
|
|||
const NSRect frameRect = newFrame;
|
||||
const NSRect contentRect = [window contentRectForFrameRect:frameRect];
|
||||
|
||||
// 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 checkHeight = _localViewProps.normalHeight;
|
||||
ClientDisplayView::ConvertNormalToTransformedBounds(1.0, _localViewProps.rotation, checkWidth, checkHeight);
|
||||
|
@ -1576,6 +1574,8 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
|
|||
@implementation DisplayView
|
||||
|
||||
@synthesize inputManager;
|
||||
@synthesize cdsVideoOutput;
|
||||
@dynamic clientDisplay3DView;
|
||||
@dynamic canUseShaderBasedFilters;
|
||||
@dynamic isHUDVisible;
|
||||
@dynamic isHUDVideoFPSVisible;
|
||||
|
@ -1606,295 +1606,161 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
|
|||
#endif
|
||||
|
||||
inputManager = nil;
|
||||
cdsVideoOutput = nil;
|
||||
|
||||
// Initialize the OpenGL context
|
||||
NSOpenGLPixelFormatAttribute attributes[] = {
|
||||
NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute)24,
|
||||
NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute)8,
|
||||
NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)0,
|
||||
NSOpenGLPFAStencilSize, (NSOpenGLPixelFormatAttribute)0,
|
||||
NSOpenGLPFADoubleBuffer,
|
||||
(NSOpenGLPixelFormatAttribute)0, (NSOpenGLPixelFormatAttribute)0,
|
||||
(NSOpenGLPixelFormatAttribute)0 };
|
||||
|
||||
#ifdef _OGLDISPLAYOUTPUT_3_2_H_
|
||||
// If we can support a 3.2 Core Profile context, then request that in our
|
||||
// pixel format attributes.
|
||||
if (IsOSXVersionSupported(10, 7, 0))
|
||||
{
|
||||
attributes[9] = NSOpenGLPFAOpenGLProfile;
|
||||
attributes[10] = NSOpenGLProfileVersion3_2Core;
|
||||
OGLInfoCreate_Func = &OGLInfoCreate_3_2;
|
||||
}
|
||||
#endif
|
||||
|
||||
NSOpenGLPixelFormat *format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
|
||||
if (format == nil)
|
||||
{
|
||||
// If we can't get a 3.2 Core Profile context, then switch to using a
|
||||
// legacy context instead.
|
||||
attributes[9] = (NSOpenGLPixelFormatAttribute)0;
|
||||
attributes[10] = (NSOpenGLPixelFormatAttribute)0;
|
||||
OGLInfoCreate_Func = &OGLInfoCreate_Legacy;
|
||||
format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
|
||||
}
|
||||
|
||||
context = [[NSOpenGLContext alloc] initWithFormat:format shareContext:nil];
|
||||
[format release];
|
||||
cglDisplayContext = (CGLContextObj)[context CGLContextObj];
|
||||
|
||||
CGLContextObj prevContext = CGLGetCurrentContext();
|
||||
CGLSetCurrentContext(cglDisplayContext);
|
||||
_cdv = new MacOGLDisplayView(cglDisplayContext);
|
||||
_cdv = new MacOGLDisplayView();
|
||||
_cdv->Init();
|
||||
|
||||
NSString *fontPath = [[NSBundle mainBundle] pathForResource:@"SourceSansPro-Bold" ofType:@"otf"];
|
||||
_cdv->SetHUDFontUsingPath([fontPath cStringUsingEncoding:NSUTF8StringEncoding]);
|
||||
|
||||
CGLSetCurrentContext(prevContext);
|
||||
|
||||
spinlockIsHUDVisible = OS_SPINLOCK_INIT;
|
||||
spinlockUseVerticalSync = OS_SPINLOCK_INIT;
|
||||
spinlockVideoFiltersPreferGPU = OS_SPINLOCK_INIT;
|
||||
spinlockOutputFilter = OS_SPINLOCK_INIT;
|
||||
spinlockSourceDeposterize = OS_SPINLOCK_INIT;
|
||||
spinlockPixelScaler = OS_SPINLOCK_INIT;
|
||||
|
||||
spinlockViewProperties = OS_SPINLOCK_INIT;
|
||||
localContext = [[NSOpenGLContext alloc] initWithCGLContextObj:((MacOGLDisplayView *)_cdv)->GetContext()];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
CGLContextObj prevContext = CGLGetCurrentContext();
|
||||
CGLSetCurrentContext(cglDisplayContext);
|
||||
delete _cdv;
|
||||
CGLSetCurrentContext(prevContext);
|
||||
|
||||
[self setInputManager:nil];
|
||||
[context clearDrawable];
|
||||
[context release];
|
||||
[self setCdsVideoOutput:nil];
|
||||
[localContext clearDrawable];
|
||||
[localContext release];
|
||||
|
||||
delete _cdv;
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
#pragma mark Dynamic Property Methods
|
||||
|
||||
- (ClientDisplay3DView *) clientDisplay3DView
|
||||
{
|
||||
return _cdv;
|
||||
}
|
||||
|
||||
- (BOOL) canUseShaderBasedFilters
|
||||
{
|
||||
return (_cdv->CanFilterOnGPU()) ? YES : NO;
|
||||
return [[self cdsVideoOutput] canFilterOnGPU];
|
||||
}
|
||||
|
||||
- (void) setIsHUDVisible:(BOOL)theState
|
||||
{
|
||||
OSSpinLockLock(&spinlockIsHUDVisible);
|
||||
_cdv->SetHUDVisibility((theState) ? true : false);
|
||||
OSSpinLockUnlock(&spinlockIsHUDVisible);
|
||||
[[self cdsVideoOutput] setIsHUDVisible:theState];
|
||||
}
|
||||
|
||||
- (BOOL) isHUDVisible
|
||||
{
|
||||
OSSpinLockLock(&spinlockIsHUDVisible);
|
||||
const BOOL theState = (_cdv->GetHUDVisibility()) ? YES : NO;
|
||||
OSSpinLockUnlock(&spinlockIsHUDVisible);
|
||||
|
||||
return theState;
|
||||
return [[self cdsVideoOutput] isHUDVisible];
|
||||
}
|
||||
|
||||
- (void) setIsHUDVideoFPSVisible:(BOOL)theState
|
||||
{
|
||||
OSSpinLockLock(&spinlockIsHUDVisible);
|
||||
_cdv->SetHUDShowVideoFPS((theState) ? true : false);
|
||||
OSSpinLockUnlock(&spinlockIsHUDVisible);
|
||||
[[self cdsVideoOutput] setIsHUDVideoFPSVisible:theState];
|
||||
}
|
||||
|
||||
- (BOOL) isHUDVideoFPSVisible
|
||||
{
|
||||
OSSpinLockLock(&spinlockIsHUDVisible);
|
||||
const BOOL theState = (_cdv->GetHUDShowVideoFPS()) ? YES : NO;
|
||||
OSSpinLockUnlock(&spinlockIsHUDVisible);
|
||||
|
||||
return theState;
|
||||
return [[self cdsVideoOutput] isHUDVideoFPSVisible];
|
||||
}
|
||||
|
||||
- (void) setIsHUDRender3DFPSVisible:(BOOL)theState
|
||||
{
|
||||
OSSpinLockLock(&spinlockIsHUDVisible);
|
||||
_cdv->SetHUDShowRender3DFPS((theState) ? true : false);
|
||||
OSSpinLockUnlock(&spinlockIsHUDVisible);
|
||||
[[self cdsVideoOutput] setIsHUDRender3DFPSVisible:theState];
|
||||
}
|
||||
|
||||
- (BOOL) isHUDRender3DFPSVisible
|
||||
{
|
||||
OSSpinLockLock(&spinlockIsHUDVisible);
|
||||
const BOOL theState = (_cdv->GetHUDShowRender3DFPS()) ? YES : NO;
|
||||
OSSpinLockUnlock(&spinlockIsHUDVisible);
|
||||
|
||||
return theState;
|
||||
return [[self cdsVideoOutput] isHUDRender3DFPSVisible];
|
||||
}
|
||||
|
||||
- (void) setIsHUDFrameIndexVisible:(BOOL)theState
|
||||
{
|
||||
OSSpinLockLock(&spinlockIsHUDVisible);
|
||||
_cdv->SetHUDShowFrameIndex((theState) ? true : false);
|
||||
OSSpinLockUnlock(&spinlockIsHUDVisible);
|
||||
[[self cdsVideoOutput] setIsHUDFrameIndexVisible:theState];
|
||||
}
|
||||
|
||||
- (BOOL) isHUDFrameIndexVisible
|
||||
{
|
||||
OSSpinLockLock(&spinlockIsHUDVisible);
|
||||
const BOOL theState = (_cdv->GetHUDShowFrameIndex()) ? YES : NO;
|
||||
OSSpinLockUnlock(&spinlockIsHUDVisible);
|
||||
|
||||
return theState;
|
||||
return [[self cdsVideoOutput] isHUDFrameIndexVisible];
|
||||
}
|
||||
|
||||
- (void) setIsHUDLagFrameCountVisible:(BOOL)theState
|
||||
{
|
||||
OSSpinLockLock(&spinlockIsHUDVisible);
|
||||
_cdv->SetHUDShowLagFrameCount((theState) ? true : false);
|
||||
OSSpinLockUnlock(&spinlockIsHUDVisible);
|
||||
[[self cdsVideoOutput] setIsHUDLagFrameCountVisible:theState];
|
||||
}
|
||||
|
||||
- (BOOL) isHUDLagFrameCountVisible
|
||||
{
|
||||
OSSpinLockLock(&spinlockIsHUDVisible);
|
||||
const BOOL theState = (_cdv->GetHUDShowLagFrameCount()) ? YES : NO;
|
||||
OSSpinLockUnlock(&spinlockIsHUDVisible);
|
||||
|
||||
return theState;
|
||||
return [[self cdsVideoOutput] isHUDLagFrameCountVisible];
|
||||
}
|
||||
|
||||
- (void) setIsHUDCPULoadAverageVisible:(BOOL)theState
|
||||
{
|
||||
OSSpinLockLock(&spinlockIsHUDVisible);
|
||||
_cdv->SetHUDShowCPULoadAverage((theState) ? true : false);
|
||||
OSSpinLockUnlock(&spinlockIsHUDVisible);
|
||||
[[self cdsVideoOutput] setIsHUDCPULoadAverageVisible:theState];
|
||||
}
|
||||
|
||||
- (BOOL) isHUDCPULoadAverageVisible
|
||||
{
|
||||
OSSpinLockLock(&spinlockIsHUDVisible);
|
||||
const BOOL theState = (_cdv->GetHUDShowCPULoadAverage()) ? YES : NO;
|
||||
OSSpinLockUnlock(&spinlockIsHUDVisible);
|
||||
|
||||
return theState;
|
||||
return [[self cdsVideoOutput] isHUDCPULoadAverageVisible];
|
||||
}
|
||||
|
||||
- (void) setIsHUDRealTimeClockVisible:(BOOL)theState
|
||||
{
|
||||
OSSpinLockLock(&spinlockIsHUDVisible);
|
||||
_cdv->SetHUDShowRTC((theState) ? true : false);
|
||||
OSSpinLockUnlock(&spinlockIsHUDVisible);
|
||||
[[self cdsVideoOutput] setIsHUDRealTimeClockVisible:theState];
|
||||
}
|
||||
|
||||
- (BOOL) isHUDRealTimeClockVisible
|
||||
{
|
||||
OSSpinLockLock(&spinlockIsHUDVisible);
|
||||
const BOOL theState = (_cdv->GetHUDShowRTC()) ? YES : NO;
|
||||
OSSpinLockUnlock(&spinlockIsHUDVisible);
|
||||
|
||||
return theState;
|
||||
return [[self cdsVideoOutput] isHUDRealTimeClockVisible];
|
||||
}
|
||||
|
||||
- (void) setUseVerticalSync:(BOOL)theState
|
||||
{
|
||||
OSSpinLockLock(&spinlockUseVerticalSync);
|
||||
_cdv->SetUseVerticalSync((theState) ? true : false);
|
||||
OSSpinLockUnlock(&spinlockUseVerticalSync);
|
||||
[[self cdsVideoOutput] setUseVerticalSync:theState];
|
||||
}
|
||||
|
||||
- (BOOL) useVerticalSync
|
||||
{
|
||||
OSSpinLockLock(&spinlockUseVerticalSync);
|
||||
const BOOL theState = (_cdv->GetUseVerticalSync()) ? YES : NO;
|
||||
OSSpinLockUnlock(&spinlockUseVerticalSync);
|
||||
|
||||
return theState;
|
||||
return [[self cdsVideoOutput] useVerticalSync];
|
||||
}
|
||||
|
||||
- (void) setVideoFiltersPreferGPU:(BOOL)theState
|
||||
{
|
||||
OSSpinLockLock(&spinlockVideoFiltersPreferGPU);
|
||||
_cdv->SetFiltersPreferGPU((theState) ? true : false);
|
||||
OSSpinLockUnlock(&spinlockVideoFiltersPreferGPU);
|
||||
[[self cdsVideoOutput] setVideoFiltersPreferGPU:theState];
|
||||
}
|
||||
|
||||
- (BOOL) videoFiltersPreferGPU
|
||||
{
|
||||
OSSpinLockLock(&spinlockVideoFiltersPreferGPU);
|
||||
const BOOL theState = (_cdv->GetFiltersPreferGPU()) ? YES : NO;
|
||||
OSSpinLockUnlock(&spinlockVideoFiltersPreferGPU);
|
||||
|
||||
return theState;
|
||||
return [[self cdsVideoOutput] videoFiltersPreferGPU];
|
||||
}
|
||||
|
||||
- (void) setSourceDeposterize:(BOOL)theState
|
||||
{
|
||||
OSSpinLockLock(&spinlockSourceDeposterize);
|
||||
_cdv->SetSourceDeposterize((theState) ? true : false);
|
||||
OSSpinLockUnlock(&spinlockSourceDeposterize);
|
||||
[[self cdsVideoOutput] setSourceDeposterize:theState];
|
||||
}
|
||||
|
||||
- (BOOL) sourceDeposterize
|
||||
{
|
||||
OSSpinLockLock(&spinlockSourceDeposterize);
|
||||
const BOOL theState = (_cdv->GetSourceDeposterize()) ? YES : NO;
|
||||
OSSpinLockUnlock(&spinlockSourceDeposterize);
|
||||
|
||||
return theState;
|
||||
return [[self cdsVideoOutput] sourceDeposterize];
|
||||
}
|
||||
|
||||
- (void) setOutputFilter:(NSInteger)filterID
|
||||
{
|
||||
OSSpinLockLock(&spinlockOutputFilter);
|
||||
_cdv->SetOutputFilter((OutputFilterTypeID)filterID);
|
||||
OSSpinLockUnlock(&spinlockOutputFilter);
|
||||
[[self cdsVideoOutput] setOutputFilter:filterID];
|
||||
}
|
||||
|
||||
- (NSInteger) outputFilter
|
||||
{
|
||||
OSSpinLockLock(&spinlockOutputFilter);
|
||||
const NSInteger filterID = _cdv->GetOutputFilter();
|
||||
OSSpinLockUnlock(&spinlockOutputFilter);
|
||||
|
||||
return filterID;
|
||||
return [[self cdsVideoOutput] outputFilter];
|
||||
}
|
||||
|
||||
- (void) setPixelScaler:(NSInteger)filterID
|
||||
{
|
||||
OSSpinLockLock(&spinlockPixelScaler);
|
||||
_cdv->SetPixelScaler((VideoFilterTypeID)filterID);
|
||||
OSSpinLockUnlock(&spinlockPixelScaler);
|
||||
[[self cdsVideoOutput] setPixelScaler:filterID];
|
||||
}
|
||||
|
||||
- (NSInteger) pixelScaler
|
||||
{
|
||||
OSSpinLockLock(&spinlockPixelScaler);
|
||||
const NSInteger filterID = _cdv->GetPixelScaler();
|
||||
OSSpinLockUnlock(&spinlockPixelScaler);
|
||||
|
||||
return filterID;
|
||||
}
|
||||
|
||||
#pragma mark Class Methods
|
||||
|
||||
- (void) setScaleFactor:(float)theScaleFactor
|
||||
{
|
||||
OSSpinLockLock(&spinlockIsHUDVisible);
|
||||
_cdv->SetScaleFactor(theScaleFactor);
|
||||
OSSpinLockUnlock(&spinlockIsHUDVisible);
|
||||
}
|
||||
|
||||
- (void) commitViewProperties:(const ClientDisplayViewProperties &)viewProps
|
||||
{
|
||||
OSSpinLockLock(&spinlockViewProperties);
|
||||
_intermediateViewProps = viewProps;
|
||||
OSSpinLockUnlock(&spinlockViewProperties);
|
||||
|
||||
DisplayWindowController *windowController = (DisplayWindowController *)[[self window] delegate];
|
||||
[CocoaDSUtil messageSendOneWay:[[windowController cdsVideoOutput] receivePort] msgID:MESSAGE_CHANGE_VIEW_PROPERTIES];
|
||||
return [[self cdsVideoOutput] pixelScaler];
|
||||
}
|
||||
|
||||
#pragma mark InputHIDManagerTarget Protocol
|
||||
|
@ -1999,8 +1865,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
|
|||
NSData *bitmapImageFileTypeData = [[NSData alloc] initWithBytes:&fileType length:sizeof(NSBitmapImageFileType)];
|
||||
NSArray *messageComponents = [[NSArray alloc] initWithObjects:fileURLStringData, bitmapImageFileTypeData, nil];
|
||||
|
||||
DisplayWindowController *windowController = (DisplayWindowController *)[[self window] delegate];
|
||||
[CocoaDSUtil messageSendOneWayWithMessageComponents:[[windowController cdsVideoOutput] receivePort] msgID:MESSAGE_REQUEST_SCREENSHOT array:messageComponents];
|
||||
[CocoaDSUtil messageSendOneWayWithMessageComponents:[[self cdsVideoOutput] receivePort] msgID:MESSAGE_REQUEST_SCREENSHOT array:messageComponents];
|
||||
|
||||
[bitmapImageFileTypeData release];
|
||||
[messageComponents release];
|
||||
|
@ -2017,16 +1882,15 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
|
|||
{
|
||||
[super lockFocus];
|
||||
|
||||
if ([context view] != self)
|
||||
if ([localContext view] != self)
|
||||
{
|
||||
[context setView:self];
|
||||
[localContext setView:self];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)drawRect:(NSRect)dirtyRect
|
||||
{
|
||||
DisplayWindowController *windowController = (DisplayWindowController *)[[self window] delegate];
|
||||
[CocoaDSUtil messageSendOneWay:[[windowController cdsVideoOutput] receivePort] msgID:MESSAGE_REDRAW_VIEW];
|
||||
[CocoaDSUtil messageSendOneWay:[[self cdsVideoOutput] receivePort] msgID:MESSAGE_REDRAW_VIEW];
|
||||
}
|
||||
|
||||
- (void)setFrame:(NSRect)rect
|
||||
|
@ -2036,7 +1900,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
|
|||
|
||||
if (rect.size.width != oldFrame.size.width || rect.size.height != oldFrame.size.height)
|
||||
{
|
||||
[context update];
|
||||
[localContext update];
|
||||
DisplayWindowController *windowController = (DisplayWindowController *)[[self window] delegate];
|
||||
|
||||
#if defined(MAC_OS_X_VERSION_10_7) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7)
|
||||
|
@ -2056,7 +1920,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
|
|||
props.clientHeight = newViewportRect.size.height;
|
||||
props.viewScale = ClientDisplayView::GetMaxScalarWithinBounds(checkWidth, checkHeight, props.clientWidth, props.clientHeight);
|
||||
|
||||
[self commitViewProperties:props];
|
||||
[[self cdsVideoOutput] commitViewProperties:props];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2164,61 +2028,6 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
|
|||
return YES;
|
||||
}
|
||||
|
||||
#pragma mark CocoaDSDisplayVideoDelegate Protocol
|
||||
|
||||
- (void)doInitVideoOutput:(NSDictionary *)properties
|
||||
{
|
||||
// No init needed, so do nothing.
|
||||
}
|
||||
|
||||
- (void)doLoadVideoFrameWithMainSizeNative:(bool)isMainSizeNative touchSizeNative:(bool)isTouchSizeNative
|
||||
{
|
||||
_cdv->HandleGPUFrameEndEvent(isMainSizeNative, isTouchSizeNative);
|
||||
}
|
||||
|
||||
- (void) doSetVideoBuffersUsingFormat:(const uint32_t)colorFormat
|
||||
bufferHead:(const void *)videoBufferHead
|
||||
nativeBuffer0:(const void *)nativeBuffer0
|
||||
nativeBuffer1:(const void *)nativeBuffer1
|
||||
customBuffer0:(const void *)customBuffer0
|
||||
customWidth0:(const size_t)customWidth0
|
||||
customHeight0:(const size_t)customHeight0
|
||||
customBuffer1:(const void *)customBuffer1
|
||||
customWidth1:(const size_t)customWidth1
|
||||
customHeight1:(const size_t)customHeight1
|
||||
{
|
||||
_cdv->SetVideoBuffers(colorFormat,
|
||||
videoBufferHead,
|
||||
nativeBuffer0,
|
||||
nativeBuffer1,
|
||||
customBuffer0, customWidth0, customHeight0,
|
||||
customBuffer1, customWidth1, customHeight1);
|
||||
}
|
||||
|
||||
- (void)doFinishFrame
|
||||
{
|
||||
_cdv->FrameFinish();
|
||||
}
|
||||
|
||||
- (void)doProcessVideoFrameWithInfo:(const NDSFrameInfo &)frameInfo
|
||||
{
|
||||
_cdv->HandleEmulatorFrameEndEvent(frameInfo);
|
||||
}
|
||||
|
||||
- (void)doViewPropertiesChanged
|
||||
{
|
||||
OSSpinLockLock(&spinlockViewProperties);
|
||||
_cdv->CommitViewProperties(_intermediateViewProps);
|
||||
OSSpinLockUnlock(&spinlockViewProperties);
|
||||
|
||||
_cdv->SetupViewProperties();
|
||||
}
|
||||
|
||||
- (void)doRedraw
|
||||
{
|
||||
_cdv->UpdateView();
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
|
|
@ -347,7 +347,7 @@
|
|||
{
|
||||
DisplayWindowController *newWindowController = [[DisplayWindowController alloc] initWithWindowNibName:@"DisplayWindow" emuControlDelegate:self];
|
||||
|
||||
[CocoaDSUtil messageSendOneWay:[[newWindowController cdsVideoOutput] receivePort] msgID:MESSAGE_RELOAD_AND_REDRAW];
|
||||
[CocoaDSUtil messageSendOneWay:[[newWindowController cdsVideoOutput] receivePort] msgID:MESSAGE_RELOAD_REPROCESS_REDRAW];
|
||||
|
||||
[[newWindowController window] makeKeyAndOrderFront:self];
|
||||
[[newWindowController window] makeMainWindow];
|
||||
|
@ -1509,7 +1509,7 @@
|
|||
|
||||
for (DisplayWindowController *windowController in windowList)
|
||||
{
|
||||
[CocoaDSUtil messageSendOneWay:[[windowController cdsVideoOutput] receivePort] msgID:MESSAGE_RELOAD_AND_REDRAW];
|
||||
[CocoaDSUtil messageSendOneWay:[[windowController cdsVideoOutput] receivePort] msgID:MESSAGE_RELOAD_REPROCESS_REDRAW];
|
||||
}
|
||||
|
||||
[self setStatusText:NSSTRING_STATUS_EMULATOR_RESET];
|
||||
|
@ -1812,7 +1812,7 @@
|
|||
|
||||
for (DisplayWindowController *windowController in windowList)
|
||||
{
|
||||
[CocoaDSUtil messageSendOneWay:[[windowController cdsVideoOutput] receivePort] msgID:MESSAGE_RELOAD_AND_REDRAW];
|
||||
[CocoaDSUtil messageSendOneWay:[[windowController cdsVideoOutput] receivePort] msgID:MESSAGE_RELOAD_REPROCESS_REDRAW];
|
||||
}
|
||||
|
||||
[self setStatusText:NSSTRING_STATUS_ROM_LOADED];
|
||||
|
@ -1891,7 +1891,7 @@
|
|||
[[cdsCore cdsGPU] clearWithColor:0x8000];
|
||||
for (DisplayWindowController *windowController in windowList)
|
||||
{
|
||||
[CocoaDSUtil messageSendOneWay:[[windowController cdsVideoOutput] receivePort] msgID:MESSAGE_RELOAD_AND_REDRAW];
|
||||
[CocoaDSUtil messageSendOneWay:[[windowController cdsVideoOutput] receivePort] msgID:MESSAGE_RELOAD_REPROCESS_REDRAW];
|
||||
}
|
||||
|
||||
[self setStatusText:NSSTRING_STATUS_ROM_UNLOADED];
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
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_OGLDISPLAYOUTPUT_H_
|
||||
#define _MAC_OGLDISPLAYOUTPUT_H_
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <OpenGL/OpenGL.h>
|
||||
|
||||
#ifdef MAC_OS_X_VERSION_10_7
|
||||
#include "../OGLDisplayOutput_3_2.h"
|
||||
#else
|
||||
#include "../OGLDisplayOutput.h"
|
||||
#endif
|
||||
|
||||
class MacOGLDisplayView : public OGLVideoOutput
|
||||
{
|
||||
protected:
|
||||
CGLContextObj _context;
|
||||
|
||||
void _FrameRenderAndFlush();
|
||||
|
||||
public:
|
||||
void operator delete(void *ptr);
|
||||
|
||||
virtual void Init();
|
||||
|
||||
CGLContextObj GetContext() const;
|
||||
void SetContext(CGLContextObj context);
|
||||
|
||||
virtual void SetHUDFontUsingPath(const char *filePath);
|
||||
|
||||
virtual void SetVideoBuffers(const uint32_t colorFormat,
|
||||
const void *videoBufferHead,
|
||||
const void *nativeBuffer0,
|
||||
const void *nativeBuffer1,
|
||||
const void *customBuffer0, const size_t customWidth0, const size_t customHeight0,
|
||||
const void *customBuffer1, const size_t customWidth1, const size_t customHeight1);
|
||||
|
||||
virtual void SetUseVerticalSync(const bool useVerticalSync);
|
||||
virtual void SetScaleFactor(const double scaleFactor);
|
||||
|
||||
virtual void SetupViewProperties();
|
||||
|
||||
virtual void SetFiltersPreferGPU(const bool preferGPU);
|
||||
virtual void SetOutputFilter(const OutputFilterTypeID filterID);
|
||||
virtual void SetPixelScaler(const VideoFilterTypeID filterID);
|
||||
|
||||
virtual void SetHUDVisibility(const bool visibleState);
|
||||
virtual void SetHUDShowVideoFPS(const bool visibleState);
|
||||
virtual void SetHUDShowRender3DFPS(const bool visibleState);
|
||||
virtual void SetHUDShowFrameIndex(const bool visibleState);
|
||||
virtual void SetHUDShowLagFrameCount(const bool visibleState);
|
||||
virtual void SetHUDShowCPULoadAverage(const bool visibleState);
|
||||
virtual void SetHUDShowRTC(const bool visibleState);
|
||||
|
||||
virtual void FrameFinish();
|
||||
virtual void HandleGPUFrameEndEvent(const bool isMainSizeNative, const bool isTouchSizeNative);
|
||||
virtual void HandleEmulatorFrameEndEvent(const NDSFrameInfo &frameInfo);
|
||||
|
||||
virtual void UpdateView();
|
||||
};
|
||||
|
||||
#endif // _MAC_OGLDISPLAYOUTPUT_H_
|
|
@ -0,0 +1,274 @@
|
|||
/*
|
||||
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 "MacOGLDisplayView.h"
|
||||
#include "../utilities.h"
|
||||
|
||||
void MacOGLDisplayView::operator delete(void *ptr)
|
||||
{
|
||||
CGLContextObj context = ((MacOGLDisplayView *)ptr)->GetContext();
|
||||
|
||||
CGLContextObj prevContext = CGLGetCurrentContext();
|
||||
CGLSetCurrentContext(context);
|
||||
::operator delete(ptr);
|
||||
CGLSetCurrentContext(prevContext);
|
||||
|
||||
CGLReleaseContext(context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::Init()
|
||||
{
|
||||
// Initialize the OpenGL context
|
||||
CGLPixelFormatAttribute attributes[] = {
|
||||
kCGLPFAColorSize, (CGLPixelFormatAttribute)24,
|
||||
kCGLPFAAlphaSize, (CGLPixelFormatAttribute)8,
|
||||
kCGLPFADepthSize, (CGLPixelFormatAttribute)0,
|
||||
kCGLPFAStencilSize, (CGLPixelFormatAttribute)0,
|
||||
kCGLPFADoubleBuffer,
|
||||
(CGLPixelFormatAttribute)0, (CGLPixelFormatAttribute)0,
|
||||
(CGLPixelFormatAttribute)0 };
|
||||
|
||||
OGLInfoCreate_Func = &OGLInfoCreate_Legacy;
|
||||
|
||||
#ifdef _OGLDISPLAYOUTPUT_3_2_H_
|
||||
// If we can support a 3.2 Core Profile context, then request that in our
|
||||
// pixel format attributes.
|
||||
if (IsOSXVersionSupported(10, 7, 0))
|
||||
{
|
||||
attributes[9] = kCGLPFAOpenGLProfile;
|
||||
attributes[10] = (CGLPixelFormatAttribute)kCGLOGLPVersion_3_2_Core;
|
||||
OGLInfoCreate_Func = &OGLInfoCreate_3_2;
|
||||
}
|
||||
#endif
|
||||
|
||||
CGLPixelFormatObj cglPixFormat = NULL;
|
||||
GLint virtualScreenCount = 0;
|
||||
CGLChoosePixelFormat(attributes, &cglPixFormat, &virtualScreenCount);
|
||||
|
||||
if (cglPixFormat == NULL)
|
||||
{
|
||||
// If we can't get a 3.2 Core Profile context, then switch to using a
|
||||
// legacy context instead.
|
||||
attributes[9] = (CGLPixelFormatAttribute)0;
|
||||
attributes[10] = (CGLPixelFormatAttribute)0;
|
||||
OGLInfoCreate_Func = &OGLInfoCreate_Legacy;
|
||||
CGLChoosePixelFormat(attributes, &cglPixFormat, &virtualScreenCount);
|
||||
}
|
||||
|
||||
CGLCreateContext(cglPixFormat, NULL, &this->_context);
|
||||
CGLReleasePixelFormat(cglPixFormat);
|
||||
|
||||
CGLContextObj prevContext = CGLGetCurrentContext();
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::Init();
|
||||
CGLSetCurrentContext(prevContext);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::_FrameRenderAndFlush()
|
||||
{
|
||||
this->FrameRender();
|
||||
CGLFlushDrawable(this->_context);
|
||||
}
|
||||
|
||||
CGLContextObj MacOGLDisplayView::GetContext() const
|
||||
{
|
||||
return this->_context;
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::SetContext(CGLContextObj context)
|
||||
{
|
||||
this->_context = context;
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::SetHUDFontUsingPath(const char *filePath)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::SetHUDFontUsingPath(filePath);
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::SetVideoBuffers(const uint32_t colorFormat,
|
||||
const void *videoBufferHead,
|
||||
const void *nativeBuffer0,
|
||||
const void *nativeBuffer1,
|
||||
const void *customBuffer0, const size_t customWidth0, const size_t customHeight0,
|
||||
const void *customBuffer1, const size_t customWidth1, const size_t customHeight1)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
|
||||
this->OGLVideoOutput::SetVideoBuffers(colorFormat,
|
||||
videoBufferHead,
|
||||
nativeBuffer0,
|
||||
nativeBuffer1,
|
||||
customBuffer0, customWidth0, customHeight0,
|
||||
customBuffer1, customWidth1, customHeight1);
|
||||
|
||||
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::SetupViewProperties()
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::SetupViewProperties();
|
||||
this->_FrameRenderAndFlush();
|
||||
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);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::SetHUDVisibility(const bool visibleState)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::SetHUDVisibility(visibleState);
|
||||
this->_FrameRenderAndFlush();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::SetHUDShowVideoFPS(const bool visibleState)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::SetHUDShowVideoFPS(visibleState);
|
||||
this->_FrameRenderAndFlush();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::SetHUDShowRender3DFPS(const bool visibleState)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::SetHUDShowRender3DFPS(visibleState);
|
||||
this->_FrameRenderAndFlush();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::SetHUDShowFrameIndex(const bool visibleState)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::SetHUDShowFrameIndex(visibleState);
|
||||
this->_FrameRenderAndFlush();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::SetHUDShowLagFrameCount(const bool visibleState)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::SetHUDShowLagFrameCount(visibleState);
|
||||
this->_FrameRenderAndFlush();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::SetHUDShowCPULoadAverage(const bool visibleState)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::SetHUDShowCPULoadAverage(visibleState);
|
||||
this->_FrameRenderAndFlush();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::SetHUDShowRTC(const bool visibleState)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::SetHUDShowRTC(visibleState);
|
||||
this->_FrameRenderAndFlush();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::FrameFinish()
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::FrameFinish();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::HandleGPUFrameEndEvent(const bool isMainSizeNative, const bool isTouchSizeNative)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->FrameLoadGPU(isMainSizeNative, isTouchSizeNative);
|
||||
this->FrameProcessGPU();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::HandleEmulatorFrameEndEvent(const NDSFrameInfo &frameInfo)
|
||||
{
|
||||
this->SetHUDInfo(frameInfo);
|
||||
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->FrameProcessHUD();
|
||||
this->_FrameRenderAndFlush();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::UpdateView()
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->_FrameRenderAndFlush();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
|
@ -694,7 +694,7 @@
|
|||
}
|
||||
|
||||
// Draw the display view now so that we guarantee that its drawn at least once.
|
||||
[CocoaDSUtil messageSendOneWay:[[windowController cdsVideoOutput] receivePort] msgID:MESSAGE_RELOAD_AND_REDRAW];
|
||||
[CocoaDSUtil messageSendOneWay:[[windowController cdsVideoOutput] receivePort] msgID:MESSAGE_RELOAD_REPROCESS_REDRAW];
|
||||
|
||||
// If this window is set to full screen mode, its associated screen index must
|
||||
// exist. If not, this window will not enter full screen mode. This is necessary,
|
||||
|
|
Loading…
Reference in New Issue