IOS: Disable scalers

This commit is contained in:
Vincent Bénony 2016-01-06 08:41:45 +01:00
parent a522c82f85
commit aa77c0c92d
4 changed files with 20 additions and 0 deletions

View file

@ -25,6 +25,9 @@
#include "graphics/surface.h" #include "graphics/surface.h"
// #define ENABLE_IOS7_SCALERS
enum InputEvent { enum InputEvent {
kInputMouseDown, kInputMouseDown,
kInputMouseUp, kInputMouseUp,

View file

@ -54,6 +54,8 @@
const OSystem::GraphicsMode OSystem_iOS7::s_supportedGraphicsModes[] = { const OSystem::GraphicsMode OSystem_iOS7::s_supportedGraphicsModes[] = {
{ "none", "No filtering", kGraphicsModeNone }, { "none", "No filtering", kGraphicsModeNone },
{ "linear", "Linear filtering", kGraphicsModeLinear }, { "linear", "Linear filtering", kGraphicsModeLinear },
#ifdef ENABLE_IOS7_SCALERS
#ifdef USE_SCALERS #ifdef USE_SCALERS
// {"2x", "2x", GFX_DOUBLESIZE}, // {"2x", "2x", GFX_DOUBLESIZE},
// {"3x", "3x", GFX_TRIPLESIZE}, // {"3x", "3x", GFX_TRIPLESIZE},
@ -68,6 +70,7 @@ const OSystem::GraphicsMode OSystem_iOS7::s_supportedGraphicsModes[] = {
#endif #endif
{"tv2x", "TV2x", kGraphicsModeTV2x}, {"tv2x", "TV2x", kGraphicsModeTV2x},
{"dotmatrix", "DotMatrix", kGraphicsModeDotMatrix}, {"dotmatrix", "DotMatrix", kGraphicsModeDotMatrix},
#endif
#endif #endif
{ 0, 0, 0 } { 0, 0, 0 }
}; };

View file

@ -88,12 +88,14 @@ typedef struct {
UITouch *_firstTouch; UITouch *_firstTouch;
UITouch *_secondTouch; UITouch *_secondTouch;
#ifdef ENABLE_IOS7_SCALERS
uint8_t *_scalerMemorySrc; uint8_t *_scalerMemorySrc;
uint8_t *_scalerMemoryDst; uint8_t *_scalerMemoryDst;
size_t _scalerMemorySrcSize; size_t _scalerMemorySrcSize;
size_t _scalerMemoryDstSize; size_t _scalerMemoryDstSize;
int _scalerScale; int _scalerScale;
ScalerProc *_scaler; ScalerProc *_scaler;
#endif
} }
- (id)initWithFrame:(struct CGRect)frame; - (id)initWithFrame:(struct CGRect)frame;

View file

@ -388,12 +388,14 @@ uint getSizeNextPOT(uint size) {
[self setContentScaleFactor:[[UIScreen mainScreen] scale]]; [self setContentScaleFactor:[[UIScreen mainScreen] scale]];
#ifdef ENABLE_IOS7_SCALERS
_scalerMemorySrc = NULL; _scalerMemorySrc = NULL;
_scalerMemoryDst = NULL; _scalerMemoryDst = NULL;
_scalerMemorySrcSize = 0; _scalerMemorySrcSize = 0;
_scalerMemoryDstSize = 0; _scalerMemoryDstSize = 0;
_scaler = NULL; _scaler = NULL;
_scalerScale = 1; _scalerScale = 1;
#endif
_keyboardView = nil; _keyboardView = nil;
_screenTexture = 0; _screenTexture = 0;
@ -424,8 +426,10 @@ uint getSizeNextPOT(uint size) {
_videoContext.overlayTexture.free(); _videoContext.overlayTexture.free();
_videoContext.mouseTexture.free(); _videoContext.mouseTexture.free();
#ifdef ENABLE_IOS7_SCALERS
free(_scalerMemorySrc); free(_scalerMemorySrc);
free(_scalerMemoryDst); free(_scalerMemoryDst);
#endif
[_eventLock release]; [_eventLock release];
[super dealloc]; [super dealloc];
@ -468,6 +472,7 @@ uint getSizeNextPOT(uint size) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); printOpenGLError(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); printOpenGLError();
} }
#ifdef ENABLE_IOS7_SCALERS
- (void)setScaler { - (void)setScaler {
ScalerProc *scaler = NULL; ScalerProc *scaler = NULL;
int scalerScale = 1; int scalerScale = 1;
@ -534,12 +539,15 @@ uint getSizeNextPOT(uint size) {
_scaler = scaler; _scaler = scaler;
_scalerScale = scalerScale; _scalerScale = scalerScale;
} }
#endif
- (void)setGraphicsMode { - (void)setGraphicsMode {
[self setFilterModeForTexture:_screenTexture]; [self setFilterModeForTexture:_screenTexture];
[self setFilterModeForTexture:_overlayTexture]; [self setFilterModeForTexture:_overlayTexture];
[self setFilterModeForTexture:_mouseCursorTexture]; [self setFilterModeForTexture:_mouseCursorTexture];
#ifdef ENABLE_IOS7_SCALERS
[self setScaler]; [self setScaler];
#endif
} }
- (void)updateSurface { - (void)updateSurface {
@ -633,6 +641,7 @@ uint getSizeNextPOT(uint size) {
// Unfortunately we have to update the whole texture every frame, since glTexSubImage2D is actually slower in all cases // Unfortunately we have to update the whole texture every frame, since glTexSubImage2D is actually slower in all cases
// due to the iPhone internals having to convert the whole texture back from its internal format when used. // due to the iPhone internals having to convert the whole texture back from its internal format when used.
// In the future we could use several tiled textures instead. // In the future we could use several tiled textures instead.
#ifdef ENABLE_IOS7_SCALERS
if (_scaler) { if (_scaler) {
size_t neededSrcMemorySize = (size_t) (_videoContext.screenTexture.pitch * (_videoContext.screenTexture.h + 4)); size_t neededSrcMemorySize = (size_t) (_videoContext.screenTexture.pitch * (_videoContext.screenTexture.h + 4));
size_t neededDstMemorySize = (size_t) (_videoContext.screenTexture.pitch * (_videoContext.screenTexture.h + 4) * _scalerScale * _scalerScale); size_t neededDstMemorySize = (size_t) (_videoContext.screenTexture.pitch * (_videoContext.screenTexture.h + 4) * _scalerScale * _scalerScale);
@ -661,8 +670,11 @@ uint getSizeNextPOT(uint size) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _videoContext.screenTexture.w * _scalerScale, _videoContext.screenTexture.h * _scalerScale, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, _scalerMemoryDst); printOpenGLError(); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _videoContext.screenTexture.w * _scalerScale, _videoContext.screenTexture.h * _scalerScale, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, _scalerMemoryDst); printOpenGLError();
} }
else { else {
#endif
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _videoContext.screenTexture.w, _videoContext.screenTexture.h, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, _videoContext.screenTexture.getPixels()); printOpenGLError(); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _videoContext.screenTexture.w, _videoContext.screenTexture.h, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, _videoContext.screenTexture.getPixels()); printOpenGLError();
#ifdef ENABLE_IOS7_SCALERS
} }
#endif
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError(); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError();
} }