mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-20 19:21:46 +00:00
VKEYBD: Make code agnostic of OverlayColor.
This removes the use of OverlayColor in vkeybd and supports both 16 and 32bit overlays.
This commit is contained in:
parent
a653ae20d5
commit
6713743441
@ -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,
|
||||
|
@ -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();
|
||||
|
@ -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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user