[Scummvm-cvs-logs] scummvm master -> 16898486fa28cb428183d94552f2c9884a718c9f

lordhoto lordhoto at gmail.com
Tue Feb 11 11:12:24 CET 2014


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

Summary:
602d3034a9 OPENGL: Release old texture name before creating a new one.
8be41e4f2c OPENGL: Add notification function about context destruction.
b5ca9f5f10 OPENGLSDL: Notify OpenGL manager about context destruction.
4d3eb4a45a TIZEN: Notify OpenGL manager about context destruction.
0063568484 OPENGL: Rename notifyContextChange to notifyContextCreate.
1f4638fe82 OPENGL: Refactor texture instantiation.
16898486fa OPENGL: Properly setup full game palette on video mode change if required.


Commit: 602d3034a97517ecdaabde14a8b4928ddb3b9303
    https://github.com/scummvm/scummvm/commit/602d3034a97517ecdaabde14a8b4928ddb3b9303
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2014-02-11T02:10:48-08:00

Commit Message:
OPENGL: Release old texture name before creating a new one.

This prevents any texture name leaks (and thus memory leaks) on
recreateInternalTexture calls.

Changed paths:
    backends/graphics/opengl/texture.cpp



diff --git a/backends/graphics/opengl/texture.cpp b/backends/graphics/opengl/texture.cpp
index 8f17ed7..dff483d 100644
--- a/backends/graphics/opengl/texture.cpp
+++ b/backends/graphics/opengl/texture.cpp
@@ -65,6 +65,9 @@ void Texture::releaseInternalTexture() {
 }
 
 void Texture::recreateInternalTexture() {
+	// Release old texture name in case it exists.
+	releaseInternalTexture();
+
 	// Get a new texture name.
 	GLCALL(glGenTextures(1, &_glTexture));
 


Commit: 8be41e4f2ce353a97a2d41bee78cc99ca12b619a
    https://github.com/scummvm/scummvm/commit/8be41e4f2ce353a97a2d41bee78cc99ca12b619a
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2014-02-11T02:10:48-08:00

Commit Message:
OPENGL: Add notification function about context destruction.

Changed paths:
    backends/graphics/opengl/opengl-graphics.cpp
    backends/graphics/opengl/opengl-graphics.h



diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index a97f680..3b92acc 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -881,6 +881,26 @@ void OpenGLGraphicsManager::notifyContextChange(const Graphics::PixelFormat &def
 #endif
 }
 
+void OpenGLGraphicsManager::notifyContextDestroy() {
+	if (_gameScreen) {
+		_gameScreen->releaseInternalTexture();
+	}
+
+	if (_overlay) {
+		_overlay->releaseInternalTexture();
+	}
+
+	if (_cursor) {
+		_cursor->releaseInternalTexture();
+	}
+
+#ifdef USE_OSD
+	if (_osd) {
+		_osd->releaseInternalTexture();
+	}
+#endif
+}
+
 void OpenGLGraphicsManager::adjustMousePosition(int16 &x, int16 &y) {
 	if (_overlayVisible) {
 		// It might be confusing that we actually have to handle something
diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h
index 93c0c5b..8d53dbe 100644
--- a/backends/graphics/opengl/opengl-graphics.h
+++ b/backends/graphics/opengl/opengl-graphics.h
@@ -137,6 +137,14 @@ protected:
 	void notifyContextChange(const Graphics::PixelFormat &defaultFormat, const Graphics::PixelFormat &defaultFormatAlpha);
 
 	/**
+	 * Notify the manager that the OpenGL context is about to be destroyed.
+	 * This will free up/reset internal OpenGL related state and *must* be
+	 * called whenever a context might be created again after destroying a
+	 * context.
+	 */
+	void notifyContextDestroy();
+
+	/**
 	 * Adjust the physical mouse coordinates according to the currently visible screen.
 	 */
 	void adjustMousePosition(int16 &x, int16 &y);


Commit: b5ca9f5f108ffd46a514656630c7ea9824a035ce
    https://github.com/scummvm/scummvm/commit/b5ca9f5f108ffd46a514656630c7ea9824a035ce
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2014-02-11T02:10:49-08:00

Commit Message:
OPENGLSDL: Notify OpenGL manager about context destruction.

Changed paths:
    backends/graphics/openglsdl/openglsdl-graphics.cpp



diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index 3f9fc1f..70190b4 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -308,6 +308,14 @@ bool OpenGLSdlGraphicsManager::setupMode(uint width, uint height) {
 		flags |= SDL_RESIZABLE;
 	}
 
+	if (_hwScreen) {
+		// When a video mode has been setup already we notify the manager that
+		// the context is about to be destroyed.
+		// We do this because on Windows SDL_SetVideoMode can destroy and
+		// recreate the OpenGL context.
+		notifyContextDestroy();
+	}
+
 	_hwScreen = SDL_SetVideoMode(width, height, 32, flags);
 
 	if (!_hwScreen) {


Commit: 4d3eb4a45a143b33bb1ecd951058161bcb4eebe1
    https://github.com/scummvm/scummvm/commit/4d3eb4a45a143b33bb1ecd951058161bcb4eebe1
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2014-02-11T02:10:49-08:00

Commit Message:
TIZEN: Notify OpenGL manager about context destruction.

Changed paths:
    backends/platform/tizen/graphics.cpp



diff --git a/backends/platform/tizen/graphics.cpp b/backends/platform/tizen/graphics.cpp
index 390796d..1892c2c 100644
--- a/backends/platform/tizen/graphics.cpp
+++ b/backends/platform/tizen/graphics.cpp
@@ -43,6 +43,7 @@ TizenGraphicsManager::~TizenGraphicsManager() {
 	logEntered();
 
 	if (_eglDisplay != EGL_NO_DISPLAY) {
+		notifyContextDestroy();
 		eglMakeCurrent(_eglDisplay, NULL, NULL, NULL);
 		if (_eglContext != EGL_NO_CONTEXT) {
 			eglDestroyContext(_eglDisplay, _eglContext);


Commit: 006356848407065bbe26488cffe0b0a927fdbb9a
    https://github.com/scummvm/scummvm/commit/006356848407065bbe26488cffe0b0a927fdbb9a
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2014-02-11T02:10:49-08:00

Commit Message:
OPENGL: Rename notifyContextChange to notifyContextCreate.

Changed paths:
    backends/graphics/opengl/opengl-graphics.cpp
    backends/graphics/opengl/opengl-graphics.h
    backends/graphics/openglsdl/openglsdl-graphics.cpp
    backends/platform/tizen/graphics.cpp



diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index 3b92acc..adae8cd 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -816,7 +816,7 @@ void OpenGLGraphicsManager::setActualScreenSize(uint width, uint height) {
 	++_screenChangeID;
 }
 
-void OpenGLGraphicsManager::notifyContextChange(const Graphics::PixelFormat &defaultFormat, const Graphics::PixelFormat &defaultFormatAlpha) {
+void OpenGLGraphicsManager::notifyContextCreate(const Graphics::PixelFormat &defaultFormat, const Graphics::PixelFormat &defaultFormatAlpha) {
 	// Initialize all extensions.
 	initializeGLExtensions();
 
diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h
index 8d53dbe..0512a65 100644
--- a/backends/graphics/opengl/opengl-graphics.h
+++ b/backends/graphics/opengl/opengl-graphics.h
@@ -127,14 +127,14 @@ protected:
 
 	/**
 	 * Notify the manager of a OpenGL context change. This should be the first
-	 * thing to call when you create an OpenGL (ES) context!
+	 * thing to call after you created an OpenGL (ES) context!
 	 *
 	 * @param defaultFormat      The new default format for the game screen
 	 *                           (this is used for the CLUT8 game screens).
 	 * @param defaultFromatAlpha The new default format with an alpha channel
 	 *                           (this is used for the overlay and cursor).
 	 */
-	void notifyContextChange(const Graphics::PixelFormat &defaultFormat, const Graphics::PixelFormat &defaultFormatAlpha);
+	void notifyContextCreate(const Graphics::PixelFormat &defaultFormat, const Graphics::PixelFormat &defaultFormatAlpha);
 
 	/**
 	 * Notify the manager that the OpenGL context is about to be destroyed.
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index 70190b4..6df67d0 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -328,7 +328,7 @@ bool OpenGLSdlGraphicsManager::setupMode(uint width, uint height) {
 
 	if (_hwScreen) {
 		const Graphics::PixelFormat rgba8888 = Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
-		notifyContextChange(rgba8888, rgba8888);
+		notifyContextCreate(rgba8888, rgba8888);
 		setActualScreenSize(_hwScreen->w, _hwScreen->h);
 	}
 
diff --git a/backends/platform/tizen/graphics.cpp b/backends/platform/tizen/graphics.cpp
index 1892c2c..af69844 100644
--- a/backends/platform/tizen/graphics.cpp
+++ b/backends/platform/tizen/graphics.cpp
@@ -59,7 +59,7 @@ result TizenGraphicsManager::Construct() {
 
 	// We default to RGB565 and RGBA5551 which is closest to the actual output
 	// mode we setup.
-	notifyContextChange(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0));
+	notifyContextCreate(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0));
 
 	// Tell our size.
 	int x, y, width, height;


Commit: 1f4638fe823d87ca6b45a79779aff9712e06ec58
    https://github.com/scummvm/scummvm/commit/1f4638fe823d87ca6b45a79779aff9712e06ec58
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2014-02-11T02:10:49-08:00

Commit Message:
OPENGL: Refactor texture instantiation.

Changed paths:
    backends/graphics/opengl/opengl-graphics.cpp
    backends/graphics/opengl/opengl-graphics.h



diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index adae8cd..c60069f 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -265,21 +265,15 @@ OSystem::TransactionError OpenGLGraphicsManager::endGFXTransaction() {
 		delete _gameScreen;
 		_gameScreen = nullptr;
 
-		GLenum glIntFormat, glFormat, glType;
 #ifdef USE_RGB_COLOR
-		if (_currentState.gameFormat.bytesPerPixel == 1) {
+		_gameScreen = createTexture(_currentState.gameFormat);
+#else
+		_gameScreen = createTexture(Graphics::PixelFormat::createFormatCLUT8());
 #endif
-			const bool supported = getGLPixelFormat(_defaultFormat, glIntFormat, glFormat, glType);
-			assert(supported);
-			_gameScreen = new TextureCLUT8(glIntFormat, glFormat, glType, _defaultFormat);
+		assert(_gameScreen);
+		if (_gameScreen->hasPalette()) {
 			_gameScreen->setPalette(0, 255, _gamePalette);
-#ifdef USE_RGB_COLOR
-		} else {
-			const bool supported = getGLPixelFormat(_currentState.gameFormat, glIntFormat, glFormat, glType);
-			assert(supported);
-			_gameScreen = new Texture(glIntFormat, glFormat, glType, _currentState.gameFormat);
 		}
-#endif
 
 		_gameScreen->allocate(_currentState.gameWidth, _currentState.gameHeight);
 		_gameScreen->enableLinearFiltering(_currentState.graphicsMode == GFX_LINEAR);
@@ -566,27 +560,19 @@ void OpenGLGraphicsManager::setMouseCursor(const void *buf, uint w, uint h, int
 
 		GLenum glIntFormat, glFormat, glType;
 
-		if (inputFormat.bytesPerPixel == 1) {
-			// In case this is not supported this is a serious programming
-			// error and the assert a bit below will trigger!
-			const bool supported = getGLPixelFormat(_defaultFormatAlpha, glIntFormat, glFormat, glType);
-			assert(supported);
-			_cursor = new TextureCLUT8(glIntFormat, glFormat, glType, _defaultFormatAlpha);
+		Graphics::PixelFormat textureFormat;
+		if (inputFormat.bytesPerPixel == 1 || (inputFormat.aBits() && getGLPixelFormat(inputFormat, glIntFormat, glFormat, glType))) {
+			// There is two cases when we can use the cursor format directly.
+			// The first is when it's CLUT8, here color key handling can
+			// always be applied because we use the alpha channel of
+			// _defaultFormatAlpha for that.
+			// The other is when the input format has alpha bits and
+			// furthermore is directly supported.
+			textureFormat = inputFormat;
 		} else {
-			// Try to use the format specified as input directly. We can only
-			// do so when it actually has alpha bits.
-			if (inputFormat.aBits() != 0 && getGLPixelFormat(inputFormat, glIntFormat, glFormat, glType)) {
-				_cursor = new Texture(glIntFormat, glFormat, glType, inputFormat);
-			}
-
-			// Otherwise fall back to the default alpha format.
-			if (!_cursor) {
-				const bool supported = getGLPixelFormat(_defaultFormatAlpha, glIntFormat, glFormat, glType);
-				assert(supported);
-				_cursor = new Texture(glIntFormat, glFormat, glType, _defaultFormatAlpha);
-			}
+			textureFormat = _defaultFormatAlpha;
 		}
-
+		_cursor = createTexture(textureFormat);
 		assert(_cursor);
 		_cursor->enableLinearFiltering(_currentState.graphicsMode == GFX_LINEAR);
 	}
@@ -778,10 +764,8 @@ void OpenGLGraphicsManager::setActualScreenSize(uint width, uint height) {
 		delete _overlay;
 		_overlay = nullptr;
 
-		GLenum glIntFormat, glFormat, glType;
-		const bool supported = getGLPixelFormat(_defaultFormatAlpha, glIntFormat, glFormat, glType);
-		assert(supported);
-		_overlay = new Texture(glIntFormat, glFormat, glType, _defaultFormatAlpha);
+		_overlay = createTexture(_defaultFormatAlpha);
+		assert(_overlay);
 		// We always filter the overlay with GL_LINEAR. This assures it's
 		// readable in case it needs to be scaled and does not affect it
 		// otherwise.
@@ -795,10 +779,8 @@ void OpenGLGraphicsManager::setActualScreenSize(uint width, uint height) {
 		delete _osd;
 		_osd = nullptr;
 
-		GLenum glIntFormat, glFormat, glType;
-		const bool supported = getGLPixelFormat(_defaultFormatAlpha, glIntFormat, glFormat, glType);
-		assert(supported);
-		_osd = new Texture(glIntFormat, glFormat, glType, _defaultFormatAlpha);
+		_osd = createTexture(_defaultFormatAlpha);
+		assert(_osd);
 		// We always filter the osd with GL_LINEAR. This assures it's
 		// readable in case it needs to be scaled and does not affect it
 		// otherwise.
@@ -929,6 +911,25 @@ void OpenGLGraphicsManager::adjustMousePosition(int16 &x, int16 &y) {
 	}
 }
 
+Texture *OpenGLGraphicsManager::createTexture(const Graphics::PixelFormat &format) {
+	GLenum glIntFormat, glFormat, glType;
+	if (format.bytesPerPixel == 1) {
+		const bool supported = getGLPixelFormat(_defaultFormat, glIntFormat, glFormat, glType);
+		if (!supported) {
+			return nullptr;
+		} else {
+			return new TextureCLUT8(glIntFormat, glFormat, glType, _defaultFormat);
+		}
+	} else {
+		const bool supported = getGLPixelFormat(format, glIntFormat, glFormat, glType);
+		if (!supported) {
+			return nullptr;
+		} else {
+			return new Texture(glIntFormat, glFormat, glType, format);
+		}
+	}
+}
+
 bool OpenGLGraphicsManager::getGLPixelFormat(const Graphics::PixelFormat &pixelFormat, GLenum &glIntFormat, GLenum &glFormat, GLenum &glType) const {
 	if (pixelFormat == Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)) { // RGBA8888
 		glIntFormat = GL_RGBA;
diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h
index 0512a65..5d80968 100644
--- a/backends/graphics/opengl/opengl-graphics.h
+++ b/backends/graphics/opengl/opengl-graphics.h
@@ -171,6 +171,14 @@ protected:
 	virtual void setInternalMousePosition(int x, int y) = 0;
 
 private:
+	/**
+	 * Create a texture with the specified pixel format.
+	 *
+	 * @param format The pixel format the Texture object should accept as input.
+	 * @return A pointer to the texture or nullptr on failure.
+	 */
+	Texture *createTexture(const Graphics::PixelFormat &format);
+
 	//
 	// Transaction support
 	//


Commit: 16898486fa28cb428183d94552f2c9884a718c9f
    https://github.com/scummvm/scummvm/commit/16898486fa28cb428183d94552f2c9884a718c9f
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2014-02-11T02:10:49-08:00

Commit Message:
OPENGL: Properly setup full game palette on video mode change if required.

Changed paths:
    backends/graphics/opengl/opengl-graphics.cpp



diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index c60069f..3321689 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -272,7 +272,7 @@ OSystem::TransactionError OpenGLGraphicsManager::endGFXTransaction() {
 #endif
 		assert(_gameScreen);
 		if (_gameScreen->hasPalette()) {
-			_gameScreen->setPalette(0, 255, _gamePalette);
+			_gameScreen->setPalette(0, 256, _gamePalette);
 		}
 
 		_gameScreen->allocate(_currentState.gameWidth, _currentState.gameHeight);






More information about the Scummvm-git-logs mailing list