[Scummvm-cvs-logs] SF.net SVN: scummvm: [32670] scummvm/branches/gsoc2008-gui
Tanoku at users.sourceforge.net
Tanoku at users.sourceforge.net
Thu Jun 12 13:26:11 CEST 2008
Revision: 32670
http://scummvm.svn.sourceforge.net/scummvm/?rev=32670&view=rev
Author: Tanoku
Date: 2008-06-12 04:26:11 -0700 (Thu, 12 Jun 2008)
Log Message:
-----------
- Widget caching for Interface manager.
- Expanded theme Interface
- Surface blitting for VectorRenderer
Modified Paths:
--------------
scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h
scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp
scummvm/branches/gsoc2008-gui/gui/InterfaceManager.h
Modified: scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h
===================================================================
--- scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h 2008-06-12 11:09:04 UTC (rev 32669)
+++ scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h 2008-06-12 11:26:11 UTC (rev 32670)
@@ -420,6 +420,14 @@
*/
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 @@
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 @@
}
}
+ /**
+ * 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 */
Modified: scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp 2008-06-12 11:09:04 UTC (rev 32669)
+++ scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp 2008-06-12 11:26:11 UTC (rev 32670)
@@ -81,6 +81,48 @@
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();
Modified: scummvm/branches/gsoc2008-gui/gui/InterfaceManager.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/InterfaceManager.h 2008-06-12 11:09:04 UTC (rev 32669)
+++ scummvm/branches/gsoc2008-gui/gui/InterfaceManager.h 2008-06-12 11:26:11 UTC (rev 32670)
@@ -55,16 +55,30 @@
};
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 @@
/** 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 @@
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 @@
}
}
+ 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;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list