[Scummvm-git-logs] scummvm master -> 04e05e7a5f71d57357941a48025fdb056ed4f3d9

lephilousophe noreply at scummvm.org
Sun Dec 5 15:43:35 UTC 2021


This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
91cf76aa64 ANDROID: Reset the framebuffer when initializing back the surfaces
05e5e10dec ANDROID: Rework 3D backend to not mangle game GL state
30baf0e599 ANDROID: Unbind everything to ensure engine don't use our stuff
f12409d321 ANDROID: Simplify texture setup in 3D
04e05e7a5f ANDROID: Sync 3D backend HiDPI with 2D one


Commit: 91cf76aa6451869df93f36a9a354d7d40d3e2b17
    https://github.com/scummvm/scummvm/commit/91cf76aa6451869df93f36a9a354d7d40d3e2b17
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2021-12-05T16:43:30+01:00

Commit Message:
ANDROID: Reset the framebuffer when initializing back the surfaces

It's needed when application is paused and resumed

Changed paths:
    backends/graphics3d/android/android-graphics3d.cpp


diff --git a/backends/graphics3d/android/android-graphics3d.cpp b/backends/graphics3d/android/android-graphics3d.cpp
index 80c2dfae50..b86080d68b 100644
--- a/backends/graphics3d/android/android-graphics3d.cpp
+++ b/backends/graphics3d/android/android-graphics3d.cpp
@@ -136,6 +136,14 @@ void AndroidGraphics3dManager::initSurface() {
 
 	if (_game_texture) {
 		_game_texture->reinit();
+		// We had a frame buffer initialized, we must renew it as the game textured got renewed
+		if (_frame_buffer) {
+			delete _frame_buffer;
+			_frame_buffer = new OpenGL::FrameBuffer(_game_texture->getTextureName(),
+	                                        _game_texture->width(), _game_texture->height(),
+	                                        _game_texture->texWidth(), _game_texture->texHeight());
+
+		}
 	}
 
 	// We don't have any content to display: just make sure surface is clean


Commit: 05e5e10dec68c2bef04b0361ef7beb2c9a674c66
    https://github.com/scummvm/scummvm/commit/05e5e10dec68c2bef04b0361ef7beb2c9a674c66
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2021-12-05T16:43:30+01:00

Commit Message:
ANDROID: Rework 3D backend to not mangle game GL state

We don't need scissor test in 3D, it was a leftover from 2D.
Don't split code in multiple functions when it's not needed.

Changed paths:
    backends/graphics3d/android/android-graphics3d.cpp
    backends/graphics3d/android/android-graphics3d.h


diff --git a/backends/graphics3d/android/android-graphics3d.cpp b/backends/graphics3d/android/android-graphics3d.cpp
index b86080d68b..fc4ac88ca1 100644
--- a/backends/graphics3d/android/android-graphics3d.cpp
+++ b/backends/graphics3d/android/android-graphics3d.cpp
@@ -46,6 +46,14 @@
 #include "backends/platform/android/android.h"
 #include "backends/platform/android/jni-android.h"
 
+// These helper macros let us setup our context only when the game has different settings than us
+#define CONTEXT_SAVE_STATE(gl_param) GLboolean saved ## gl_param; GLCALL(saved ## gl_param = glIsEnabled(gl_param))
+#define CONTEXT_SET_ENABLE(gl_param) if (!(saved ## gl_param)) { GLCALL(glEnable(gl_param)); }
+#define CONTEXT_SET_DISABLE(gl_param) if (saved ## gl_param) { GLCALL(glDisable(gl_param)); }
+// These helper macros do the opposite to get back what the game expected
+#define CONTEXT_RESET_ENABLE(gl_param) if (!(saved ## gl_param)) { GLCALL(glDisable(gl_param)); }
+#define CONTEXT_RESET_DISABLE(gl_param) if (saved ## gl_param) { GLCALL(glEnable(gl_param)); }
+
 AndroidGraphics3dManager::AndroidGraphics3dManager() :
 	_screenChangeID(0),
 	_graphicsMode(0),
@@ -160,7 +168,6 @@ void AndroidGraphics3dManager::initSurface() {
 		_mouse_texture->reinit();
 	}
 
-	initViewport();
 	updateScreenRect();
 	// double buffered, flip twice
 	clearScreen(kClearUpdate, 2);
@@ -218,15 +225,54 @@ void AndroidGraphics3dManager::updateScreen() {
 
 	_force_redraw = false;
 
+	// Save the game state
+	GLint savedBlendSrcRGB, savedBlendDstRGB, savedBlendSrcAlpha, savedBlendDstAlpha,
+	      savedBlendEqRGB, savedBlendEqAlpha;
+	GLint savedViewport[4];
+	CONTEXT_SAVE_STATE(GL_BLEND);
+	GLCALL(glGetIntegerv(GL_BLEND_SRC_RGB, &savedBlendSrcRGB));
+	GLCALL(glGetIntegerv(GL_BLEND_DST_RGB, &savedBlendDstRGB));
+	GLCALL(glGetIntegerv(GL_BLEND_SRC_ALPHA, &savedBlendSrcAlpha));
+	GLCALL(glGetIntegerv(GL_BLEND_DST_ALPHA, &savedBlendDstAlpha));
+	GLCALL(glGetIntegerv(GL_BLEND_EQUATION_RGB, &savedBlendEqRGB));
+	GLCALL(glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &savedBlendEqAlpha));
+	CONTEXT_SAVE_STATE(GL_CULL_FACE);
+	CONTEXT_SAVE_STATE(GL_DEPTH_TEST);
+	CONTEXT_SAVE_STATE(GL_DITHER);
+	CONTEXT_SAVE_STATE(GL_POLYGON_OFFSET_FILL);
+	CONTEXT_SAVE_STATE(GL_SAMPLE_ALPHA_TO_COVERAGE);
+	CONTEXT_SAVE_STATE(GL_SAMPLE_COVERAGE);
+	CONTEXT_SAVE_STATE(GL_SCISSOR_TEST);
+	CONTEXT_SAVE_STATE(GL_STENCIL_TEST);
+	GLCALL(glGetIntegerv(GL_VIEWPORT, savedViewport));
+
 	if (_frame_buffer) {
 		_frame_buffer->detach();
-		glViewport(0, 0, JNI::egl_surface_width, JNI::egl_surface_height);
 	}
 
-	// We don't use depth stencil to draw on screen
-	glDisable(GL_DEPTH_TEST);
-	// We do blend though
-	glEnable(GL_BLEND);
+	// Make sure everything we need is correctly set up
+	// Enable what we need and disable the other if it is not already
+	CONTEXT_SET_ENABLE(GL_BLEND);
+	if (savedBlendSrcRGB != GL_SRC_ALPHA ||
+	    savedBlendDstRGB != GL_ONE_MINUS_SRC_ALPHA ||
+	    savedBlendSrcAlpha != GL_SRC_ALPHA ||
+	    savedBlendDstAlpha != GL_ONE_MINUS_SRC_ALPHA) {
+		GLCALL(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
+	}
+	if (savedBlendEqRGB != GL_FUNC_ADD ||
+	    savedBlendEqAlpha != GL_FUNC_ADD) {
+		GLCALL(glBlendEquation(GL_FUNC_ADD));
+	}
+	CONTEXT_SET_DISABLE(GL_CULL_FACE);
+	CONTEXT_SET_DISABLE(GL_DEPTH_TEST);
+	CONTEXT_SET_DISABLE(GL_DITHER);
+	CONTEXT_SET_DISABLE(GL_POLYGON_OFFSET_FILL);
+	CONTEXT_SET_DISABLE(GL_SAMPLE_ALPHA_TO_COVERAGE);
+	CONTEXT_SET_DISABLE(GL_SAMPLE_COVERAGE);
+	CONTEXT_SET_DISABLE(GL_SCISSOR_TEST);
+	CONTEXT_SET_DISABLE(GL_STENCIL_TEST);
+
+	glViewport(0, 0, JNI::egl_surface_width, JNI::egl_surface_height);
 
 	// clear pointer leftovers in dead areas
 	clearScreen(kClear);
@@ -260,6 +306,34 @@ void AndroidGraphics3dManager::updateScreen() {
 		LOGW("swapBuffers failed: 0x%x", glGetError());
 	}
 
+	// Here we restore back the GLES state so if we enabled something we disable it back if it needs too and vice versa
+
+	CONTEXT_RESET_ENABLE(GL_BLEND);
+	if (savedGL_BLEND && (
+	    savedBlendSrcRGB != GL_SRC_ALPHA ||
+	    savedBlendDstRGB != GL_ONE_MINUS_SRC_ALPHA ||
+	    savedBlendSrcAlpha != GL_SRC_ALPHA ||
+	    savedBlendDstAlpha != GL_ONE_MINUS_SRC_ALPHA)) {
+		GLCALL(glBlendFuncSeparate(savedBlendSrcRGB, savedBlendDstRGB,
+		                           savedBlendSrcAlpha, savedBlendDstAlpha));
+	}
+	if (savedGL_BLEND && (
+	    savedBlendEqRGB != GL_FUNC_ADD ||
+	    savedBlendEqAlpha != GL_FUNC_ADD)) {
+		GLCALL(glBlendEquationSeparate(savedBlendEqRGB, savedBlendEqAlpha));
+	}
+	CONTEXT_RESET_DISABLE(GL_CULL_FACE);
+	CONTEXT_RESET_DISABLE(GL_DEPTH_TEST);
+	CONTEXT_RESET_DISABLE(GL_DITHER);
+	CONTEXT_RESET_DISABLE(GL_POLYGON_OFFSET_FILL);
+	CONTEXT_RESET_DISABLE(GL_SAMPLE_ALPHA_TO_COVERAGE);
+	CONTEXT_RESET_DISABLE(GL_SAMPLE_COVERAGE);
+	CONTEXT_RESET_DISABLE(GL_SCISSOR_TEST);
+	CONTEXT_RESET_DISABLE(GL_STENCIL_TEST);
+
+	// Restore game viewport
+	GLCALL(glViewport(savedViewport[0], savedViewport[1], savedViewport[2], savedViewport[3]));
+
 	if (_frame_buffer) {
 		_frame_buffer->attach();
 	}
@@ -358,16 +432,24 @@ void AndroidGraphics3dManager::showOverlay() {
 		_overlay_background->release();
 
 		if (g_engine) {
+			GLint savedViewport[4];
+			GLCALL(glGetIntegerv(GL_VIEWPORT, savedViewport));
+
 			if (_frame_buffer) {
 				_frame_buffer->detach();
-				glViewport(0, 0, JNI::egl_surface_width, JNI::egl_surface_height);
 			}
+
+			GLCALL(glViewport(0, 0, JNI::egl_surface_width, JNI::egl_surface_height));
 			_overlay_background->allocBuffer(_overlay_texture->width(), _overlay_texture->height());
 			_overlay_background->setDrawRect(0, 0,
 			                                 JNI::egl_surface_width, JNI::egl_surface_height);
 			Graphics::Surface *background = _overlay_background->surface();
-			glReadPixels(0, 0, background->w, background->h, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1,
-			             background->getPixels());
+			GLCALL(glReadPixels(0, 0, background->w, background->h, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1,
+			             background->getPixels()));
+
+			// Restore game viewport
+			GLCALL(glViewport(savedViewport[0], savedViewport[1], savedViewport[2], savedViewport[3]));
+
 			if (_frame_buffer) {
 				_frame_buffer->attach();
 			}
@@ -375,8 +457,6 @@ void AndroidGraphics3dManager::showOverlay() {
 	}
 
 	warpMouse(_overlay_texture->width() / 2, _overlay_texture->height() / 2);
-
-	GLCALL(glDisable(GL_SCISSOR_TEST));
 }
 
 void AndroidGraphics3dManager::hideOverlay() {
@@ -396,8 +476,6 @@ void AndroidGraphics3dManager::hideOverlay() {
 
 	// double buffered, flip twice
 	clearScreen(kClearUpdate, 2);
-
-	GLCALL(glEnable(GL_SCISSOR_TEST));
 }
 
 void AndroidGraphics3dManager::clearOverlay() {
@@ -535,18 +613,12 @@ void AndroidGraphics3dManager::copyRectToScreen(const void *buf, int pitch,
 
 void AndroidGraphics3dManager::initSize(uint width, uint height,
                                         const Graphics::PixelFormat *format) {
-	initViewport();
-
 	// resize game texture
-	initSizeIntern(width, height, 0);
-
-	_game_texture->setGameTexture();
-}
-
-void AndroidGraphics3dManager::initSizeIntern(uint width, uint height,
-        const Graphics::PixelFormat *format) {
 	ENTER("%d, %d, %p", width, height, format);
 
+	// We do only 3D with this manager and in 3D there is no format
+	assert(format == nullptr);
+
 	bool engineSupportsArbitraryResolutions = !g_engine ||
 	        g_engine->hasFeature(Engine::kSupportsArbitraryResolutions);
 	if (engineSupportsArbitraryResolutions) {
@@ -576,6 +648,8 @@ void AndroidGraphics3dManager::initSizeIntern(uint width, uint height,
 	_mouse_texture_palette->allocBuffer(20, 20);
 
 	clearScreen(kClear);
+
+	_game_texture->setGameTexture();
 }
 
 int AndroidGraphics3dManager::getScreenChangeID() const {
@@ -802,9 +876,6 @@ Common::List<Graphics::PixelFormat> AndroidGraphics3dManager::getSupportedFormat
 void AndroidGraphics3dManager::updateScreenRect() {
 	Common::Rect rect(0, 0, JNI::egl_surface_width, JNI::egl_surface_height);
 
-	// setup the scissor to the full screen as we enable it when overlay is hidden
-	glScissor(0, 0, JNI::egl_surface_width, JNI::egl_surface_height);
-
 	_overlay_texture->setDrawRect(rect);
 
 	// Clear the overlay background so it is not displayed distorted while resizing
@@ -862,28 +933,14 @@ void AndroidGraphics3dManager::initOverlay() {
 	                              JNI::egl_surface_width, JNI::egl_surface_height);
 }
 
-void AndroidGraphics3dManager::initViewport() {
-	LOGD("initializing viewport");
-
-	assert(JNI::haveSurface());
-
-	GLCALL(glDisable(GL_CULL_FACE));
-	GLCALL(glDisable(GL_DEPTH_TEST));
-
-	GLCALL(glEnable(GL_BLEND));
-	GLCALL(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
-
-	GLCALL(glViewport(0, 0, JNI::egl_surface_width, JNI::egl_surface_height));
-	LOGD("viewport size: %dx%d", JNI::egl_surface_width, JNI::egl_surface_height);
-}
-
 void AndroidGraphics3dManager::clearScreen(FixupType type, byte count) {
 	assert(count > 0);
 
 	bool sm = _show_mouse;
 	_show_mouse = false;
 
-	GLCALL(glDisable(GL_SCISSOR_TEST));
+	CONTEXT_SAVE_STATE(GL_SCISSOR_TEST);
+	CONTEXT_SET_DISABLE(GL_SCISSOR_TEST);
 
 	for (byte i = 0; i < count; ++i) {
 		// clear screen
@@ -905,9 +962,7 @@ void AndroidGraphics3dManager::clearScreen(FixupType type, byte count) {
 		}
 	}
 
-	if (!_show_overlay) {
-		GLCALL(glEnable(GL_SCISSOR_TEST));
-	}
+	CONTEXT_RESET_DISABLE(GL_SCISSOR_TEST);
 
 	_show_mouse = sm;
 	_force_redraw = true;
diff --git a/backends/graphics3d/android/android-graphics3d.h b/backends/graphics3d/android/android-graphics3d.h
index 4e234fdaf1..7ebcee5d90 100644
--- a/backends/graphics3d/android/android-graphics3d.h
+++ b/backends/graphics3d/android/android-graphics3d.h
@@ -133,8 +133,6 @@ private:
 	void setCursorPaletteInternal(const byte *colors, uint start, uint num);
 	void disableCursorPalette();
 	void initOverlay();
-	void initViewport();
-	void initSizeIntern(uint width, uint height, const Graphics::PixelFormat *format);
 
 	enum FixupType {
 		kClear = 0,     // glClear


Commit: 30baf0e5999676eb916bce8246499bdcbde076c5
    https://github.com/scummvm/scummvm/commit/30baf0e5999676eb916bce8246499bdcbde076c5
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2021-12-05T16:43:30+01:00

Commit Message:
ANDROID: Unbind everything to ensure engine don't use our stuff

Changed paths:
    backends/graphics3d/android/android-graphics3d.cpp
    backends/graphics3d/android/texture.cpp
    backends/graphics3d/android/texture.h


diff --git a/backends/graphics3d/android/android-graphics3d.cpp b/backends/graphics3d/android/android-graphics3d.cpp
index fc4ac88ca1..7b0dd7dc9c 100644
--- a/backends/graphics3d/android/android-graphics3d.cpp
+++ b/backends/graphics3d/android/android-graphics3d.cpp
@@ -334,6 +334,11 @@ void AndroidGraphics3dManager::updateScreen() {
 	// Restore game viewport
 	GLCALL(glViewport(savedViewport[0], savedViewport[1], savedViewport[2], savedViewport[3]));
 
+	// Don't keep our texture attached to avoid the engine writing on it if it forgets to setup its own texture
+	GLCALL(glBindTexture(GL_TEXTURE_2D, 0));
+	// Unload our program to make sure engine will use its own
+	GLESBaseTexture::unbindShader();
+
 	if (_frame_buffer) {
 		_frame_buffer->attach();
 	}
diff --git a/backends/graphics3d/android/texture.cpp b/backends/graphics3d/android/texture.cpp
index 808e509f30..1d84a9b1d0 100644
--- a/backends/graphics3d/android/texture.cpp
+++ b/backends/graphics3d/android/texture.cpp
@@ -89,6 +89,12 @@ void GLESBaseTexture::initGL() {
 	                                   2 * sizeof(float), 0);
 }
 
+void GLESBaseTexture::unbindShader() {
+	if (_box_shader) {
+		_box_shader->unbind();
+	}
+}
+
 GLESBaseTexture::GLESBaseTexture(GLenum glFormat, GLenum glType,
                                  Graphics::PixelFormat pixelFormat) :
 	_glFormat(glFormat),
diff --git a/backends/graphics3d/android/texture.h b/backends/graphics3d/android/texture.h
index 1680d97f85..468a891579 100644
--- a/backends/graphics3d/android/texture.h
+++ b/backends/graphics3d/android/texture.h
@@ -39,6 +39,7 @@ class ShaderGL;
 class GLESBaseTexture {
 public:
 	static void initGL();
+	static void unbindShader();
 
 protected:
 	GLESBaseTexture(GLenum glFormat, GLenum glType,


Commit: f12409d3217dd174606c04e561f077dc88056d51
    https://github.com/scummvm/scummvm/commit/f12409d3217dd174606c04e561f077dc88056d51
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2021-12-05T16:43:30+01:00

Commit Message:
ANDROID: Simplify texture setup in 3D

There is no specific format for the game texture, use 16-bit one

Changed paths:
    backends/graphics3d/android/android-graphics3d.cpp
    backends/graphics3d/android/android-graphics3d.h


diff --git a/backends/graphics3d/android/android-graphics3d.cpp b/backends/graphics3d/android/android-graphics3d.cpp
index 7b0dd7dc9c..3578fe8e3c 100644
--- a/backends/graphics3d/android/android-graphics3d.cpp
+++ b/backends/graphics3d/android/android-graphics3d.cpp
@@ -633,11 +633,8 @@ void AndroidGraphics3dManager::initSize(uint width, uint height,
 
 	GLTHREADCHECK;
 
-#ifdef USE_RGB_COLOR
-	initTexture(&_game_texture, width, height, format);
-#else
 	_game_texture->allocBuffer(width, height);
-#endif
+
 	delete _frame_buffer;
 	_frame_buffer = new OpenGL::FrameBuffer(_game_texture->getTextureName(),
 	                                        _game_texture->width(), _game_texture->height(),
@@ -973,58 +970,6 @@ void AndroidGraphics3dManager::clearScreen(FixupType type, byte count) {
 	_force_redraw = true;
 }
 
-#ifdef USE_RGB_COLOR
-void AndroidGraphics3dManager::initTexture(GLESBaseTexture **texture,
-        uint width, uint height,
-        const Graphics::PixelFormat *format) {
-	assert(texture);
-	Graphics::PixelFormat format_clut8 =
-	    Graphics::PixelFormat::createFormatCLUT8();
-	Graphics::PixelFormat format_current;
-	Graphics::PixelFormat format_new;
-
-	if (*texture) {
-		format_current = (*texture)->getPixelFormat();
-	} else {
-		format_current = Graphics::PixelFormat();
-	}
-
-	if (format) {
-		format_new = *format;
-	} else {
-		format_new = format_clut8;
-	}
-
-	if (format_current != format_new) {
-		if (*texture)
-			LOGD("switching pixel format from: %s",
-			     (*texture)->getPixelFormat().toString().c_str());
-
-		delete *texture;
-
-		if (format_new == GLES565Texture::pixelFormat()) {
-			*texture = new GLES565Texture();
-		} else if (format_new == GLES5551Texture::pixelFormat()) {
-			*texture = new GLES5551Texture();
-		} else if (format_new == GLES4444Texture::pixelFormat()) {
-			*texture = new GLES4444Texture();
-		} else {
-			// TODO what now?
-			if (format_new != format_clut8)
-				LOGE("unsupported pixel format: %s",
-				     format_new.toString().c_str());
-
-			*texture = new GLESFakePalette565Texture;
-		}
-
-		LOGD("new pixel format: %s",
-		     (*texture)->getPixelFormat().toString().c_str());
-	}
-
-	(*texture)->allocBuffer(width, height);
-}
-#endif
-
 AndroidCommonGraphics::State AndroidGraphics3dManager::getState() const {
 	AndroidCommonGraphics::State state;
 
@@ -1040,11 +985,8 @@ AndroidCommonGraphics::State AndroidGraphics3dManager::getState() const {
 }
 
 bool AndroidGraphics3dManager::setState(const AndroidCommonGraphics::State &state) {
-#ifdef USE_RGB_COLOR
-	initSize(state.screenWidth, state.screenHeight, &state.pixelFormat);
-#else
+	// In 3d we don't have a pixel format so we ignore it
 	initSize(state.screenWidth, state.screenHeight, nullptr);
-#endif
 	setFeatureState(OSystem::kFeatureAspectRatioCorrection, state.aspectRatio);
 	setFeatureState(OSystem::kFeatureFullscreenMode, state.fullscreen);
 	setFeatureState(OSystem::kFeatureCursorPalette, state.cursorPalette);
diff --git a/backends/graphics3d/android/android-graphics3d.h b/backends/graphics3d/android/android-graphics3d.h
index 7ebcee5d90..592376e001 100644
--- a/backends/graphics3d/android/android-graphics3d.h
+++ b/backends/graphics3d/android/android-graphics3d.h
@@ -141,10 +141,6 @@ private:
 	};
 
 	void clearScreen(FixupType type, byte count = 1);
-#ifdef USE_RGB_COLOR
-	void initTexture(GLESBaseTexture **texture, uint width, uint height,
-	                 const Graphics::PixelFormat *format);
-#endif
 
 private:
 	int _screenChangeID;


Commit: 04e05e7a5f71d57357941a48025fdb056ed4f3d9
    https://github.com/scummvm/scummvm/commit/04e05e7a5f71d57357941a48025fdb056ed4f3d9
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2021-12-05T16:43:30+01:00

Commit Message:
ANDROID: Sync 3D backend HiDPI with 2D one

Changed paths:
    backends/graphics3d/android/android-graphics3d.cpp
    backends/graphics3d/android/android-graphics3d.h


diff --git a/backends/graphics3d/android/android-graphics3d.cpp b/backends/graphics3d/android/android-graphics3d.cpp
index 3578fe8e3c..e6e6025725 100644
--- a/backends/graphics3d/android/android-graphics3d.cpp
+++ b/backends/graphics3d/android/android-graphics3d.cpp
@@ -970,6 +970,17 @@ void AndroidGraphics3dManager::clearScreen(FixupType type, byte count) {
 	_force_redraw = true;
 }
 
+float AndroidGraphics3dManager::getHiDPIScreenFactor() const {
+	// TODO: Use JNI to get DisplayMetrics.density, which according to the documentation
+	// seems to be what we want.
+	// "On a medium-density screen, DisplayMetrics.density equals 1.0; on a high-density
+	//  screen it equals 1.5; on an extra-high-density screen, it equals 2.0; and on a
+	//  low-density screen, it equals 0.75. This figure is the factor by which you should
+	//  multiply the dp units in order to get the actual pixel count for the current screen."
+
+	return 2.f;
+}
+
 AndroidCommonGraphics::State AndroidGraphics3dManager::getState() const {
 	AndroidCommonGraphics::State state;
 
diff --git a/backends/graphics3d/android/android-graphics3d.h b/backends/graphics3d/android/android-graphics3d.h
index 592376e001..bdd1e0363f 100644
--- a/backends/graphics3d/android/android-graphics3d.h
+++ b/backends/graphics3d/android/android-graphics3d.h
@@ -110,6 +110,7 @@ public:
 	                            const Graphics::PixelFormat *format) override;
 	virtual void setCursorPalette(const byte *colors, uint start, uint num) override;
 
+	float getHiDPIScreenFactor() const override;
 
 #ifdef USE_RGB_COLOR
 	virtual Graphics::PixelFormat getScreenFormat() const override;




More information about the Scummvm-git-logs mailing list