aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorBastien Bouclet2019-08-27 08:07:14 +0200
committerBastien Bouclet2019-10-07 21:47:42 +0200
commit1d764bd787a20ab4b8d6edd79d3bc7db459e3eb0 (patch)
treeb6e201244aabf6c87b40905cc1097c0955c73991 /gui
parentb87ebdce2101a9943f727168526fe89725ebe759 (diff)
downloadscummvm-rg350-1d764bd787a20ab4b8d6edd79d3bc7db459e3eb0.tar.gz
scummvm-rg350-1d764bd787a20ab4b8d6edd79d3bc7db459e3eb0.tar.bz2
scummvm-rg350-1d764bd787a20ab4b8d6edd79d3bc7db459e3eb0.zip
GRAPHICS: Vector renderer clipping rect related cleanups
Selecting whether a clipping variant of a draw call needs to be used is no longer the responsibility to the caller. The clipping rect is now part of the state of the renderer. Also fix some of the draw calls to better apply the clipping rect.
Diffstat (limited to 'gui')
-rw-r--r--gui/ThemeEngine.cpp38
-rw-r--r--gui/ThemeEngine.h8
-rw-r--r--gui/dialog.cpp1
-rw-r--r--gui/widget.cpp4
4 files changed, 27 insertions, 24 deletions
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index 666b9b3d8a..e27ee7ac9d 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -875,7 +875,7 @@ void ThemeEngine::drawDD(DrawData type, const Common::Rect &r, uint32 dynamic, b
if (drawData->_layer == _layerToDraw) {
Common::List<Graphics::DrawStep>::const_iterator step;
for (step = drawData->_steps.begin(); step != drawData->_steps.end(); ++step) {
- _vectorRenderer->drawStepClip(area, _clip, *step, dynamic);
+ _vectorRenderer->drawStep(area, _clip, *step, dynamic);
}
addDirtyRect(extendedRect);
@@ -912,23 +912,6 @@ void ThemeEngine::drawDDText(TextData type, TextColor color, const Common::Rect
addDirtyRect(dirty);
}
-void ThemeEngine::drawBitmap(const Graphics::Surface *bitmap, const Common::Rect &r, bool alpha) {
- if (_layerToDraw == kDrawLayerBackground)
- return;
-
- Common::Rect area = r;
- area.clip(_screen.w, _screen.h);
-
- if (alpha)
- _vectorRenderer->blitKeyBitmapClip(bitmap, area, _clip);
- else
- _vectorRenderer->blitSubSurfaceClip(bitmap, area, _clip);
-
- Common::Rect dirtyRect = area;
- dirtyRect.clip(_clip);
- addDirtyRect(dirtyRect);
-}
-
/**********************************************************
* Widget drawing functions
*********************************************************/
@@ -1123,11 +1106,22 @@ void ThemeEngine::drawPopUpWidget(const Common::Rect &r, const Common::String &s
}
}
-void ThemeEngine::drawSurface(const Common::Rect &r, const Graphics::Surface &surface, bool themeTrans) {
+void ThemeEngine::drawSurface(const Common::Point &p, const Graphics::Surface &surface, bool themeTrans) {
if (!ready())
return;
- drawBitmap(&surface, r, themeTrans);
+ if (_layerToDraw == kDrawLayerBackground)
+ return;
+
+ _vectorRenderer->setClippingRect(_clip);
+ if (themeTrans)
+ _vectorRenderer->blitKeyBitmap(&surface, p);
+ else
+ _vectorRenderer->blitSubSurface(&surface, p);
+
+ Common::Rect dirtyRect = Common::Rect(p.x, p.y, p.x + surface.w, p.y + surface.h);
+ dirtyRect.clip(_clip);
+ addDirtyRect(dirtyRect);
}
void ThemeEngine::drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background) {
@@ -1911,4 +1905,8 @@ Common::Rect ThemeEngine::swapClipRect(const Common::Rect &newRect) {
return oldRect;
}
+void ThemeEngine::disableClipRect() {
+ _clip = Common::Rect(_screen.w, _screen.h);
+}
+
} // End of namespace GUI.
diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h
index 367f5cb2c6..1c35b1ea03 100644
--- a/gui/ThemeEngine.h
+++ b/gui/ThemeEngine.h
@@ -387,6 +387,11 @@ public:
*/
Common::Rect swapClipRect(const Common::Rect &newRect);
+ /**
+ * Set the clipping rect to allow rendering on the whole surface.
+ */
+ void disableClipRect();
+
/** @name WIDGET DRAWING METHODS */
//@{
@@ -395,7 +400,7 @@ public:
void drawButton(const Common::Rect &r, const Common::String &str, WidgetStateInfo state = kStateEnabled,
uint16 hints = 0);
- void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, bool themeTrans = false);
+ void drawSurface(const Common::Point &p, const Graphics::Surface &surface, bool themeTrans = false);
void drawSlider(const Common::Rect &r, int width, WidgetStateInfo state = kStateEnabled);
@@ -633,7 +638,6 @@ protected:
bool elipsis, Graphics::TextAlign alignH = Graphics::kTextAlignLeft,
TextAlignVertical alignV = kTextAlignVTop, int deltax = 0,
const Common::Rect &drawableTextArea = Common::Rect(0, 0, 0, 0));
- void drawBitmap(const Graphics::Surface *bitmap, const Common::Rect &clippingRect, bool alpha);
/**
* DEBUG: Draws a white square and writes some text next to it.
diff --git a/gui/dialog.cpp b/gui/dialog.cpp
index 99441e0841..aeb2e1ad90 100644
--- a/gui/dialog.cpp
+++ b/gui/dialog.cpp
@@ -163,6 +163,7 @@ void Dialog::drawDialog(DrawLayer layerToDraw) {
if (!isVisible())
return;
+ g_gui.theme()->disableClipRect();
g_gui.theme()->_layerToDraw = layerToDraw;
g_gui.theme()->drawDialogBackground(Common::Rect(_x, _y, _x + _w, _y + _h), _backgroundType);
diff --git a/gui/widget.cpp b/gui/widget.cpp
index 3e372828e1..750fa4e80f 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -482,7 +482,7 @@ void PicButtonWidget::drawWidget() {
const int x = _x + (_w - gfx->w) / 2;
const int y = _y + (_h - gfx->h) / 2;
- g_gui.theme()->drawSurface(Common::Rect(x, y, x + gfx->w, y + gfx->h), *gfx, _transparency);
+ g_gui.theme()->drawSurface(Common::Point(x, y), *gfx, _transparency);
}
}
@@ -733,7 +733,7 @@ void GraphicsWidget::drawWidget() {
const int x = _x + (_w - _gfx.w) / 2;
const int y = _y + (_h - _gfx.h) / 2;
- g_gui.theme()->drawSurface(Common::Rect(x, y, x + _gfx.w, y + _gfx.h), _gfx, _transparency);
+ g_gui.theme()->drawSurface(Common::Point(x, y), _gfx, _transparency);
}
}