VirtualBox

Ignore:
Timestamp:
Feb 11, 2014 10:21:01 AM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
92180
Message:

crOpenGL: scaling bugfixes; rename stretch -> scale

Location:
trunk/src/VBox/HostServices/SharedOpenGL
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_presenter.cpp

    r50405 r50412  
    262262}
    263263
    264 static void crFbBltImgStretched(const CR_BLITTER_IMG *pSrc, const RTPOINT *pSrcDataPoint, bool fSrcInvert, const RTRECT *pCopyRect, const RTPOINT *pDstDataPoint, float strX, float strY, CR_BLITTER_IMG *pDst)
     264static void crFbBltImgScaled(const CR_BLITTER_IMG *pSrc, const RTPOINT *pSrcDataPoint, bool fSrcInvert, const RTRECT *pCopyRect, const RTPOINT *pDstDataPoint, float strX, float strY, CR_BLITTER_IMG *pDst)
    265265{
    266266    int32_t srcX = pCopyRect->xLeft - pSrcDataPoint->x;
     
    271271    Assert(srcY < pSrc->height);
    272272
    273     int32_t dstX = CR_FLOAT_RCAST(int32_t, strX * (pCopyRect->xLeft - pDstDataPoint->x));
    274     int32_t dstY = CR_FLOAT_RCAST(int32_t, strY * (pCopyRect->yTop - pDstDataPoint->y));
     273    RTPOINT ScaledDtsDataPoint;
     274    RTRECT ScaledCopyRect;
     275
     276    VBoxRectScaled(pCopyRect, strX, strY, &ScaledCopyRect);
     277    ScaledDtsDataPoint.x = CR_FLOAT_RCAST(int32_t, strX * pDstDataPoint->x);
     278    ScaledDtsDataPoint.y = CR_FLOAT_RCAST(int32_t, strY * pDstDataPoint->y);
     279
     280    int32_t dstX = ScaledCopyRect.xLeft - ScaledDtsDataPoint.x;
     281    int32_t dstY = ScaledCopyRect.yTop - ScaledDtsDataPoint.y;
    275282    Assert(dstX >= 0);
    276283    Assert(dstY >= 0);
    277284
     285    int32_t ScaledDstWidth = ScaledCopyRect.xRight - ScaledCopyRect.xLeft;
     286    int32_t delta = (int32_t)pDst->width - dstX - ScaledDstWidth;
     287    if (delta < 0)
     288        ScaledDstWidth += delta;
     289
     290    if (ScaledDstWidth <= 0)
     291    {
     292        WARN(("dst width (%d) <= 0", ScaledDstWidth));
     293        return;
     294    }
     295
     296    int32_t ScaledDstHeight = ScaledCopyRect.yBottom - ScaledCopyRect.yTop;
     297    delta = (int32_t)pDst->height - dstY - ScaledDstHeight;
     298    if (delta < 0)
     299        ScaledDstHeight += delta;
     300
     301    if (ScaledDstHeight <= 0)
     302    {
     303        WARN(("dst height (%d) <= 0", ScaledDstHeight));
     304        return;
     305    }
     306
    278307    uint8_t *pu8Src = ((uint8_t*)pSrc->pvData) + pSrc->pitch * (!fSrcInvert ? srcY : pSrc->height - srcY - 1) + srcX * 4;
    279308    uint8_t *pu8Dst = ((uint8_t*)pDst->pvData) + pDst->pitch * dstY + dstX * 4;
    280309
    281310    CrBmpScale32(pu8Dst, pDst->pitch,
    282                         CR_FLOAT_RCAST(int32_t, strX * (pCopyRect->xRight - pCopyRect->xLeft)),
    283                         CR_FLOAT_RCAST(int32_t, strY * (pCopyRect->yBottom - pCopyRect->yTop)),
     311                        ScaledDstWidth,
     312                        ScaledDstHeight,
    284313                        pu8Src,
    285314                        fSrcInvert ? -pSrc->pitch : pSrc->pitch,
     
    312341    PCR_BLITTER pEnteredBlitter = NULL;
    313342    uint32_t width = 0, height = 0;
    314     RTPOINT StretchedEntryPoint = {0};
     343    RTPOINT ScaledEntryPoint = {0};
    315344
    316345    VBOXVR_SCR_COMPOSITOR_CONST_ITERATOR Iter;
     
    319348    float strY = ((float)pImg->height) / (pSrcRect->yBottom - pSrcRect->yTop);
    320349
    321     RTPOINT StretchedSrcPoint;
    322     StretchedSrcPoint.x = CR_FLOAT_RCAST(int32_t, strX * SrcPoint.x);
    323     StretchedSrcPoint.y = CR_FLOAT_RCAST(int32_t, strY * SrcPoint.y);
     350    RTPOINT ScaledSrcPoint;
     351    ScaledSrcPoint.x = CR_FLOAT_RCAST(int32_t, strX * SrcPoint.x);
     352    ScaledSrcPoint.y = CR_FLOAT_RCAST(int32_t, strY * SrcPoint.y);
    324353
    325354    RTPOINT ZeroPoint = {0, 0};
     
    366395                    continue;
    367396
    368                 VBoxRectStretch(&Intersection, strX, strY);
     397                VBoxRectScale(&Intersection, strX, strY);
    369398                if (VBoxRectIsZero(&Intersection))
    370399                    continue;
     
    422451                    width = CR_FLOAT_RCAST(uint32_t, strX * pVrTex->width);
    423452                    height = CR_FLOAT_RCAST(uint32_t, strY * pVrTex->height);
    424                     StretchedEntryPoint.x = CR_FLOAT_RCAST(int32_t, strX * CrVrScrCompositorEntryRectGet(pEntry)->xLeft);
    425                     StretchedEntryPoint.y = CR_FLOAT_RCAST(int32_t, strY * CrVrScrCompositorEntryRectGet(pEntry)->yTop);
     453                    ScaledEntryPoint.x = CR_FLOAT_RCAST(int32_t, strX * CrVrScrCompositorEntryRectGet(pEntry)->xLeft);
     454                    ScaledEntryPoint.y = CR_FLOAT_RCAST(int32_t, strY * CrVrScrCompositorEntryRectGet(pEntry)->yTop);
    426455                }
    427456
    428                 rc = CrTdBltDataAcquireStretched(pTex, GL_BGRA, false, width, height, &pSrcImg);
     457                rc = CrTdBltDataAcquireScaled(pTex, GL_BGRA, false, width, height, &pSrcImg);
    429458                if (!RT_SUCCESS(rc))
    430459                {
     
    435464                bool fInvert = !(CrVrScrCompositorEntryFlagsGet(pEntry) & CRBLT_F_INVERT_SRC_YCOORDS);
    436465
    437                 crFbBltImg(pSrcImg, &StretchedEntryPoint, fInvert, &Intersection, &StretchedSrcPoint, pImg);
    438 
    439                 CrTdBltDataReleaseStretched(pTex, pSrcImg);
     466                crFbBltImg(pSrcImg, &ScaledEntryPoint, fInvert, &Intersection, &ScaledSrcPoint, pImg);
     467
     468                CrTdBltDataReleaseScaled(pTex, pSrcImg);
    440469            }
    441470        }
     
    481510        CR_BLITTER_IMG FbImg;
    482511
    483         bool fStretch = fbWidth != stretchedWidth || fbHeight != stretchedHeight;
     512        bool fScale = fbWidth != stretchedWidth || fbHeight != stretchedHeight;
    484513
    485514        crFbImgFromFb(hFb, &FbImg);
     
    496525                    continue;
    497526
    498                 if (!fStretch)
     527                if (!fScale)
    499528                    crFbBltImg(&FbImg, &ZeroPoint, false, &Intersection, &SrcPoint, pImg);
    500529                else
    501                     crFbBltImgStretched(&FbImg, &ZeroPoint, false, &Intersection, &SrcPoint, strX, strY, pImg);
     530                    crFbBltImgScaled(&FbImg, &ZeroPoint, false, &Intersection, &SrcPoint, strX, strY, pImg);
    502531            }
    503532        }
     
    517546}
    518547
    519 static int crFbBltGetContentsStretchCPU(HCR_FRAMEBUFFER hFb, const RTRECT *pSrcRect, uint32_t cRects, const RTRECT *pRects, CR_BLITTER_IMG *pImg)
     548static int crFbBltGetContentsScaleCPU(HCR_FRAMEBUFFER hFb, const RTRECT *pSrcRect, uint32_t cRects, const RTRECT *pRects, CR_BLITTER_IMG *pImg)
    520549{
    521550    uint32_t srcWidth = pSrcRect->xRight - pSrcRect->xLeft;
     
    568597    }
    569598
    570     return crFbBltGetContentsStretchCPU(hFb, pSrcRect, cRects, pRects, pImg);
     599    return crFbBltGetContentsScaleCPU(hFb, pSrcRect, cRects, pRects, pImg);
    571600}
    572601
     
    871900        CR_TEXDATA *pReplacingTex = CrVrScrCompositorEntryTexGet(&pFbReplacingEntry->Entry);
    872901
    873         CrTdBltStretchCacheMoveTo(pTex, pReplacingTex);
     902        CrTdBltScaleCacheMoveTo(pTex, pReplacingTex);
    874903
    875904        if (pFb->pDisplay)
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m

    r50274 r50412  
    14981498                            VBoxRectTranslate(&DstRect, -RestrictDstRect.xLeft, -RestrictDstRect.yTop);
    14991499                           
    1500                             VBoxRectStretch(&DstRect, m_FBOThumbScaleX, m_FBOThumbScaleY);
     1500                            VBoxRectScale(&DstRect, m_FBOThumbScaleX, m_FBOThumbScaleY);
    15011501                   
    15021502                            if (VBoxRectIsZero(&DstRect))
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