Permalink
Browse files

Cocoa Port: New feature -- add Hybrid display orientations.

- The new Hybrid display orientations show three NDS screens — the top
and bottom screens on the left side, and a larger major screen on the
right side. This feature is intended to better use the widescreen
resolution of most users’ host displays, which are usually 16:9 or
16:10. Three different Hybrid orientations are provided (3:2, 16:9, and
16:10) so that users can choose the display size ratio that they prefer.
- Horizontal display orientation no longer uses the display separation
setting.
- Do some additional code cleanup.
1 parent cf8f021 commit 207a3b2e9e6fccbb330b095e74e56264437c41e5 @rogerman rogerman committed Jan 1, 2017
Oops, something went wrong.
@@ -43,7 +43,29 @@
class OGLVideoOutput;
struct NDSFrameInfo;
-enum
+enum ClientDisplayMode
+{
+ ClientDisplayMode_Main = 0,
+ ClientDisplayMode_Touch,
+ ClientDisplayMode_Dual
+};
+
+enum ClientDisplayLayout
+{
+ ClientDisplayLayout_Vertical = 0,
+ ClientDisplayLayout_Horizontal = 1,
+ ClientDisplayLayout_Hybrid_3_2 = 1000,
+ ClientDisplayLayout_Hybrid_16_9 = 1001,
+ ClientDisplayLayout_Hybrid_16_10 = 1002
+};
+
+enum ClientDisplayOrder
+{
+ ClientDisplayOrder_MainFirst = 0,
+ ClientDisplayOrder_TouchFirst
+};
+
+enum OutputFilterTypeID
{
OutputFilterTypeID_NearestNeighbor = 0,
OutputFilterTypeID_Bilinear = 1,
@@ -251,7 +273,7 @@ class OGLImage
void SetSourceDeposterize(bool useDeposterize);
bool CanUseShaderBasedFilters();
- void GetNormalSize(double &w, double &h);
+ void GetNormalSize(double &w, double &h) const;
int GetOutputFilter();
virtual void SetOutputFilterOGL(const int filterID);
@@ -411,15 +433,13 @@ class OGLDisplayLayer : public OGLVideoLayer
VideoFilter *_vf[2];
GLuint _texCPUFilterDstID[2];
- uint16_t _displayWidth;
- uint16_t _displayHeight;
- int _displayMode;
- int _displayOrder;
- int _displayOrientation;
+ ClientDisplayMode _displayMode;
+ ClientDisplayOrder _displayOrder;
+ ClientDisplayLayout _displayOrientation;
double _normalWidth;
double _normalHeight;
- GLfloat _gapScalar;
- GLfloat _rotation;
+ double _gapScalar;
+ double _rotation;
GLuint _texLQ2xLUT;
GLuint _texHQ2xLUT;
@@ -457,24 +477,21 @@ class OGLDisplayLayer : public OGLVideoLayer
bool GetFiltersPreferGPU();
void SetFiltersPreferGPUOGL(bool preferGPU);
- uint16_t GetDisplayWidth();
- uint16_t GetDisplayHeight();
- void SetDisplaySize(uint16_t w, uint16_t h);
- int GetMode();
- void SetMode(int dispMode);
- int GetOrientation();
- void SetOrientation(int dispOrientation);
- int GetOrder();
- void SetOrder(int dispOrder);
- GLfloat GetGapScalar();
- void SetGapScalar(GLfloat theScalar);
- GLfloat GetRotation();
- void SetRotation(GLfloat theRotation);
+ ClientDisplayMode GetMode() const;
+ void SetMode(ClientDisplayMode dispMode);
+ ClientDisplayLayout GetOrientation() const;
+ void SetOrientation(ClientDisplayLayout dispOrientation);
+ ClientDisplayOrder GetOrder() const;
+ void SetOrder(ClientDisplayOrder dispOrder);
+ double GetGapScalar() const;
+ void SetGapScalar(double theScalar);
+ double GetRotation() const;
+ void SetRotation(double theRotation);
bool GetSourceDeposterize();
void SetSourceDeposterize(bool useDeposterize);
bool CanUseShaderBasedFilters();
- void GetNormalSize(double &w, double &h);
+ void GetNormalSize(double &w, double &h) const;
int GetOutputFilter();
virtual void SetOutputFilterOGL(const int filterID);
@@ -487,6 +504,8 @@ class OGLDisplayLayer : public OGLVideoLayer
virtual void ProcessOGL();
virtual void RenderOGL();
virtual void FinishOGL();
+
+ static void CalculateNormalSize(const ClientDisplayMode mode, const ClientDisplayLayout layout, const double gapScalar, double &outWidth, double &outHeight);
};
class OGLVideoOutput
@@ -445,34 +445,12 @@ enum
MESSAGE_COPY_TO_PASTEBOARD
};
-/*
- DS DISPLAY TYPES
- */
-enum
-{
- DS_DISPLAY_TYPE_MAIN = 0,
- DS_DISPLAY_TYPE_TOUCH,
- DS_DISPLAY_TYPE_DUAL
-};
-
enum
{
VIDEO_SOURCE_INTERNAL = 0,
VIDEO_SOURCE_EMULATOR = 1
};
-enum
-{
- DS_DISPLAY_ORIENTATION_VERTICAL = 0,
- DS_DISPLAY_ORIENTATION_HORIZONTAL
-};
-
-enum
-{
- DS_DISPLAY_ORDER_MAIN_FIRST = 0,
- DS_DISPLAY_ORDER_TOUCH_FIRST
-};
-
/*
COCOA DS CORE STATES
*/
@@ -108,9 +108,6 @@ typedef struct
- (void) doFinishFrame;
- (void) doDisplayModeChanged:(NSInteger)displayModeID;
-@optional
-- (void) doDisplaySizeChanged:(NSSize)displaySize;
-
@end
@protocol CocoaDSDisplayVideoDelegate <CocoaDSDisplayDelegate>
@@ -149,8 +146,6 @@ typedef struct
id <CocoaDSDisplayDelegate> delegate;
NSSize displaySize;
NSInteger displayMode;
- size_t _gpuCurrentWidth;
- size_t _gpuCurrentHeight;
uint32_t _receivedFrameIndex;
uint32_t _currentReceivedFrameIndex;
@@ -32,6 +32,8 @@
#include "../../metaspu/metaspu.h"
#include "../../rtc.h"
+#include "OGLDisplayOutput.h"
+
#import <Cocoa/Cocoa.h>
#undef BOOL
@@ -520,9 +522,7 @@ - (id)init
spinlockCPULoadAverage = OS_SPINLOCK_INIT;
delegate = nil;
- displayMode = DS_DISPLAY_TYPE_DUAL;
- _gpuCurrentWidth = GPU_DISPLAY_WIDTH;
- _gpuCurrentHeight = GPU_DISPLAY_HEIGHT;
+ displayMode = ClientDisplayMode_Dual;
_receivedFrameIndex = 0;
_currentReceivedFrameIndex = 0;
@@ -547,7 +547,7 @@ - (void)dealloc
- (NSSize) displaySize
{
pthread_rwlock_rdlock(self.rwlockProducer);
- NSSize size = NSMakeSize((CGFloat)GPU->GetCustomFramebufferWidth(), (displayMode == DS_DISPLAY_TYPE_DUAL) ? (CGFloat)(GPU->GetCustomFramebufferHeight() * 2): (CGFloat)GPU->GetCustomFramebufferHeight());
+ NSSize size = NSMakeSize((CGFloat)GPU->GetCustomFramebufferWidth(), (displayMode == ClientDisplayMode_Dual) ? (CGFloat)(GPU->GetCustomFramebufferHeight() * 2): (CGFloat)GPU->GetCustomFramebufferHeight());
pthread_rwlock_unlock(self.rwlockProducer);
return size;
@@ -559,15 +559,15 @@ - (void) setDisplayMode:(NSInteger)displayModeID
switch (displayModeID)
{
- case DS_DISPLAY_TYPE_MAIN:
+ case ClientDisplayMode_Main:
newDispString = NSSTRING_DISPLAYMODE_MAIN;
break;
- case DS_DISPLAY_TYPE_TOUCH:
+ case ClientDisplayMode_Touch:
newDispString = NSSTRING_DISPLAYMODE_TOUCH;
break;
- case DS_DISPLAY_TYPE_DUAL:
+ case ClientDisplayMode_Dual:
newDispString = NSSTRING_DISPLAYMODE_DUAL;
break;
@@ -726,7 +726,7 @@ - (NSBitmapImageRep *) bitmapImageRep
const NSInteger dispMode = [self displayMode];
NSUInteger w = (NSUInteger)dispInfo.customWidth;
- NSUInteger h = (dispMode == DS_DISPLAY_TYPE_DUAL) ? (NSUInteger)(dispInfo.customHeight * 2) : (NSUInteger)dispInfo.customHeight;
+ NSUInteger h = (dispMode == ClientDisplayMode_Dual) ? (NSUInteger)(dispInfo.customHeight * 2) : (NSUInteger)dispInfo.customHeight;
NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
pixelsWide:w
@@ -895,20 +895,6 @@ - (void) handleReceiveGPUFrame
pthread_rwlock_rdlock(self.rwlockProducer);
const NDSDisplayInfo &dispInfo = GPU->GetDisplayInfo();
- const uint16_t newGpuWidth = dispInfo.customWidth;
- const uint16_t newGpuHeight = dispInfo.customHeight;
-
- if (newGpuWidth != _gpuCurrentWidth || newGpuHeight != _gpuCurrentHeight)
- {
- if (delegate != nil && [delegate respondsToSelector:@selector(doDisplaySizeChanged:)])
- {
- [(id<CocoaDSDisplayDelegate>)delegate doDisplaySizeChanged:NSMakeSize(newGpuWidth, newGpuHeight)];
- }
-
- _gpuCurrentWidth = newGpuWidth;
- _gpuCurrentHeight = newGpuHeight;
- }
-
const bool isMainSizeNative = !dispInfo.didPerformCustomRender[NDSDisplayID_Main];
const bool isTouchSizeNative = !dispInfo.didPerformCustomRender[NDSDisplayID_Touch];
@@ -114,7 +114,7 @@ - (id)init
SPU_SetVolume(100);
// Set up the DS display
- displayMode = DS_DISPLAY_TYPE_DUAL;
+ displayMode = ClientDisplayMode_Dual;
displayRect = OEIntRectMake(0, 0, GPU_DISPLAY_WIDTH, GPU_DISPLAY_HEIGHT * 2);
displayAspectRatio = OEIntSizeMake(2, 3);
@@ -153,17 +153,17 @@ - (void) setDisplayMode:(NSInteger)theMode
switch (theMode)
{
- case DS_DISPLAY_TYPE_MAIN:
+ case ClientDisplayMode_Main:
newDisplayRect = OEIntRectMake(0, 0, GPU_DISPLAY_WIDTH, GPU_DISPLAY_HEIGHT);
newDisplayAspectRatio = OEIntSizeMake(4, 3);
break;
- case DS_DISPLAY_TYPE_TOUCH:
+ case ClientDisplayMode_Touch:
newDisplayRect = OEIntRectMake(0, GPU_DISPLAY_HEIGHT + 1, GPU_DISPLAY_WIDTH, GPU_DISPLAY_HEIGHT);
newDisplayAspectRatio = OEIntSizeMake(4, 3);
break;
- case DS_DISPLAY_TYPE_DUAL:
+ case ClientDisplayMode_Dual:
newDisplayRect = OEIntRectMake(0, 0, GPU_DISPLAY_WIDTH, GPU_DISPLAY_HEIGHT * 2);
newDisplayAspectRatio = OEIntSizeMake(2, 3);
break;
@@ -312,16 +312,16 @@ - (void)changeDisplayMode
{
switch (displayMode)
{
- case DS_DISPLAY_TYPE_MAIN:
- [self setDisplayMode:DS_DISPLAY_TYPE_TOUCH];
+ case ClientDisplayMode_Main:
+ [self setDisplayMode:ClientDisplayMode_Touch];
break;
- case DS_DISPLAY_TYPE_TOUCH:
- [self setDisplayMode:DS_DISPLAY_TYPE_DUAL];
+ case ClientDisplayMode_Touch:
+ [self setDisplayMode:ClientDisplayMode_Dual];
break;
- case DS_DISPLAY_TYPE_DUAL:
- [self setDisplayMode:DS_DISPLAY_TYPE_MAIN];
+ case ClientDisplayMode_Dual:
+ [self setDisplayMode:ClientDisplayMode_Main];
break;
default:
@@ -386,15 +386,15 @@ - (oneway void)didTouchScreenPoint:(OEIntPoint)aPoint
switch (dispMode)
{
- case DS_DISPLAY_TYPE_MAIN:
+ case ClientDisplayMode_Main:
isTouchPressed = NO; // Reject touch input if showing only the main screen.
break;
- case DS_DISPLAY_TYPE_TOUCH:
+ case ClientDisplayMode_Touch:
isTouchPressed = YES;
break;
- case DS_DISPLAY_TYPE_DUAL:
+ case ClientDisplayMode_Dual:
isTouchPressed = YES;
aPoint.y -= GPU_DISPLAY_HEIGHT; // Normalize the y-coordinate to the DS.
break;
Oops, something went wrong.

0 comments on commit 207a3b2

Please sign in to comment.