VirtualBox

Changeset 35280 in vbox


Ignore:
Timestamp:
Dec 21, 2010 4:48:30 PM (14 years ago)
Author:
vboxsync
Message:

2d: fix playback for odd-sized images

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.cpp

    r34740 r35280  
    371371}
    372372
    373 static VBoxVHWATexture* vboxVHWATextureCreate(const QGLContext * pContext, const QRect & aRect, const VBoxVHWAColorFormat & aFormat, VBOXVHWAIMG_TYPE flags)
     373static VBoxVHWATexture* vboxVHWATextureCreate(const QGLContext * pContext, const QRect & aRect, const VBoxVHWAColorFormat & aFormat, uint32_t bytesPerLine, VBOXVHWAIMG_TYPE flags)
    374374{
    375375    const VBoxVHWAInfo & info = vboxVHWAGetSupportInfo(pContext);
     
    378378    {
    379379        VBOXQGLLOG(("VBoxVHWATextureNP2RectPBO\n"));
    380         return new VBoxVHWATextureNP2RectPBO(aRect, aFormat, scaleFunc);
     380        return new VBoxVHWATextureNP2RectPBO(aRect, aFormat, bytesPerLine, scaleFunc);
    381381    }
    382382    else if(info.getGlInfo().isTextureRectangleSupported())
    383383    {
    384384        VBOXQGLLOG(("VBoxVHWATextureNP2Rect\n"));
    385         return new VBoxVHWATextureNP2Rect(aRect, aFormat, scaleFunc);
     385        return new VBoxVHWATextureNP2Rect(aRect, aFormat, bytesPerLine, scaleFunc);
    386386    }
    387387    else if(info.getGlInfo().isTextureNP2Supported())
    388388    {
    389389        VBOXQGLLOG(("VBoxVHWATextureNP2\n"));
    390         return new VBoxVHWATextureNP2(aRect, aFormat, scaleFunc);
     390        return new VBoxVHWATextureNP2(aRect, aFormat, bytesPerLine, scaleFunc);
    391391    }
    392392    VBOXQGLLOG(("VBoxVHWATexture\n"));
    393     return new VBoxVHWATexture(aRect, aFormat, scaleFunc);
     393    return new VBoxVHWATexture(aRect, aFormat, bytesPerLine, scaleFunc);
    394394}
    395395
     
    14351435
    14361436    VBOXQGL_CHECKERR(
    1437             glPixelStorei(GL_UNPACK_ROW_LENGTH, mRect.width()/mColorFormat.widthCompression());
     1437            glPixelStorei(GL_UNPACK_ROW_LENGTH, mBytesPerLine * 8 /mColorFormat.bitsPerPixelTex());
    14381438            );
    14391439
     
    14461446                address);
    14471447            );
     1448
     1449    VBOXQGL_CHECKERR(
     1450            glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
     1451            );
    14481452}
    14491453
     
    14661470}
    14671471
    1468 VBoxVHWATexture::VBoxVHWATexture(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, GLint scaleFuncttion) :
     1472VBoxVHWATexture::VBoxVHWATexture(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, uint32_t bytesPerLine, GLint scaleFuncttion) :
    14691473            mAddress(NULL),
    14701474            mTexture(0),
     
    14781482    mBytesPerPixel = mColorFormat.bitsPerPixel()/8;
    14791483    mBytesPerPixelTex = mColorFormat.bitsPerPixelTex()/8;
    1480     mBytesPerLine = mBytesPerPixel * mRect.width();
     1484    mBytesPerLine = bytesPerLine ? bytesPerLine : mBytesPerPixel * mRect.width();
    14811485    GLsizei wdt = VBoxVHWASurfaceBase::makePowerOf2(mRect.width()/mColorFormat.widthCompression());
    14821486    GLsizei hgt = VBoxVHWASurfaceBase::makePowerOf2(mRect.height()/mColorFormat.heightCompression());
     
    24322436    if (!reportedFormat.isValid())
    24332437    {
    2434         pCmd->SurfInfo.pitch = surf->bitsPerPixel() * surf->width() / 8;
     2438        pCmd->SurfInfo.pitch = surf->bytesPerLine();
    24352439        pCmd->SurfInfo.sizeX = surf->memSize();
    24362440        pCmd->SurfInfo.sizeY = 1;
     
    24932497    if (format.isValid())
    24942498    {
    2495         pCmd->SurfInfo.pitch = format.bitsPerPixel() * pCmd->SurfInfo.width / 8;
    2496 //        pCmd->SurfInfo.pitch = ((pCmd->SurfInfo.pitch + 3) & (~3));
    2497         pCmd->SurfInfo.sizeX = format.bitsPerPixelMem() * pCmd->SurfInfo.width / 8;
    2498 //        pCmd->SurfInfo.sizeX = ((pCmd->SurfInfo.sizeX + 3) & (~3));
    2499         pCmd->SurfInfo.sizeX *= pCmd->SurfInfo.height;
     2499        pCmd->SurfInfo.pitch = VBoxVHWATextureImage::calcBytesPerLine(format, pCmd->SurfInfo.width);
     2500        pCmd->SurfInfo.sizeX = VBoxVHWATextureImage::calcMemSize(format,
     2501                pCmd->SurfInfo.width, pCmd->SurfInfo.height);
    25002502        pCmd->SurfInfo.sizeY = 1;
    25012503        return VINF_SUCCESS;
     
    39703972        case FOURCC_AYUV:
    39713973            mBitsPerPixel = 32;
    3972 #ifdef VBOX_WITH_WDDM
    3973             mBitsPerPixelMem = 32;
    3974 #endif
    39753974            mWidthCompression = 1;
    39763975            break;
     
    39783977        case FOURCC_YUY2:
    39793978            mBitsPerPixel = 16;
    3980 #ifdef VBOX_WITH_WDDM
    3981             mBitsPerPixelMem = 16;
    3982 #endif
    39833979            mWidthCompression = 2;
    39843980            break;
    39853981        case FOURCC_YV12:
    39863982            mBitsPerPixel = 8;
    3987 #ifdef VBOX_WITH_WDDM
    3988             mBitsPerPixelMem = 12;
    3989 #endif
    39903983            mWidthCompression = 4;
    39913984            break;
     
    39943987            mBitsPerPixel = 0;
    39953988            mBitsPerPixelTex = 0;
    3996 #ifdef VBOX_WITH_WDDM
    3997             mBitsPerPixelMem = 0;
    3998 #endif
    39993989            mWidthCompression = 0;
    40003990            break;
     
    40063996    mBitsPerPixel = bitsPerPixel;
    40073997    mBitsPerPixelTex = bitsPerPixel;
    4008 #ifdef VBOX_WITH_WDDM
    4009     mBitsPerPixelMem = bitsPerPixel;
    4010 #endif
    40113998    mDataFormat = 0;
    40123999    switch (bitsPerPixel)
     
    40664053            mBitsPerPixel = 0;
    40674054            mBitsPerPixelTex = 0;
    4068 #ifdef VBOX_WITH_WDDM
    4069             mBitsPerPixelMem = 0;
    4070 #endif
    40714055            break;
    40724056    }
     
    53835367}
    53845368
     5369/* static */
     5370uint32_t VBoxVHWATextureImage::calcBytesPerLine(const VBoxVHWAColorFormat & format, int width)
     5371{
     5372    uint32_t pitch = (format.bitsPerPixel() * width + 7)/8;
     5373    switch (format.fourcc())
     5374    {
     5375        case FOURCC_YV12:
     5376            /* make sure the color components pitch is multiple of 8
     5377             * where 8 is 2 (for color component width is Y width / 2) * 4 for 4byte texture format */
     5378            pitch = (pitch + 7) & ~7;
     5379            break;
     5380        default:
     5381            pitch = (pitch + 3) & ~3;
     5382            break;
     5383    }
     5384    return pitch;
     5385}
     5386
     5387/* static */
     5388uint32_t VBoxVHWATextureImage::calcMemSize(const VBoxVHWAColorFormat & format, int width, int height)
     5389{
     5390    uint32_t pitch = calcBytesPerLine(format, width);
     5391    switch (format.fourcc())
     5392    {
     5393        case FOURCC_YV12:
     5394            /* we have 3 separate planes here
     5395             * Y - pitch x height
     5396             * U - pitch/2 x height/2
     5397             * V - pitch/2 x height/2
     5398             * */
     5399            return 3 * pitch * height / 2;
     5400            break;
     5401        default:
     5402            return pitch * height;
     5403            break;
     5404    }
     5405}
     5406
    53855407VBoxVHWATextureImage::VBoxVHWATextureImage(const QRect &size, const VBoxVHWAColorFormat &format, class VBoxVHWAGlProgramMngr * aMgr, VBOXVHWAIMG_TYPE flags) :
    53865408        mVisibleDisplay(0),
     
    53925414        mbNotIntersected(false)
    53935415{
    5394     mpTex[0] = vboxVHWATextureCreate(NULL, size, format, flags);
     5416    uint32_t pitch = calcBytesPerLine(format, size.width());
     5417
     5418    mpTex[0] = vboxVHWATextureCreate(NULL, size, format, pitch, flags);
    53955419    mColorFormat = format;
    53965420    if(mColorFormat.fourcc() == FOURCC_YV12)
    53975421    {
    53985422        QRect rect(size.x()/2,size.y()/2,size.width()/2,size.height()/2);
    5399         mpTex[1] = vboxVHWATextureCreate(NULL, rect, format, flags);
    5400         mpTex[2] = vboxVHWATextureCreate(NULL, rect, format, flags);
     5423        mpTex[1] = vboxVHWATextureCreate(NULL, rect, format, pitch/2, flags);
     5424        mpTex[2] = vboxVHWATextureCreate(NULL, rect, format, pitch/2, flags);
    54015425        mcTex = 3;
    54025426    }
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.h

    r34490 r35280  
    233233    uint32_t bitsPerPixel() const { return mBitsPerPixel; }
    234234    uint32_t bitsPerPixelTex() const { return mBitsPerPixelTex; }
    235 #ifdef VBOX_WITH_WDDM
    236     uint32_t bitsPerPixelMem() const { return mBitsPerPixelMem; }
    237 #endif
    238235    void pixel2Normalized(uint32_t pix, float *r, float *g, float *b) const;
    239236    uint32_t widthCompression() const {return mWidthCompression;}
     
    271268    uint32_t mBitsPerPixel;
    272269    uint32_t mBitsPerPixelTex;
    273 #ifdef VBOX_WITH_WDDM
    274     uint32_t mBitsPerPixelMem;
    275 #endif
    276270    uint32_t mWidthCompression;
    277271    uint32_t mHeightCompression;
     
    293287            mScaleFuncttion(GL_NEAREST)
    294288{}
    295     VBoxVHWATexture(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, GLint scaleFuncttion);
     289    VBoxVHWATexture(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, uint32_t bytesPerLine, GLint scaleFuncttion);
    296290    virtual ~VBoxVHWATexture();
    297291    virtual void init(uchar *pvMem);
     
    349343public:
    350344    VBoxVHWATextureNP2() : VBoxVHWATexture() {}
    351     VBoxVHWATextureNP2(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, GLint scaleFuncttion) :
    352         VBoxVHWATexture(aRect, aFormat, scaleFuncttion){
     345    VBoxVHWATextureNP2(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, uint32_t bytesPerLine, GLint scaleFuncttion) :
     346        VBoxVHWATexture(aRect, aFormat, bytesPerLine, scaleFuncttion){
    353347        mTexRect = QRect(0, 0, aRect.width()/aFormat.widthCompression(), aRect.height()/aFormat.heightCompression());
    354348    }
     
    359353public:
    360354    VBoxVHWATextureNP2Rect() : VBoxVHWATextureNP2() {}
    361     VBoxVHWATextureNP2Rect(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, GLint scaleFuncttion) :
    362         VBoxVHWATextureNP2(aRect, aFormat, scaleFuncttion){}
     355    VBoxVHWATextureNP2Rect(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, uint32_t bytesPerLine, GLint scaleFuncttion) :
     356        VBoxVHWATextureNP2(aRect, aFormat, bytesPerLine, scaleFuncttion){}
    363357
    364358    virtual void texCoord(int x, int y);
     
    375369        mPBO(0)
    376370    {}
    377     VBoxVHWATextureNP2RectPBO(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, GLint scaleFuncttion) :
    378         VBoxVHWATextureNP2Rect(aRect, aFormat, scaleFuncttion),
     371    VBoxVHWATextureNP2RectPBO(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, uint32_t bytesPerLine, GLint scaleFuncttion) :
     372        VBoxVHWATextureNP2Rect(aRect, aFormat, bytesPerLine, scaleFuncttion),
    379373        mPBO(0)
    380374    {}
     
    398392        mcbOffset(0)
    399393    {}
    400     VBoxVHWATextureNP2RectPBOMapped(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, GLint scaleFuncttion) :
    401             VBoxVHWATextureNP2RectPBO(aRect, aFormat, scaleFuncttion),
     394    VBoxVHWATextureNP2RectPBOMapped(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, uint32_t bytesPerLine, GLint scaleFuncttion) :
     395            VBoxVHWATextureNP2RectPBO(aRect, aFormat, bytesPerLine, scaleFuncttion),
    402396            mpMappedAllignedBuffer(NULL),
    403397            mcbOffset(0)
     
    529523    const VBoxVHWAColorKey* srcCKey() { return mpSrcCKey; }
    530524    bool notIntersectedMode() { return mbNotIntersected; }
     525
     526    static uint32_t calcBytesPerLine(const VBoxVHWAColorFormat & format, int width);
     527    static uint32_t calcMemSize(const VBoxVHWAColorFormat & format, int width, int height);
    531528
    532529#ifdef DEBUG_misha
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