Implement concurrent rendering.
This commit is contained in:
@@ -4,10 +4,7 @@
|
|||||||
#include "LowLevelWindow.h"
|
#include "LowLevelWindow.h"
|
||||||
#include "RageDisplay.h"
|
#include "RageDisplay.h"
|
||||||
|
|
||||||
#ifndef __OBJC__
|
typedef struct objc_object *id;
|
||||||
typedef void *id;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef const struct __CFDictionary *CFDictionaryRef;
|
typedef const struct __CFDictionary *CFDictionaryRef;
|
||||||
|
|
||||||
class LowLevelWindow_Cocoa : public LowLevelWindow
|
class LowLevelWindow_Cocoa : public LowLevelWindow
|
||||||
@@ -15,6 +12,7 @@ class LowLevelWindow_Cocoa : public LowLevelWindow
|
|||||||
VideoModeParams m_CurrentParams;
|
VideoModeParams m_CurrentParams;
|
||||||
id m_Window;
|
id m_Window;
|
||||||
id m_Context;
|
id m_Context;
|
||||||
|
id m_BGContext;
|
||||||
CFDictionaryRef m_CurrentDisplayMode;
|
CFDictionaryRef m_CurrentDisplayMode;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -27,6 +25,11 @@ public:
|
|||||||
void Update();
|
void Update();
|
||||||
|
|
||||||
const VideoModeParams &GetActualVideoModeParams() const { return m_CurrentParams; }
|
const VideoModeParams &GetActualVideoModeParams() const { return m_CurrentParams; }
|
||||||
|
|
||||||
|
bool SupportsThreadedRendering() { return m_BGContext; }
|
||||||
|
void BeginConcurrentRendering();
|
||||||
|
void EndConcurrentRendering();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ShutDownFullScreen();
|
void ShutDownFullScreen();
|
||||||
int ChangeDisplayMode( const VideoModeParams& p );
|
int ChangeDisplayMode( const VideoModeParams& p );
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public:
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
LowLevelWindow_Cocoa::LowLevelWindow_Cocoa() : m_Context(nil), m_CurrentDisplayMode(NULL)
|
LowLevelWindow_Cocoa::LowLevelWindow_Cocoa() : m_Context(nil), m_BGContext(nil), m_CurrentDisplayMode(NULL)
|
||||||
{
|
{
|
||||||
POOL;
|
POOL;
|
||||||
NSRect rect = { {0, 0}, {0, 0} };
|
NSRect rect = { {0, 0}, {0, 0} };
|
||||||
@@ -218,6 +218,14 @@ CString LowLevelWindow_Cocoa::TryVideoMode( const VideoModeParams& p, bool& newD
|
|||||||
m_Context = newContext;
|
m_Context = newContext;
|
||||||
newDeviceOut = !bShared;
|
newDeviceOut = !bShared;
|
||||||
m_CurrentParams.bpp = p.bpp;
|
m_CurrentParams.bpp = p.bpp;
|
||||||
|
[m_BGContext release];
|
||||||
|
m_BGContext = CreateOGLContext( p.bpp, true, m_Context, bShared );
|
||||||
|
|
||||||
|
if( m_BGContext && !bShared )
|
||||||
|
{
|
||||||
|
[m_BGContext release];
|
||||||
|
m_BGContext = nil;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SMMainThread *mt = [[SMMainThread alloc] init];
|
SMMainThread *mt = [[SMMainThread alloc] init];
|
||||||
|
|
||||||
@@ -259,6 +267,14 @@ CString LowLevelWindow_Cocoa::TryVideoMode( const VideoModeParams& p, bool& newD
|
|||||||
m_Context = newContext;
|
m_Context = newContext;
|
||||||
newDeviceOut = !bShared;
|
newDeviceOut = !bShared;
|
||||||
m_CurrentParams.bpp = p.bpp;
|
m_CurrentParams.bpp = p.bpp;
|
||||||
|
[m_BGContext release];
|
||||||
|
m_BGContext = CreateOGLContext( p.bpp, false, m_Context, bShared );
|
||||||
|
|
||||||
|
if( m_BGContext && !bShared )
|
||||||
|
{
|
||||||
|
[m_BGContext release];
|
||||||
|
m_BGContext = nil;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[m_Context setFullScreen];
|
[m_Context setFullScreen];
|
||||||
@@ -393,7 +409,8 @@ void LowLevelWindow_Cocoa::GetDisplayResolutions( DisplayResolutions &dr ) const
|
|||||||
|
|
||||||
void LowLevelWindow_Cocoa::SwapBuffers()
|
void LowLevelWindow_Cocoa::SwapBuffers()
|
||||||
{
|
{
|
||||||
[m_Context flushBuffer];
|
// XXX don't use Obj-C here, use CG.
|
||||||
|
[[NSOpenGLContext currentContext] flushBuffer];
|
||||||
}
|
}
|
||||||
|
|
||||||
void LowLevelWindow_Cocoa::Update()
|
void LowLevelWindow_Cocoa::Update()
|
||||||
@@ -410,3 +427,20 @@ void LowLevelWindow_Cocoa::Update()
|
|||||||
[m_Context update];
|
[m_Context update];
|
||||||
DISPLAY->ResolutionChanged();
|
DISPLAY->ResolutionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LowLevelWindow_Cocoa::BeginConcurrentRendering()
|
||||||
|
{
|
||||||
|
LOG->Trace( __func__ );
|
||||||
|
if( m_CurrentParams.windowed )
|
||||||
|
[m_BGContext setView:[m_Window contentView]];
|
||||||
|
else
|
||||||
|
[m_BGContext setFullScreen];
|
||||||
|
[m_BGContext makeCurrentContext];
|
||||||
|
}
|
||||||
|
|
||||||
|
void LowLevelWindow_Cocoa::EndConcurrentRendering()
|
||||||
|
{
|
||||||
|
LOG->Trace( __func__ );
|
||||||
|
[NSOpenGLContext clearCurrentContext];
|
||||||
|
[m_BGContext clearDrawable];
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user