aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicent Marti2008-06-12 11:26:11 +0000
committerVicent Marti2008-06-12 11:26:11 +0000
commit5dd77ea8203c7d63848b0423fbc3c9bfbb8987b5 (patch)
treec63aa96ba15f34669e3e56d0fc4430745c45ba60
parentda6e5c46607f733154f1f932a158678f5293c884 (diff)
downloadscummvm-rg350-5dd77ea8203c7d63848b0423fbc3c9bfbb8987b5.tar.gz
scummvm-rg350-5dd77ea8203c7d63848b0423fbc3c9bfbb8987b5.tar.bz2
scummvm-rg350-5dd77ea8203c7d63848b0423fbc3c9bfbb8987b5.zip
- Widget caching for Interface manager.
- Expanded theme Interface - Surface blitting for VectorRenderer svn-id: r32670
-rw-r--r--graphics/VectorRenderer.h52
-rw-r--r--gui/InterfaceManager.cpp42
-rw-r--r--gui/InterfaceManager.h44
3 files changed, 126 insertions, 12 deletions
diff --git a/graphics/VectorRenderer.h b/graphics/VectorRenderer.h
index 3a2d98a376..918ed1c39e 100644
--- a/graphics/VectorRenderer.h
+++ b/graphics/VectorRenderer.h
@@ -420,6 +420,14 @@ public:
*/
virtual void copyFrame(OSystem *sys) = 0;
+ /**
+ * Blits a given graphics surface on top of the current drawing surface.
+ *
+ * @param source Surface to blit into the drawing surface.
+ * @param r Position in the active drawing surface to do the blitting.
+ */
+ virtual void blitSurface(Graphics::Surface *source, const Common::Rect &r) = 0;
+
protected:
Surface *_activeSurface; /** Pointer to the surface currently being drawn */
@@ -548,6 +556,25 @@ public:
sys->updateScreen();
}
+ /**
+ * @see VectorRenderer::blitSurface()
+ */
+ virtual void blitSurface(Graphics::Surface *source, const Common::Rect &r) {
+ PixelType *dst_ptr = (PixelType *)_activeSurface->getBasePtr(r.top, r.left);
+ PixelType *src_ptr = (PixelType *)source->getBasePtr(0, 0);
+
+ int dst_pitch = surfacePitch();
+ int src_pitch = source->pitch / source->bytesPerPixel;
+
+ int h = r.height(), w = r.width();
+
+ while (h--) {
+ colorCopy(src_ptr, dst_ptr, w);
+ dst_ptr += dst_pitch;
+ src_ptr += src_pitch;
+ }
+ }
+
protected:
/**
@@ -718,6 +745,31 @@ protected:
}
}
+ /**
+ * Copies several pixes in a row from a surface to another one.
+ * Used for surface blitting.
+ * See colorFill() for optimization guidelines.
+ *
+ * @param src Source surface.
+ * @param dst Destination surface.
+ * @param count Amount of pixels to copy over.
+ */
+ virtual inline void colorCopy(PixelType *src, PixelType *dst, int count) {
+ register int n = (count + 7) >> 3;
+ switch (count % 8) {
+ case 0: do {
+ *dst++ = *src++;
+ case 7: *dst++ = *src++;
+ case 6: *dst++ = *src++;
+ case 5: *dst++ = *src++;
+ case 4: *dst++ = *src++;
+ case 3: *dst++ = *src++;
+ case 2: *dst++ = *src++;
+ case 1: *dst++ = *src++;
+ } while (--n > 0);
+ }
+ }
+
PixelType _fgColor; /** Foreground color currently being used to draw on the renderer */
PixelType _bgColor; /** Background color currently being used to draw on the renderer */
diff --git a/gui/InterfaceManager.cpp b/gui/InterfaceManager.cpp
index 613a445fa3..e64d292e16 100644
--- a/gui/InterfaceManager.cpp
+++ b/gui/InterfaceManager.cpp
@@ -81,6 +81,48 @@ bool InterfaceManager::init() {
return false;
}
+bool InterfaceManager::isWidgetCached(DrawData type, const Common::Rect &r) {
+ return _widgets[type] && _widgets[type]->_cached &&
+ _widgets[type]->_surfaceCache->w == r.width() &&
+ _widgets[type]->_surfaceCache->h == r.height();
+}
+
+void InterfaceManager::drawCached(DrawData type, const Common::Rect &r) {
+ assert(_widgets[type]->_surfaceCache->bytesPerPixel == _screen->bytesPerPixel);
+ _vectorRenderer->blitSurface(_widgets[type]->_surfaceCache, r);
+}
+
+void InterfaceManager::drawDD(DrawData type, const Common::Rect &r) {
+ if (isWidgetCached(type, r)) {
+ drawCached(type, r);
+ } else {
+ for (int i = 0; i < _widgets[type]->_stepCount; ++i)
+ _vectorRenderer->drawStep(r, _widgets[type]->_steps[i]);
+ }
+}
+
+void InterfaceManager::drawButton(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, uint16 hints) {
+ if (!_initOk)
+ return;
+
+ if (state == kStateEnabled)
+ drawDD(kDDButtonIdle, r);
+ else if (state == kStateHighlight)
+ drawDD(kDDButtonHover, r);
+
+ // TODO: Add text drawing.
+
+ addDirtyRect(r);
+}
+
+void InterfaceManager::drawLineSeparator(const Common::Rect &r, WidgetStateInfo state) {
+ if (!_initOk)
+ return;
+
+ drawDD(kDDSeparator, r);
+ addDirtyRect(r);
+}
+
int InterfaceManager::runGUI() {
Common::EventManager *eventMan = _system->getEventManager();
_system->showOverlay();
diff --git a/gui/InterfaceManager.h b/gui/InterfaceManager.h
index 7820abd6c7..05f95ee435 100644
--- a/gui/InterfaceManager.h
+++ b/gui/InterfaceManager.h
@@ -55,16 +55,30 @@ public:
};
enum DrawData {
- kDrawDataBackground,
- kDrawDataButton,
- kDrawDataSurface,
- kDrawDataSlider,
- kDrawDataCheckbox,
- kDrawDataTab,
- kDrawDataScrollBar,
- kDrawDataPopUp,
- kDrawDataCaret,
- kDrawDataSeparator,
+ kDDMainDialogBackground,
+ kDDSpecialColorBackground,
+ kDDPlainColorBackground,
+ kDDDefaulBackground,
+
+ kDDButtonIdle,
+ kDDButtonHover,
+
+ kDDSurface,
+
+ kDDSliderFull,
+ kDDSliderEmpty,
+
+ kDDCheckboxEnabled,
+ kDDCheckboxDisabled,
+
+ kDDTab,
+
+ kDDScrollBarBase,
+ kDDScrollBarHandle,
+
+ kDDPopUp,
+ kDDCaret,
+ kDDSeparator,
kDrawDataMAX
};
@@ -141,7 +155,7 @@ public:
/** Widget drawing */
void drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background = kWidgetBackgroundPlain, WidgetStateInfo state = kStateEnabled) {}
- void drawButton(const Common::Rect &r, const Common::String &str, WidgetStateInfo state = kStateEnabled, uint16 hints = 0) {}
+ 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, WidgetStateInfo state = kStateEnabled, int alpha = 256, bool themeTrans = false) {}
void drawSlider(const Common::Rect &r, int width, WidgetStateInfo state = kStateEnabled) {}
void drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state = kStateEnabled) {}
@@ -149,7 +163,7 @@ public:
void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState, WidgetStateInfo state = kStateEnabled) {}
void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, WidgetStateInfo state = kStateEnabled, TextAlign align = kTextAlignLeft) {}
void drawCaret(const Common::Rect &r, bool erase, WidgetStateInfo state = kStateEnabled) {}
- void drawLineSeparator(const Common::Rect &r, WidgetStateInfo state = kStateEnabled) {}
+ void drawLineSeparator(const Common::Rect &r, WidgetStateInfo state = kStateEnabled);
protected:
template<typename PixelType> void screenInit();
@@ -167,6 +181,12 @@ protected:
}
}
+ bool isWidgetCached(DrawData type, const Common::Rect &r);
+ void drawCached(DrawData type, const Common::Rect &r);
+
+ inline void drawDD(DrawData type, const Common::Rect &r);
+ void addDirtyRect(const Common::Rect &r) {}
+
OSystem *_system;
Graphics::VectorRenderer *_vectorRenderer;
Graphics::Surface *_screen;