aboutsummaryrefslogtreecommitdiff
path: root/engines/bladerunner/ui
diff options
context:
space:
mode:
authorPeter Kohaut2019-08-31 23:06:30 +0200
committerPeter Kohaut2019-08-31 23:09:19 +0200
commita7399c5111cc7ebeea284498a1ee5ac7542bb96d (patch)
treef89653b084b58ce909d4487a8251338acaf236d0 /engines/bladerunner/ui
parent6fc73734c12248947ff2214ffd517a32816031c4 (diff)
downloadscummvm-rg350-a7399c5111cc7ebeea284498a1ee5ac7542bb96d.tar.gz
scummvm-rg350-a7399c5111cc7ebeea284498a1ee5ac7542bb96d.tar.bz2
scummvm-rg350-a7399c5111cc7ebeea284498a1ee5ac7542bb96d.zip
BLADERUNNER: Use best pixel format on every platform
Updated all drawing routines to be pixel format agnostic. Might decrease performance.
Diffstat (limited to 'engines/bladerunner/ui')
-rw-r--r--engines/bladerunner/ui/esper.cpp106
-rw-r--r--engines/bladerunner/ui/esper.h6
-rw-r--r--engines/bladerunner/ui/kia.cpp1
-rw-r--r--engines/bladerunner/ui/kia_section_diagnostic.cpp2
-rw-r--r--engines/bladerunner/ui/ui_slider.cpp2
-rw-r--r--engines/bladerunner/ui/vk.cpp4
6 files changed, 56 insertions, 65 deletions
diff --git a/engines/bladerunner/ui/esper.cpp b/engines/bladerunner/ui/esper.cpp
index bb97ae308a..5f49830f44 100644
--- a/engines/bladerunner/ui/esper.cpp
+++ b/engines/bladerunner/ui/esper.cpp
@@ -672,7 +672,7 @@ void ESPER::drawPhotoOpening(Graphics::Surface &surface) {
_timePhotoOpeningNextDiff = 20u;
_timePhotoOpeningNextStart = timeNow;
}
- copyImageScale(&_surfacePhoto, _viewport, &surface, Common::Rect(_screen.left, _screen.top, _photoOpeningWidth, _photoOpeningHeight));
+ copyImageScale(_surfacePhoto, _viewport, surface, Common::Rect(_screen.left, _screen.top, _photoOpeningWidth, _photoOpeningHeight));
surface.hLine(_screen.left, _photoOpeningHeight, _screen.right - 1, surface.format.RGBToColor(0, 248, 0));
surface.vLine(_photoOpeningWidth, _screen.top, _screen.bottom - 1, surface.format.RGBToColor(0, 248, 0));
@@ -830,12 +830,12 @@ void ESPER::drawPhotoSharpening(Graphics::Surface &surface) {
if (_regionSelectedAck && !_regions[_regionSelected].name.empty()) {
_vqaPlayerPhoto->update(true, false);
- copyImageBlur(&_surfaceViewport, Common::Rect(0, 0, 299, 263), &surface, _screen, _blur);
- copyImageBlit(&_surfaceViewport, Common::Rect(0, 0, 0, 0), &surface, Common::Rect(_screen.left, _screen.top, _photoOpeningWidth, _photoOpeningHeight));
+ copyImageBlur(_surfaceViewport, Common::Rect(0, 0, 299, 263), surface, _screen, _blur);
+ copyImageBlit(_surfaceViewport, Common::Rect(0, 0, 0, 0), surface, Common::Rect(_screen.left, _screen.top, _photoOpeningWidth, _photoOpeningHeight));
} else {
drawPhoto(surface);
- copyImageScale(&_surfacePhoto, _viewport, &_surfaceViewport, Common::Rect(0, 0, _screen.width(), _screen.height()));
- copyImageBlit(&_surfaceViewport, Common::Rect(0, 0, 0, 0), &surface, Common::Rect(_screen.left, _screen.top, _photoOpeningWidth, _photoOpeningHeight));
+ copyImageScale(_surfacePhoto, _viewport, _surfaceViewport, Common::Rect(0, 0, _screen.width(), _screen.height()));
+ copyImageBlit(_surfaceViewport, Common::Rect(0, 0, 0, 0), surface, Common::Rect(_screen.left, _screen.top, _photoOpeningWidth, _photoOpeningHeight));
}
drawGrid(surface);
@@ -921,7 +921,7 @@ void ESPER::drawVideoZooming(Graphics::Surface &surface) {
flashViewport();
}
- copyImageBlur(&_surfaceViewport, Common::Rect(0, 0, 299, 263), &surface, _screen, _blur);
+ copyImageBlur(_surfaceViewport, Common::Rect(0, 0, 299, 263), surface, _screen, _blur);
drawGrid(surface);
}
@@ -955,7 +955,7 @@ void ESPER::drawVideoZoomOut(Graphics::Surface &surface) {
if (flash) {
flashViewport();
}
- copyImageBlit(&_surfaceViewport, Common::Rect(0, 0, 0, 0), &surface, _screen);
+ copyImageBlit(_surfaceViewport, Common::Rect(0, 0, 0, 0), surface, _screen);
drawGrid(surface);
// unsigned difference is intentional
if (timeNow - _timeZoomNextStart > _timeZoomNextDiff && _vqaLastFrame <= 0) {
@@ -972,7 +972,7 @@ void ESPER::drawVideoZoomOut(Graphics::Surface &surface) {
}
void ESPER::drawPhoto(Graphics::Surface &surface) {
- copyImageBlur(&_surfacePhoto, _viewport, &surface, _screen, _blur);
+ copyImageBlur(_surfacePhoto, _viewport, surface, _screen, _blur);
}
void ESPER::drawGrid(Graphics::Surface &surface) {
@@ -986,7 +986,7 @@ void ESPER::drawGrid(Graphics::Surface &surface) {
}
void ESPER::drawPhotoWithGrid(Graphics::Surface &surface) {
- copyImageScale(&_surfacePhoto, _viewport, &surface, _screen);
+ copyImageScale(_surfacePhoto, _viewport, surface, _screen);
drawGrid(surface);
}
@@ -1049,7 +1049,7 @@ void ESPER::drawSelection(Graphics::Surface &surface, bool crosshair, int style)
void ESPER::drawVideoFrame(Graphics::Surface &surface) {
_vqaPlayerPhoto->update(true, false);
- copyImageBlit(&_surfaceViewport, Common::Rect(0, 0, 0, 0), &surface, _screen);
+ copyImageBlit(_surfaceViewport, Common::Rect(0, 0, 0, 0), surface, _screen);
}
void ESPER::drawTextCoords(Graphics::Surface &surface) {
@@ -1148,16 +1148,18 @@ void ESPER::drawMouse(Graphics::Surface &surface) {
}
void ESPER::flashViewport() {
- uint16 *ptr = (uint16 *)_surfaceViewport.getPixels();
- for (int i = 0; i < _surfaceViewport.w * _surfaceViewport.h; ++i, ++ptr) {
- uint8 r, g, b;
- _surfaceViewport.format.colorToRGB(*ptr, r, g, b);
- b *= 2;
- *ptr = _surfaceViewport.format.RGBToColor(r, g, b);
+ for (int y = 0; y < _surfaceViewport.h; ++y) {
+ for (int x = 0; x < _surfaceViewport.w; ++x) {
+ uint8 r, g, b;
+ void *ptr = _surfaceViewport.getBasePtr(x, y);
+ _surfaceViewport.format.colorToRGB(*(uint32*)ptr, r, g, b);
+ b *= 2;
+ drawPixel(_surfaceViewport, ptr, _surfaceViewport.format.RGBToColor(r, g, b));
+ }
}
}
-void ESPER::copyImageScale(Graphics::Surface *src, Common::Rect srcRect, Graphics::Surface *dst, Common::Rect dstRect) {
+void ESPER::copyImageScale(Graphics::Surface &src, Common::Rect srcRect, Graphics::Surface &dst, Common::Rect dstRect) {
if (_flash) {
playSound(kSfxBR031_1P, 25);
}
@@ -1175,22 +1177,19 @@ void ESPER::copyImageScale(Graphics::Surface *src, Common::Rect srcRect, Graphic
int srcX = srcRect.left;
int srcXCounter = 0;
for (int dstX = dstRect.left; dstX < dstRect.right; ++dstX) {
- srcX = CLIP(srcX, 0, src->w - 1);
- srcY = CLIP(srcY, 0, src->h - 1);
-
- dstX = CLIP(dstX, 0, dst->w - 1);
- dstY = CLIP(dstY, 0, dst->h - 1);
+ srcX = CLIP(srcX, 0, src.w - 1);
+ srcY = CLIP(srcY, 0, src.h - 1);
- uint16 *srcPtr = (uint16 *)src->getBasePtr(srcX, srcY);
- uint16 *dstPtr = (uint16 *)dst->getBasePtr(dstX, dstY);
+ dstX = CLIP(dstX, 0, dst.w - 1);
+ dstY = CLIP(dstY, 0, dst.h - 1);
uint8 r, g, b;
- src->format.colorToRGB(*srcPtr, r, g, b);
+ src.format.colorToRGB(*(uint32*)src.getBasePtr(srcX, srcY), r, g, b);
if (_flash) {
// add blue-ish tint
b *= 2;
}
- *dstPtr = dst->format.RGBToColor(r, g, b);
+ drawPixel(dst, dst.getBasePtr(dstX, dstY), dst.format.RGBToColor(r, g, b));
srcX += srcDstWidthRatio;
srcXCounter += srcDstWidthRest;
@@ -1221,22 +1220,19 @@ void ESPER::copyImageScale(Graphics::Surface *src, Common::Rect srcRect, Graphic
++srcX;
}
- srcX = CLIP(srcX, 0, src->w - 1);
- srcY = CLIP(srcY, 0, src->h - 1);
-
- dstX = CLIP(dstX, 0, dst->w - 1);
- dstY = CLIP(dstY, 0, dst->h - 1);
+ srcX = CLIP(srcX, 0, src.w - 1);
+ srcY = CLIP(srcY, 0, src.h - 1);
- uint16 *srcPtr = (uint16 *)src->getBasePtr(srcX, srcY);
- uint16 *dstPtr = (uint16 *)dst->getBasePtr(dstX, dstY);
+ dstX = CLIP(dstX, 0, dst.w - 1);
+ dstY = CLIP(dstY, 0, dst.h - 1);
uint8 r, g, b;
- src->format.colorToRGB(*srcPtr, r, g, b);
+ src.format.colorToRGB(*(uint32*)src.getBasePtr(srcX, srcY), r, g, b);
if (_flash) {
// add blue-ish tint
b *= 2;
}
- *dstPtr = dst->format.RGBToColor(r, g, b);
+ drawPixel(dst, dst.getBasePtr(dstX, dstY), dst.format.RGBToColor(r, g, b));
}
srcYCounter += srcRect.height();
@@ -1249,7 +1245,7 @@ void ESPER::copyImageScale(Graphics::Surface *src, Common::Rect srcRect, Graphic
_flash = false;
}
-void ESPER::copyImageBlur(Graphics::Surface *src, Common::Rect srcRect, Graphics::Surface *dst, Common::Rect dstRect, float blur) {
+void ESPER::copyImageBlur(Graphics::Surface &src, Common::Rect srcRect, Graphics::Surface &dst, Common::Rect dstRect, float blur) {
if (_flash) {
playSound(kSfxBR031_1P, 25);
}
@@ -1289,22 +1285,19 @@ void ESPER::copyImageBlur(Graphics::Surface *src, Common::Rect srcRect, Graphics
int skipX = 0;
while (dstX < dstRect.right && skipX < skipXMax) {
- srcX = CLIP(srcX, 0, src->w - 1);
- srcY = CLIP(srcY, 0, src->h - 1);
+ srcX = CLIP(srcX, 0, src.w - 1);
+ srcY = CLIP(srcY, 0, src.h - 1);
- dstX = CLIP(dstX, 0, dst->w - 1);
- dstY = CLIP(dstY, 0, dst->h - 1);
-
- uint16 *srcPtr = (uint16 *)src->getBasePtr(srcX, srcY);
- uint16 *dstPtr = (uint16 *)dst->getBasePtr(dstX, dstY);
+ dstX = CLIP(dstX, 0, dst.w - 1);
+ dstY = CLIP(dstY, 0, dst.h - 1);
uint8 r, g, b;
- src->format.colorToRGB(*srcPtr, r, g, b);
+ src.format.colorToRGB(*(uint32*)src.getBasePtr(srcX, srcY), r, g, b);
if (_flash) {
// add blue-ish tint
b *= 2;
}
- *dstPtr = dst->format.RGBToColor(r, g, b);
+ drawPixel(dst, dst.getBasePtr(dstX, dstY), dst.format.RGBToColor(r, g, b));
++dstX;
++skipX;
@@ -1362,22 +1355,19 @@ void ESPER::copyImageBlur(Graphics::Surface *src, Common::Rect srcRect, Graphics
srcX += 1; // bug in original game? Is using 1 instead of skipX as for Y
}
- srcX = CLIP(srcX, 0, src->w - 1);
- srcY = CLIP(srcY, 0, src->h - 1);
-
- dstX = CLIP(dstX, 0, dst->w - 1);
- dstY = CLIP(dstY, 0, dst->h - 1);
+ srcX = CLIP(srcX, 0, src.w - 1);
+ srcY = CLIP(srcY, 0, src.h - 1);
- uint16 *srcPtr = (uint16 *)src->getBasePtr(srcX, srcY);
- uint16 *dstPtr = (uint16 *)dst->getBasePtr(dstX, dstY);
+ dstX = CLIP(dstX, 0, dst.w - 1);
+ dstY = CLIP(dstY, 0, dst.h - 1);
uint8 r, g, b;
- src->format.colorToRGB(*srcPtr, r, g, b);
+ src.format.colorToRGB(*(uint32*)src.getBasePtr(srcX, srcY), r, g, b);
if (_flash) {
// add blue-ish tint
b *= 2;
}
- *dstPtr = dst->format.RGBToColor(r, g, b);
+ drawPixel(dst, dst.getBasePtr(dstX, dstY), dst.format.RGBToColor(r, g, b));
++dstX;
++skipX;
@@ -1398,12 +1388,12 @@ void ESPER::copyImageBlur(Graphics::Surface *src, Common::Rect srcRect, Graphics
_flash = false;
}
-void ESPER::copyImageBlit(Graphics::Surface *src, Common::Rect srcRect, Graphics::Surface *dst, Common::Rect dstRect) {
+void ESPER::copyImageBlit(Graphics::Surface &src, Common::Rect srcRect, Graphics::Surface &dst, Common::Rect dstRect) {
for (int y = 0; y < dstRect.height(); ++y) {
for (int x = 0; x < dstRect.width(); ++x) {
- uint16 *srcPtr = (uint16 *)src->getBasePtr(CLIP(srcRect.left + x, 0, src->w - 1), CLIP(srcRect.top + y, 0, src->h - 1));
- uint16 *dstPtr = (uint16 *)dst->getBasePtr(CLIP(dstRect.left + x, 0, dst->w - 1), CLIP(dstRect.top + y, 0, dst->h - 1));
- *dstPtr = *srcPtr;
+ uint8 r, g, b;
+ src.format.colorToRGB(*(uint32*)src.getBasePtr(CLIP(srcRect.left + x, 0, src.w - 1), CLIP(srcRect.top + y, 0, src.h - 1)), r, g, b);
+ drawPixel(dst, dst.getBasePtr(CLIP(dstRect.left + x, 0, dst.w - 1), CLIP(dstRect.top + y, 0, dst.h - 1)), dst.format.RGBToColor(r, g, b));
}
}
}
diff --git a/engines/bladerunner/ui/esper.h b/engines/bladerunner/ui/esper.h
index 8360864963..6feb2cae2d 100644
--- a/engines/bladerunner/ui/esper.h
+++ b/engines/bladerunner/ui/esper.h
@@ -247,9 +247,9 @@ private:
void flashViewport();
- void copyImageScale(Graphics::Surface *src, Common::Rect srcRect, Graphics::Surface *dst, Common::Rect dstRect);
- void copyImageBlur(Graphics::Surface *src, Common::Rect srcRect, Graphics::Surface *dst, Common::Rect dstRect, float u);
- void copyImageBlit(Graphics::Surface *src, Common::Rect srcRect, Graphics::Surface *dst, Common::Rect dstRect);
+ void copyImageScale(Graphics::Surface &src, Common::Rect srcRect, Graphics::Surface &dst, Common::Rect dstRect);
+ void copyImageBlur(Graphics::Surface &src, Common::Rect srcRect, Graphics::Surface &dst, Common::Rect dstRect, float u);
+ void copyImageBlit(Graphics::Surface &src, Common::Rect srcRect, Graphics::Surface &dst, Common::Rect dstRect);
void tickSound();
void tickScroll();
diff --git a/engines/bladerunner/ui/kia.cpp b/engines/bladerunner/ui/kia.cpp
index ed5dabcb54..a40a78670e 100644
--- a/engines/bladerunner/ui/kia.cpp
+++ b/engines/bladerunner/ui/kia.cpp
@@ -601,6 +601,7 @@ void KIA::playPhotograph(int photographId) {
void KIA::playImage(const Graphics::Surface &image) {
_playerImage.copyFrom(image);
+ _playerImage.convertToInPlace(screenPixelFormat());
}
void KIA::mouseDownCallback(int buttonId, void *callbackData) {
diff --git a/engines/bladerunner/ui/kia_section_diagnostic.cpp b/engines/bladerunner/ui/kia_section_diagnostic.cpp
index 662aef3621..a5928685f5 100644
--- a/engines/bladerunner/ui/kia_section_diagnostic.cpp
+++ b/engines/bladerunner/ui/kia_section_diagnostic.cpp
@@ -31,7 +31,7 @@
namespace BladeRunner {
-const Color256 KIASectionDiagnostic::kTextColors[] = {
+const Color256 KIASectionDiagnostic::kTextColors[] = {
{ 0, 0, 0 },
{ 16, 8, 8 },
{ 32, 24, 8 },
diff --git a/engines/bladerunner/ui/ui_slider.cpp b/engines/bladerunner/ui/ui_slider.cpp
index 7a8857582f..18538e9c49 100644
--- a/engines/bladerunner/ui/ui_slider.cpp
+++ b/engines/bladerunner/ui/ui_slider.cpp
@@ -115,7 +115,7 @@ void UISlider::draw(Graphics::Surface &surface) {
colorIndex = 3;
}
- uint16 color = surface.format.RGBToColor(kColors[colorIndex].r, kColors[colorIndex].g, kColors[colorIndex].b);
+ uint32 color = surface.format.RGBToColor(kColors[colorIndex].r, kColors[colorIndex].g, kColors[colorIndex].b);
if ((striding + x) & 1 || x == sliderX) {
color = surface.format.RGBToColor(0, 0, 0);
}
diff --git a/engines/bladerunner/ui/vk.cpp b/engines/bladerunner/ui/vk.cpp
index 5fbf763166..06056c33dd 100644
--- a/engines/bladerunner/ui/vk.cpp
+++ b/engines/bladerunner/ui/vk.cpp
@@ -772,8 +772,8 @@ void VK::drawNeedle(Graphics::Surface &surface) {
float colorIntensity = MIN(78.0f, _needleValue + 39.0f) / 78.0f;
- uint16 color1 = surface.format.RGBToColor(56 - 48 * colorIntensity, 144 - 64 * colorIntensity, 184 - 96 * colorIntensity);
- uint16 color2 = surface.format.RGBToColor(56 - 24 * colorIntensity, 144 - 32 * colorIntensity, 184 - 48 * colorIntensity);
+ uint32 color1 = surface.format.RGBToColor(56 - 48 * colorIntensity, 144 - 64 * colorIntensity, 184 - 96 * colorIntensity);
+ uint32 color2 = surface.format.RGBToColor(56 - 24 * colorIntensity, 144 - 32 * colorIntensity, 184 - 48 * colorIntensity);
surface.drawLine(203, 324, x - 2, y, color1);
surface.drawLine(203, 324, x + 2, y, color1);