aboutsummaryrefslogtreecommitdiff
path: root/backends/vkeybd
diff options
context:
space:
mode:
authorJohannes Schickel2013-08-14 00:15:40 +0200
committerJohannes Schickel2013-08-16 05:34:38 +0200
commit67137434416df22f5e75cd29d94c8a9fa195ed66 (patch)
tree7e25049f2fb92430573a254ef6eea61c00efdb25 /backends/vkeybd
parenta653ae20d59efe4260d3e2febdf4533943027d00 (diff)
downloadscummvm-rg350-67137434416df22f5e75cd29d94c8a9fa195ed66.tar.gz
scummvm-rg350-67137434416df22f5e75cd29d94c8a9fa195ed66.tar.bz2
scummvm-rg350-67137434416df22f5e75cd29d94c8a9fa195ed66.zip
VKEYBD: Make code agnostic of OverlayColor.
This removes the use of OverlayColor in vkeybd and supports both 16 and 32bit overlays.
Diffstat (limited to 'backends/vkeybd')
-rw-r--r--backends/vkeybd/virtual-keyboard-gui.cpp34
-rw-r--r--backends/vkeybd/virtual-keyboard-gui.h6
-rw-r--r--backends/vkeybd/virtual-keyboard.h4
3 files changed, 26 insertions, 18 deletions
diff --git a/backends/vkeybd/virtual-keyboard-gui.cpp b/backends/vkeybd/virtual-keyboard-gui.cpp
index 8bf9a54251..ec4cbf1de2 100644
--- a/backends/vkeybd/virtual-keyboard-gui.cpp
+++ b/backends/vkeybd/virtual-keyboard-gui.cpp
@@ -32,11 +32,9 @@
namespace Common {
-static void blit(Graphics::Surface *surf_dst, Graphics::Surface *surf_src, int16 x, int16 y, OverlayColor transparent) {
- if (surf_dst->format.bytesPerPixel != sizeof(OverlayColor) || surf_src->format.bytesPerPixel != sizeof(OverlayColor))
- return;
-
- const OverlayColor *src = (const OverlayColor *)surf_src->getPixels();
+template<typename ColorType>
+static void blitImplementation(Graphics::Surface *surf_dst, Graphics::Surface *surf_src, int16 x, int16 y, ColorType transparent) {
+ const ColorType *src = (const ColorType *)surf_src->getPixels();
int blitW = surf_src->w;
int blitH = surf_src->h;
@@ -58,13 +56,13 @@ static void blit(Graphics::Surface *surf_dst, Graphics::Surface *surf_src, int16
if (blitW <= 0 || blitH <= 0)
return;
- OverlayColor *dst = (OverlayColor *)surf_dst->getBasePtr(x, y);
+ ColorType *dst = (ColorType *)surf_dst->getBasePtr(x, y);
int dstAdd = surf_dst->w - blitW;
int srcAdd = surf_src->w - blitW;
for (int i = 0; i < blitH; ++i) {
for (int j = 0; j < blitW; ++j, ++dst, ++src) {
- OverlayColor col = *src;
+ ColorType col = *src;
if (col != transparent)
*dst = col;
}
@@ -73,6 +71,16 @@ static void blit(Graphics::Surface *surf_dst, Graphics::Surface *surf_src, int16
}
}
+static void blit(Graphics::Surface *surf_dst, Graphics::Surface *surf_src, int16 x, int16 y, uint32 transparent) {
+ if (surf_dst->format.bytesPerPixel != surf_src->format.bytesPerPixel)
+ return;
+
+ if (surf_dst->format.bytesPerPixel == 2)
+ blitImplementation<uint16>(surf_dst, surf_src, x, y, transparent);
+ else if (surf_dst->format.bytesPerPixel == 4)
+ blitImplementation<uint32>(surf_dst, surf_src, x, y, transparent);
+}
+
VirtualKeyboardGUI::VirtualKeyboardGUI(VirtualKeyboard *kbd)
: _kbd(kbd), _displaying(false), _drag(false),
_drawCaret(false), _displayEnabled(false), _firstRun(true),
@@ -111,7 +119,7 @@ void VirtualKeyboardGUI::initMode(VirtualKeyboard::Mode *mode) {
}
}
-void VirtualKeyboardGUI::setupDisplayArea(Rect &r, OverlayColor forecolor) {
+void VirtualKeyboardGUI::setupDisplayArea(Rect &r, uint32 forecolor) {
_dispFont = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
if (!fontIsSuitable(_dispFont, r)) {
@@ -356,13 +364,13 @@ void VirtualKeyboardGUI::redraw() {
Graphics::Surface surf;
surf.create(w, h, _system->getOverlayFormat());
- OverlayColor *dst = (OverlayColor *)surf.getPixels();
- const OverlayColor *src = (OverlayColor *) _overlayBackup.getBasePtr(_dirtyRect.left, _dirtyRect.top);
+ byte *dst = (byte *)surf.getPixels();
+ const byte *src = (const byte *)_overlayBackup.getBasePtr(_dirtyRect.left, _dirtyRect.top);
while (h--) {
- memcpy(dst, src, surf.w * sizeof(OverlayColor));
- dst += surf.w;
- src += _overlayBackup.w;
+ memcpy(dst, src, surf.pitch);
+ dst += surf.pitch;
+ src += _overlayBackup.pitch;
}
blit(&surf, _kbdSurface, _kbdBound.left - _dirtyRect.left,
diff --git a/backends/vkeybd/virtual-keyboard-gui.h b/backends/vkeybd/virtual-keyboard-gui.h
index d0f9c884ed..a2000adea0 100644
--- a/backends/vkeybd/virtual-keyboard-gui.h
+++ b/backends/vkeybd/virtual-keyboard-gui.h
@@ -99,7 +99,7 @@ private:
VirtualKeyboard *_kbd;
Rect _kbdBound;
Graphics::Surface *_kbdSurface;
- OverlayColor _kbdTransparentColor;
+ uint32 _kbdTransparentColor;
Point _dragPoint;
bool _drag;
@@ -113,7 +113,7 @@ private:
const Graphics::Font *_dispFont;
int16 _dispX, _dispY;
uint _dispI;
- OverlayColor _dispForeColor, _dispBackColor;
+ uint32 _dispForeColor, _dispBackColor;
int _lastScreenChanged;
int16 _screenW, _screenH;
@@ -121,7 +121,7 @@ private:
bool _displaying;
bool _firstRun;
- void setupDisplayArea(Rect &r, OverlayColor forecolor);
+ void setupDisplayArea(Rect &r, uint32 forecolor);
void move(int16 x, int16 y);
void moveToDefaultPosition();
void screenChanged();
diff --git a/backends/vkeybd/virtual-keyboard.h b/backends/vkeybd/virtual-keyboard.h
index 4ab5ad446d..3b2b2196bd 100644
--- a/backends/vkeybd/virtual-keyboard.h
+++ b/backends/vkeybd/virtual-keyboard.h
@@ -112,11 +112,11 @@ protected:
String resolution;
String bitmapName;
Graphics::Surface *image;
- OverlayColor transparentColor;
+ uint32 transparentColor;
ImageMap imageMap;
VKEventMap events;
Rect displayArea;
- OverlayColor displayFontColor;
+ uint32 displayFontColor;
Mode() : image(0) {}
~Mode() {