aboutsummaryrefslogtreecommitdiff
path: root/gui/ThemeEngine.h
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.h
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.h')
-rw-r--r--gui/ThemeEngine.h120
1 files changed, 70 insertions, 50 deletions
diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h
index 9d8ed41738..5675f0c5d7 100644
--- a/gui/ThemeEngine.h
+++ b/gui/ThemeEngine.h
@@ -54,7 +54,6 @@ struct TextColorData;
class Dialog;
class GuiObject;
class ThemeEval;
-class ThemeItem;
class ThemeParser;
/**
@@ -113,6 +112,18 @@ enum DrawData {
kDDNone = -1
};
+/**
+ * Dialog layers.
+ * The currently active dialog has two layers, background and foreground.
+ * The background layer is drawn to the backbuffer. The foreground layer
+ * is drawn to the screen. This allows draw calls to restore the background
+ * layer before redrawing a widget.
+ */
+enum DrawLayer {
+ kDrawLayerBackground,
+ kDrawLayerForeground
+};
+
// FIXME: TextData is really a bad name, not conveying what this enum is about.
enum TextData {
kTextDataNone = -1,
@@ -308,22 +319,38 @@ public:
const Graphics::PixelFormat getPixelFormat() const { return _overlayFormat; }
/**
- * Implementation of the GUI::Theme API. Called when a
- * new dialog is opened. Note that the boolean parameter
- * meaning has been changed.
+ * Draw full screen shading with the supplied style
+ *
+ * This is used to dim the inactive dialogs so the active one stands out.
+ */
+ void applyScreenShading(ShadingStyle shading);
+
+ /**
+ * Sets the active drawing surface to the back buffer.
+ *
+ * All drawing from this point on will be done on that surface.
+ * The back buffer surface needs to be copied to the screen surface
+ * in order to become visible.
+ */
+ void drawToBackbuffer();
+
+ /**
+ * Sets the active drawing surface to the screen.
*
- * @param enableBuffering If set to true, buffering is enabled for
- * drawing this dialog, and will continue enabled
- * until disabled.
+ * All drawing from this point on will be done on that surface.
*/
- void openDialog(bool enableBuffering, ShadingStyle shading = kShadingNone);
+ void drawToScreen();
/**
* The updateScreen() method is called every frame.
- * It processes all the drawing queues and then copies dirty rects
- * in the current Screen surface to the overlay.
+ * It copies dirty rectangles in the Screen surface to the overlay.
*/
- void updateScreen(bool render = true);
+ void updateScreen();
+
+ /**
+ * Copy the entire backbuffer surface to the screen surface
+ */
+ void copyBackBufferToScreen();
/** @name FONT MANAGEMENT METHODS */
@@ -425,8 +452,8 @@ public:
/**
* Actual implementation of a dirty rect handling.
- * Dirty rectangles are queued on a list and are later used for the
- * actual drawing.
+ * Dirty rectangles are queued on a list, merged and optimized
+ * when possible and are later used for the actual drawing.
*
* @param r Area of the dirty rect.
*/
@@ -534,13 +561,6 @@ protected:
void setGraphicsMode(GraphicsMode mode);
public:
- /**
- * Finishes buffering: widgets from then on will be drawn straight on the screen
- * without drawing queues.
- */
- inline void finishBuffering() { _buffering = false; }
- inline void startBuffering() { _buffering = true; }
-
inline ThemeEval *getEvaluator() { return _themeEval; }
inline Graphics::VectorRenderer *renderer() { return _vectorRenderer; }
@@ -623,33 +643,35 @@ protected:
const Graphics::Font *loadFont(const Common::String &filename, const Common::String &scalableFilename, const Common::String &charset, const int pointsize, const bool makeLocalizedFont);
/**
- * Actual Dirty Screen handling function.
- * Handles all the dirty squares in the list, merges and optimizes
- * them when possible and draws them to the screen.
- * Called from updateScreen()
+ * Dirty Screen handling function.
+ * Draws all the dirty rectangles in the list to the overlay.
*/
- void renderDirtyScreen();
+ void updateDirtyScreen();
/**
- * Generates a DrawQueue item and enqueues it so it's drawn to the screen
- * when the drawing queue is processed.
+ * Draws a GUI element according to a DrawData descriptor.
*
- * If Buffering is enabled, the DrawQueue item will be automatically placed
- * on its corresponding queue.
- * If Buffering is disabled, the DrawQueue item will be processed immediately
- * and drawn to the screen.
+ * Only calls with a DrawData layer attribute matching the active layer
+ * are actually drawn to the active surface.
*
- * This function is called from all the Widget Drawing methods.
+ * These functions are called from all the Widget drawing methods.
*/
- void queueDD(DrawData type, const Common::Rect &r, uint32 dynamic = 0, bool restore = false);
- void queueDDClip(DrawData type, const Common::Rect &r, const Common::Rect &clippingRect, uint32 dynamic = 0, bool restore = false);
- void queueDDText(TextData type, TextColor color, const Common::Rect &r, const Common::String &text, bool restoreBg,
- bool elipsis, Graphics::TextAlign alignH = Graphics::kTextAlignLeft, TextAlignVertical alignV = kTextAlignVTop, int deltax = 0, const Common::Rect &drawableTextArea = Common::Rect(0, 0, 0, 0));
- void queueDDTextClip(TextData type, TextColor color, const Common::Rect &r, const Common::Rect &clippingRect, const Common::String &text, bool restoreBg,
- bool elipsis, Graphics::TextAlign alignH = Graphics::kTextAlignLeft, TextAlignVertical alignV = kTextAlignVTop, int deltax = 0, const Common::Rect &drawableTextArea = Common::Rect(0, 0, 0, 0));
- void queueBitmap(const Graphics::Surface *bitmap, const Common::Rect &r, bool alpha);
- void queueBitmapClip(const Graphics::Surface *bitmap, const Common::Rect &clippingRect, const Common::Rect &r, bool alpha);
- void queueABitmap(Graphics::TransparentSurface *bitmap, const Common::Rect &r, AutoScaleMode autoscale, int alpha);
+ void drawDD(DrawData type, const Common::Rect &r, uint32 dynamic = 0, bool forceRestore = false);
+ void drawDDClip(DrawData type, const Common::Rect &r, const Common::Rect &clippingRect, uint32 dynamic = 0,
+ bool forceRestore = false);
+ void drawDDText(TextData type, TextColor color, const Common::Rect &r, const Common::String &text, bool restoreBg,
+ bool elipsis, Graphics::TextAlign alignH = Graphics::kTextAlignLeft,
+ TextAlignVertical alignV = kTextAlignVTop, int deltax = 0,
+ const Common::Rect &drawableTextArea = Common::Rect(0, 0, 0, 0));
+ void drawDDTextClip(TextData type, TextColor color, const Common::Rect &r, const Common::Rect &clippingRect,
+ const Common::String &text, bool restoreBg,
+ 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 &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.
@@ -695,9 +717,13 @@ protected:
/** Backbuffer surface. Stores previous states of the screen to blit back */
Graphics::TransparentSurface _backBuffer;
- /** Sets whether the current drawing is being buffered (stored for later
- processing) or drawn directly to the screen. */
- bool _buffering;
+ /**
+ * Filter the submitted DrawData descriptors according to their layer attribute
+ *
+ * This is used to selectively draw the background or foreground layer
+ * of the dialogs.
+ */
+ DrawLayer _layerToDraw;
/** Bytes per pixel of the Active Drawing Surface (i.e. the screen) */
int _bytesPerPixel;
@@ -731,12 +757,6 @@ protected:
/** List of all the dirty screens that must be blitted to the overlay. */
Common::List<Common::Rect> _dirtyScreen;
- /** Queue with all the drawing that must be done to the Back Buffer */
- Common::List<ThemeItem *> _bufferQueue;
-
- /** Queue with all the drawing that must be done to the screen */
- Common::List<ThemeItem *> _screenQueue;
-
bool _initOk; ///< Class and renderer properly initialized
bool _themeOk; ///< Theme data successfully loaded.
bool _enabled; ///< Whether the Theme is currently shown on the overlay