Index: /trunk/src/VBox/Frontends/VirtualBox/include/VBoxFBOverlay.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/include/VBoxFBOverlay.h	(revision 22821)
+++ /trunk/src/VBox/Frontends/VirtualBox/include/VBoxFBOverlay.h	(revision 22822)
@@ -1257,4 +1257,59 @@
 
 
+template <class T>
+class VBoxOverlayFrameBuffer : public T
+{
+public:
+    VBoxOverlayFrameBuffer (class VBoxConsoleView *aView)
+        : T(aView),
+          mOverlay(aView, this)
+    {}
+
+
+    STDMETHOD(ProcessVHWACommand)(BYTE *pCommand)
+    {
+        return mOverlay.onVHWACommand((VBOXVHWACMD*)pCommand);
+    }
+
+    void doProcessVHWACommand(QEvent * pEvent)
+    {
+        mOverlay.onVHWACommandEvent(pEvent);
+    }
+
+    STDMETHOD(NotifyUpdate) (ULONG aX, ULONG aY,
+                             ULONG aW, ULONG aH)
+    {
+        if(mOverlay.onNotifyUpdate(aX, aY, aW, aH))
+            return S_OK;
+        return T::NotifyUpdate(aX, aY, aW, aH);
+    }
+
+    void paintEvent (QPaintEvent *pe)
+    {
+        QRect rect;
+        VBOXFBOVERLAY_RESUT res = mOverlay.onPaintEvent(pe, &rect);
+        switch(res)
+        {
+            case VBOXFBOVERLAY_MODIFIED:
+            {
+                QPaintEvent modified(rect);
+                T::paintEvent(&modified);
+            } break;
+            case VBOXFBOVERLAY_UNTOUCHED:
+                T::paintEvent(pe);
+                break;
+        }
+    }
+
+    void resizeEvent (VBoxResizeEvent *re)
+    {
+        mOverlay.onResizeEvent(re);
+        T::resizeEvent(re);
+        mOverlay.onResizeEventPostprocess(re);
+    }
+private:
+    VBoxQGLOverlay mOverlay;
+};
+
 #endif
 
Index: /trunk/src/VBox/Frontends/VirtualBox/include/VBoxFrameBuffer.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/include/VBoxFrameBuffer.h	(revision 22821)
+++ /trunk/src/VBox/Frontends/VirtualBox/include/VBoxFrameBuffer.h	(revision 22822)
@@ -333,27 +333,4 @@
 };
 
-# ifdef VBOX_WITH_VIDEOHWACCEL
-#  ifdef VBOX_GUI_USE_QIMAGE
-class VBoxQImageOverlayFrameBuffer : public VBoxQImageFrameBuffer
-{
-public:
-    VBoxQImageOverlayFrameBuffer (VBoxConsoleView *aView);
-
-
-    STDMETHOD(ProcessVHWACommand)(BYTE *pCommand);
-
-    void doProcessVHWACommand(QEvent * pEvent);
-
-    STDMETHOD(NotifyUpdate) (ULONG aX, ULONG aY,
-                             ULONG aW, ULONG aH);
-
-    void paintEvent (QPaintEvent *pe);
-    void resizeEvent (VBoxResizeEvent *re);
-private:
-    VBoxQGLOverlay mOverlay;
-};
-#  endif /* #  ifdef VBOX_GUI_USE_QIMAGE */
-# endif /* # ifdef VBOX_WITH_VIDEOHWACCEL */
-
 #endif
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp	(revision 22821)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp	(revision 22822)
@@ -840,5 +840,5 @@
             mFrameBuf =
 #ifdef VBOX_WITH_VIDEOHWACCEL
-                    mAccelerate2DVideo ? new VBoxQImageOverlayFrameBuffer (this) :
+                    mAccelerate2DVideo ? new VBoxOverlayFrameBuffer<VBoxQImageFrameBuffer>(this) :
 #endif
                     new VBoxQImageFrameBuffer (this);
@@ -855,5 +855,9 @@
             XFlush(QX11Info::display());
 # endif
-            mFrameBuf = new VBoxSDLFrameBuffer (this);
+            mFrameBuf =
+#if defined(VBOX_WITH_VIDEOHWACCEL) && defined(DEBUG_misha) /* not tested yet */
+                    mAccelerate2DVideo ? new VBoxOverlayFrameBuffer<VBoxSDLFrameBuffer>(this) :
+#endif
+                    new VBoxSDLFrameBuffer (this);
             /*
              *  disable scrollbars because we cannot correctly draw in a
Index: /trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.cpp	(revision 22821)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.cpp	(revision 22822)
@@ -5711,3 +5711,4 @@
     }
 }
-#endif
+
+#endif
Index: /trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBQGL.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBQGL.cpp	(revision 22821)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBQGL.cpp	(revision 22822)
@@ -164,53 +164,4 @@
 }
 
-
-VBoxQImageOverlayFrameBuffer::VBoxQImageOverlayFrameBuffer (VBoxConsoleView *aView)
-    : VBoxQImageFrameBuffer(aView),
-      mOverlay(aView, this)
-{}
-
-
-STDMETHODIMP VBoxQImageOverlayFrameBuffer::ProcessVHWACommand(BYTE *pCommand)
-{
-    return mOverlay.onVHWACommand((VBOXVHWACMD*)pCommand);
-}
-
-void VBoxQImageOverlayFrameBuffer::doProcessVHWACommand(QEvent * pEvent)
-{
-    mOverlay.onVHWACommandEvent(pEvent);
-}
-
-STDMETHODIMP VBoxQImageOverlayFrameBuffer::NotifyUpdate (ULONG aX, ULONG aY,
-                             ULONG aW, ULONG aH)
-{
-    if(mOverlay.onNotifyUpdate(aX, aY, aW, aH))
-        return S_OK;
-    return VBoxQImageFrameBuffer::NotifyUpdate(aX, aY, aW, aH);
-}
-
-void VBoxQImageOverlayFrameBuffer::paintEvent (QPaintEvent *pe)
-{
-    QRect rect;
-    VBOXFBOVERLAY_RESUT res = mOverlay.onPaintEvent(pe, &rect);
-    switch(res)
-    {
-        case VBOXFBOVERLAY_MODIFIED:
-        {
-            QPaintEvent modified(rect);
-            VBoxQImageFrameBuffer::paintEvent(&modified);
-        } break;
-        case VBOXFBOVERLAY_UNTOUCHED:
-            VBoxQImageFrameBuffer::paintEvent(pe);
-            break;
-    }
-}
-
-void VBoxQImageOverlayFrameBuffer::resizeEvent (VBoxResizeEvent *re)
-{
-    mOverlay.onResizeEvent(re);
-    VBoxQImageFrameBuffer::resizeEvent(re);
-    mOverlay.onResizeEventPostprocess(re);
-}
-
 #endif
 
