aboutsummaryrefslogtreecommitdiff
path: root/gui/ThemeEngine.cpp
diff options
context:
space:
mode:
authorBastien Bouclet2018-01-07 10:39:22 +0100
committerEugene Sandulenko2018-03-12 11:46:04 +0100
commit4d0bb753e418ee9f70937777cb3827cd3181a26b (patch)
tree151cffe7d73693389430ba33f8843f941629c6fb /gui/ThemeEngine.cpp
parent99eb0159dbd35c0081352fbc9bfeaf3077204655 (diff)
downloadscummvm-rg350-4d0bb753e418ee9f70937777cb3827cd3181a26b.tar.gz
scummvm-rg350-4d0bb753e418ee9f70937777cb3827cd3181a26b.tar.bz2
scummvm-rg350-4d0bb753e418ee9f70937777cb3827cd3181a26b.zip
GUI: Remove the ThemeItem draw queues
Drawing nows happens directly when the Dialog or Widget draw methods are called. This makes it easy to debug why a particular low level draw method was called, by inspecting the call stack. This replaces the notion of "buffering" by two independant ways to control what is drawn and where: - The active layer is used to select whether the foreground or background part of the dialogs are rendered by the draw calls. - The active surface is used to select if the draw calls affect the back buffer or the screen. The foreground layer of the active dialog is drawn directly to the screen. Its background layer is drawn to the back buffer. This way widgets can restore the back buffer in order to update without having to redraw the dialog's background. Dialogs lower in the dialog stack are drawn entirely to the back buffer.
Diffstat (limited to 'gui/ThemeEngine.cpp')
-rw-r--r--gui/ThemeEngine.cpp687
1 files changed, 246 insertions, 441 deletions
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index cff0947775..b16a6cfe4f 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -89,7 +89,7 @@ struct WidgetDrawData {
uint16 _backgroundOffset;
uint16 _shadowOffset;
- bool _buffer;
+ DrawLayer _layer;
/**
@@ -102,111 +102,13 @@ struct WidgetDrawData {
void calcBackgroundOffset();
};
-class ThemeItem {
-
-public:
- ThemeItem(ThemeEngine *engine, const Common::Rect &area) :
- _engine(engine), _area(area) {}
- virtual ~ThemeItem() {}
-
- virtual void drawSelf(bool doDraw, bool doRestore) = 0;
-
-protected:
- ThemeEngine *_engine;
- Common::Rect _area;
-};
-
-class ThemeItemDrawData : public ThemeItem {
-public:
- ThemeItemDrawData(ThemeEngine *engine, const WidgetDrawData *data, const Common::Rect &area, uint32 dynData) :
- ThemeItem(engine, area), _dynamicData(dynData), _data(data) {}
-
- void drawSelf(bool draw, bool restore);
-
-protected:
- uint32 _dynamicData;
- const WidgetDrawData *_data;
-};
-
-class ThemeItemDrawDataClip: public ThemeItem{
-public:
- ThemeItemDrawDataClip(ThemeEngine *engine, const WidgetDrawData *data, const Common::Rect &area, const Common::Rect &clip, uint32 dynData) :
- ThemeItem(engine, area), _dynamicData(dynData), _data(data), _clip(clip) {}
-
- void drawSelf(bool draw, bool restore);
-
-protected:
- uint32 _dynamicData;
- const WidgetDrawData *_data;
- const Common::Rect _clip;
-};
-
-class ThemeItemTextData : public ThemeItem {
-public:
- ThemeItemTextData(ThemeEngine *engine, const TextDrawData *data, const TextColorData *color, const Common::Rect &area, const Common::Rect &textDrawableArea,
- const Common::String &text, Graphics::TextAlign alignH, GUI::ThemeEngine::TextAlignVertical alignV,
- bool ellipsis, bool restoreBg, int deltaX) :
- ThemeItem(engine, area), _data(data), _color(color), _text(text), _alignH(alignH), _alignV(alignV),
- _ellipsis(ellipsis), _restoreBg(restoreBg), _deltax(deltaX), _textDrawableArea(textDrawableArea) {}
-
- void drawSelf(bool draw, bool restore);
-
-protected:
- Common::Rect _textDrawableArea;
- const TextDrawData *_data;
- const TextColorData *_color;
- Common::String _text;
- Graphics::TextAlign _alignH;
- GUI::ThemeEngine::TextAlignVertical _alignV;
- bool _ellipsis;
- bool _restoreBg;
- int _deltax;
-};
-
-class ThemeItemBitmap : public ThemeItem {
-public:
- ThemeItemBitmap(ThemeEngine *engine, const Common::Rect &area, const Graphics::Surface *bitmap, bool alpha) :
- ThemeItem(engine, area), _bitmap(bitmap), _alpha(alpha) {}
-
- void drawSelf(bool draw, bool restore);
-
-protected:
- const Graphics::Surface *_bitmap;
- bool _alpha;
-};
-
-class ThemeItemABitmap : public ThemeItem {
-public:
- ThemeItemABitmap(ThemeEngine *engine, const Common::Rect &area, Graphics::TransparentSurface *bitmap, ThemeEngine::AutoScaleMode autoscale, int alpha) :
- ThemeItem(engine, area), _bitmap(bitmap), _autoscale(autoscale), _alpha(alpha) {}
-
- void drawSelf(bool draw, bool restore);
-
-protected:
- Graphics::TransparentSurface *_bitmap;
- ThemeEngine::AutoScaleMode _autoscale;
- int _alpha;
-};
-
-class ThemeItemBitmapClip : public ThemeItem {
-public:
- ThemeItemBitmapClip(ThemeEngine *engine, const Common::Rect &area, const Common::Rect &clip, const Graphics::Surface *bitmap, bool alpha) :
- ThemeItem(engine, area), _bitmap(bitmap), _alpha(alpha), _clip(clip) {}
- void drawSelf(bool draw, bool restore);
-
-protected:
- const Graphics::Surface *_bitmap;
- bool _alpha;
- const Common::Rect _clip;
-};
-
/**********************************************************
* Data definitions for theme engine elements
*********************************************************/
struct DrawDataInfo {
DrawData id; ///< The actual ID of the DrawData item.
const char *name; ///< The name of the DrawData item as it appears in the Theme Description files
- bool buffer; ///< Sets whether this item is buffered on the backbuffer or drawn directly to the screen.
+ DrawLayer layer; ///< Sets whether this item is part of the foreground or background layer of its dialog
DrawData parent; ///< Parent DrawData item, for items that overlay. E.g. kDDButtonIdle -> kDDButtonHover
};
@@ -214,167 +116,62 @@ struct DrawDataInfo {
* Default values for each DrawData item.
*/
static const DrawDataInfo kDrawDataDefaults[] = {
- {kDDMainDialogBackground, "mainmenu_bg", true, kDDNone},
- {kDDSpecialColorBackground, "special_bg", true, kDDNone},
- {kDDPlainColorBackground, "plain_bg", true, kDDNone},
- {kDDTooltipBackground, "tooltip_bg", true, kDDNone},
- {kDDDefaultBackground, "default_bg", true, kDDNone},
- {kDDTextSelectionBackground, "text_selection", false, kDDNone},
- {kDDTextSelectionFocusBackground, "text_selection_focus", false, kDDNone},
-
- {kDDWidgetBackgroundDefault, "widget_default", true, kDDNone},
- {kDDWidgetBackgroundSmall, "widget_small", true, kDDNone},
- {kDDWidgetBackgroundEditText, "widget_textedit", true, kDDNone},
- {kDDWidgetBackgroundSlider, "widget_slider", true, kDDNone},
-
- {kDDButtonIdle, "button_idle", true, kDDNone},
- {kDDButtonHover, "button_hover", false, kDDButtonIdle},
- {kDDButtonDisabled, "button_disabled", true, kDDNone},
- {kDDButtonPressed, "button_pressed", false, kDDButtonIdle},
-
- {kDDSliderFull, "slider_full", false, kDDNone},
- {kDDSliderHover, "slider_hover", false, kDDNone},
- {kDDSliderDisabled, "slider_disabled", false, kDDNone},
-
- {kDDCheckboxDefault, "checkbox_default", true, kDDNone},
- {kDDCheckboxDisabled, "checkbox_disabled", true, kDDNone},
- {kDDCheckboxSelected, "checkbox_selected", false, kDDCheckboxDefault},
-
- {kDDRadiobuttonDefault, "radiobutton_default", true, kDDNone},
- {kDDRadiobuttonDisabled, "radiobutton_disabled", true, kDDNone},
- {kDDRadiobuttonSelected, "radiobutton_selected", false, kDDRadiobuttonDefault},
-
- {kDDTabActive, "tab_active", false, kDDTabInactive},
- {kDDTabInactive, "tab_inactive", true, kDDNone},
- {kDDTabBackground, "tab_background", true, kDDNone},
-
- {kDDScrollbarBase, "scrollbar_base", true, kDDNone},
-
- {kDDScrollbarButtonIdle, "scrollbar_button_idle", true, kDDNone},
- {kDDScrollbarButtonHover, "scrollbar_button_hover", false, kDDScrollbarButtonIdle},
-
- {kDDScrollbarHandleIdle, "scrollbar_handle_idle", false, kDDNone},
- {kDDScrollbarHandleHover, "scrollbar_handle_hover", false, kDDScrollbarBase},
-
- {kDDPopUpIdle, "popup_idle", true, kDDNone},
- {kDDPopUpHover, "popup_hover", false, kDDPopUpIdle},
- {kDDPopUpDisabled, "popup_disabled", true, kDDNone},
-
- {kDDCaret, "caret", false, kDDNone},
- {kDDSeparator, "separator", true, kDDNone},
+ {kDDMainDialogBackground, "mainmenu_bg", kDrawLayerBackground, kDDNone},
+ {kDDSpecialColorBackground, "special_bg", kDrawLayerBackground, kDDNone},
+ {kDDPlainColorBackground, "plain_bg", kDrawLayerBackground, kDDNone},
+ {kDDTooltipBackground, "tooltip_bg", kDrawLayerBackground, kDDNone},
+ {kDDDefaultBackground, "default_bg", kDrawLayerBackground, kDDNone},
+ {kDDTextSelectionBackground, "text_selection", kDrawLayerForeground, kDDNone},
+ {kDDTextSelectionFocusBackground, "text_selection_focus", kDrawLayerForeground, kDDNone},
+
+ {kDDWidgetBackgroundDefault, "widget_default", kDrawLayerBackground, kDDNone},
+ {kDDWidgetBackgroundSmall, "widget_small", kDrawLayerBackground, kDDNone},
+ {kDDWidgetBackgroundEditText, "widget_textedit", kDrawLayerBackground, kDDNone},
+ {kDDWidgetBackgroundSlider, "widget_slider", kDrawLayerBackground, kDDNone},
+
+ {kDDButtonIdle, "button_idle", kDrawLayerBackground, kDDNone},
+ {kDDButtonHover, "button_hover", kDrawLayerForeground, kDDButtonIdle},
+ {kDDButtonDisabled, "button_disabled", kDrawLayerBackground, kDDNone},
+ {kDDButtonPressed, "button_pressed", kDrawLayerForeground, kDDButtonIdle},
+
+ {kDDSliderFull, "slider_full", kDrawLayerForeground, kDDNone},
+ {kDDSliderHover, "slider_hover", kDrawLayerForeground, kDDNone},
+ {kDDSliderDisabled, "slider_disabled", kDrawLayerForeground, kDDNone},
+
+ {kDDCheckboxDefault, "checkbox_default", kDrawLayerBackground, kDDNone},
+ {kDDCheckboxDisabled, "checkbox_disabled", kDrawLayerBackground, kDDNone},
+ {kDDCheckboxSelected, "checkbox_selected", kDrawLayerForeground, kDDCheckboxDefault},
+
+ {kDDRadiobuttonDefault, "radiobutton_default", kDrawLayerBackground, kDDNone},
+ {kDDRadiobuttonDisabled, "radiobutton_disabled", kDrawLayerBackground, kDDNone},
+ {kDDRadiobuttonSelected, "radiobutton_selected", kDrawLayerForeground, kDDRadiobuttonDefault},
+
+ {kDDTabActive, "tab_active", kDrawLayerForeground, kDDTabInactive},
+ {kDDTabInactive, "tab_inactive", kDrawLayerBackground, kDDNone},
+ {kDDTabBackground, "tab_background", kDrawLayerBackground, kDDNone},
+
+ {kDDScrollbarBase, "scrollbar_base", kDrawLayerBackground, kDDNone},
+
+ {kDDScrollbarButtonIdle, "scrollbar_button_idle", kDrawLayerBackground, kDDNone},
+ {kDDScrollbarButtonHover, "scrollbar_button_hover", kDrawLayerForeground, kDDScrollbarButtonIdle},
+
+ {kDDScrollbarHandleIdle, "scrollbar_handle_idle", kDrawLayerForeground, kDDNone},
+ {kDDScrollbarHandleHover, "scrollbar_handle_hover", kDrawLayerForeground, kDDScrollbarBase},
+
+ {kDDPopUpIdle, "popup_idle", kDrawLayerBackground, kDDNone},
+ {kDDPopUpHover, "popup_hover", kDrawLayerForeground, kDDPopUpIdle},
+ {kDDPopUpDisabled, "popup_disabled", kDrawLayerBackground, kDDNone},
+
+ {kDDCaret, "caret", kDrawLayerForeground, kDDNone},
+ {kDDSeparator, "separator", kDrawLayerBackground, kDDNone},
};
-
-/**********************************************************
- * ThemeItem functions for drawing queues.
- *********************************************************/
-void ThemeItemDrawData::drawSelf(bool draw, bool restore) {
-
- Common::Rect extendedRect = _area;
- extendedRect.grow(_engine->kDirtyRectangleThreshold + _data->_backgroundOffset);
- if (_data->_shadowOffset > _data->_backgroundOffset) {
- extendedRect.right += _data->_shadowOffset - _data->_backgroundOffset;
- extendedRect.bottom += _data->_shadowOffset - _data->_backgroundOffset;
- }
-
- if (restore)
- _engine->restoreBackground(extendedRect);
-
- if (draw) {
- Common::List<Graphics::DrawStep>::const_iterator step;
- for (step = _data->_steps.begin(); step != _data->_steps.end(); ++step)
- _engine->renderer()->drawStep(_area, *step, _dynamicData);
- }
-
- _engine->addDirtyRect(extendedRect);
-}
-
-void ThemeItemDrawDataClip::drawSelf(bool draw, bool restore) {
-
- Common::Rect extendedRect = _area;
- extendedRect.grow(_engine->kDirtyRectangleThreshold + _data->_backgroundOffset);
- if (_data->_shadowOffset > _data->_backgroundOffset) {
- extendedRect.right += _data->_shadowOffset - _data->_backgroundOffset;
- extendedRect.bottom += _data->_shadowOffset - _data->_backgroundOffset;
- }
-
- if (restore)
- _engine->restoreBackground(extendedRect);
-
- if (draw) {
- Common::List<Graphics::DrawStep>::const_iterator step;
- for (step = _data->_steps.begin(); step != _data->_steps.end(); ++step) {
- _engine->renderer()->drawStepClip(_area, _clip, *step, _dynamicData);
- }
- }
-
- extendedRect.clip(_clip);
-
- _engine->addDirtyRect(extendedRect);
-}
-
-void ThemeItemTextData::drawSelf(bool draw, bool restore) {
- Common::Rect dirty = _textDrawableArea;
- if (dirty.isEmpty()) dirty = _area;
- else dirty.clip(_area);
-
- if (_restoreBg || restore)
- _engine->restoreBackground(dirty);
-
- if (draw) {
- _engine->renderer()->setFgColor(_color->r, _color->g, _color->b);
- _engine->renderer()->drawString(_data->_fontPtr, _text, _area, _alignH, _alignV, _deltax, _ellipsis, _textDrawableArea);
- }
-
- _engine->addDirtyRect(dirty);
-}
-
-void ThemeItemBitmap::drawSelf(bool draw, bool restore) {
- if (restore)
- _engine->restoreBackground(_area);
-
- if (draw) {
- if (_alpha)
- _engine->renderer()->blitKeyBitmap(_bitmap, _area);
- else
- _engine->renderer()->blitSubSurface(_bitmap, _area);
- }
-
- _engine->addDirtyRect(_area);
-}
-
-void ThemeItemABitmap::drawSelf(bool draw, bool restore) {
- if (restore)
- _engine->restoreBackground(_area);
-
- if (draw)
- _engine->renderer()->blitAlphaBitmap(_bitmap, _area, _autoscale, Graphics::DrawStep::kVectorAlignManual, Graphics::DrawStep::kVectorAlignManual, _alpha);
-
- _engine->addDirtyRect(_area);
-}
-
-void ThemeItemBitmapClip::drawSelf(bool draw, bool restore) {
- if (restore)
- _engine->restoreBackground(_area);
-
- if (draw) {
- if (_alpha)
- _engine->renderer()->blitKeyBitmapClip(_bitmap, _area, _clip);
- else
- _engine->renderer()->blitSubSurfaceClip(_bitmap, _area, _clip);
- }
-
- Common::Rect dirtyRect = _area;
- dirtyRect.clip(_clip);
- _engine->addDirtyRect(dirtyRect);
-}
-
/**********************************************************
* ThemeEngine class
*********************************************************/
ThemeEngine::ThemeEngine(Common::String id, GraphicsMode mode) :
_system(0), _vectorRenderer(0),
- _buffering(false), _bytesPerPixel(0), _graphicsMode(kGfxDisabled),
+ _layerToDraw(kDrawLayerBackground), _bytesPerPixel(0), _graphicsMode(kGfxDisabled),
_font(0), _initOk(false), _themeOk(false), _enabled(false), _themeFiles(),
_cursor(0) {
@@ -555,7 +352,7 @@ bool ThemeEngine::init() {
void ThemeEngine::clearAll() {
if (_initOk) {
_system->clearOverlay();
- _system->grabOverlay(_screen.getPixels(), _screen.pitch);
+ _system->grabOverlay(_backBuffer.getPixels(), _backBuffer.pitch);
}
}
@@ -671,8 +468,15 @@ void WidgetDrawData::calcBackgroundOffset() {
}
void ThemeEngine::restoreBackground(Common::Rect r) {
+ if (_vectorRenderer->getActiveSurface() == &_backBuffer) {
+ // Only restore the background when drawing to the screen surface
+ return;
+ }
+
r.clip(_screen.w, _screen.h);
_vectorRenderer->blitSurface(&_backBuffer, r);
+
+ addDirtyRect(r);
}
@@ -871,7 +675,7 @@ bool ThemeEngine::addDrawData(const Common::String &data, bool cached) {
delete _widgets[id];
_widgets[id] = new WidgetDrawData;
- _widgets[id]->_buffer = kDrawDataDefaults[id].buffer;
+ _widgets[id]->_layer = kDrawDataDefaults[id].layer;
_widgets[id]->_textDataId = kTextDataNone;
return true;
@@ -1028,143 +832,167 @@ bool ThemeEngine::loadThemeXML(const Common::String &themeId) {
/**********************************************************
- * Drawing Queue management
+ * Draw Date descriptors drawing functions
*********************************************************/
-void ThemeEngine::queueDD(DrawData type, const Common::Rect &r, uint32 dynamic, bool restore) {
- if (_widgets[type] == 0)
+void ThemeEngine::drawDD(DrawData type, const Common::Rect &r, uint32 dynamic, bool forceRestore) {
+ WidgetDrawData *drawData = _widgets[type];
+
+ if (!drawData)
return;
+ if (kDrawDataDefaults[type].parent != kDDNone && kDrawDataDefaults[type].parent != type)
+ drawDD(kDrawDataDefaults[type].parent, r);
+
Common::Rect area = r;
area.clip(_screen.w, _screen.h);
- ThemeItemDrawData *q = new ThemeItemDrawData(this, _widgets[type], area, dynamic);
+ Common::Rect extendedRect = area;
+ extendedRect.grow(kDirtyRectangleThreshold + drawData->_backgroundOffset);
+ if (drawData->_shadowOffset > drawData->_backgroundOffset) {
+ extendedRect.right += drawData->_shadowOffset - drawData->_backgroundOffset;
+ extendedRect.bottom += drawData->_shadowOffset - drawData->_backgroundOffset;
+ }
- if (_buffering) {
- if (_widgets[type]->_buffer) {
- _bufferQueue.push_back(q);
- } else {
- if (kDrawDataDefaults[type].parent != kDDNone && kDrawDataDefaults[type].parent != type)
- queueDD(kDrawDataDefaults[type].parent, r);
+ if (forceRestore || drawData->_layer == kDrawLayerBackground)
+ restoreBackground(extendedRect);
- _screenQueue.push_back(q);
- }
- } else {
- q->drawSelf(!_widgets[type]->_buffer, restore || _widgets[type]->_buffer);
- delete q;
+ if (drawData->_layer == _layerToDraw) {
+ Common::List<Graphics::DrawStep>::const_iterator step;
+ for (step = drawData->_steps.begin(); step != drawData->_steps.end(); ++step)
+ _vectorRenderer->drawStep(area, *step, dynamic);
+
+ addDirtyRect(extendedRect);
}
}
-void ThemeEngine::queueDDClip(DrawData type, const Common::Rect &r, const Common::Rect &clippingRect, uint32 dynamic, bool restore) {
- if (_widgets[type] == 0)
+void ThemeEngine::drawDDClip(DrawData type, const Common::Rect &r, const Common::Rect &clippingRect, uint32 dynamic,
+ bool forceRestore) {
+ WidgetDrawData *drawData = _widgets[type];
+
+ if (!drawData)
return;
+ if (kDrawDataDefaults[type].parent != kDDNone && kDrawDataDefaults[type].parent != type)
+ drawDDClip(kDrawDataDefaults[type].parent, r, clippingRect);
+
Common::Rect area = r;
area.clip(_screen.w, _screen.h);
- ThemeItemDrawDataClip *q = new ThemeItemDrawDataClip(this, _widgets[type], area, clippingRect, dynamic);
+ Common::Rect extendedRect = area;
+ extendedRect.grow(kDirtyRectangleThreshold + drawData->_backgroundOffset);
+ if (drawData->_shadowOffset > drawData->_backgroundOffset) {
+ extendedRect.right += drawData->_shadowOffset - drawData->_backgroundOffset;
+ extendedRect.bottom += drawData->_shadowOffset - drawData->_backgroundOffset;
+ }
+ extendedRect.clip(clippingRect);
- if (_buffering) {
- if (_widgets[type]->_buffer) {
- _bufferQueue.push_back(q);
- } else {
- if (kDrawDataDefaults[type].parent != kDDNone && kDrawDataDefaults[type].parent != type)
- queueDDClip(kDrawDataDefaults[type].parent, r, clippingRect);
+ if (forceRestore || drawData->_layer == kDrawLayerBackground)
+ restoreBackground(extendedRect);
- _screenQueue.push_back(q);
+ if (drawData->_layer == _layerToDraw) {
+ Common::List<Graphics::DrawStep>::const_iterator step;
+ for (step = drawData->_steps.begin(); step != drawData->_steps.end(); ++step) {
+ _vectorRenderer->drawStepClip(area, clippingRect, *step, dynamic);
}
- } else {
- q->drawSelf(!_widgets[type]->_buffer, restore || _widgets[type]->_buffer);
- delete q;
+
+ addDirtyRect(extendedRect);
}
}
-void ThemeEngine::queueDDText(TextData type, TextColor color, const Common::Rect &r, const Common::String &text, bool restoreBg,
- bool ellipsis, Graphics::TextAlign alignH, TextAlignVertical alignV, int deltax, const Common::Rect &drawableTextArea) {
+void ThemeEngine::drawDDText(TextData type, TextColor color, const Common::Rect &r, const Common::String &text,
+ bool restoreBg, bool ellipsis, Graphics::TextAlign alignH, TextAlignVertical alignV,
+ int deltax, const Common::Rect &drawableTextArea) {
- if (type == kTextDataNone || _texts[type] == 0)
+ if (type == kTextDataNone || !_texts[type] || _layerToDraw == kDrawLayerBackground)
return;
Common::Rect area = r;
area.clip(_screen.w, _screen.h);
- ThemeItemTextData *q = new ThemeItemTextData(this, _texts[type], _textColors[color], area, drawableTextArea, text, alignH, alignV, ellipsis, restoreBg, deltax);
+ Common::Rect dirty = drawableTextArea;
+ if (dirty.isEmpty()) dirty = area;
+ else dirty.clip(area);
- if (_buffering) {
- _screenQueue.push_back(q);
- } else {
- q->drawSelf(true, false);
- delete q;
- }
+ if (restoreBg)
+ restoreBackground(dirty);
+
+ _vectorRenderer->setFgColor(_textColors[color]->r, _textColors[color]->g, _textColors[color]->b);
+ _vectorRenderer->drawString(_texts[type]->_fontPtr, text, area, alignH, alignV, deltax, ellipsis, drawableTextArea);
+
+ addDirtyRect(dirty);
}
-void ThemeEngine::queueDDTextClip(TextData type, TextColor color, const Common::Rect &r, const Common::Rect &clippingArea, const Common::String &text, bool restoreBg,
- bool ellipsis, Graphics::TextAlign alignH, TextAlignVertical alignV, int deltax, const Common::Rect &drawableTextArea) {
+void ThemeEngine::drawDDTextClip(TextData type, TextColor color, const Common::Rect &r,
+ const Common::Rect &clippingArea, const Common::String &text, bool restoreBg,
+ bool ellipsis, Graphics::TextAlign alignH, TextAlignVertical alignV, int deltax,
+ const Common::Rect &drawableTextArea) {
- if (_texts[type] == 0)
+ if (type == kTextDataNone || !_texts[type] || _layerToDraw == kDrawLayerBackground)
return;
Common::Rect area = r;
area.clip(_screen.w, _screen.h);
- Common::Rect textArea = drawableTextArea;
- if (textArea.isEmpty()) textArea = clippingArea;
- else {
- textArea.clip(clippingArea);
- if (textArea.isEmpty()) textArea = Common::Rect(0, 0, 1, 1); // one small pixel should be invisible enough
- }
- ThemeItemTextData *q = new ThemeItemTextData(this, _texts[type], _textColors[color], area, textArea, text, alignH, alignV, ellipsis, restoreBg, deltax);
+ Common::Rect dirty = drawableTextArea;
+ if (dirty.isEmpty()) dirty = area;
+ else dirty.clip(area);
- if (_buffering) {
- _screenQueue.push_back(q);
- } else {
- q->drawSelf(true, false);
- delete q;
- }
+ dirty.clip(clippingArea);
+
+ // HACK: One small pixel should be invisible enough
+ if (dirty.isEmpty()) dirty = Common::Rect(0, 0, 1, 1);
+
+ if (restoreBg)
+ restoreBackground(dirty);
+
+ _vectorRenderer->setFgColor(_textColors[color]->r, _textColors[color]->g, _textColors[color]->b);
+ _vectorRenderer->drawString(_texts[type]->_fontPtr, text, area, alignH, alignV, deltax, ellipsis, dirty);
+
+ addDirtyRect(dirty);
}
-void ThemeEngine::queueBitmap(const Graphics::Surface *bitmap, const Common::Rect &r, bool alpha) {
+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);
- ThemeItemBitmap *q = new ThemeItemBitmap(this, area, bitmap, alpha);
+ if (alpha)
+ _vectorRenderer->blitKeyBitmap(bitmap, r);
+ else
+ _vectorRenderer->blitSubSurface(bitmap, r);
- if (_buffering) {
- _screenQueue.push_back(q);
- } else {
- q->drawSelf(true, false);
- delete q;
- }
+ addDirtyRect(r);
}
-void ThemeEngine::queueABitmap(Graphics::TransparentSurface *bitmap, const Common::Rect &r, AutoScaleMode autoscale, int alpha) {
+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);
- ThemeItemABitmap *q = new ThemeItemABitmap(this, area, bitmap, autoscale, alpha);
+ _vectorRenderer->blitAlphaBitmap(bitmap, area, autoscale, Graphics::DrawStep::kVectorAlignManual, Graphics::DrawStep::kVectorAlignManual, alpha);
- if (_buffering) {
- _screenQueue.push_back(q);
- } else {
- q->drawSelf(true, false);
- delete q;
- }
+ addDirtyRect(area);
}
-void ThemeEngine::queueBitmapClip(const Graphics::Surface *bitmap, const Common::Rect &r, const Common::Rect &clip, bool alpha) {
+void ThemeEngine::drawBitmapClip(const Graphics::Surface *bitmap, const Common::Rect &r, const Common::Rect &clip, bool alpha) {
+ if (_layerToDraw == kDrawLayerBackground)
+ return;
Common::Rect area = r;
area.clip(_screen.w, _screen.h);
- ThemeItemBitmapClip *q = new ThemeItemBitmapClip(this, area, clip, bitmap, alpha);
+ if (alpha)
+ _vectorRenderer->blitKeyBitmapClip(bitmap, area, clip);
+ else
+ _vectorRenderer->blitSubSurfaceClip(bitmap, area, clip);
- if (_buffering) {
- _screenQueue.push_back(q);
- } else {
- q->drawSelf(true, false);
- delete q;
- }
+ Common::Rect dirtyRect = area;
+ dirtyRect.clip(clip);
+ addDirtyRect(dirtyRect);
}
/**********************************************************
@@ -1185,8 +1013,8 @@ void ThemeEngine::drawButton(const Common::Rect &r, const Common::String &str, W
else if (state == kStatePressed)
dd = kDDButtonPressed;
- queueDD(dd, r, 0, hints & WIDGET_CLEARBG);
- queueDDText(getTextData(dd), getTextColor(dd), r, str, false, true, _widgets[dd]->_textAlignH, _widgets[dd]->_textAlignV);
+ drawDD(dd, r, 0, hints & WIDGET_CLEARBG);
+ drawDDText(getTextData(dd), getTextColor(dd), r, str, false, true, _widgets[dd]->_textAlignH, _widgets[dd]->_textAlignV);
}
void ThemeEngine::drawButtonClip(const Common::Rect &r, const Common::Rect &clippingRect, const Common::String &str, WidgetStateInfo state, uint16 hints) {
@@ -1204,22 +1032,22 @@ void ThemeEngine::drawButtonClip(const Common::Rect &r, const Common::Rect &clip
else if (state == kStatePressed)
dd = kDDButtonPressed;
- queueDDClip(dd, r, clippingRect, 0, hints & WIDGET_CLEARBG);
- queueDDTextClip(getTextData(dd), getTextColor(dd), r, clippingRect, str, false, true, _widgets[dd]->_textAlignH, _widgets[dd]->_textAlignV);
+ drawDDClip(dd, r, clippingRect, 0, hints & WIDGET_CLEARBG);
+ drawDDTextClip(getTextData(dd), getTextColor(dd), r, clippingRect, str, false, true, _widgets[dd]->_textAlignH, _widgets[dd]->_textAlignV);
}
void ThemeEngine::drawLineSeparator(const Common::Rect &r, WidgetStateInfo state) {
if (!ready())
return;
- queueDD(kDDSeparator, r);
+ drawDD(kDDSeparator, r);
}
void ThemeEngine::drawLineSeparatorClip(const Common::Rect &r, const Common::Rect &clippingRect, WidgetStateInfo state) {
if (!ready())
return;
- queueDDClip(kDDSeparator, r, clippingRect);
+ drawDDClip(kDDSeparator, r, clippingRect);
}
void ThemeEngine::drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state) {
@@ -1240,12 +1068,12 @@ void ThemeEngine::drawCheckbox(const Common::Rect &r, const Common::String &str,
r2.bottom = r2.top + checkBoxSize;
r2.right = r2.left + checkBoxSize;
- queueDD(dd, r2);
+ drawDD(dd, r2);
r2.left = r2.right + checkBoxSize;
r2.right = r.right;
- queueDDText(getTextData(dd), getTextColor(dd), r2, str, true, false, _widgets[kDDCheckboxDefault]->_textAlignH, _widgets[dd]->_textAlignV);
+ drawDDText(getTextData(dd), getTextColor(dd), r2, str, true, false, _widgets[kDDCheckboxDefault]->_textAlignH, _widgets[dd]->_textAlignV);
}
void ThemeEngine::drawCheckboxClip(const Common::Rect &r, const Common::Rect &clip, const Common::String &str, bool checked, WidgetStateInfo state) {
@@ -1266,12 +1094,12 @@ void ThemeEngine::drawCheckboxClip(const Common::Rect &r, const Common::Rect &cl
r2.bottom = r2.top + checkBoxSize;
r2.right = r2.left + checkBoxSize;
- queueDDClip(dd, r2, clip);
+ drawDDClip(dd, r2, clip);
r2.left = r2.right + checkBoxSize;
r2.right = r.right;
- queueDDTextClip(getTextData(dd), getTextColor(dd), r2, clip, str, true, false, _widgets[kDDCheckboxDefault]->_textAlignH, _widgets[dd]->_textAlignV);
+ drawDDTextClip(getTextData(dd), getTextColor(dd), r2, clip, str, true, false, _widgets[kDDCheckboxDefault]->_textAlignH, _widgets[dd]->_textAlignV);
}
void ThemeEngine::drawRadiobutton(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state) {
@@ -1292,12 +1120,12 @@ void ThemeEngine::drawRadiobutton(const Common::Rect &r, const Common::String &s
r2.bottom = r2.top + checkBoxSize;
r2.right = r2.left + checkBoxSize;
- queueDD(dd, r2);
+ drawDD(dd, r2);
r2.left = r2.right + checkBoxSize;
r2.right = r.right;
- queueDDText(getTextData(dd), getTextColor(dd), r2, str, true, false, _widgets[kDDRadiobuttonDefault]->_textAlignH, _widgets[dd]->_textAlignV);
+ drawDDText(getTextData(dd), getTextColor(dd), r2, str, true, false, _widgets[kDDRadiobuttonDefault]->_textAlignH, _widgets[dd]->_textAlignV);
}
void ThemeEngine::drawRadiobuttonClip(const Common::Rect &r, const Common::Rect &clippingRect, const Common::String &str, bool checked, WidgetStateInfo state) {
@@ -1318,12 +1146,12 @@ void ThemeEngine::drawRadiobuttonClip(const Common::Rect &r, const Common::Rect
r2.bottom = r2.top + checkBoxSize;
r2.right = r2.left + checkBoxSize;
- queueDDClip(dd, r2, clippingRect);
+ drawDDClip(dd, r2, clippingRect);
r2.left = r2.right + checkBoxSize;
r2.right = MAX(r2.left, r.right);
- queueDDTextClip(getTextData(dd), getTextColor(dd), r2, clippingRect, str, true, false, _widgets[kDDRadiobuttonDefault]->_textAlignH, _widgets[dd]->_textAlignV);
+ drawDDTextClip(getTextData(dd), getTextColor(dd), r2, clippingRect, str, true, false, _widgets[kDDRadiobuttonDefault]->_textAlignH, _widgets[dd]->_textAlignV);
}
void ThemeEngine::drawSlider(const Common::Rect &r, int width, WidgetStateInfo state) {
@@ -1343,7 +1171,7 @@ void ThemeEngine::drawSlider(const Common::Rect &r, int width, WidgetStateInfo s
drawWidgetBackground(r, 0, kWidgetBackgroundSlider, kStateEnabled);
- queueDD(dd, r2);
+ drawDD(dd, r2);
}
void ThemeEngine::drawSliderClip(const Common::Rect &r, const Common::Rect &clip, int width, WidgetStateInfo state) {
@@ -1363,23 +1191,23 @@ void ThemeEngine::drawSliderClip(const Common::Rect &r, const Common::Rect &clip
drawWidgetBackgroundClip(r, clip, 0, kWidgetBackgroundSlider, kStateEnabled);
- queueDDClip(dd, r2, clip);
+ drawDDClip(dd, r2, clip);
}
void ThemeEngine::drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState scrollState, WidgetStateInfo state) {
if (!ready())
return;
- queueDD(kDDScrollbarBase, r);
+ drawDD(kDDScrollbarBase, r);
Common::Rect r2 = r;
const int buttonExtra = (r.width() * 120) / 100;
r2.bottom = r2.top + buttonExtra;
- queueDD(scrollState == kScrollbarStateUp ? kDDScrollbarButtonHover : kDDScrollbarButtonIdle, r2, Graphics::VectorRenderer::kTriangleUp);
+ drawDD(scrollState == kScrollbarStateUp ? kDDScrollbarButtonHover : kDDScrollbarButtonIdle, r2, Graphics::VectorRenderer::kTriangleUp);
r2.translate(0, r.height() - r2.height());
- queueDD(scrollState == kScrollbarStateDown ? kDDScrollbarButtonHover : kDDScrollbarButtonIdle, r2, Graphics::VectorRenderer::kTriangleDown);
+ drawDD(scrollState == kScrollbarStateDown ? kDDScrollbarButtonHover : kDDScrollbarButtonIdle, r2, Graphics::VectorRenderer::kTriangleDown);
r2 = r;
r2.left += 1;
@@ -1389,30 +1217,30 @@ void ThemeEngine::drawScrollbar(const Common::Rect &r, int sliderY, int sliderHe
//r2.top += r.width() / 5;
//r2.bottom -= r.width() / 5;
- queueDD(scrollState == kScrollbarStateSlider ? kDDScrollbarHandleHover : kDDScrollbarHandleIdle, r2);
+ drawDD(scrollState == kScrollbarStateSlider ? kDDScrollbarHandleHover : kDDScrollbarHandleIdle, r2);
}
void ThemeEngine::drawScrollbarClip(const Common::Rect &r, const Common::Rect &clippingRect, int sliderY, int sliderHeight, ScrollbarState scrollState, WidgetStateInfo state) {
if (!ready())
return;
- queueDDClip(kDDScrollbarBase, r, clippingRect);
+ drawDDClip(kDDScrollbarBase, r, clippingRect);
Common::Rect r2 = r;
const int buttonExtra = (r.width() * 120) / 100;
r2.bottom = r2.top + buttonExtra;
- queueDDClip(scrollState == kScrollbarStateUp ? kDDScrollbarButtonHover : kDDScrollbarButtonIdle, r2, clippingRect, Graphics::VectorRenderer::kTriangleUp);
+ drawDDClip(scrollState == kScrollbarStateUp ? kDDScrollbarButtonHover : kDDScrollbarButtonIdle, r2, clippingRect, Graphics::VectorRenderer::kTriangleUp);
r2.translate(0, r.height() - r2.height());
- queueDDClip(scrollState == kScrollbarStateDown ? kDDScrollbarButtonHover : kDDScrollbarButtonIdle, r2, clippingRect, Graphics::VectorRenderer::kTriangleDown);
+ drawDDClip(scrollState == kScrollbarStateDown ? kDDScrollbarButtonHover : kDDScrollbarButtonIdle, r2, clippingRect, Graphics::VectorRenderer::kTriangleDown);
r2 = r;
r2.left += 1;
r2.right -= 1;
r2.top += sliderY;
r2.bottom = r2.top + sliderHeight;
- queueDDClip(scrollState == kScrollbarStateSlider ? kDDScrollbarHandleHover : kDDScrollbarHandleIdle, r2, clippingRect);
+ drawDDClip(scrollState == kScrollbarStateSlider ? kDDScrollbarHandleHover : kDDScrollbarHandleIdle, r2, clippingRect);
}
void ThemeEngine::drawDialogBackground(const Common::Rect &r, DialogBackground bgtype, WidgetStateInfo state) {
@@ -1421,23 +1249,23 @@ void ThemeEngine::drawDialogBackground(const Common::Rect &r, DialogBackground b
switch (bgtype) {
case kDialogBackgroundMain:
- queueDD(kDDMainDialogBackground, r);
+ drawDD(kDDMainDialogBackground, r);
break;
case kDialogBackgroundSpecial:
- queueDD(kDDSpecialColorBackground, r);
+ drawDD(kDDSpecialColorBackground, r);
break;
case kDialogBackgroundPlain:
- queueDD(kDDPlainColorBackground, r);
+ drawDD(kDDPlainColorBackground, r);
break;
case kDialogBackgroundTooltip:
- queueDD(kDDTooltipBackground, r);
+ drawDD(kDDTooltipBackground, r);
break;
case kDialogBackgroundDefault:
- queueDD(kDDDefaultBackground, r);
+ drawDD(kDDDefaultBackground, r);
break;
case kDialogBackgroundNone:
break;
@@ -1450,23 +1278,23 @@ void ThemeEngine::drawDialogBackgroundClip(const Common::Rect &r, const Common::
switch (bgtype) {
case kDialogBackgroundMain:
- queueDDClip(kDDMainDialogBackground, r, clip);
+ drawDDClip(kDDMainDialogBackground, r, clip);
break;
case kDialogBackgroundSpecial:
- queueDDClip(kDDSpecialColorBackground, r, clip);
+ drawDDClip(kDDSpecialColorBackground, r, clip);
break;
case kDialogBackgroundPlain:
- queueDDClip(kDDPlainColorBackground, r, clip);
+ drawDDClip(kDDPlainColorBackground, r, clip);
break;
case kDialogBackgroundTooltip:
- queueDDClip(kDDTooltipBackground, r, clip);
+ drawDDClip(kDDTooltipBackground, r, clip);
break;
case kDialogBackgroundDefault:
- queueDDClip(kDDDefaultBackground, r, clip);
+ drawDDClip(kDDDefaultBackground, r, clip);
break;
case kDialogBackgroundNone:
// no op
@@ -1480,9 +1308,8 @@ void ThemeEngine::drawCaret(const Common::Rect &r, bool erase, WidgetStateInfo s
if (erase) {
restoreBackground(r);
- addDirtyRect(r);
} else
- queueDD(kDDCaret, r);
+ drawDD(kDDCaret, r);
}
void ThemeEngine::drawCaretClip(const Common::Rect &r, const Common::Rect &clip, bool erase, WidgetStateInfo state) {
@@ -1491,9 +1318,8 @@ void ThemeEngine::drawCaretClip(const Common::Rect &r, const Common::Rect &clip,
if (erase) {
restoreBackground(r);
- addDirtyRect(r);
} else
- queueDDClip(kDDCaret, r, clip);
+ drawDDClip(kDDCaret, r, clip);
}
void ThemeEngine::drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, WidgetStateInfo state, Graphics::TextAlign align) {
@@ -1509,11 +1335,11 @@ void ThemeEngine::drawPopUpWidget(const Common::Rect &r, const Common::String &s
else if (state == kStateDisabled)
dd = kDDPopUpDisabled;
- queueDD(dd, r);
+ drawDD(dd, r);
if (!sel.empty()) {
Common::Rect text(r.left + 3, r.top + 1, r.right - 10, r.bottom);
- queueDDText(getTextData(dd), getTextColor(dd), text, sel, true, false, _widgets[dd]->_textAlignH, _widgets[dd]->_textAlignV, deltax);
+ drawDDText(getTextData(dd), getTextColor(dd), text, sel, true, false, _widgets[dd]->_textAlignH, _widgets[dd]->_textAlignV, deltax);
}
}
@@ -1530,11 +1356,11 @@ void ThemeEngine::drawPopUpWidgetClip(const Common::Rect &r, const Common::Rect
else if (state == kStateDisabled)
dd = kDDPopUpDisabled;
- queueDDClip(dd, r, clip);
+ drawDDClip(dd, r, clip);
if (!sel.empty() && r.width() >= 13 && r.height() >= 1) {
Common::Rect text(r.left + 3, r.top + 1, r.right - 10, r.bottom);
- queueDDTextClip(getTextData(dd), getTextColor(dd), text, clip, sel, true, false, _widgets[dd]->_textAlignH, _widgets[dd]->_textAlignV, deltax);
+ drawDDTextClip(getTextData(dd), getTextColor(dd), text, clip, sel, true, false, _widgets[dd]->_textAlignH, _widgets[dd]->_textAlignV, deltax);
}
}
@@ -1542,21 +1368,21 @@ void ThemeEngine::drawSurface(const Common::Rect &r, const Graphics::Surface &su
if (!ready())
return;
- queueBitmap(&surface, r, themeTrans);
+ drawBitmap(&surface, r, themeTrans);
}
void ThemeEngine::drawASurface(const Common::Rect &r, Graphics::TransparentSurface &surface, AutoScaleMode autoscale, int alpha) {
if (!ready())
return;
- queueABitmap(&surface, r, autoscale, alpha);
+ 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;
- queueBitmapClip(&surface, r, clip, themeTrans);
+ drawBitmapClip(&surface, r, clip, themeTrans);
}
void ThemeEngine::drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background, WidgetStateInfo state) {
@@ -1565,19 +1391,19 @@ void ThemeEngine::drawWidgetBackground(const Common::Rect &r, uint16 hints, Widg
switch (background) {
case kWidgetBackgroundBorderSmall:
- queueDD(kDDWidgetBackgroundSmall, r);
+ drawDD(kDDWidgetBackgroundSmall, r);
break;
case kWidgetBackgroundEditText:
- queueDD(kDDWidgetBackgroundEditText, r);
+ drawDD(kDDWidgetBackgroundEditText, r);
break;
case kWidgetBackgroundSlider:
- queueDD(kDDWidgetBackgroundSlider, r);
+ drawDD(kDDWidgetBackgroundSlider, r);
break;
default:
- queueDD(kDDWidgetBackgroundDefault, r);
+ drawDD(kDDWidgetBackgroundDefault, r);
break;
}
}
@@ -1588,19 +1414,19 @@ void ThemeEngine::drawWidgetBackgroundClip(const Common::Rect &r, const Common::
switch (background) {
case kWidgetBackgroundBorderSmall:
- queueDDClip(kDDWidgetBackgroundSmall, r, clip);
+ drawDDClip(kDDWidgetBackgroundSmall, r, clip);
break;
case kWidgetBackgroundEditText:
- queueDDClip(kDDWidgetBackgroundEditText, r, clip);
+ drawDDClip(kDDWidgetBackgroundEditText, r, clip);
break;
case kWidgetBackgroundSlider:
- queueDDClip(kDDWidgetBackgroundSlider, r, clip);
+ drawDDClip(kDDWidgetBackgroundSlider, r, clip);
break;
default:
- queueDDClip(kDDWidgetBackgroundDefault, r, clip);
+ drawDDClip(kDDWidgetBackgroundDefault, r, clip);
break;
}
}
@@ -1609,7 +1435,7 @@ void ThemeEngine::drawTab(const Common::Rect &r, int tabHeight, int tabWidth, co
if (!ready())
return;
- queueDD(kDDTabBackground, Common::Rect(r.left, r.top, r.right, r.top + tabHeight));
+ drawDD(kDDTabBackground, Common::Rect(r.left, r.top, r.right, r.top + tabHeight));
for (int i = 0; i < (int)tabs.size(); ++i) {
if (i == active)
@@ -1619,8 +1445,8 @@ void ThemeEngine::drawTab(const Common::Rect &r, int tabHeight, int tabWidth, co
continue;
Common::Rect tabRect(r.left + i * tabWidth, r.top, r.left + (i + 1) * tabWidth, r.top + tabHeight);
- queueDD(kDDTabInactive, tabRect);
- queueDDText(getTextData(kDDTabInactive), getTextColor(kDDTabInactive), tabRect, tabs[i], false, false, _widgets[kDDTabInactive]->_textAlignH, _widgets[kDDTabInactive]->_textAlignV);
+ drawDD(kDDTabInactive, tabRect);
+ drawDDText(getTextData(kDDTabInactive), getTextColor(kDDTabInactive), tabRect, tabs[i], false, false, _widgets[kDDTabInactive]->_textAlignH, _widgets[kDDTabInactive]->_textAlignV);
}
if (active >= 0 &&
@@ -1628,8 +1454,8 @@ void ThemeEngine::drawTab(const Common::Rect &r, int tabHeight, int tabWidth, co
Common::Rect tabRect(r.left + active * tabWidth, r.top, r.left + (active + 1) * tabWidth, r.top + tabHeight);
const uint16 tabLeft = active * tabWidth;
const uint16 tabRight = MAX(r.right - tabRect.right, 0);
- queueDD(kDDTabActive, tabRect, (tabLeft << 16) | (tabRight & 0xFFFF));
- queueDDText(getTextData(kDDTabActive), getTextColor(kDDTabActive), tabRect, tabs[active], false, false, _widgets[kDDTabActive]->_textAlignH, _widgets[kDDTabActive]->_textAlignV);
+ drawDD(kDDTabActive, tabRect, (tabLeft << 16) | (tabRight & 0xFFFF));
+ drawDDText(getTextData(kDDTabActive), getTextColor(kDDTabActive), tabRect, tabs[active], false, false, _widgets[kDDTabActive]->_textAlignH, _widgets[kDDTabActive]->_textAlignV);
}
}
@@ -1639,7 +1465,7 @@ void ThemeEngine::drawTabClip(const Common::Rect &r, const Common::Rect &clip, i
assert(tabs.size() == tabWidths.size());
- queueDDClip(kDDTabBackground, Common::Rect(r.left, r.top, r.right, r.top + tabHeight), clip);
+ drawDDClip(kDDTabBackground, Common::Rect(r.left, r.top, r.right, r.top + tabHeight), clip);
int width = 0;
int activePos = -1;
@@ -1654,16 +1480,16 @@ void ThemeEngine::drawTabClip(const Common::Rect &r, const Common::Rect &clip, i
Common::Rect tabRect(r.left + width, r.top, r.left + width + tabWidths[i], r.top + tabHeight);
- queueDDClip(kDDTabInactive, tabRect, clip);
- queueDDTextClip(getTextData(kDDTabInactive), getTextColor(kDDTabInactive), tabRect, clip, tabs[i], false, false, _widgets[kDDTabInactive]->_textAlignH, _widgets[kDDTabInactive]->_textAlignV);
+ drawDDClip(kDDTabInactive, tabRect, clip);
+ drawDDTextClip(getTextData(kDDTabInactive), getTextColor(kDDTabInactive), tabRect, clip, tabs[i], false, false, _widgets[kDDTabInactive]->_textAlignH, _widgets[kDDTabInactive]->_textAlignV);
}
if (activePos >= 0) {
Common::Rect tabRect(r.left + activePos, r.top, r.left + activePos + tabWidths[active], r.top + tabHeight);
const uint16 tabLeft = activePos;
const uint16 tabRight = MAX(r.right - tabRect.right, 0);
- queueDDClip(kDDTabActive, tabRect, clip, (tabLeft << 16) | (tabRight & 0xFFFF));
- queueDDTextClip(getTextData(kDDTabActive), getTextColor(kDDTabActive), tabRect, clip, tabs[active], false, false, _widgets[kDDTabActive]->_textAlignH, _widgets[kDDTabActive]->_textAlignV);
+ drawDDClip(kDDTabActive, tabRect, clip, (tabLeft << 16) | (tabRight & 0xFFFF));
+ drawDDTextClip(getTextData(kDDTabActive), getTextColor(kDDTabActive), tabRect, clip, tabs[active], false, false, _widgets[kDDTabActive]->_textAlignH, _widgets[kDDTabActive]->_textAlignV);
}
}
@@ -1724,12 +1550,12 @@ void ThemeEngine::drawText(const Common::Rect &r, const Common::String &str, Wid
switch (inverted) {
case kTextInversion:
- queueDD(kDDTextSelectionBackground, r);
+ drawDD(kDDTextSelectionBackground, r);
restore = false;
break;
case kTextInversionFocus:
- queueDD(kDDTextSelectionFocusBackground, r);
+ drawDD(kDDTextSelectionFocusBackground, r);
restore = false;
break;
@@ -1737,7 +1563,7 @@ void ThemeEngine::drawText(const Common::Rect &r, const Common::String &str, Wid
break;
}
- queueDDText(textId, colorId, r, str, restore, useEllipsis, align, kTextAlignVCenter, deltax, drawableTextArea);
+ drawDDText(textId, colorId, r, str, restore, useEllipsis, align, kTextAlignVCenter, deltax, drawableTextArea);
}
void ThemeEngine::drawTextClip(const Common::Rect &r, const Common::Rect &clippingArea, const Common::String &str, WidgetStateInfo state, Graphics::TextAlign align, TextInversionState inverted, int deltax, bool useEllipsis, FontStyle font, FontColor color, bool restore, const Common::Rect &drawableTextArea) {
@@ -1797,12 +1623,12 @@ void ThemeEngine::drawTextClip(const Common::Rect &r, const Common::Rect &clippi
switch (inverted) {
case kTextInversion:
- queueDDClip(kDDTextSelectionBackground, r, clippingArea);
+ drawDDClip(kDDTextSelectionBackground, r, clippingArea);
restore = false;
break;
case kTextInversionFocus:
- queueDDClip(kDDTextSelectionFocusBackground, r, clippingArea);
+ drawDDClip(kDDTextSelectionFocusBackground, r, clippingArea);
restore = false;
break;
@@ -1810,7 +1636,7 @@ void ThemeEngine::drawTextClip(const Common::Rect &r, const Common::Rect &clippi
break;
}
- queueDDTextClip(textId, colorId, r, clippingArea, str, restore, useEllipsis, align, kTextAlignVCenter, deltax, drawableTextArea);
+ drawDDTextClip(textId, colorId, r, clippingArea, str, restore, useEllipsis, align, kTextAlignVCenter, deltax, drawableTextArea);
}
void ThemeEngine::drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, WidgetStateInfo state, FontColor color) {
@@ -1853,40 +1679,18 @@ void ThemeEngine::debugWidgetPosition(const char *name, const Common::Rect &r) {
/**********************************************************
* Screen/overlay management
*********************************************************/
-void ThemeEngine::updateScreen(bool render) {
- if (!_bufferQueue.empty()) {
- _vectorRenderer->setSurface(&_backBuffer);
-
- for (Common::List<ThemeItem *>::iterator q = _bufferQueue.begin(); q != _bufferQueue.end(); ++q) {
- (*q)->drawSelf(true, false);
- delete *q;
- }
-
- _vectorRenderer->setSurface(&_screen);
- memcpy(_screen.getPixels(), _backBuffer.getPixels(), _screen.pitch * _screen.h);
- _bufferQueue.clear();
- }
-
- if (!_screenQueue.empty()) {
- _vectorRenderer->disableShadows();
- for (Common::List<ThemeItem *>::iterator q = _screenQueue.begin(); q != _screenQueue.end(); ++q) {
- (*q)->drawSelf(true, false);
- delete *q;
- }
-
- _vectorRenderer->enableShadows();
- _screenQueue.clear();
- }
+void ThemeEngine::copyBackBufferToScreen() {
+ memcpy(_screen.getPixels(), _backBuffer.getPixels(), _screen.pitch * _screen.h);
+}
- if (render) {
+void ThemeEngine::updateScreen() {
#ifdef LAYOUT_DEBUG_DIALOG
- _vectorRenderer->fillSurface();
- _themeEval->debugDraw(&_screen, _font);
- _vectorRenderer->copyWholeFrame(_system);
+ _vectorRenderer->fillSurface();
+ _themeEval->debugDraw(&_screen, _font);
+ _vectorRenderer->copyWholeFrame(_system);
#else
- renderDirtyScreen();
+ updateDirtyScreen();
#endif
- }
}
void ThemeEngine::addDirtyRect(Common::Rect r) {
@@ -1917,7 +1721,7 @@ void ThemeEngine::addDirtyRect(Common::Rect r) {
_dirtyScreen.push_back(r);
}
-void ThemeEngine::renderDirtyScreen() {
+void ThemeEngine::updateDirtyScreen() {
if (_dirtyScreen.empty())
return;
@@ -1929,17 +1733,11 @@ void ThemeEngine::renderDirtyScreen() {
_dirtyScreen.clear();
}
-void ThemeEngine::openDialog(bool doBuffer, ShadingStyle style) {
- if (doBuffer)
- _buffering = true;
-
+void ThemeEngine::applyScreenShading(ShadingStyle style) {
if (style != kShadingNone) {
_vectorRenderer->applyScreenShading(style);
addDirtyRect(Common::Rect(0, 0, _screen.w, _screen.h));
}
-
- memcpy(_backBuffer.getPixels(), _screen.getPixels(), _screen.pitch * _screen.h);
- _vectorRenderer->setSurface(&_screen);
}
bool ThemeEngine::createCursor(const Common::String &filename, int hotspotX, int hotspotY) {
@@ -2476,5 +2274,12 @@ void ThemeEngine::hideCursor() {
}
}
+void ThemeEngine::drawToBackbuffer() {
+ _vectorRenderer->setSurface(&_backBuffer);
+}
+
+void ThemeEngine::drawToScreen() {
+ _vectorRenderer->setSurface(&_screen);
+}
} // End of namespace GUI.