Skip to content
Permalink
Browse files

IOS: Disable scalers

  • Loading branch information...
Vincent Bénony
Vincent Bénony committed Jan 6, 2016
1 parent a522c82 commit aa77c0c92ddf76fb2284d3df5a75a36bacf0a976
@@ -25,6 +25,9 @@

#include "graphics/surface.h"

// #define ENABLE_IOS7_SCALERS


enum InputEvent {
kInputMouseDown,
kInputMouseUp,
@@ -54,6 +54,8 @@
const OSystem::GraphicsMode OSystem_iOS7::s_supportedGraphicsModes[] = {
{ "none", "No filtering", kGraphicsModeNone },
{ "linear", "Linear filtering", kGraphicsModeLinear },

#ifdef ENABLE_IOS7_SCALERS
#ifdef USE_SCALERS
// {"2x", "2x", GFX_DOUBLESIZE},
// {"3x", "3x", GFX_TRIPLESIZE},
@@ -68,6 +70,7 @@ const OSystem::GraphicsMode OSystem_iOS7::s_supportedGraphicsModes[] = {
#endif
{"tv2x", "TV2x", kGraphicsModeTV2x},
{"dotmatrix", "DotMatrix", kGraphicsModeDotMatrix},
#endif
#endif
{ 0, 0, 0 }
};
@@ -88,12 +88,14 @@ typedef struct {
UITouch *_firstTouch;
UITouch *_secondTouch;

#ifdef ENABLE_IOS7_SCALERS
uint8_t *_scalerMemorySrc;
uint8_t *_scalerMemoryDst;
size_t _scalerMemorySrcSize;
size_t _scalerMemoryDstSize;
int _scalerScale;
ScalerProc *_scaler;
#endif
}

- (id)initWithFrame:(struct CGRect)frame;
@@ -388,12 +388,14 @@ - (id)initWithFrame:(struct CGRect)frame {

[self setContentScaleFactor:[[UIScreen mainScreen] scale]];

#ifdef ENABLE_IOS7_SCALERS
_scalerMemorySrc = NULL;
_scalerMemoryDst = NULL;
_scalerMemorySrcSize = 0;
_scalerMemoryDstSize = 0;
_scaler = NULL;
_scalerScale = 1;
#endif

_keyboardView = nil;
_screenTexture = 0;
@@ -424,8 +426,10 @@ - (void)dealloc {
_videoContext.overlayTexture.free();
_videoContext.mouseTexture.free();

#ifdef ENABLE_IOS7_SCALERS
free(_scalerMemorySrc);
free(_scalerMemoryDst);
#endif

[_eventLock release];
[super dealloc];
@@ -468,6 +472,7 @@ - (void)setFilterModeForTexture:(GLuint)tex {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); printOpenGLError();
}

#ifdef ENABLE_IOS7_SCALERS
- (void)setScaler {
ScalerProc *scaler = NULL;
int scalerScale = 1;
@@ -534,12 +539,15 @@ - (void)setScaler {
_scaler = scaler;
_scalerScale = scalerScale;
}
#endif

- (void)setGraphicsMode {
[self setFilterModeForTexture:_screenTexture];
[self setFilterModeForTexture:_overlayTexture];
[self setFilterModeForTexture:_mouseCursorTexture];
#ifdef ENABLE_IOS7_SCALERS
[self setScaler];
#endif
}

- (void)updateSurface {
@@ -633,6 +641,7 @@ - (void)updateMainSurface {
// 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.
// In the future we could use several tiled textures instead.
#ifdef ENABLE_IOS7_SCALERS
if (_scaler) {
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);
@@ -661,8 +670,11 @@ - (void)updateMainSurface {
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 {
#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();
#ifdef ENABLE_IOS7_SCALERS
}
#endif

glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError();
}

0 comments on commit aa77c0c

Please sign in to comment.
You can’t perform that action at this time.