VirtualBox

Ignore:
Timestamp:
Jul 6, 2009 2:29:39 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
49581
Message:

video hw accel: Blt fixes/enhances, Flip basis for Guest driver & QGLFramebuffer

File:
1 edited

Legend:

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

    r20985 r21253  
    354354    }
    355355
     356    void add(const VBoxVHWADirtyRect & aRect)
     357    {
     358        if(aRect.isClear())
     359            return;
     360        add(aRect.rect());
     361    }
     362
    356363    void set(const QRect & aRect)
    357364    {
     
    464471};
    465472
     473/* data flow:
     474 * I. NON-Yinverted surface:
     475 * 1.direct memory update (paint, lock/unlock):
     476 *  mem->tex->fb
     477 * 2.blt
     478 *  srcTex->invFB->tex->fb
     479 *              |->mem
     480 *
     481 * II. Yinverted surface:
     482 * 1.direct memory update (paint, lock/unlock):
     483 *  mem->tex->fb
     484 * 2.blt
     485 *  srcTex->fb->tex
     486 *           |->mem
     487 * */
    466488class VBoxVHWASurfaceBase
    467489{
    468490public:
    469     VBoxVHWASurfaceBase(GLsizei aWidth, GLsizei aHeight,
     491    VBoxVHWASurfaceBase(class VBoxVHWAGlContextState *aState, bool aIsYInverted, GLsizei aWidth, GLsizei aHeight,
    470492            VBoxVHWAColorFormat & aColorFormat,
    471493            VBoxVHWAColorKey * pSrcBltCKey, VBoxVHWAColorKey * pDstBltCKey,
     
    518540
    519541    /* clients should treat the returned texture as read-only */
    520     GLuint textureSynched(const QRect * aRect) { synchTexture(aRect); return mTexture; }
     542    GLuint textureSynched(const QRect * aRect) { synchTex(aRect); return mTexture; }
    521543
    522544    void setAddress(uchar * addr);
     
    529551//    virtual bool isMainFramebuffer() = 0;
    530552    virtual void makeCurrent() = 0;
     553    virtual void makeYInvertedCurrent() = 0;
     554
     555    bool isYInverted() {return mIsYInverted; }
     556
    531557#ifdef VBOX_WITH_VIDEOHWACCEL
    532558    virtual class VBoxVHWAGlProgramMngr * getGlProgramMngr() = 0;
     
    536562    void initDisplay();
    537563    void deleteDisplay();
    538     void updateTexture(const QRect * aRect);
    539     void synchTexture(const QRect * aRect);
     564    void synchTex(const QRect * aRect);
     565    void synchTexMem(const QRect * aRect);
     566    void synchTexFB(const QRect * aRect);
    540567    void synchMem(const QRect * aRect);
     568    void synchFB(const QRect * aRect);
     569
     570    void doTex2FB(const QRect * aRect);
     571
     572
    541573
    542574    QRect mRect;
     
    567599    int mLockCount;
    568600    /* memory buffer not reflected in fm and texture, e.g if memory buffer is replaced or in case of lock/unlock  */
    569     VBoxVHWADirtyRect mUpdateMemRect;
     601    VBoxVHWADirtyRect mUpdateMem2TexRect;
     602    /* memory buffer not reflected in fm and texture, e.g if memory buffer is replaced or in case of lock/unlock  */
     603    VBoxVHWADirtyRect mUpdateTex2FBRect;
    570604    /*in case of blit we blit from another surface's texture, so our current texture gets durty  */
    571605    VBoxVHWADirtyRect mUpdateFB2TexRect;
     
    574608
    575609    bool mFreeAddress;
     610
     611    bool mIsYInverted;
     612    typedef std::list <VBoxVHWASurfaceBase*> OverlayList;
     613    VBoxVHWASurfaceBase * mOverlayed;
     614    OverlayList mOverlays;
     615protected:
     616    virtual void init(uchar *pvMem, bool bInverted);
     617
     618    class VBoxVHWAGlContextState *mState;
     619
     620};
     621
     622class VBoxVHWAGlContextState
     623{
     624public:
     625    VBoxVHWAGlContextState() : mContext(NULL), mInverted(false) {}
     626
     627    void assertCurrent(class VBoxVHWASurfaceBase *aContext, bool bInverted)
     628    {
     629        mContext = aContext;
     630        if(aContext && aContext->isYInverted())
     631        {
     632            mInverted = true;
     633        }
     634        else
     635        {
     636            mInverted = bInverted;
     637        }
     638    }
     639
     640    void makeYInvertedCurrent(class VBoxVHWASurfaceBase *aContext)
     641    {
     642        if(mContext != aContext)
     643        {
     644//            aContext->makeCurrent();
     645            aContext->makeYInvertedCurrent();
     646            assertCurrent(aContext, true);
     647        }
     648        else
     649        {
     650            if(!aContext->isYInverted() && !mInverted)
     651            {
     652//                aContext->makeCurrent();
     653                aContext->makeYInvertedCurrent();
     654                mInverted = true;
     655            }
     656        }
     657    }
     658
     659    void makeCurrent(class VBoxVHWASurfaceBase *aContext)
     660    {
     661        if(mContext != aContext)
     662        {
     663            aContext->makeCurrent();
     664            assertCurrent(aContext, false);
     665        }
     666        else
     667        {
     668            if(!aContext->isYInverted() && mInverted)
     669            {
     670                aContext->makeCurrent();
     671                mInverted = false;
     672            }
     673        }
     674    }
     675
     676    class VBoxVHWASurfaceBase * getCurrent() {return mContext; }
     677    bool isCurrentYInverted() {return mInverted; }
     678
     679private:
     680
     681    class VBoxVHWASurfaceBase *mContext;
     682    bool mInverted;
    576683};
    577684
     
    579686{
    580687public:
    581     VBoxVHWASurfaceQGL(GLsizei aWidth, GLsizei aHeight,
     688    VBoxVHWASurfaceQGL(class VBoxVHWAGlContextState *aState, GLsizei aWidth, GLsizei aHeight,
    582689            VBoxVHWAColorFormat & aColorFormat,
    583690            VBoxVHWAColorKey * pSrcBltCKey, VBoxVHWAColorKey * pDstBltCKey,
    584691            VBoxVHWAColorKey * pSrcOverlayCKey, VBoxVHWAColorKey * pDstOverlayCKey,
    585692            class VBoxGLWidget *pWidget,
    586             bool bBackBuffer) :
    587                 VBoxVHWASurfaceBase(aWidth, aHeight,
     693            bool bInvisibleBuffer) :
     694                VBoxVHWASurfaceBase(aState, bInvisibleBuffer, aWidth, aHeight,
    588695                        aColorFormat,
    589696                        pSrcBltCKey, pDstBltCKey, pSrcOverlayCKey, pDstOverlayCKey),
    590697                mWidget(pWidget),
    591                 mCreateBuf(bBackBuffer)
     698                mBuffer(NULL)
    592699    {}
    593700
     701    ~VBoxVHWASurfaceQGL();
     702
    594703    void makeCurrent();
     704    void makeYInvertedCurrent();
    595705
    596706    void init(uchar *pvMem);
     707
     708    void uninit();
     709
     710    int flip(VBoxVHWASurfaceQGL * aCurrSurface);
    597711
    598712//    int unlock()
     
    609723    class VBoxGLWidget *mWidget;
    610724    class QGLPixelBuffer *mBuffer;
    611     bool mCreateBuf;
     725protected:
     726    virtual void init(uchar *pvMem, bool bInverted);
    612727};
    613728
     
    631746    void vboxPaintEvent (QPaintEvent *pe) {vboxPerformGLOp(&VBoxGLWidget::vboxDoPaint, pe);}
    632747    void vboxResizeEvent (VBoxResizeEvent *re) {vboxPerformGLOp(&VBoxGLWidget::vboxDoResize, re);}
     748#ifdef DEBUG_misha
     749    void vboxTestSurfaces () {vboxPerformGLOp(&VBoxGLWidget::vboxDoTestSurfaces, NULL);}
     750#endif
    633751#ifdef VBOX_WITH_VIDEOHWACCEL
    634752    void vboxVHWACmd (struct _VBOXVHWACMD * pCmd) {vboxPerformGLOp(&VBoxGLWidget::vboxDoVHWACmd, pCmd);}
     
    640758//    void resizeGL (int height, int width);
    641759
    642     void paintGL() { (this->*mpfnOp)(mOpContext); }
     760    void paintGL()
     761    {
     762        Assert(mState.getCurrent() == NULL);
     763        /* we are called with QGLWidget context */
     764        mState.assertCurrent(pDisplay, false);
     765        (this->*mpfnOp)(mOpContext);
     766        /* restore the context */
     767        mState.makeCurrent(pDisplay);
     768        /* clear*/
     769        mState.assertCurrent(NULL, false);
     770    }
    643771
    644772    void initializeGL();
     
    650778    void vboxDoResize(void *re);
    651779    void vboxDoPaint(void *rec);
     780#ifdef DEBUG_misha
     781    void vboxDoTestSurfaces(void *context);
     782#endif
    652783#ifdef VBOX_WITH_VIDEOHWACCEL
    653784    void vboxDoVHWACmd(void *cmd);
     
    669800    int vhwaSurfaceUnlock(struct _VBOXVHWACMD_SURF_UNLOCK *pCmd);
    670801    int vhwaSurfaceBlt(struct _VBOXVHWACMD_SURF_BLT *pCmd);
     802    int vhwaSurfaceFlip(struct _VBOXVHWACMD_SURF_FLIP *pCmd);
    671803    int vhwaQueryInfo1(struct _VBOXVHWACMD_QUERYINFO1 *pCmd);
    672804    int vhwaQueryInfo2(struct _VBOXVHWACMD_QUERYINFO2 *pCmd);
     
    674806
    675807    VBoxVHWASurfaceQGL * pDisplay;
     808
    676809    /* we need to do all opengl stuff in the paintGL context,
    677810     * submit the operation to be performed */
     
    684817    ulong  mPixelFormat;
    685818    bool   mUsesGuestVRAM;
     819
     820    VBoxVHWAGlContextState mState;
    686821
    687822#ifdef VBOX_WITH_VIDEOHWACCEL
     
    718853
    719854private:
    720     void vboxMakeCurrent();
     855//    void vboxMakeCurrent();
    721856    VBoxGLWidget * vboxWidget();
    722857};
Note: See TracChangeset for help on using the changeset viewer.

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