aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics
diff options
context:
space:
mode:
authorJohannes Schickel2011-02-25 04:04:56 +0100
committerJohannes Schickel2011-02-25 04:04:56 +0100
commit63cc9de1df7326bf92da3df7d2e38f86a43be506 (patch)
tree64f089a881c8b4f2abb2789056dfbc3113264442 /backends/graphics
parentf1b16fe0840336dbf87f4c6d1a767c3d2c9dd3d4 (diff)
downloadscummvm-rg350-63cc9de1df7326bf92da3df7d2e38f86a43be506.tar.gz
scummvm-rg350-63cc9de1df7326bf92da3df7d2e38f86a43be506.tar.bz2
scummvm-rg350-63cc9de1df7326bf92da3df7d2e38f86a43be506.zip
OPENGL: Cleanup cursor refresh code a bit.
Diffstat (limited to 'backends/graphics')
-rw-r--r--backends/graphics/opengl/opengl-graphics.cpp36
1 files changed, 13 insertions, 23 deletions
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index 0bd10b62ed..f8e1937858 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -757,11 +757,14 @@ void OpenGLGraphicsManager::refreshCursor() {
// Allocate a texture big enough for cursor
_cursorTexture->allocBuffer(_cursorState.w, _cursorState.h);
- if (_cursorFormat.bytesPerPixel == 1) {
- // Create a temporary RGBA8888 surface
- byte *surface = new byte[_cursorState.w * _cursorState.h * 4];
- memset(surface, 0, _cursorState.w * _cursorState.h * 4);
+ // Create a temporary RGBA8888 surface
+ byte *surface = new byte[_cursorState.w * _cursorState.h * 4];
+ memset(surface, 0, _cursorState.w * _cursorState.h * 4);
+
+ byte *dst = surface;
+ // Convert the paletted cursor to RGBA8888
+ if (_cursorFormat.bytesPerPixel == 1) {
// Select palette
byte *palette;
if (_cursorPaletteDisabled)
@@ -771,7 +774,6 @@ void OpenGLGraphicsManager::refreshCursor() {
// Convert the paletted cursor to RGBA8888
const byte *src = (byte *)_cursorData.pixels;
- byte *dst = surface;
for (int i = 0; i < _cursorState.w * _cursorState.h; i++) {
// Check for keycolor
if (src[i] != _cursorKeyColor) {
@@ -782,22 +784,10 @@ void OpenGLGraphicsManager::refreshCursor() {
}
dst += 4;
}
-
- // Update the texture with new cursor
- _cursorTexture->updateBuffer(surface, _cursorState.w * 4, 0, 0, _cursorState.w, _cursorState.h);
-
- // Free the temp surface
- delete[] surface;
} else {
- // Create a temporary RGBA8888 surface
- byte *surface = new byte[_cursorState.w * _cursorState.h * 4];
- memset(surface, 0, _cursorState.w * _cursorState.h * 4);
-
- // Convert the paletted cursor to RGBA8888
- byte *dst = surface;
-
const bool gotNoAlpha = (_cursorFormat.aLoss == 8);
+ // Convert the RGB cursor to RGBA8888
if (_cursorFormat.bytesPerPixel == 2) {
const uint16 *src = (uint16 *)_cursorData.pixels;
for (int i = 0; i < _cursorState.w * _cursorState.h; i++) {
@@ -823,13 +813,13 @@ void OpenGLGraphicsManager::refreshCursor() {
dst += 4;
}
}
+ }
- // Update the texture with new cursor
- _cursorTexture->updateBuffer(surface, _cursorState.w * 4, 0, 0, _cursorState.w, _cursorState.h);
+ // Update the texture with new cursor
+ _cursorTexture->updateBuffer(surface, _cursorState.w * 4, 0, 0, _cursorState.w, _cursorState.h);
- // Free the temp surface
- delete[] surface;
- }
+ // Free the temp surface
+ delete[] surface;
}
void OpenGLGraphicsManager::refreshCursorScale() {