VirtualBox

Changeset 22794 in vbox


Ignore:
Timestamp:
Sep 5, 2009 7:31:56 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
51987
Message:

video 2d accel: first step to make ogl be used only when overlay is enabled, bugfixes

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxDefs.h

    r22099 r22794  
    8484        InvalidRenderMode, TimerMode, QImageMode, SDLMode, DDRAWMode, Quartz2DMode
    8585#ifdef VBOX_GUI_USE_QGL
    86         , QGLMode
     86        , QGLMode, QGLOverlayMode
    8787#endif
    8888    };
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxFrameBuffer.h

    r22776 r22794  
    420420    const QRect & rect() const {return mRect;}
    421421
     422    const QRect & toRect()
     423    {
     424        if(isClear())
     425        {
     426            mRect.setCoords(0, 0, -1, -1);
     427        }
     428        return mRect;
     429    }
     430
    422431    bool intersects(const QRect & aRect) const {return mIsClear ? false : mRect.intersects(aRect);}
    423432
     
    665674            bool aIsYInverted,
    666675#endif
    667             const QSize * aSize, const QSize * aTargetSize,
     676            const QSize & aSize,
     677            const QRect & aTargRect,
     678            const QRect & aSrcRect,
     679            const QRect & aVisTargRect,
    668680            VBoxVHWAColorFormat & aColorFormat,
    669681            VBoxVHWAColorKey * pSrcBltCKey, VBoxVHWAColorKey * pDstBltCKey,
     
    689701    void performDisplay(VBoxVHWASurfaceBase *pPrimary);
    690702
    691     void setRects(VBoxVHWASurfaceBase *pPrimary, const QRect * aTargRect, const QRect * aSrcRect);
    692     void setTargetRectPosition(VBoxVHWASurfaceBase *pPrimary, const QPoint * aPoint);
     703    void setRects(VBoxVHWASurfaceBase *pPrimary, const QRect & aTargRect, const QRect & aSrcRect, const QRect & aVisibleTargRect, bool bForceReinit);
     704    void setTargRectPosition(VBoxVHWASurfaceBase *pPrimary, const QPoint & aPoint, const QRect & aVisibleTargRect);
     705    void updateVisibleTargRect(VBoxVHWASurfaceBase *pPrimary, const QRect & aVisibleTargRect);
    693706
    694707    static ulong calcBytesPerPixel(GLenum format, GLenum type);
     
    824837    static int setCKey(class VBoxVHWAGlProgramVHWA * pProgram, const VBoxVHWAColorFormat * pFormat, const VBoxVHWAColorKey * pCKey, bool bDst);
    825838
    826     uint32_t handle() {return mHGHandle;}
     839    uint32_t handle() const {return mHGHandle;}
    827840    void setHandle(uint32_t h) {mHGHandle = h;}
    828 private:
     841
     842private:
     843    void doSetRectValuesInternal(const QRect & aTargRect, const QRect & aSrcRect, const QRect & aVisTargRect);
     844
    829845    void setComplexList(VBoxVHWASurfList *aComplexList) { mComplexList = aComplexList; }
    830846    void initDisplay(VBoxVHWASurfaceBase *pPrimary);
     
    845861    QRect mSrcRect;
    846862    QRect mTargRect; /* == Vis FB size */
    847     QRect mTargSize;
     863
     864    QRect mVisibleTargRect;
     865    QRect mVisibleSrcRect;
    848866
    849867    GLuint mVisibleDisplay;
     
    10261044
    10271045    const OverlayList & overlays() const {return mOverlays;}
     1046    const VBoxVHWASurfList & primaries() const { return mPrimary; }
    10281047
    10291048private:
     
    12021221    void vhwaSaveExec(struct SSMHANDLE * pSSM);
    12031222    int vhwaLoadExec(struct SSMHANDLE * pSSM, uint32_t u32Version);
    1204 #endif
    1205 
    1206     ulong vboxBitsPerPixel() { return mDisplay.getVGA()->bitsPerPixel(); }
    1207     ulong vboxBytesPerLine() { return mDisplay.getVGA() ? mDisplay.getVGA()->bytesPerLine() : 0; }
    1208 
    1209     void vboxPaintEvent (QPaintEvent *pe) {vboxPerformGLOp(&VBoxGLWidget::vboxDoPaint, pe); }
    1210     void vboxResizeEvent (VBoxResizeEvent *re) {vboxPerformGLOp(&VBoxGLWidget::vboxDoResize, re); }
    1211 
    1212     void vboxProcessVHWACommands(class VBoxVHWACommandProcessEvent * pEvent) {vboxPerformGLOp(&VBoxGLWidget::vboxDoProcessVHWACommands, pEvent);}
    1213 #ifdef VBOX_WITH_VIDEOHWACCEL
    1214     void vboxVHWACmd (struct _VBOXVHWACMD * pCmd) {vboxPerformGLOp(&VBoxGLWidget::vboxDoVHWACmd, pCmd);}
    1215 #endif
    1216     class VBoxVHWAGlProgramMngr * vboxVHWAGetGlProgramMngr() { return mpMngr; }
    1217 
    1218     VBoxVHWASurfaceBase * vboxGetVGASurface() { return mDisplay.getVGA(); }
    1219 
    1220     void postCmd(VBOXVHWA_PIPECMD_TYPE aType, void * pvData);
    1221 
    1222     static void doSetupMatrix(const QSize & aSize, bool bInverted);
    1223 protected:
    1224 
    1225     void paintGL()
    1226     {
    1227         if(mpfnOp)
    1228         {
    1229             (this->*mpfnOp)(mOpContext);
    1230             mpfnOp = NULL;
    1231         }
    1232         else
    1233         {
    1234             mDisplay.performDisplay();
    1235         }
    1236     }
    1237 
    1238     void initializeGL();
    1239 private:
    1240     static void setupMatricies(const QSize &display);
    1241     static void adjustViewport(const QSize &display, const QRect &viewport);
    1242     void vboxDoResize(void *re);
    1243     void vboxDoPaint(void *rec);
    1244 
    1245     void vboxDoUpdateRect(const QRect * pRect);
    1246 #ifdef VBOXQGL_DBG_SURF
    1247     void vboxDoTestSurfaces(void *context);
    1248 #endif
    1249 #ifdef VBOX_WITH_VIDEOHWACCEL
    1250     void vboxDoVHWACmdExec(void *cmd);
    1251     void vboxDoVHWACmdAndFree(void *cmd);
    1252     void vboxDoVHWACmd(void *cmd);
    1253 
    1254     void vboxCheckUpdateAddress (VBoxVHWASurfaceBase * pSurface, uint64_t offset)
    1255     {
    1256         if (pSurface->addressAlocated())
    1257         {
    1258             uchar * addr = vboxVRAMAddressFromOffset(offset);
    1259             if(addr)
    1260             {
    1261                 pSurface->setAddress(addr);
    1262             }
    1263         }
    1264     }
     1223
    12651224    int vhwaSurfaceCanCreate(struct _VBOXVHWACMD_SURF_CANCREATE *pCmd);
    12661225    int vhwaSurfaceCreate(struct _VBOXVHWACMD_SURF_CREATE *pCmd);
     
    12771236    int vhwaConstruct(struct _VBOXVHWACMD_HH_CONSTRUCT *pCmd);
    12781237
     1238    bool hasSurfaces() const;
     1239    bool hasVisibleOverlays();
     1240    const QRect & overlaysRectUnion();
     1241#endif
     1242
     1243    ulong vboxBitsPerPixel() { return mDisplay.getVGA()->bitsPerPixel(); }
     1244    ulong vboxBytesPerLine() { return mDisplay.getVGA() ? mDisplay.getVGA()->bytesPerLine() : 0; }
     1245
     1246//    void vboxPaintEvent (QPaintEvent *pe) {vboxPerformGLOp(&VBoxGLWidget::vboxDoPaint, pe); }
     1247    void vboxResizeEvent (VBoxResizeEvent *re) {vboxPerformGLOp(&VBoxGLWidget::vboxDoResize, re); }
     1248
     1249    void vboxProcessVHWACommands(class VBoxVHWACommandProcessEvent * pEvent) {vboxPerformGLOp(&VBoxGLWidget::vboxDoProcessVHWACommands, pEvent);}
     1250#ifdef VBOX_WITH_VIDEOHWACCEL
     1251    void vboxVHWACmd (struct _VBOXVHWACMD * pCmd) {vboxPerformGLOp(&VBoxGLWidget::vboxDoVHWACmd, pCmd);}
     1252#endif
     1253    class VBoxVHWAGlProgramMngr * vboxVHWAGetGlProgramMngr() { return mpMngr; }
     1254
     1255    VBoxVHWASurfaceBase * vboxGetVGASurface() { return mDisplay.getVGA(); }
     1256
     1257    void postCmd(VBOXVHWA_PIPECMD_TYPE aType, void * pvData);
     1258
     1259    static void doSetupMatrix(const QSize & aSize, bool bInverted);
     1260
     1261    void vboxDoUpdateViewport(const QRect * pRect);
     1262    const QRect & vboxViewport() const {return mViewport;}
     1263
     1264    void performDisplay() { mDisplay.performDisplay(); }
     1265protected:
     1266
     1267    void paintGL()
     1268    {
     1269        if(mpfnOp)
     1270        {
     1271            (this->*mpfnOp)(mOpContext);
     1272            mpfnOp = NULL;
     1273        }
     1274//        else
     1275//        {
     1276            mDisplay.performDisplay();
     1277//        }
     1278    }
     1279
     1280    void initializeGL();
     1281
     1282private:
     1283    static void setupMatricies(const QSize &display);
     1284    static void adjustViewport(const QSize &display, const QRect &viewport);
     1285    void vboxDoResize(void *re);
     1286//    void vboxDoPaint(void *rec);
     1287
     1288
     1289    void vboxDoUpdateRect(const QRect * pRect);
     1290#ifdef VBOXQGL_DBG_SURF
     1291    void vboxDoTestSurfaces(void *context);
     1292#endif
     1293#ifdef VBOX_WITH_VIDEOHWACCEL
     1294    void vboxDoVHWACmdExec(void *cmd);
     1295    void vboxDoVHWACmdAndFree(void *cmd);
     1296    void vboxDoVHWACmd(void *cmd);
     1297
     1298    void vboxCheckUpdateAddress (VBoxVHWASurfaceBase * pSurface, uint64_t offset)
     1299    {
     1300        if (pSurface->addressAlocated())
     1301        {
     1302            uchar * addr = vboxVRAMAddressFromOffset(offset);
     1303            if(addr)
     1304            {
     1305                pSurface->setAddress(addr);
     1306            }
     1307        }
     1308    }
     1309
    12791310    int vhwaSaveSurface(struct SSMHANDLE * pSSM, VBoxVHWASurfaceBase *pSurf, uint32_t surfCaps);
    12801311    int vhwaLoadSurface(struct SSMHANDLE * pSSM, uint32_t u32Version);
    12811312    int vhwaSaveOverlayData(struct SSMHANDLE * pSSM, VBoxVHWASurfaceBase *pSurf, bool bVisible);
    12821313    int vhwaLoadOverlayData(struct SSMHANDLE * pSSM, uint32_t u32Version);
    1283 
    12841314    void vhwaDoSurfaceOverlayUpdate(VBoxVHWASurfaceBase *pDstSurf, VBoxVHWASurfaceBase *pSrcSurf, struct _VBOXVHWACMD_SURF_OVERLAY_UPDATE *pCmd);
    12851315#endif
     
    12921322     * submit the operation to be performed
    12931323     * @todo: could be moved outside the updateGL */
    1294     void vboxPerformGLOp(PFNVBOXQGLOP pfn, void* pContext) {mpfnOp = pfn; mOpContext = pContext; updateGL();}
     1324    void vboxPerformGLOp(PFNVBOXQGLOP pfn, void* pContext)
     1325    {
     1326        mpfnOp = pfn;
     1327        mOpContext = pContext;
     1328        updateGL();
     1329    }
    12951330
    12961331//    /* posts op to UI thread */
     
    13801415};
    13811416
     1417#ifdef VBOX_WITH_VIDEOHWACCEL
     1418class VBoxQGLOverlayFrameBuffer : public VBoxQImageFrameBuffer
     1419{
     1420public:
     1421    VBoxQGLOverlayFrameBuffer (VBoxConsoleView *aView);
     1422
     1423
     1424    STDMETHOD(ProcessVHWACommand)(BYTE *pCommand);
     1425
     1426    void doProcessVHWACommand(QEvent * pEvent);
     1427
     1428    STDMETHOD(NotifyUpdate) (ULONG aX, ULONG aY,
     1429                             ULONG aW, ULONG aH);
     1430
     1431    void paintEvent (QPaintEvent *pe);
     1432    void resizeEvent (VBoxResizeEvent *re);
     1433
     1434    void vboxUpdateRect(const QRect * pRect);
     1435private:
     1436    void vboxSetGlOn(bool on);
     1437    bool vboxGetGlOn() { return mGlOn; }
     1438    void vboxSynchGl();
     1439    void vboxDoVHWACmdExec(void *cmd);
     1440    void vboxShowOverlay(bool show);
     1441    void vboxUpdateOverlayPosition(const QPoint & pos);
     1442    void vboxUpdateOverlay(const QPoint & pos, const QRect & rect, bool show);
     1443    VBoxGLWidget *mpOverlayWidget;
     1444    bool mGlOn;
     1445    bool mOverlayVisible;
     1446    VBoxVHWADirtyRect mMainDirtyRect;
     1447};
     1448#endif
    13821449
    13831450#endif
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h

    r22189 r22794  
    750750#ifdef VBOX_WITH_VIDEOHWACCEL
    751751    static bool isAcceleration2DVideoAvailable();
    752     VBoxDefs::RenderMode vmAcceleration2DVideoRenderMode() { return VBoxDefs::QGLMode; }
     752    VBoxDefs::RenderMode vmAcceleration2DVideoRenderMode() {
     753#if 0
     754        return VBoxDefs::QGLOverlayMode;
     755#else
     756        return VBoxDefs::QGLMode;
     757#endif
     758        }
    753759#endif
    754760
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp

    r22703 r22794  
    825825        case VBoxDefs::QGLMode:
    826826            mFrameBuf = new VBoxQGLFrameBuffer (this);
     827            break;
     828        case VBoxDefs::QGLOverlayMode:
     829            mFrameBuf = new VBoxQGLOverlayFrameBuffer (this);
    827830            break;
    828831#endif
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBQGL.cpp

    r22793 r22794  
    17351735}
    17361736
    1737 VBoxVHWASurfaceBase::VBoxVHWASurfaceBase(class VBoxGLWidget *aWidget, const QSize * aSize, const QSize * aTargSize,
     1737VBoxVHWASurfaceBase::VBoxVHWASurfaceBase(class VBoxGLWidget *aWidget,
     1738        const QSize & aSize,
     1739        const QRect & aTargRect,
     1740        const QRect & aSrcRect,
     1741        const QRect & aVisTargRect,
    17381742        VBoxVHWAColorFormat & aColorFormat,
    17391743        VBoxVHWAColorKey * pSrcBltCKey, VBoxVHWAColorKey * pDstBltCKey,
    17401744                    VBoxVHWAColorKey * pSrcOverlayCKey, VBoxVHWAColorKey * pDstOverlayCKey,
    17411745                    bool bVGA) :
    1742                 mRect(0,0,aSize->width(),aSize->height()),
     1746                mRect(0,0,aSize.width(),aSize.height()),
    17431747                mVisibleDisplayInitialized(false),
    17441748                mAddress(NULL),
     
    17701774    resetDefaultSrcOverlayCKey();
    17711775
    1772     mpTex[0] = vboxVHWATextureCreate(QRect(0,0,aSize->width(),aSize->height()), mColorFormat, bVGA);
     1776    mpTex[0] = vboxVHWATextureCreate(QRect(0,0,aSize.width(),aSize.height()), mColorFormat, bVGA);
    17731777    if(mColorFormat.fourcc() == FOURCC_YV12)
    17741778    {
    1775         QRect rect(0,0,aSize->width()/2,aSize->height()/2);
     1779        QRect rect(0,0,aSize.width()/2,aSize.height()/2);
    17761780        mpTex[1] = vboxVHWATextureCreate(rect, mColorFormat, bVGA);
    17771781        mpTex[2] = vboxVHWATextureCreate(rect, mColorFormat, bVGA);
    17781782    }
    17791783
    1780     mSrcRect = mRect;
    1781     mTargRect = mRect; /* == Vis FB size */
    1782     mTargSize = QRect(0, 0, aTargSize->width(), aTargSize->height());
     1784    doSetRectValuesInternal(aTargRect, aSrcRect, aVisTargRect);
     1785//    mTargSize = QRect(0, 0, aTargSize->width(), aTargSize->height());
    17831786
    17841787//    mBytesPerPixel = calcBytesPerPixel(mColorFormat.format(), mColorFormat.type());
     
    26442647}
    26452648
    2646 void VBoxVHWASurfaceBase::setRects(VBoxVHWASurfaceBase *pPrimary, const QRect * aTargRect, const QRect * aSrcRect)
    2647 {
    2648     if(mTargRect == *aTargRect && mSrcRect == *aSrcRect)
    2649         return;
    2650 
    2651     mTargRect = *aTargRect;
    2652     mSrcRect = *aSrcRect;
    2653 
    2654     initDisplay(pPrimary);
    2655 }
    2656 
    2657 void VBoxVHWASurfaceBase::setTargetRectPosition(VBoxVHWASurfaceBase *pPrimary, const QPoint * aPoint)
    2658 {
    2659     if(mTargRect.topLeft() == *aPoint)
    2660         return;
    2661 
    2662     mTargRect = QRect(aPoint->x(), aPoint->y(), mTargRect.width(), mTargRect.height());
    2663 
    2664     initDisplay(pPrimary
    2665 //            false
    2666             );
     2649void VBoxVHWASurfaceBase::doSetRectValuesInternal(const QRect & aTargRect, const QRect & aSrcRect, const QRect & aVisTargRect)
     2650{
     2651    mVisibleTargRect = aVisTargRect.intersected(aTargRect);
     2652    mTargRect = aTargRect;
     2653    mSrcRect = aSrcRect;
     2654    if(mVisibleTargRect.isEmpty() || mTargRect.isEmpty())
     2655    {
     2656        mVisibleSrcRect.setSize(QSize(0, 0));
     2657    }
     2658    else
     2659    {
     2660        float stretchX = float(mSrcRect.width()) / mTargRect.width();
     2661        float stretchY = float(mSrcRect.height()) / mTargRect.height();
     2662        int tx1, tx2, ty1, ty2, vtx1, vtx2, vty1, vty2;
     2663        int sx1, sx2, sy1, sy2;
     2664        mVisibleTargRect.getCoords(&vtx1, &vty1, &vtx2, &vty2);
     2665        mTargRect.getCoords(&tx1, &ty1, &tx2, &ty2);
     2666        mSrcRect.getCoords(&sx1, &sy1, &sx2, &sy2);
     2667        int dx1 = vtx1 - tx1;
     2668        int dy1 = vty1 - ty1;
     2669        int dx2 = vtx2 - tx2;
     2670        int dy2 = vty2 - ty2;
     2671        int vsx1, vsy1, vsx2, vsy2;
     2672        Assert(dx1 >= 0);
     2673        Assert(dy1 >= 0);
     2674        Assert(dx2 <= 0);
     2675        Assert(dy2 <= 0);
     2676        vsx1 = sx1 + int(dx1*stretchX);
     2677        vsy1 = sy1 + int(dy1*stretchY);
     2678        vsx2 = sx2 + int(dx2*stretchX);
     2679        vsy2 = sy2 + int(dy2*stretchY);
     2680        mVisibleSrcRect.setCoords(vsx1, vsy1, vsx2, vsy2);
     2681        Assert(mSrcRect.contains(mVisibleSrcRect));
     2682    }
     2683}
     2684
     2685void VBoxVHWASurfaceBase::setRects(VBoxVHWASurfaceBase *pPrimary, const QRect & aTargRect, const QRect & aSrcRect, const QRect & aVisTargRect, bool bForceReinit)
     2686{
     2687    QRect aVisibleTargRect = aVisTargRect.intersected(mTargRect);
     2688
     2689    if(mTargRect != aTargRect || mSrcRect != aSrcRect || mVisibleTargRect != aVisibleTargRect)
     2690    {
     2691        doSetRectValuesInternal(aTargRect, aSrcRect, aVisTargRect);
     2692        bForceReinit = true;
     2693    }
     2694
     2695    if(bForceReinit)
     2696    {
     2697        initDisplay(pPrimary);
     2698    }
     2699}
     2700
     2701void VBoxVHWASurfaceBase::setTargRectPosition(VBoxVHWASurfaceBase *pPrimary, const QPoint & aPoint, const QRect & aVisibleTargRect)
     2702{
     2703    QRect tRect = targRect();
     2704    tRect.moveTopLeft(aPoint);
     2705    setRects(pPrimary, tRect, srcRect(), aVisibleTargRect, false);
     2706}
     2707
     2708void VBoxVHWASurfaceBase::updateVisibleTargRect(VBoxVHWASurfaceBase *pPrimary, const QRect & aVisibleTargRect)
     2709{
     2710    setRects(pPrimary, targRect(), srcRect(), aVisibleTargRect, false);
    26672711}
    26682712
     
    28072851}
    28082852
     2853//void VBoxVHWASurfaceBase::setVisibleTargetRect(const QRect & aRect)
     2854//{
     2855//    Assert(mVisibleRect.contains(aRect));
     2856//    mVisibleRect = mSrcRect.intersected(aRect);
     2857//}
     2858
    28092859void VBoxVHWASurfaceBase::performDisplay(VBoxVHWASurfaceBase *pPrimary)
    28102860{
     
    29242974void VBoxQGLFrameBuffer::paintEvent (QPaintEvent *pe)
    29252975{
    2926     vboxWidget()->vboxPaintEvent(pe);
     2976    VBoxGLWidget * pw = vboxWidget();
     2977    pw->makeCurrent();
     2978
     2979    QRect vp(mView->contentsX(), mView->contentsY(), pw->width(), pw->height());
     2980    if(vp != pw->vboxViewport())
     2981    {
     2982        pw->vboxDoUpdateViewport(&vp);
     2983    }
     2984
     2985    pw->performDisplay();
     2986
     2987    pw->swapBuffers();
    29272988}
    29282989
     
    31733234    } while(pFirst);
    31743235
    3175     mDisplay.performDisplay();
     3236//    mDisplay.performDisplay();
    31763237}
    31773238
     
    34733534                                                pCmd->SurfInfo.PixelFormat.m3.rgbBBitMask);
    34743535            QSize surfSize(pCmd->SurfInfo.width, pCmd->SurfInfo.height);
    3475             QSize primarySize = mDisplay.getPrimary()->rect().size();
    3476             surf = new VBoxVHWASurfaceBase(this, &surfSize,
     3536            QRect primaryRect = mDisplay.getPrimary()->rect();
     3537            surf = new VBoxVHWASurfaceBase(this, surfSize,
    34773538//                        ((pCmd->SurfInfo.surfCaps & VBOXVHWA_SCAPS_OVERLAY) ? mDisplay.getPrimary()->rect().size() : &surfSize),
    3478                         &primarySize,
     3539                        primaryRect,
     3540                        QRect(0, 0, surfSize.width(), surfSize.height()),
     3541                        mViewport,
    34793542                        format,
    34803543                        pSrcBltCKey, pDstBltCKey, pSrcOverlayCKey, pDstOverlayCKey,
     
    34843547        {
    34853548            QSize surfSize(pCmd->SurfInfo.width, pCmd->SurfInfo.height);
    3486             QSize primarySize = mDisplay.getPrimary()->rect().size();
     3549            QRect primaryRect = mDisplay.getPrimary()->rect();
    34873550
    34883551            VBoxVHWAColorFormat format(pCmd->SurfInfo.PixelFormat.fourCC);
    3489             surf = new VBoxVHWASurfaceBase(this, &surfSize,
     3552            surf = new VBoxVHWASurfaceBase(this, surfSize,
    34903553            //                        ((pCmd->SurfInfo.surfCaps & VBOXVHWA_SCAPS_OVERLAY) ? mDisplay.getPrimary()->rect().size() : &QSize(pCmd->SurfInfo.width, pCmd->SurfInfo.height)),
    3491                                     &primarySize,
     3554                                    primaryRect,
     3555                                    QRect(0, 0, surfSize.width(), surfSize.height()),
     3556                                    mViewport,
    34923557                                    format,
    34933558                                    pSrcBltCKey, pDstBltCKey, pSrcOverlayCKey, pDstOverlayCKey,
     
    35023567
    35033568        uchar * addr = vboxVRAMAddressFromOffset(pCmd->SurfInfo.offSurface);
    3504         surf->init(mDisplay.getVGA(), addr);
     3569        surf->init(mDisplay.getPrimary(), addr);
    35053570
    35063571        if(pCmd->SurfInfo.surfCaps & VBOXVHWA_SCAPS_OVERLAY)
     
    38283893        }
    38293894
    3830         pSrcSurf->setRects(pDstSurf, &dstRect, &srcRect);
     3895        pSrcSurf->setRects(pDstSurf, dstRect, srcRect, mViewport, true);
    38313896    }
    38323897}
     
    38893954    {
    38903955        VBoxVHWASurfaceBase *pCurSrcSurf = (*it);
    3891         pCurSrcSurf->setTargetRectPosition(pDstSurf, &pos);
     3956        pCurSrcSurf->setTargRectPosition(pDstSurf, pos, mViewport);
    38923957    }
    38933958
     
    42504315    int rc = SSMR3PutU32(pSSM, flags); AssertRC(rc);
    42514316
    4252     rc = SSMR3PutU32(pSSM, mDisplay.getVGA()->handle()); AssertRC(rc);
     4317    rc = SSMR3PutU32(pSSM, mDisplay.getPrimary()->handle()); AssertRC(rc);
    42534318    rc = SSMR3PutU32(pSSM, pSurf->handle()); AssertRC(rc);
    42544319
     
    46014666#endif
    46024667
    4603 void VBoxGLWidget::vboxDoPaint(void *pe)
    4604 {
    4605     Q_UNUSED(pe);
    4606 
    4607 #ifdef VBOXQGL_DBG_SURF
    4608     vboxDoTestSurfaces(NULL);
    4609 #endif
    4610     QRect vp(mView->contentsX(), mView->contentsY(), width(), height());
    4611 
    4612     if(vp != mViewport)
    4613     {
    4614         adjustViewport(mDisplay.getVGA()->size(), vp);
    4615         mViewport = vp;
    4616     }
    4617 
    4618 //#ifdef VBOXQGL_PROF_BASE
    4619 //    vboxDoUpdateRect(&((QPaintEvent*)pe)->rect());
     4668void VBoxGLWidget::vboxDoUpdateViewport(const QRect * pRect)
     4669{
     4670    adjustViewport(mDisplay.getPrimary()->size(), *pRect);
     4671    mViewport = *pRect;
     4672
     4673    const SurfList & primaryList = mDisplay.primaries().surfaces();
     4674
     4675    for (SurfList::const_iterator pr = primaryList.begin();
     4676         pr != primaryList.end(); ++ pr)
     4677    {
     4678        VBoxVHWASurfaceBase *pSurf = *pr;
     4679        pSurf->updateVisibleTargRect(NULL, *pRect);
     4680    }
     4681
     4682    const OverlayList & overlays = mDisplay.overlays();
     4683
     4684    for (OverlayList::const_iterator it = overlays.begin();
     4685         it != overlays.end(); ++ it)
     4686    {
     4687        VBoxVHWASurfList * pSurfList = *it;
     4688        const SurfList & surfaces = pSurfList->surfaces();
     4689        for (SurfList::const_iterator sit = surfaces.begin();
     4690             sit != surfaces.end(); ++ sit)
     4691        {
     4692            VBoxVHWASurfaceBase *pSurf = *sit;
     4693            pSurf->updateVisibleTargRect(mDisplay.getPrimary(), *pRect);
     4694        }
     4695    }
     4696}
     4697
     4698bool VBoxGLWidget::hasSurfaces() const
     4699{
     4700    return mDisplay.overlays().size() != 0;
     4701}
     4702
     4703bool VBoxGLWidget::hasVisibleOverlays()
     4704{
     4705    const OverlayList & overlays = mDisplay.overlays();
     4706    for (OverlayList::const_iterator it = overlays.begin();
     4707         it != overlays.end(); ++ it)
     4708    {
     4709        VBoxVHWASurfList * pSurfList = *it;
     4710        if(pSurfList->current() != NULL)
     4711            return true;
     4712    }
     4713    return false;
     4714}
     4715
     4716const QRect & VBoxGLWidget::overlaysRectUnion()
     4717{
     4718    const OverlayList & overlays = mDisplay.overlays();
     4719    VBoxVHWADirtyRect un;
     4720    for (OverlayList::const_iterator it = overlays.begin();
     4721         it != overlays.end(); ++ it)
     4722    {
     4723        VBoxVHWASurfaceBase * pOverlay = (*it)->current();
     4724        if(pOverlay != NULL)
     4725        {
     4726            un.add(pOverlay->targRect());
     4727        }
     4728    }
     4729    return un.toRect();
     4730}
     4731
     4732//void VBoxGLWidget::vboxDoPaint(void *pe)
     4733//{
     4734//    Q_UNUSED(pe);
     4735//
     4736//#ifdef VBOXQGL_DBG_SURF
     4737//    vboxDoTestSurfaces(NULL);
    46204738//#endif
    4621     mDisplay.performDisplay();
    4622 }
     4739////#ifdef VBOXQGL_PROF_BASE
     4740////    vboxDoUpdateRect(&((QPaintEvent*)pe)->rect());
     4741////#endif
     4742////    mDisplay.performDisplay();
     4743//}
    46234744
    46244745void VBoxGLWidget::vboxDoUpdateRect(const QRect * pRect)
    46254746{
    4626     mDisplay.getVGA()->updatedMem(pRect);
     4747    mDisplay.getPrimary()->updatedMem(pRect);
    46274748}
    46284749
     
    47904911    VBoxVHWAColorFormat format(bitsPerPixel, r,g,b);
    47914912    QSize dispSize(displayWidth, displayHeight);
    4792     pDisplay = new VBoxVHWASurfaceBase(this, &dispSize, &dispSize,
     4913    QRect dispRect(0, 0, displayWidth, displayHeight);
     4914    pDisplay = new VBoxVHWASurfaceBase(this,
     4915            dispSize,
     4916            dispRect,
     4917            dispRect,
     4918            dispRect, /* we do not know viewport at the stage of recise, set as a disp rect, it will be updated on repaint */
    47934919                format,
    47944920            (VBoxVHWAColorKey*)NULL, (VBoxVHWAColorKey*)NULL, (VBoxVHWAColorKey*)NULL, (VBoxVHWAColorKey*)NULL, true);
     
    49065032
    49075033
    4908     mDisplay.performDisplay();
     5034//    mDisplay.performDisplay();
    49095035
    49105036    if (remind)
     
    51365262    *b = mB.colorValNorm(pix);
    51375263}
    5138 
    5139 #endif
     5264#ifdef VBOX_WITH_VIDEOHWACCEL
     5265VBoxQGLOverlayFrameBuffer::VBoxQGLOverlayFrameBuffer (VBoxConsoleView *aView)
     5266    : VBoxQImageFrameBuffer(aView),
     5267      mGlOn(false),
     5268      mOverlayVisible(false)
     5269{
     5270    mpOverlayWidget = new VBoxGLWidget (aView, aView->viewport());
     5271    mpOverlayWidget->setVisible(false);
     5272}
     5273
     5274STDMETHODIMP VBoxQGLOverlayFrameBuffer::ProcessVHWACommand(BYTE *pCommand)
     5275{
     5276//    Assert(0);
     5277    VBOXVHWACMD * pCmd = (VBOXVHWACMD*)pCommand;
     5278    /* indicate that we process and complete the command asynchronously */
     5279    pCmd->Flags |= VBOXVHWACMD_FLAG_HG_ASYNCH;
     5280    /* post the command to the GUI thread for processing */
     5281//    QApplication::postEvent (mView,
     5282//                             new VBoxVHWACommandProcessEvent (pCmd));
     5283    mpOverlayWidget->postCmd(VBOXVHWA_PIPECMD_VHWA, pCmd);
     5284    return S_OK;
     5285//    return E_NOTIMPL;
     5286}
     5287
     5288void VBoxQGLOverlayFrameBuffer::doProcessVHWACommand(QEvent * pEvent)
     5289{
     5290    mpOverlayWidget->vboxProcessVHWACommands((VBoxVHWACommandProcessEvent*)pEvent);
     5291}
     5292
     5293STDMETHODIMP VBoxQGLOverlayFrameBuffer::NotifyUpdate(ULONG aX, ULONG aY,
     5294                         ULONG aW, ULONG aH)
     5295{
     5296    return VBoxQImageFrameBuffer::NotifyUpdate(aX, aY, aW, aH);
     5297}
     5298
     5299void VBoxQGLOverlayFrameBuffer::paintEvent (QPaintEvent *pe)
     5300{
     5301    VBoxQImageFrameBuffer::paintEvent (pe);
     5302}
     5303
     5304void VBoxQGLOverlayFrameBuffer::resizeEvent (VBoxResizeEvent *re)
     5305{
     5306    VBoxQImageFrameBuffer::resizeEvent(re);
     5307
     5308    if(mGlOn)
     5309    {
     5310        /* need to ensure we're in synch */
     5311        vboxSynchGl();
     5312    }
     5313}
     5314
     5315void VBoxQGLOverlayFrameBuffer::vboxSynchGl()
     5316{
     5317    /* create and issue a resize event to the gl widget to ensure we have all gl data initialized
     5318     * and synchronized with the framebuffer */
     5319    VBoxResizeEvent re(pixelFormat(),
     5320            address(),
     5321            bitsPerPixel(),
     5322            bytesPerLine(),
     5323            width(),
     5324            height());
     5325
     5326    mpOverlayWidget->vboxResizeEvent(&re);
     5327}
     5328
     5329void VBoxQGLOverlayFrameBuffer::vboxSetGlOn(bool on)
     5330{
     5331    if(on == mGlOn)
     5332        return;
     5333
     5334    mGlOn = on;
     5335
     5336    if(on)
     5337    {
     5338        VBOXQGLLOGREL(("Switching Gl mode on\n"));
     5339        Assert(!mpOverlayWidget->isVisible());
     5340        /* just to ensure */
     5341        mpOverlayWidget->setVisible(false);
     5342        vboxSynchGl();
     5343    }
     5344    else
     5345    {
     5346        VBOXQGLLOGREL(("Switching Gl mode off\n"));
     5347        /* for now just set the flag w/o destroying anything */
     5348    }
     5349}
     5350
     5351void VBoxQGLOverlayFrameBuffer::vboxShowOverlay(bool show)
     5352{
     5353    /** @todo */
     5354    Assert(0);
     5355}
     5356
     5357void VBoxQGLOverlayFrameBuffer::vboxUpdateOverlayPosition(const QPoint & pos)
     5358{
     5359    /** @todo */
     5360    Assert(0);
     5361}
     5362
     5363void VBoxQGLOverlayFrameBuffer::vboxUpdateOverlay(const QPoint & pos, const QRect & rect, bool show)
     5364{
     5365    /** @todo */
     5366    Assert(0);
     5367}
     5368
     5369void VBoxQGLOverlayFrameBuffer::vboxDoVHWACmdExec(void *cmd)
     5370{
     5371    struct _VBOXVHWACMD * pCmd = (struct _VBOXVHWACMD *)cmd;
     5372    switch(pCmd->enmCmd)
     5373    {
     5374        case VBOXVHWACMD_TYPE_SURF_CANCREATE:
     5375        {
     5376            VBOXVHWACMD_SURF_CANCREATE * pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_CANCREATE);
     5377            pCmd->rc = mpOverlayWidget->vhwaSurfaceCanCreate(pBody);
     5378        } break;
     5379        case VBOXVHWACMD_TYPE_SURF_CREATE:
     5380        {
     5381            VBOXVHWACMD_SURF_CREATE * pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_CREATE);
     5382            vboxSetGlOn(true);
     5383            pCmd->rc = mpOverlayWidget->vhwaSurfaceCreate(pBody);
     5384            if(!mpOverlayWidget->hasSurfaces())
     5385            {
     5386                vboxSetGlOn(false);
     5387            }
     5388            else if(mpOverlayWidget->hasVisibleOverlays())
     5389            {
     5390                QRect overRect = mpOverlayWidget->overlaysRectUnion();
     5391                vboxUpdateOverlay(QPoint(overRect.x(), overRect.y()), overRect, true);
     5392            }
     5393        } break;
     5394        case VBOXVHWACMD_TYPE_SURF_DESTROY:
     5395        {
     5396            VBOXVHWACMD_SURF_DESTROY * pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_DESTROY);
     5397            pCmd->rc = mpOverlayWidget->vhwaSurfaceDestroy(pBody);
     5398            if(!mpOverlayWidget->hasSurfaces())
     5399            {
     5400                vboxSetGlOn(false);
     5401            }
     5402        } break;
     5403        case VBOXVHWACMD_TYPE_SURF_LOCK:
     5404        {
     5405            VBOXVHWACMD_SURF_LOCK * pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_LOCK);
     5406            pCmd->rc = mpOverlayWidget->vhwaSurfaceLock(pBody);
     5407        } break;
     5408        case VBOXVHWACMD_TYPE_SURF_UNLOCK:
     5409        {
     5410            VBOXVHWACMD_SURF_UNLOCK * pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_UNLOCK);
     5411            pCmd->rc = mpOverlayWidget->vhwaSurfaceUnlock(pBody);
     5412        } break;
     5413        case VBOXVHWACMD_TYPE_SURF_BLT:
     5414        {
     5415            VBOXVHWACMD_SURF_BLT * pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_BLT);
     5416            pCmd->rc = mpOverlayWidget->vhwaSurfaceBlt(pBody);
     5417        } break;
     5418        case VBOXVHWACMD_TYPE_SURF_FLIP:
     5419        {
     5420            VBOXVHWACMD_SURF_FLIP * pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_FLIP);
     5421            pCmd->rc = mpOverlayWidget->vhwaSurfaceFlip(pBody);
     5422        } break;
     5423        case VBOXVHWACMD_TYPE_SURF_OVERLAY_UPDATE:
     5424        {
     5425            VBOXVHWACMD_SURF_OVERLAY_UPDATE * pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_OVERLAY_UPDATE);
     5426            pCmd->rc = mpOverlayWidget->vhwaSurfaceOverlayUpdate(pBody);
     5427            if(mpOverlayWidget->hasVisibleOverlays())
     5428            {
     5429                QRect overRect = mpOverlayWidget->overlaysRectUnion();
     5430                vboxUpdateOverlay(QPoint(overRect.x(), overRect.y()), overRect, true);
     5431            }
     5432        } break;
     5433        case VBOXVHWACMD_TYPE_SURF_OVERLAY_SETPOSITION:
     5434        {
     5435            VBOXVHWACMD_SURF_OVERLAY_SETPOSITION * pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_OVERLAY_SETPOSITION);
     5436            pCmd->rc = mpOverlayWidget->vhwaSurfaceOverlaySetPosition(pBody);
     5437            if(mpOverlayWidget->hasVisibleOverlays())
     5438            {
     5439                QRect overRect = mpOverlayWidget->overlaysRectUnion();
     5440                vboxUpdateOverlayPosition(QPoint(overRect.x(), overRect.y()));
     5441            }
     5442        } break;
     5443        case VBOXVHWACMD_TYPE_SURF_COLORKEY_SET:
     5444        {
     5445            VBOXVHWACMD_SURF_COLORKEY_SET * pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_COLORKEY_SET);
     5446            pCmd->rc = mpOverlayWidget->vhwaSurfaceColorkeySet(pBody);
     5447        } break;
     5448        case VBOXVHWACMD_TYPE_QUERY_INFO1:
     5449        {
     5450            VBOXVHWACMD_QUERYINFO1 * pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_QUERYINFO1);
     5451            pCmd->rc = mpOverlayWidget->vhwaQueryInfo1(pBody);
     5452        } break;
     5453        case VBOXVHWACMD_TYPE_QUERY_INFO2:
     5454        {
     5455            VBOXVHWACMD_QUERYINFO2 * pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_QUERYINFO2);
     5456            pCmd->rc = mpOverlayWidget->vhwaQueryInfo2(pBody);
     5457        } break;
     5458        case VBOXVHWACMD_TYPE_ENABLE:
     5459        case VBOXVHWACMD_TYPE_DISABLE:
     5460            pCmd->rc = VINF_SUCCESS;
     5461            break;
     5462        case VBOXVHWACMD_TYPE_HH_CONSTRUCT:
     5463        {
     5464            VBOXVHWACMD_HH_CONSTRUCT * pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_HH_CONSTRUCT);
     5465            pCmd->rc = mpOverlayWidget->vhwaConstruct(pBody);
     5466        } break;
     5467        default:
     5468            Assert(0);
     5469            pCmd->rc = VERR_NOT_IMPLEMENTED;
     5470            break;
     5471    }
     5472}
     5473#endif
     5474#endif
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp

    r22637 r22794  
    549549            mode = VBoxDefs::QGLMode;
    550550#endif
     551#if defined (VBOX_GUI_USE_QGL)
     552        else if (::strcmp (aModeStr, "qgloverlay") == 0)
     553            mode = VBoxDefs::QGLOverlayMode;
     554#endif
     555
    551556    }
    552557
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette