[Scummvm-cvs-logs] scummvm master -> 12fb8177519c6ba760b898a1f79bf770bfd6e6ac

dhewg dhewg at wiibrew.org
Sat Mar 5 23:10:03 CET 2011


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

Summary:
a2c02367f7 ANDROID: Rename function for less confusion
53ee7c5513 ANDROID: Proper fillBuffer() for non CLUT8 colors
12fb817751 ANDROID: Fix 16bit cursors


Commit: a2c02367f7fe76a6a76fbd872908274f679e4b4d
    https://github.com/scummvm/scummvm/commit/a2c02367f7fe76a6a76fbd872908274f679e4b4d
Author: dhewg (dhewg at wiibrew.org)
Date: 2011-03-05T14:08:41-08:00

Commit Message:
ANDROID: Rename function for less confusion

Changed paths:
    backends/platform/android/android.h
    backends/platform/android/gfx.cpp



diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h
index 2c0641f..6eb43a3 100644
--- a/backends/platform/android/android.h
+++ b/backends/platform/android/android.h
@@ -153,7 +153,7 @@ private:
 #endif
 
 	void setupKeymapper();
-	void _setCursorPalette(const byte *colors, uint start, uint num);
+	void setCursorPaletteInternal(const byte *colors, uint start, uint num);
 
 public:
 	OSystem_Android(int audio_sample_rate, int audio_buffer_size);
diff --git a/backends/platform/android/gfx.cpp b/backends/platform/android/gfx.cpp
index d6dc71f..12262f8 100644
--- a/backends/platform/android/gfx.cpp
+++ b/backends/platform/android/gfx.cpp
@@ -298,7 +298,7 @@ void OSystem_Android::setPalette(const byte *colors, uint start, uint num) {
 			colors, num * 3);
 
 	if (!_use_mouse_palette)
-		_setCursorPalette(colors, start, num);
+		setCursorPaletteInternal(colors, start, num);
 }
 
 void OSystem_Android::grabPalette(byte *colors, uint start, uint num) {
@@ -618,8 +618,8 @@ void OSystem_Android::setMouseCursor(const byte *buf, uint w, uint h,
 	_mouse_targetscale = cursorTargetScale;
 }
 
-void OSystem_Android::_setCursorPalette(const byte *colors,
-										uint start, uint num) {
+void OSystem_Android::setCursorPaletteInternal(const byte *colors,
+												uint start, uint num) {
 	byte *palette = _mouse_texture_palette->palette() + start * 4;
 
 	for (uint i = 0; i < num; ++i, palette += 4, colors += 3) {
@@ -645,7 +645,7 @@ void OSystem_Android::setCursorPalette(const byte *colors,
 		_mouse_texture_rgb = 0;
 	}
 
-	_setCursorPalette(colors, start, num);
+	setCursorPaletteInternal(colors, start, num);
 	_use_mouse_palette = true;
 }
 


Commit: 53ee7c551369cf00b5073f10c21b836759b8c302
    https://github.com/scummvm/scummvm/commit/53ee7c551369cf00b5073f10c21b836759b8c302
Author: dhewg (dhewg at wiibrew.org)
Date: 2011-03-05T14:08:41-08:00

Commit Message:
ANDROID: Proper fillBuffer() for non CLUT8 colors

Changed paths:
    backends/platform/android/gfx.cpp
    backends/platform/android/texture.cpp
    backends/platform/android/texture.h



diff --git a/backends/platform/android/gfx.cpp b/backends/platform/android/gfx.cpp
index 12262f8..10ffa3a 100644
--- a/backends/platform/android/gfx.cpp
+++ b/backends/platform/android/gfx.cpp
@@ -458,8 +458,6 @@ void OSystem_Android::fillScreen(uint32 col) {
 
 	GLTHREADCHECK;
 
-	// TODO FIXME rgb colors
-	assert(col < 256);
 	_game_texture->fillBuffer(col);
 }
 
diff --git a/backends/platform/android/texture.cpp b/backends/platform/android/texture.cpp
index e4c98e3..7f3db05 100644
--- a/backends/platform/android/texture.cpp
+++ b/backends/platform/android/texture.cpp
@@ -212,13 +212,18 @@ void GLESTexture::updateBuffer(GLuint x, GLuint y, GLuint w, GLuint h,
 	}
 }
 
-void GLESTexture::fillBuffer(byte x) {
+void GLESTexture::fillBuffer(uint32 color) {
 	uint rowbytes = _surface.w * _bytesPerPixel;
 
 	byte *tmp = new byte[rowbytes];
 	assert(tmp);
 
-	memset(tmp, x, rowbytes);
+	if (_bytesPerPixel == 1 || ((color & 0xff) == ((color >> 8) & 0xff))) {
+		memset(tmp, color & 0xff, rowbytes);
+	} else {
+		uint16 *p = (uint16 *)tmp;
+		Common::set_to(p, p + _surface.w, (uint16)color);
+	}
 
 	GLCALL(glBindTexture(GL_TEXTURE_2D, _texture_name));
 	GLCALL(glPixelStorei(GL_UNPACK_ALIGNMENT, 1));
@@ -346,9 +351,9 @@ void GLESPaletteTexture::allocBuffer(GLuint w, GLuint h) {
 	_surface.pixels = _texture + _paletteSize;
 }
 
-void GLESPaletteTexture::fillBuffer(byte x) {
+void GLESPaletteTexture::fillBuffer(uint32 color) {
 	assert(_surface.pixels);
-	memset(_surface.pixels, x, _surface.pitch * _surface.h);
+	memset(_surface.pixels, color & 0xff, _surface.pitch * _surface.h);
 	setDirty();
 }
 
diff --git a/backends/platform/android/texture.h b/backends/platform/android/texture.h
index 14eea44..e3d4463 100644
--- a/backends/platform/android/texture.h
+++ b/backends/platform/android/texture.h
@@ -55,7 +55,7 @@ public:
 
 	virtual void updateBuffer(GLuint x, GLuint y, GLuint width, GLuint height,
 								const void *buf, int pitch);
-	virtual void fillBuffer(byte x);
+	virtual void fillBuffer(uint32 color);
 
 	virtual void drawTexture(GLshort x, GLshort y, GLshort w, GLshort h);
 
@@ -164,7 +164,7 @@ public:
 	virtual void allocBuffer(GLuint width, GLuint height);
 	virtual void updateBuffer(GLuint x, GLuint y, GLuint width, GLuint height,
 								const void *buf, int pitch);
-	virtual void fillBuffer(byte x);
+	virtual void fillBuffer(uint32 color);
 
 	virtual void drawTexture(GLshort x, GLshort y, GLshort w, GLshort h);
 


Commit: 12fb8177519c6ba760b898a1f79bf770bfd6e6ac
    https://github.com/scummvm/scummvm/commit/12fb8177519c6ba760b898a1f79bf770bfd6e6ac
Author: dhewg (dhewg at wiibrew.org)
Date: 2011-03-05T14:08:42-08:00

Commit Message:
ANDROID: Fix 16bit cursors

I hate this code

Changed paths:
    backends/platform/android/android.h
    backends/platform/android/gfx.cpp
    backends/platform/android/texture.h



diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h
index 6eb43a3..5c7154a 100644
--- a/backends/platform/android/android.h
+++ b/backends/platform/android/android.h
@@ -114,7 +114,7 @@ private:
 	// Mouse layer
 	GLESTexture *_mouse_texture;
 	GLESPaletteTexture *_mouse_texture_palette;
-	GLESTexture *_mouse_texture_rgb;
+	GLES5551Texture *_mouse_texture_rgb;
 	Common::Point _mouse_hotspot;
 	int _mouse_targetscale;
 	bool _show_mouse;
diff --git a/backends/platform/android/gfx.cpp b/backends/platform/android/gfx.cpp
index 10ffa3a..90b1c3e 100644
--- a/backends/platform/android/gfx.cpp
+++ b/backends/platform/android/gfx.cpp
@@ -25,6 +25,8 @@
 
 #if defined(__ANDROID__)
 
+#include "graphics/conversion.h"
+
 #include "backends/platform/android/android.h"
 #include "backends/platform/android/jni.h"
 
@@ -578,39 +580,65 @@ void OSystem_Android::setMouseCursor(const byte *buf, uint w, uint h,
 		if (_mouse_texture != _mouse_texture_rgb)
 			LOGD("switching to rgb mouse cursor");
 
-		initTexture(&_mouse_texture_rgb, w, h, format, true);
-
+		_mouse_texture_rgb = new GLES5551Texture();
 		_mouse_texture = _mouse_texture_rgb;
 	} else {
 		if (_mouse_texture != _mouse_texture_palette)
 			LOGD("switching to paletted mouse cursor");
 
-		initTexture((GLESTexture **)&_mouse_texture_palette, w, h, format,
-					true);
-
 		_mouse_texture = _mouse_texture_palette;
 
 		delete _mouse_texture_rgb;
 		_mouse_texture_rgb = 0;
 	}
-#else
-	_mouse_texture_palette->allocBuffer(w, h);
 #endif
 
-	if (_mouse_texture->getPixelFormat().bytesPerPixel == 1) {
+	_mouse_texture->allocBuffer(w, h);
+
+	if (_mouse_texture == _mouse_texture_palette) {
 		// Update palette alpha based on keycolor
 		byte *palette = _mouse_texture_palette->palette();
 
 		for (uint i = 0; i < 256; ++i, palette += 4)
 			palette[3] = 0xff;
 
-		_mouse_texture_palette->palette()[keycolor * 4 + 3] = 0x00;
+		_mouse_texture_palette->palette()[keycolor * 4 + 3] = 0;
 	}
 
 	if (w == 0 || h == 0)
 		return;
 
-	_mouse_texture->updateBuffer(0, 0, w, h, buf, w);
+	if (_mouse_texture == _mouse_texture_palette) {
+		_mouse_texture->updateBuffer(0, 0, w, h, buf, w);
+	} else {
+		uint16 pitch = _mouse_texture->pitch();
+
+		byte *tmp = new byte[pitch * h];
+
+		// meh, a 16bit cursor without alpha bits... this is so silly
+		if (!crossBlit(tmp, buf, pitch, w * 2, w, h,
+						_mouse_texture->getPixelFormat(),
+						*format)) {
+			LOGE("crossblit failed");
+
+			delete[] tmp;
+
+			_mouse_texture->fillBuffer(0);
+
+			return;
+		}
+
+		uint16 *s = (uint16 *)buf;
+		uint16 *d = (uint16 *)tmp;
+		for (uint16 y = 0; y < h; ++y, d += pitch / 2 - w)
+			for (uint16 x = 0; x < w; ++x, d++)
+				if (*s++ != (keycolor & 0xffff))
+					*d |= 1;
+
+		_mouse_texture->updateBuffer(0, 0, w, h, tmp, pitch);
+
+		delete[] tmp;
+	}
 
 	_mouse_hotspot = Common::Point(hotspotX, hotspotY);
 	_mouse_targetscale = cursorTargetScale;
diff --git a/backends/platform/android/texture.h b/backends/platform/android/texture.h
index e3d4463..c149253 100644
--- a/backends/platform/android/texture.h
+++ b/backends/platform/android/texture.h
@@ -71,6 +71,10 @@ public:
 		return _surface.h;
 	}
 
+	inline uint16 pitch() const {
+		return _surface.pitch;
+	}
+
 	inline const Graphics::Surface *surface_const() const {
 		return &_surface;
 	}
@@ -84,7 +88,7 @@ public:
 		return _all_dirty || !_dirty_rect.isEmpty();
 	}
 
-	inline Graphics::PixelFormat getPixelFormat() const {
+	inline const Graphics::PixelFormat &getPixelFormat() const {
 		return _pixelFormat;
 	}
 






More information about the Scummvm-git-logs mailing list