diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-09-12 23:07:39 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-09-12 23:28:39 +0300 |
commit | 81524e1cb634881b7c1629f7030facb308f5f853 (patch) | |
tree | 318f0ef6b48e49cb420760afd5fe2f728e35a309 /src/render | |
parent | 96aaa9f5d56637373fe474b0113b9e6ba083a12a (diff) | |
download | mv-81524e1cb634881b7c1629f7030facb308f5f853.tar.gz mv-81524e1cb634881b7c1629f7030facb308f5f853.tar.bz2 mv-81524e1cb634881b7c1629f7030facb308f5f853.tar.xz mv-81524e1cb634881b7c1629f7030facb308f5f853.zip |
Add option for enable high dpi mode in SDL 2.
Diffstat (limited to 'src/render')
-rw-r--r-- | src/render/graphics.cpp | 40 | ||||
-rw-r--r-- | src/render/graphics.h | 7 | ||||
-rw-r--r-- | src/render/graphicsdef.hpp | 3 | ||||
-rw-r--r-- | src/render/imagegraphics.h | 4 | ||||
-rw-r--r-- | src/render/mobileopengl2graphics.cpp | 14 | ||||
-rw-r--r-- | src/render/mobileopenglgraphics.cpp | 12 | ||||
-rw-r--r-- | src/render/modernopenglgraphics.cpp | 14 | ||||
-rw-r--r-- | src/render/normalopenglgraphics.cpp | 12 | ||||
-rw-r--r-- | src/render/nullopenglgraphics.cpp | 12 | ||||
-rw-r--r-- | src/render/safeopenglgraphics.cpp | 14 | ||||
-rw-r--r-- | src/render/sdl2graphics.cpp | 14 | ||||
-rw-r--r-- | src/render/sdl2softwaregraphics.cpp | 12 | ||||
-rw-r--r-- | src/render/sdlgraphics.cpp | 12 | ||||
-rw-r--r-- | src/render/surfacegraphics.h | 4 |
14 files changed, 140 insertions, 34 deletions
diff --git a/src/render/graphics.cpp b/src/render/graphics.cpp index 82a4cbfd6..8ee3b5efa 100644 --- a/src/render/graphics.cpp +++ b/src/render/graphics.cpp @@ -137,6 +137,7 @@ Graphics::Graphics() : mOpenGL(RENDER_SOFTWARE), mEnableResize(false), mNoFrame(false), + mAllowHighDPI(false), mName("Unknown"), mStartFreeMem(0), mSync(false), @@ -183,7 +184,8 @@ void Graphics::setMainFlags(const int w, const int h, const bool fs, const bool hwaccel, const bool resize, - const bool noFrame) restrict2 + const bool noFrame, + const bool allowHighDPI) restrict2 { logger->log("graphics backend: %s", getName().c_str()); logger->log("Setting video mode %dx%d %s", @@ -194,6 +196,7 @@ void Graphics::setMainFlags(const int w, const int h, mHWAccel = hwaccel; mEnableResize = resize; mNoFrame = noFrame; + mAllowHighDPI = allowHighDPI; mActualWidth = w; mActualHeight = h; setScale(scale); @@ -243,6 +246,8 @@ int Graphics::getOpenGLFlags() const restrict2 int displayFlags = SDL_WINDOW_OPENGL; if (mFullscreen) displayFlags |= SDL_WINDOW_FULLSCREEN; + if (mAllowHighDPI) + displayFlags |= SDL_WINDOW_ALLOW_HIGHDPI; #else // USE_SDL2 int displayFlags = SDL_ANYFORMAT | SDL_OPENGL; @@ -382,6 +387,8 @@ int Graphics::getSoftwareFlags() const restrict2 { #ifdef USE_SDL2 int displayFlags = SDL_WINDOW_SHOWN; + if (mAllowHighDPI) + displayFlags |= SDL_WINDOW_ALLOW_HIGHDPI; #else // USE_SDL2 int displayFlags = SDL_ANYFORMAT; @@ -525,8 +532,15 @@ bool Graphics::setFullscreen(const bool fs) restrict2 if (mFullscreen == fs) return true; - return setVideoMode(mActualWidth, mActualHeight, mScale, mBpp, fs, - mHWAccel, mEnableResize, mNoFrame); + return setVideoMode(mActualWidth, + mActualHeight, + mScale, + mBpp, + fs, + mHWAccel, + mEnableResize, + mNoFrame, + mAllowHighDPI); } bool Graphics::resizeScreen(const int width, @@ -580,15 +594,27 @@ bool Graphics::resizeScreen(const int width, else #endif // __native_client__ { - success = setVideoMode(width, height, mScale, mBpp, - mFullscreen, mHWAccel, mEnableResize, mNoFrame); + success = setVideoMode(width, height, + mScale, + mBpp, + mFullscreen, + mHWAccel, + mEnableResize, + mNoFrame, + mAllowHighDPI); // If it didn't work, try to restore the previous size. If that didn't // work either, bail out (but then we're in deep trouble). if (!success) { - if (!setVideoMode(prevWidth, prevHeight, mScale, mBpp, - mFullscreen, mHWAccel, mEnableResize, mNoFrame)) + if (!setVideoMode(prevWidth, prevHeight, + mScale, + mBpp, + mFullscreen, + mHWAccel, + mEnableResize, + mNoFrame, + mAllowHighDPI)) { return false; } diff --git a/src/render/graphics.h b/src/render/graphics.h index 6eb18dfab..87f2f1429 100644 --- a/src/render/graphics.h +++ b/src/render/graphics.h @@ -161,7 +161,8 @@ class Graphics notfinal const bool fs, const bool hwaccel, const bool resize, - const bool noFrame) restrict2 = 0; + const bool noFrame, + const bool allowHighDPI) restrict2 = 0; /** * Set fullscreen mode. @@ -496,7 +497,8 @@ class Graphics notfinal const bool fs, const bool hwaccel, const bool resize, - const bool noFrame) restrict2; + const bool noFrame, + const bool allowHighDPI) restrict2; int getOpenGLFlags() const restrict2 A_WARN_UNUSED; @@ -542,6 +544,7 @@ class Graphics notfinal RenderType mOpenGL; bool mEnableResize; bool mNoFrame; + bool mAllowHighDPI; std::string mName; int mStartFreeMem; bool mSync; diff --git a/src/render/graphicsdef.hpp b/src/render/graphicsdef.hpp index 7217361c0..8f8cf93ed 100644 --- a/src/render/graphicsdef.hpp +++ b/src/render/graphicsdef.hpp @@ -111,7 +111,8 @@ public: const bool fs, const bool hwaccel, const bool resize, - const bool noFrame) restrict2 override final; + const bool noFrame, + const bool allowHighDPI) restrict2 override final; void drawImage(const Image *restrict const image, int dstX, int dstY) restrict2 override final; diff --git a/src/render/imagegraphics.h b/src/render/imagegraphics.h index fde338ec3..2b3e5bd71 100644 --- a/src/render/imagegraphics.h +++ b/src/render/imagegraphics.h @@ -168,7 +168,9 @@ class ImegeGraphics final : public Graphics const int bpp A_UNUSED, const bool fs A_UNUSED, const bool hwaccel A_UNUSED, const bool resize A_UNUSED, - const bool noFrame A_UNUSED) restrict2 override final + const bool noFrame A_UNUSED, + const bool allowHighDPI A_UNUSED) + restrict2 override final { return false; } void drawImage(const Image *const image, diff --git a/src/render/mobileopengl2graphics.cpp b/src/render/mobileopengl2graphics.cpp index 919eb67fe..03fe5d016 100644 --- a/src/render/mobileopengl2graphics.cpp +++ b/src/render/mobileopengl2graphics.cpp @@ -236,9 +236,17 @@ bool MobileOpenGL2Graphics::setVideoMode(const int w, const int h, const bool fs, const bool hwaccel, const bool resize, - const bool noFrame) restrict2 -{ - setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame); + const bool noFrame, + const bool allowHighDPI) restrict2 +{ + setMainFlags(w, h, + scale, + bpp, + fs, + hwaccel, + resize, + noFrame, + allowHighDPI); return setOpenGLMode(); } diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp index 8118e96a4..0f3ce09ea 100644 --- a/src/render/mobileopenglgraphics.cpp +++ b/src/render/mobileopenglgraphics.cpp @@ -154,9 +154,17 @@ bool MobileOpenGLGraphics::setVideoMode(const int w, const int h, const bool fs, const bool hwaccel, const bool resize, - const bool noFrame) restrict2 + const bool noFrame, + const bool allowHighDPI) restrict2 { - setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame); + setMainFlags(w, h, + scale, + bpp, + fs, + hwaccel, + resize, + noFrame, + allowHighDPI); return setOpenGLMode(); } diff --git a/src/render/modernopenglgraphics.cpp b/src/render/modernopenglgraphics.cpp index 6950f4555..be1ec4f73 100644 --- a/src/render/modernopenglgraphics.cpp +++ b/src/render/modernopenglgraphics.cpp @@ -237,9 +237,17 @@ bool ModernOpenGLGraphics::setVideoMode(const int w, const int h, const bool fs, const bool hwaccel, const bool resize, - const bool noFrame) restrict2 -{ - setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame); + const bool noFrame, + const bool allowHighDPI) restrict2 +{ + setMainFlags(w, h, + scale, + bpp, + fs, + hwaccel, + resize, + noFrame, + allowHighDPI); return setOpenGLMode(); } diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp index a03ae4341..96aca6f15 100644 --- a/src/render/normalopenglgraphics.cpp +++ b/src/render/normalopenglgraphics.cpp @@ -178,9 +178,17 @@ bool NormalOpenGLGraphics::setVideoMode(const int w, const int h, const bool fs, const bool hwaccel, const bool resize, - const bool noFrame) restrict2 + const bool noFrame, + const bool allowHighDPI) restrict2 { - setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame); + setMainFlags(w, h, + scale, + bpp, + fs, + hwaccel, + resize, + noFrame, + allowHighDPI); return setOpenGLMode(); } diff --git a/src/render/nullopenglgraphics.cpp b/src/render/nullopenglgraphics.cpp index ff4a765bf..265ac92f1 100644 --- a/src/render/nullopenglgraphics.cpp +++ b/src/render/nullopenglgraphics.cpp @@ -99,9 +99,17 @@ bool NullOpenGLGraphics::setVideoMode(const int w, const int h, const bool fs, const bool hwaccel, const bool resize, - const bool noFrame) restrict2 + const bool noFrame, + const bool allowHighDPI) restrict2 { - setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame); + setMainFlags(w, h, + scale, + bpp, + fs, + hwaccel, + resize, + noFrame, + allowHighDPI); return setOpenGLMode(); } diff --git a/src/render/safeopenglgraphics.cpp b/src/render/safeopenglgraphics.cpp index 43a22bea3..e65ff94b0 100644 --- a/src/render/safeopenglgraphics.cpp +++ b/src/render/safeopenglgraphics.cpp @@ -64,9 +64,17 @@ bool SafeOpenGLGraphics::setVideoMode(const int w, const int h, const bool fs, const bool hwaccel, const bool resize, - const bool noFrame) restrict2 -{ - setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame); + const bool noFrame, + const bool allowHighDPI) restrict2 +{ + setMainFlags(w, h, + scale, + bpp, + fs, + hwaccel, + resize, + noFrame, + allowHighDPI); return setOpenGLMode(); } diff --git a/src/render/sdl2graphics.cpp b/src/render/sdl2graphics.cpp index a8b5515c4..baa69ca69 100644 --- a/src/render/sdl2graphics.cpp +++ b/src/render/sdl2graphics.cpp @@ -740,9 +740,17 @@ bool SDLGraphics::setVideoMode(const int w, const int h, const bool fs, const bool hwaccel, const bool resize, - const bool noFrame) restrict2 -{ - setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame); + const bool noFrame, + const bool allowHighDPI) restrict2 +{ + setMainFlags(w, h, + scale, + bpp, + fs, + hwaccel, + resize, + noFrame, + allowHighDPI); if (!(mWindow = graphicsManager.createWindow(w, h, bpp, getSoftwareFlags()))) diff --git a/src/render/sdl2softwaregraphics.cpp b/src/render/sdl2softwaregraphics.cpp index 789ec413b..808f7c601 100644 --- a/src/render/sdl2softwaregraphics.cpp +++ b/src/render/sdl2softwaregraphics.cpp @@ -1465,9 +1465,17 @@ bool SDL2SoftwareGraphics::setVideoMode(const int w, const int h, const bool fs, const bool hwaccel, const bool resize, - const bool noFrame) restrict2 + const bool noFrame, + const bool allowHighDPI) restrict2 { - setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame); + setMainFlags(w, h, + scale, + bpp, + fs, + hwaccel, + resize, + noFrame, + allowHighDPI); if (!(mWindow = graphicsManager.createWindow(w, h, bpp, getSoftwareFlags()))) diff --git a/src/render/sdlgraphics.cpp b/src/render/sdlgraphics.cpp index 9220f530e..b67e23d8e 100644 --- a/src/render/sdlgraphics.cpp +++ b/src/render/sdlgraphics.cpp @@ -1474,9 +1474,17 @@ bool SDLGraphics::setVideoMode(const int w, const int h, const bool fs, const bool hwaccel, const bool resize, - const bool noFrame) restrict2 + const bool noFrame, + const bool allowHighDPI) restrict2 { - setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame); + setMainFlags(w, h, + scale, + bpp, + fs, + hwaccel, + resize, + noFrame, + allowHighDPI); if ((mWindow = graphicsManager.createWindow(w, h, bpp, getSoftwareFlags())) == nullptr) diff --git a/src/render/surfacegraphics.h b/src/render/surfacegraphics.h index 095b320c7..2e46c9f1e 100644 --- a/src/render/surfacegraphics.h +++ b/src/render/surfacegraphics.h @@ -177,7 +177,9 @@ class SurfaceGraphics final : public Graphics const int bpp A_UNUSED, const bool fs A_UNUSED, const bool hwaccel A_UNUSED, const bool resize A_UNUSED, - const bool noFrame A_UNUSED) restrict2 override final + const bool noFrame A_UNUSED, + const bool allowHighDPI A_UNUSED) + restrict2 override final { return false; } void drawImage(const Image *restrict const image, |