From dcfac42bb3ebec723a8762d3b2b72ff4113bf900 Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Thu, 19 Apr 2018 19:13:12 +0200 Subject: GUI: Remove alpha bitmap support It was never used since its introduction 4 years ago It was not updated to work with the clipping rect --- gui/ThemeEngine.cpp | 19 -------- gui/ThemeEngine.h | 2 - gui/widget.cpp | 126 +++++++++------------------------------------------- gui/widget.h | 7 --- 4 files changed, 21 insertions(+), 133 deletions(-) (limited to 'gui') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index b16a6cfe4f..bb424fc3dc 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -966,18 +966,6 @@ void ThemeEngine::drawBitmap(const Graphics::Surface *bitmap, const Common::Rect addDirtyRect(r); } -void ThemeEngine::drawABitmap(Graphics::TransparentSurface *bitmap, const Common::Rect &r, AutoScaleMode autoscale, int alpha) { - if (_layerToDraw == kDrawLayerBackground) - return; - - Common::Rect area = r; - area.clip(_screen.w, _screen.h); - - _vectorRenderer->blitAlphaBitmap(bitmap, area, autoscale, Graphics::DrawStep::kVectorAlignManual, Graphics::DrawStep::kVectorAlignManual, alpha); - - addDirtyRect(area); -} - void ThemeEngine::drawBitmapClip(const Graphics::Surface *bitmap, const Common::Rect &r, const Common::Rect &clip, bool alpha) { if (_layerToDraw == kDrawLayerBackground) return; @@ -1371,13 +1359,6 @@ void ThemeEngine::drawSurface(const Common::Rect &r, const Graphics::Surface &su drawBitmap(&surface, r, themeTrans); } -void ThemeEngine::drawASurface(const Common::Rect &r, Graphics::TransparentSurface &surface, AutoScaleMode autoscale, int alpha) { - if (!ready()) - return; - - drawABitmap(&surface, r, autoscale, alpha); -} - void ThemeEngine::drawSurfaceClip(const Common::Rect &r, const Common::Rect &clip, const Graphics::Surface &surface, WidgetStateInfo state, int alpha, bool themeTrans) { if (!ready()) return; diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h index 5675f0c5d7..ba301acbe0 100644 --- a/gui/ThemeEngine.h +++ b/gui/ThemeEngine.h @@ -395,7 +395,6 @@ public: void drawSurfaceClip(const Common::Rect &r, const Common::Rect &clippingRect, const Graphics::Surface &surface, WidgetStateInfo state = kStateEnabled, int alpha = 255, bool themeTrans = false); - void drawASurface(const Common::Rect &r, Graphics::TransparentSurface &surface, AutoScaleMode autoscale, int alpha); void drawSlider(const Common::Rect &r, int width, WidgetStateInfo state = kStateEnabled); @@ -671,7 +670,6 @@ protected: void drawBitmap(const Graphics::Surface *bitmap, const Common::Rect &r, bool alpha); void drawBitmapClip(const Graphics::Surface *bitmap, const Common::Rect &clippingRect, const Common::Rect &r, bool alpha); - void drawABitmap(Graphics::TransparentSurface *bitmap, const Common::Rect &r, AutoScaleMode autoscale, int alpha); /** * DEBUG: Draws a white square and writes some text next to it. diff --git a/gui/widget.cpp b/gui/widget.cpp index 9993d64dbb..3c28aab04f 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -411,19 +411,17 @@ void ButtonWidget::setUnpressedState() { PicButtonWidget::PicButtonWidget(GuiObject *boss, int x, int y, int w, int h, const char *tooltip, uint32 cmd, uint8 hotkey) : ButtonWidget(boss, x, y, w, h, "", tooltip, cmd, hotkey), - _alpha(255), _transparency(false), _showButton(true), _isAlpha(false) { + _alpha(255), _transparency(false), _showButton(true) { setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG); _type = kButtonWidget; - _mode = ThemeEngine::kAutoScaleNone; } PicButtonWidget::PicButtonWidget(GuiObject *boss, const Common::String &name, const char *tooltip, uint32 cmd, uint8 hotkey) : ButtonWidget(boss, name, "", tooltip, cmd, hotkey), - _alpha(255), _transparency(false), _showButton(true), _isAlpha(false) { + _alpha(255), _transparency(false), _showButton(true) { setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG); _type = kButtonWidget; - _mode = ThemeEngine::kAutoScaleNone; } PicButtonWidget::~PicButtonWidget() { @@ -451,23 +449,6 @@ void PicButtonWidget::setGfx(const Graphics::Surface *gfx, int statenum) { _gfx[statenum].copyFrom(*gfx); } -void PicButtonWidget::setAGfx(const Graphics::TransparentSurface *gfx, int statenum, ThemeEngine::AutoScaleMode mode) { - _agfx[statenum].free(); - - if (!gfx || !gfx->getPixels()) - return; - - if (gfx->format.bytesPerPixel == 1) { - warning("PicButtonWidget::setGfx got paletted surface passed"); - return; - } - - _agfx[statenum].copyFrom(*gfx); - - _isAlpha = true; - _mode = mode; -} - void PicButtonWidget::setGfx(int w, int h, int r, int g, int b, int statenum) { if (w == -1) w = _w; @@ -483,62 +464,34 @@ void PicButtonWidget::setGfx(int w, int h, int r, int g, int b, int statenum) { void PicButtonWidget::drawWidget() { if (_showButton) - g_gui.theme()->drawButtonClip(Common::Rect(_x, _y, _x + _w, _y + _h), getBossClipRect(), "", _state, getFlags()); + g_gui.theme()->drawButton(Common::Rect(_x, _y, _x + _w, _y + _h), "", _state, getFlags()); - if (!_isAlpha) { - Graphics::Surface *gfx; + Graphics::Surface *gfx; - if (_state == ThemeEngine::kStateHighlight) - gfx = &_gfx[kPicButtonHighlight]; - else if (_state == ThemeEngine::kStateDisabled) - gfx = &_gfx[kPicButtonStateDisabled]; - else if (_state == ThemeEngine::kStatePressed) - gfx = &_gfx[kPicButtonStatePressed]; - else - gfx = &_gfx[kPicButtonStateEnabled]; + if (_state == ThemeEngine::kStateHighlight) + gfx = &_gfx[kPicButtonHighlight]; + else if (_state == ThemeEngine::kStateDisabled) + gfx = &_gfx[kPicButtonStateDisabled]; + else if (_state == ThemeEngine::kStatePressed) + gfx = &_gfx[kPicButtonStatePressed]; + else + gfx = &_gfx[kPicButtonStateEnabled]; - if (!gfx->getPixels()) - gfx = &_gfx[kPicButtonStateEnabled]; + if (!gfx->getPixels()) + gfx = &_gfx[kPicButtonStateEnabled]; - if (gfx->getPixels()) { + if (gfx->getPixels()) { // Check whether the set up surface needs to be converted to the GUI // color format. - const Graphics::PixelFormat &requiredFormat = g_gui.theme()->getPixelFormat(); - if (gfx->format != requiredFormat) { - gfx->convertToInPlace(requiredFormat); - } - - const int x = _x + (_w - gfx->w) / 2; - const int y = _y + (_h - gfx->h) / 2; - - g_gui.theme()->drawSurfaceClip(Common::Rect(x, y, x + gfx->w, y + gfx->h), getBossClipRect(), *gfx, _state, _alpha, _transparency); + const Graphics::PixelFormat &requiredFormat = g_gui.theme()->getPixelFormat(); + if (gfx->format != requiredFormat) { + gfx->convertToInPlace(requiredFormat); } - } else { - Graphics::TransparentSurface *gfx; - - if (_state == ThemeEngine::kStateHighlight) - gfx = &_agfx[kPicButtonHighlight]; - else if (_state == ThemeEngine::kStateDisabled) - gfx = &_agfx[kPicButtonStateDisabled]; - else if (_state == ThemeEngine::kStatePressed) - gfx = &_agfx[kPicButtonStatePressed]; - else - gfx = &_agfx[kPicButtonStateEnabled]; - - if (!gfx->getPixels()) - gfx = &_agfx[kPicButtonStateEnabled]; - - if (gfx->getPixels()) { - if (_mode == GUI::ThemeEngine::kAutoScaleNone) { - const int x = _x + (_w - gfx->w) / 2; - const int y = _y + (_h - gfx->h) / 2; - g_gui.theme()->drawASurface(Common::Rect(x, y, x + gfx->w, y + gfx->h), *gfx, _mode, _alpha); + const int x = _x + (_w - gfx->w) / 2; + const int y = _y + (_h - gfx->h) / 2; - } else { - g_gui.theme()->drawASurface(Common::Rect(_x, _y, _x + _w, _y + _h), *gfx, _mode, _alpha); - } - } + g_gui.theme()->drawSurfaceClip(Common::Rect(x, y, x + gfx->w, y + gfx->h), getBossClipRect(), *gfx, _state, _alpha, _transparency); } } @@ -764,26 +717,6 @@ void GraphicsWidget::setGfx(const Graphics::Surface *gfx) { _gfx.copyFrom(*gfx); } -void GraphicsWidget::setAGfx(const Graphics::TransparentSurface *gfx, ThemeEngine::AutoScaleMode mode) { - _agfx.free(); - - if (!gfx || !gfx->getPixels()) - return; - - if (gfx->format.bytesPerPixel == 1) { - warning("GraphicsWidget::setGfx got paletted surface passed"); - return; - } - - if ((gfx->w > _w || gfx->h > _h) && mode == ThemeEngine::kAutoScaleNone) { - warning("GraphicsWidget has size %dx%d, but a surface with %dx%d is to be set", _w, _h, gfx->w, gfx->h); - return; - } - - _agfx.copyFrom(*gfx); - _mode = mode; -} - void GraphicsWidget::setGfx(int w, int h, int r, int g, int b) { if (w == -1) w = _w; @@ -810,23 +743,6 @@ void GraphicsWidget::drawWidget() { const int y = _y + (_h - _gfx.h) / 2; g_gui.theme()->drawSurfaceClip(Common::Rect(x, y, x + _gfx.w, y + _gfx.h), getBossClipRect(), _gfx, _state, _alpha, _transparency); - } else if (_agfx.getPixels()) { - // Check whether the set up surface needs to be converted to the GUI - // color format. - const Graphics::PixelFormat &requiredFormat = g_gui.theme()->getPixelFormat(); - if (_agfx.format != requiredFormat) { - _agfx.convertToInPlace(requiredFormat); - } - - if (_mode == GUI::ThemeEngine::kAutoScaleNone) { - const int x = _x + (_w - _agfx.w) / 2; - const int y = _y + (_h - _agfx.h) / 2; - - g_gui.theme()->drawASurface(Common::Rect(x, y, x + _agfx.w, y + _agfx.h), _agfx, _mode, _alpha); - - } else { - g_gui.theme()->drawASurface(Common::Rect(_x, _y, _x + _w, _y + _h), _agfx, _mode, _alpha); - } } } diff --git a/gui/widget.h b/gui/widget.h index e57f3cde51..09ee446386 100644 --- a/gui/widget.h +++ b/gui/widget.h @@ -240,7 +240,6 @@ public: ~PicButtonWidget(); void setGfx(const Graphics::Surface *gfx, int statenum = kPicButtonStateEnabled); - void setAGfx(const Graphics::TransparentSurface *gfx, int statenum = kPicButtonStateEnabled, ThemeEngine::AutoScaleMode mode = ThemeEngine::kAutoScaleNone); void setGfx(int w, int h, int r, int g, int b, int statenum = kPicButtonStateEnabled); void useAlpha(int alpha) { _alpha = alpha; } @@ -251,12 +250,9 @@ protected: void drawWidget(); Graphics::Surface _gfx[kPicButtonStateMax + 1]; - Graphics::TransparentSurface _agfx[kPicButtonStateMax + 1]; int _alpha; bool _transparency; bool _showButton; - bool _isAlpha; - ThemeEngine::AutoScaleMode _mode; }; /* CheckboxWidget */ @@ -375,7 +371,6 @@ public: void setGfx(const Graphics::Surface *gfx); void setGfx(int w, int h, int r, int g, int b); - void setAGfx(const Graphics::TransparentSurface *gfx, ThemeEngine::AutoScaleMode mode = ThemeEngine::kAutoScaleNone); void useAlpha(int alpha) { _alpha = alpha; } void useThemeTransparency(bool enable) { _transparency = enable; } @@ -384,10 +379,8 @@ protected: void drawWidget(); Graphics::Surface _gfx; - Graphics::TransparentSurface _agfx; int _alpha; bool _transparency; - ThemeEngine::AutoScaleMode _mode; }; /* ContainerWidget */ -- cgit v1.2.3