[Scummvm-git-logs] scummvm master -> a11ac4edcceb386b827d0f28560298653226887e
Scorpeg
noreply at scummvm.org
Tue Nov 17 06:45:43 UTC 2026
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
a11ac4edcc GRAPHICS: Add hotspot label bounds and backend overlay alpha check
Commit: a11ac4edcceb386b827d0f28560298653226887e
https://github.com/scummvm/scummvm/commit/a11ac4edcceb386b827d0f28560298653226887e
Author: Scorp (scorp at mrs.mn)
Date: 2026-11-17T09:44:48+03:00
Commit Message:
GRAPHICS: Add hotspot label bounds and backend overlay alpha check
Changed paths:
graphics/hotspot_renderer.cpp
graphics/hotspot_renderer.h
diff --git a/graphics/hotspot_renderer.cpp b/graphics/hotspot_renderer.cpp
index 66c5df12d5f..79c91a6aad3 100644
--- a/graphics/hotspot_renderer.cpp
+++ b/graphics/hotspot_renderer.cpp
@@ -55,6 +55,13 @@ void HotspotRenderer::invalidate() {
_dirty = true;
}
+void HotspotRenderer::setLabelBounds(const Common::Rect &bounds) {
+ if (_labelBounds == bounds)
+ return;
+ _labelBounds = bounds;
+ _dirty = true;
+}
+
void HotspotRenderer::clearLabels() {
_labels.clear();
_labelBytes = 0;
@@ -192,8 +199,9 @@ void HotspotRenderer::renderOverlay(OSystem &system, MarkerShape markerShape, bo
const bool visible = system.isOverlayVisible();
if (visible && !_ownsOverlay)
return;
+ _alphaOverlay = format.aBits() && system.hasFeature(OSystem::kFeatureOverlaySupportsAlpha);
const bool resized = _overlay.w != width || _overlay.h != height || _overlay.format != format;
- if (!_dirty && !forceRedraw && !resized && visible && format.aBits() &&
+ if (!_dirty && !forceRedraw && !resized && visible && _alphaOverlay &&
_gameSize.x == gameWidth && _gameSize.y == gameHeight && _screenChangeID == screenChangeID &&
_shape == markerShape && _font == font)
return;
@@ -203,7 +211,7 @@ void HotspotRenderer::renderOverlay(OSystem &system, MarkerShape markerShape, bo
}
if (resized)
_overlay.create(width, height, format);
- if (format.aBits()) {
+ if (_alphaOverlay) {
if (!resized)
_overlay.fillRect(_previousBounds, 0);
} else {
@@ -212,7 +220,7 @@ void HotspotRenderer::renderOverlay(OSystem &system, MarkerShape markerShape, bo
}
renderFrame(&_overlay, _hotspots, gameWidth, gameHeight, width, height, format, markerShape, font);
Common::Rect upload = _drawBounds;
- if (format.aBits())
+ if (_alphaOverlay)
upload = unionRects(upload, _previousBounds);
if (resized || !visible || forceRedraw || screenChangeID != _screenChangeID)
upload = Common::Rect(width, height);
@@ -235,6 +243,7 @@ void HotspotRenderer::render(Surface *surface,
MarkerShape markerShape,
bool showText) {
const Font *font = showText ? (_style.font ? _style.font : FontMan.getFontByUsage(FontManager::kGUIFont)) : nullptr;
+ _alphaOverlay = format.aBits() != 0;
renderFrame(surface, hotspots, gameWidth, gameHeight, overlayWidth, overlayHeight, format, markerShape, font);
}
@@ -256,9 +265,12 @@ void HotspotRenderer::renderFrame(Surface *surface, const Common::Array<HotspotI
_markerSize = MAX(2, (int)(_style.markerSize * _sizeScale));
_pointRadius = MAX(1, (int)(_style.pointRadius * _sizeScale));
_lineThickness = MAX(1, (int)(_style.lineThickness * _sizeScale));
- _markerBlendColor = format.aBits() ? format.ARGBToColor(_style.markerOpacity,
+ _markerBlendColor = _alphaOverlay ? format.ARGBToColor(_style.markerOpacity,
_style.markerColor >> 16, _style.markerColor >> 8, _style.markerColor) : 0;
+ _scaledLabelBounds = Common::Rect((int)(_labelBounds.left * rawScaleX), (int)(_labelBounds.top * rawScaleY),
+ (int)(_labelBounds.right * rawScaleX), (int)(_labelBounds.bottom * rawScaleY));
+
_drawBounds = Common::Rect();
prepareRender(hotspots, gameWidth, gameHeight, overlayWidth, overlayHeight);
@@ -355,6 +367,12 @@ void HotspotRenderer::drawHotspotLabel(Surface *surface, const LabelLayout &layo
}
bool HotspotRenderer::isLabelSlotFree(const Common::Rect &candidate, int borderGrow) const {
+ if (!_scaledLabelBounds.isEmpty()) {
+ Common::Rect grown(candidate);
+ grown.grow(borderGrow);
+ if (!_scaledLabelBounds.contains(grown))
+ return false;
+ }
Common::Rect spaced(candidate);
spaced.grow(borderGrow + 2);
for (uint i = 0; i < _labelRects.size(); ++i)
@@ -612,7 +630,7 @@ void HotspotRenderer::blendPixel(Surface *surface, int px, int py,
if (!_style.markerOpacity || distance > maxSolidDistance)
return;
- if (format.aBits()) {
+ if (_alphaOverlay) {
surface->setPixel(px, py, _markerBlendColor);
return;
}
@@ -633,7 +651,7 @@ void HotspotRenderer::fillBlendRect(Surface *surface, Common::Rect rect,
if (!opacity)
return;
rect.clip(Common::Rect(surface->w, surface->h));
- if (format.aBits()) {
+ if (_alphaOverlay) {
surface->fillRect(rect, format.ARGBToColor(opacity, color >> 16, color >> 8, color));
return;
}
diff --git a/graphics/hotspot_renderer.h b/graphics/hotspot_renderer.h
index 2466859b156..2c6e6b4c13b 100644
--- a/graphics/hotspot_renderer.h
+++ b/graphics/hotspot_renderer.h
@@ -102,6 +102,7 @@ public:
const HotspotStyle &getStyle() const { return _style; }
void setStyle(const HotspotStyle &style);
void invalidate();
+ void setLabelBounds(const Common::Rect &bounds);
void releaseResources();
bool ownsOverlay() const { return _ownsOverlay; }
void hideOverlay(OSystem &system);
@@ -189,10 +190,12 @@ private:
const LabelMask &getLabelMask(const Common::U32String &text, const Font *font,
int width, int height, int baseWidth, int baseHeight, const PixelFormat &format, LabelMask &scratch);
Common::Rect _drawBounds, _previousBounds;
+ Common::Rect _labelBounds, _scaledLabelBounds;
Surface _overlay;
Common::Array<HotspotInfo> _hotspots;
bool _dirty = true;
bool _ownsOverlay = false;
+ bool _alphaOverlay = true;
Common::Point _gameSize;
int _screenChangeID = -1;
MarkerShape _shape = kMarkerCrosshair;
More information about the Scummvm-git-logs
mailing list