aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorEugene Sandulenko2014-05-05 21:36:16 +0300
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commitec7312ac13ce19f64b2b453b43e2c37235dcbe7a (patch)
tree8be300bb5049397d5d70732ed0be46dea2f269bc /graphics
parent4474ccf8144563c4bacbb060c943c0f68e317cea (diff)
downloadscummvm-rg350-ec7312ac13ce19f64b2b453b43e2c37235dcbe7a.tar.gz
scummvm-rg350-ec7312ac13ce19f64b2b453b43e2c37235dcbe7a.tar.bz2
scummvm-rg350-ec7312ac13ce19f64b2b453b43e2c37235dcbe7a.zip
GUI: Implemented more modes to autoscale
Diffstat (limited to 'graphics')
-rw-r--r--graphics/VectorRenderer.h10
-rw-r--r--graphics/VectorRendererSpec.cpp18
-rw-r--r--graphics/VectorRendererSpec.h2
3 files changed, 24 insertions, 6 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);