aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--graphics/VectorRenderer.h10
-rw-r--r--graphics/VectorRendererSpec.cpp18
-rw-r--r--graphics/VectorRendererSpec.h2
-rw-r--r--gui/ThemeEngine.cpp2
-rw-r--r--gui/ThemeParser.cpp11
5 files changed, 32 insertions, 11 deletions
diff --git a/graphics/VectorRenderer.h b/graphics/VectorRenderer.h
index 2f609ea6db..fb19fa3156 100644
--- a/graphics/VectorRenderer.h
+++ b/graphics/VectorRenderer.h
@@ -68,6 +68,12 @@ struct DrawStep {
kVectorAlignCenter
};
+ enum AutoScaleMode {
+ kAutoScaleNone = 0,
+ kAutoScaleStretch = 1,
+ kAutoScaleFit = 2
+ };
+
VectorAlignment xAlign;
VectorAlignment yAlign;
@@ -80,7 +86,7 @@ struct DrawStep {
uint32 scale; /**< scale of all the coordinates in FIXED POINT with 16 bits mantissa */
- bool autoscale; /**< scale alphaimage if present */
+ Graphics::DrawStep::AutoScaleMode autoscale; /**< scale alphaimage if present */
DrawingFunctionCallback drawingCall; /**< Pointer to drawing function */
Graphics::Surface *blitSrc;
@@ -495,7 +501,7 @@ public:
virtual void blitKeyBitmap(const Graphics::Surface *source, const Common::Rect &r) = 0;
virtual void blitKeyBitmapClip(const Graphics::Surface *source, const Common::Rect &r, const Common::Rect &clipping) = 0;
- virtual void blitAlphaBitmap(Graphics::TransparentSurface *source, const Common::Rect &r, bool autoscale) = 0;
+ virtual void blitAlphaBitmap(Graphics::TransparentSurface *source, const Common::Rect &r, Graphics::DrawStep::AutoScaleMode autoscale = Graphics::DrawStep::kAutoScaleNone) = 0;
/**
* Draws a string into the screen. Wrapper for the Graphics::Font string drawing
diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp
index 1fdd0fc4eb..68b77d20ee 100644
--- a/graphics/VectorRendererSpec.cpp
+++ b/graphics/VectorRendererSpec.cpp
@@ -886,13 +886,25 @@ blitKeyBitmap(const Graphics::Surface *source, const Common::Rect &r) {
template<typename PixelType>
void VectorRendererSpec<PixelType>::
-blitAlphaBitmap(Graphics::TransparentSurface *source, const Common::Rect &r, bool autoscale) {
- if (autoscale)
+blitAlphaBitmap(Graphics::TransparentSurface *source, const Common::Rect &r, Graphics::DrawStep::AutoScaleMode autoscale) {
+ if (autoscale == Graphics::DrawStep::kAutoScaleStretch) {
source->blit(*_activeSurface, r.left, r.top, Graphics::FLIP_NONE,
nullptr, TS_ARGB(255, 255, 255, 255),
r.width(), r.height());
- else
+ } else if (autoscale == Graphics::DrawStep::kAutoScaleFit) {
+ double ratio = (double)r.width() / source->w;
+ double ratio2 = (double)r.height() / source->h;
+
+ if (ratio2 < ratio)
+ ratio = ratio2;
+
+ source->blit(*_activeSurface, r.left, r.top, Graphics::FLIP_NONE,
+ nullptr, TS_ARGB(255, 255, 255, 255),
+ (int)(source->w * ratio), (int)(source->h * ratio));
+
+ } else {
source->blit(*_activeSurface, r.left, r.top);
+ }
}
template<typename PixelType>
diff --git a/graphics/VectorRendererSpec.h b/graphics/VectorRendererSpec.h
index 308fdc5c94..50ee268d4d 100644
--- a/graphics/VectorRendererSpec.h
+++ b/graphics/VectorRendererSpec.h
@@ -95,7 +95,7 @@ public:
void blitSubSurfaceClip(const Graphics::Surface *source, const Common::Rect &r, const Common::Rect &clipping);
void blitKeyBitmap(const Graphics::Surface *source, const Common::Rect &r);
void blitKeyBitmapClip(const Graphics::Surface *source, const Common::Rect &r, const Common::Rect &clipping);
- void blitAlphaBitmap(Graphics::TransparentSurface *source, const Common::Rect &r, bool autoscale);
+ void blitAlphaBitmap(Graphics::TransparentSurface *source, const Common::Rect &r, Graphics::DrawStep::AutoScaleMode autoscale = Graphics::DrawStep::kAutoScaleNone);
void applyScreenShading(GUI::ThemeEngine::ShadingStyle shadingStyle);
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index 545b9b5c56..26729b916f 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -334,7 +334,7 @@ void ThemeItemABitmap::drawSelf(bool draw, bool restore) {
_engine->restoreBackground(_area);
if (draw)
- _engine->renderer()->blitAlphaBitmap(_bitmap, _area, false);
+ _engine->renderer()->blitAlphaBitmap(_bitmap, _area);
_engine->addDirtyRect(_area);
}
diff --git a/gui/ThemeParser.cpp b/gui/ThemeParser.cpp
index ca8b2631a5..226281122f 100644
--- a/gui/ThemeParser.cpp
+++ b/gui/ThemeParser.cpp
@@ -468,10 +468,13 @@ bool ThemeParser::parseDrawStep(ParserNode *stepNode, Graphics::DrawStep *drawst
drawstep->blitAlphaSrc = _theme->getAlphaBitmap(stepNode->values["file"]);
- if (stepNode->values.contains("autoscale") && stepNode->values["autoscale"] == "true")
- drawstep->autoscale = true;
- else
- drawstep->autoscale = false;
+ if (stepNode->values.contains("autoscale"))
+ if (stepNode->values["autoscale"] == "true" || stepNode->values["autoscale"] == "stretch")
+ drawstep->autoscale = Graphics::DrawStep::kAutoScaleStretch;
+ else if (stepNode->values["autoscale"] == "fit")
+ drawstep->autoscale = Graphics::DrawStep::kAutoScaleFit;
+ else
+ drawstep->autoscale = Graphics::DrawStep::kAutoScaleNone;
if (!drawstep->blitAlphaSrc)
return parserError("The given filename hasn't been loaded into the GUI.");