[Scummvm-git-logs] scummvm master -> 5a5eb7811dbdd6895f16b1b0b5fb752397f1e864
bluegr
noreply at scummvm.org
Sun Jun 19 21:29:10 UTC 2022
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
5a5eb7811d ULTIMA8: Avoid internal compiler error on RISC OS with -O2 and -mfpu=vfp
Commit: 5a5eb7811dbdd6895f16b1b0b5fb752397f1e864
https://github.com/scummvm/scummvm/commit/5a5eb7811dbdd6895f16b1b0b5fb752397f1e864
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2022-06-20T00:29:07+03:00
Commit Message:
ULTIMA8: Avoid internal compiler error on RISC OS with -O2 and -mfpu=vfp
Changed paths:
engines/ultima/ultima8/graphics/fonts/tt_font.cpp
engines/ultima/ultima8/graphics/fonts/tt_font.h
diff --git a/engines/ultima/ultima8/graphics/fonts/tt_font.cpp b/engines/ultima/ultima8/graphics/fonts/tt_font.cpp
index c3faf0742df..7ac15eb9256 100644
--- a/engines/ultima/ultima8/graphics/fonts/tt_font.cpp
+++ b/engines/ultima/ultima8/graphics/fonts/tt_font.cpp
@@ -118,6 +118,76 @@ void TTFont::getTextSize(const Std::string &text,
}
+void TTFont::addTextBorder(Graphics::ManagedSurface &textSurf, uint32 *texBuf, const Ultima::Ultima8::Rect &dims, int32 resultWidth, int32 resultHeight, uint32 borderColor) {
+ uint8 bA, bR, bG, bB;
+ _PF_RGBA.colorToARGB(borderColor, bA, bR, bG, bB);
+
+ int sqrSize = _borderSize * _borderSize;
+ int sqrEdge = (_borderSize + 1) * (_borderSize + 1);
+
+ for (int y = 0; y < textSurf.h; y++) {
+ const byte* surfrow = (const byte*)textSurf.getBasePtr(0, y);
+
+ for (int x = 0; x < textSurf.w; x++) {
+ if (_antiAliased) {
+ uint32 sColor = *((const uint32 *)(surfrow + x * 4));
+ uint8 sR, sG, sB, sA;
+ _PF_RGBA.colorToARGB(sColor, sA, sR, sG, sB);
+
+ if (sA == 0x00)
+ continue;
+
+ for (int dx = -_borderSize; dx <= _borderSize; dx++) {
+ for (int dy = -_borderSize; dy <= _borderSize; dy++) {
+ int tx = dims.left + x + _borderSize + dx;
+ int ty = dims.top + y + _borderSize + dy;
+ if (tx >= 0 && tx < resultWidth && ty >= 0 && ty < resultHeight) {
+ uint32 dColor = texBuf[ty * resultWidth + tx];
+ if (borderColor != dColor) {
+ int sqrDist = (dx * dx) + (dy * dy);
+ if (sqrDist < sqrSize) {
+ texBuf[ty * resultWidth + tx] = borderColor;
+ }
+ else if (sqrDist < sqrEdge) {
+ // Blend border color at source intensity with destination
+ uint8 dA, dR, dG, dB;
+ _PF_RGBA.colorToARGB(dColor, dA, dR, dG, dB);
+
+ double bAlpha = (double)bA / 255.0;
+ double sAlpha = (double)sA / 255.0;
+ double dAlpha = (double)dA / 255.0;
+ dAlpha *= (1.0 - sAlpha);
+
+ dR = static_cast<uint8>((bR * sAlpha + dR * dAlpha) / (sAlpha + dAlpha));
+ dG = static_cast<uint8>((bG * sAlpha + dG * dAlpha) / (sAlpha + dAlpha));
+ dB = static_cast<uint8>((bB * sAlpha + dB * dAlpha) / (sAlpha + dAlpha));
+ dA = static_cast<uint8>(255. * bAlpha * (sAlpha + dAlpha));
+
+ texBuf[ty * resultWidth + tx] = _PF_RGBA.ARGBToColor(dA, dR, dG, dB);
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (surfrow[x] == 1) {
+ for (int dx = -_borderSize; dx <= _borderSize; dx++) {
+ for (int dy = -_borderSize; dy <= _borderSize; dy++) {
+ int tx = dims.left + x + _borderSize + dx;
+ int ty = dims.top + y + _borderSize + dy;
+ if (tx >= 0 && tx < resultWidth && ty >= 0 && ty < resultHeight) {
+ int sqrDist = (dx * dx) + (dy * dy);
+ if (sqrDist < sqrEdge) {
+ texBuf[ty * resultWidth + tx] = borderColor;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
RenderedText *TTFont::renderText(const Std::string &text, unsigned int &remaining,
int32 width, int32 height, TextAlign align, bool u8specials,
Std::string::size_type cursor) {
@@ -161,73 +231,7 @@ RenderedText *TTFont::renderText(const Std::string &text, unsigned int &remainin
// Add border within radius. Pixels on the edge are alpha blended if antialiased
if (_borderSize > 0) {
- uint8 bA, bR, bG, bB;
- _PF_RGBA.colorToARGB(borderColor, bA, bR, bG, bB);
-
- int sqrSize = _borderSize * _borderSize;
- int sqrEdge = (_borderSize + 1) * (_borderSize + 1);
-
- for (int y = 0; y < textSurf.h; y++) {
- const byte* surfrow = (const byte*)textSurf.getBasePtr(0, y);
-
- for (int x = 0; x < textSurf.w; x++) {
- if (_antiAliased) {
- uint32 sColor = *((const uint32 *)(surfrow + x * 4));
- uint8 sR, sG, sB, sA;
- _PF_RGBA.colorToARGB(sColor, sA, sR, sG, sB);
-
- if (sA == 0x00)
- continue;
-
- for (int dx = -_borderSize; dx <= _borderSize; dx++) {
- for (int dy = -_borderSize; dy <= _borderSize; dy++) {
- int tx = iter->_dims.left + x + _borderSize + dx;
- int ty = iter->_dims.top + y + _borderSize + dy;
- if (tx >= 0 && tx < resultWidth && ty >= 0 && ty < resultHeight) {
- uint32 dColor = texBuf[ty * resultWidth + tx];
- if (borderColor != dColor) {
- int sqrDist = (dx * dx) + (dy * dy);
- if (sqrDist < sqrSize) {
- texBuf[ty * resultWidth + tx] = borderColor;
- }
- else if (sqrDist < sqrEdge) {
- // Blend border color at source intensity with destination
- uint8 dA, dR, dG, dB;
- _PF_RGBA.colorToARGB(dColor, dA, dR, dG, dB);
-
- double bAlpha = (double)bA / 255.0;
- double sAlpha = (double)sA / 255.0;
- double dAlpha = (double)dA / 255.0;
- dAlpha *= (1.0 - sAlpha);
-
- dR = static_cast<uint8>((bR * sAlpha + dR * dAlpha) / (sAlpha + dAlpha));
- dG = static_cast<uint8>((bG * sAlpha + dG * dAlpha) / (sAlpha + dAlpha));
- dB = static_cast<uint8>((bB * sAlpha + dB * dAlpha) / (sAlpha + dAlpha));
- dA = static_cast<uint8>(255. * bAlpha * (sAlpha + dAlpha));
-
- texBuf[ty * resultWidth + tx] = _PF_RGBA.ARGBToColor(dA, dR, dG, dB);
- }
- }
- }
- }
- }
- }
- else if (surfrow[x] == 1) {
- for (int dx = -_borderSize; dx <= _borderSize; dx++) {
- for (int dy = -_borderSize; dy <= _borderSize; dy++) {
- int tx = iter->_dims.left + x + _borderSize + dx;
- int ty = iter->_dims.top + y + _borderSize + dy;
- if (tx >= 0 && tx < resultWidth && ty >= 0 && ty < resultHeight) {
- int sqrDist = (dx * dx) + (dy * dy);
- if (sqrDist < sqrEdge) {
- texBuf[ty * resultWidth + tx] = borderColor;
- }
- }
- }
- }
- }
- }
- }
+ addTextBorder(textSurf, texBuf, iter->_dims, resultWidth, resultHeight, borderColor);
}
// render the text surface into our texture buffer
diff --git a/engines/ultima/ultima8/graphics/fonts/tt_font.h b/engines/ultima/ultima8/graphics/fonts/tt_font.h
index ba863a0b37d..0d48eeb1138 100644
--- a/engines/ultima/ultima8/graphics/fonts/tt_font.h
+++ b/engines/ultima/ultima8/graphics/fonts/tt_font.h
@@ -65,6 +65,8 @@ protected:
Graphics::PixelFormat _PF_RGBA;
uint16 _bullet;
+
+ void addTextBorder(Graphics::ManagedSurface &textSurf, uint32 *texBuf, const Ultima::Ultima8::Rect &dims, int32 resultWidth, int32 resultHeight, uint32 borderColor);
};
} // End of namespace Ultima8
More information about the Scummvm-git-logs
mailing list