Changeset 22794 in vbox
- Timestamp:
- Sep 5, 2009 7:31:56 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 51987
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxDefs.h
r22099 r22794 84 84 InvalidRenderMode, TimerMode, QImageMode, SDLMode, DDRAWMode, Quartz2DMode 85 85 #ifdef VBOX_GUI_USE_QGL 86 , QGLMode 86 , QGLMode, QGLOverlayMode 87 87 #endif 88 88 }; -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxFrameBuffer.h
r22776 r22794 420 420 const QRect & rect() const {return mRect;} 421 421 422 const QRect & toRect() 423 { 424 if(isClear()) 425 { 426 mRect.setCoords(0, 0, -1, -1); 427 } 428 return mRect; 429 } 430 422 431 bool intersects(const QRect & aRect) const {return mIsClear ? false : mRect.intersects(aRect);} 423 432 … … 665 674 bool aIsYInverted, 666 675 #endif 667 const QSize * aSize, const QSize * aTargetSize, 676 const QSize & aSize, 677 const QRect & aTargRect, 678 const QRect & aSrcRect, 679 const QRect & aVisTargRect, 668 680 VBoxVHWAColorFormat & aColorFormat, 669 681 VBoxVHWAColorKey * pSrcBltCKey, VBoxVHWAColorKey * pDstBltCKey, … … 689 701 void performDisplay(VBoxVHWASurfaceBase *pPrimary); 690 702 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); 693 706 694 707 static ulong calcBytesPerPixel(GLenum format, GLenum type); … … 824 837 static int setCKey(class VBoxVHWAGlProgramVHWA * pProgram, const VBoxVHWAColorFormat * pFormat, const VBoxVHWAColorKey * pCKey, bool bDst); 825 838 826 uint32_t handle() {return mHGHandle;}839 uint32_t handle() const {return mHGHandle;} 827 840 void setHandle(uint32_t h) {mHGHandle = h;} 828 private: 841 842 private: 843 void doSetRectValuesInternal(const QRect & aTargRect, const QRect & aSrcRect, const QRect & aVisTargRect); 844 829 845 void setComplexList(VBoxVHWASurfList *aComplexList) { mComplexList = aComplexList; } 830 846 void initDisplay(VBoxVHWASurfaceBase *pPrimary); … … 845 861 QRect mSrcRect; 846 862 QRect mTargRect; /* == Vis FB size */ 847 QRect mTargSize; 863 864 QRect mVisibleTargRect; 865 QRect mVisibleSrcRect; 848 866 849 867 GLuint mVisibleDisplay; … … 1026 1044 1027 1045 const OverlayList & overlays() const {return mOverlays;} 1046 const VBoxVHWASurfList & primaries() const { return mPrimary; } 1028 1047 1029 1048 private: … … 1202 1221 void vhwaSaveExec(struct SSMHANDLE * pSSM); 1203 1222 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 1265 1224 int vhwaSurfaceCanCreate(struct _VBOXVHWACMD_SURF_CANCREATE *pCmd); 1266 1225 int vhwaSurfaceCreate(struct _VBOXVHWACMD_SURF_CREATE *pCmd); … … 1277 1236 int vhwaConstruct(struct _VBOXVHWACMD_HH_CONSTRUCT *pCmd); 1278 1237 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(); } 1265 protected: 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 1282 private: 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 1279 1310 int vhwaSaveSurface(struct SSMHANDLE * pSSM, VBoxVHWASurfaceBase *pSurf, uint32_t surfCaps); 1280 1311 int vhwaLoadSurface(struct SSMHANDLE * pSSM, uint32_t u32Version); 1281 1312 int vhwaSaveOverlayData(struct SSMHANDLE * pSSM, VBoxVHWASurfaceBase *pSurf, bool bVisible); 1282 1313 int vhwaLoadOverlayData(struct SSMHANDLE * pSSM, uint32_t u32Version); 1283 1284 1314 void vhwaDoSurfaceOverlayUpdate(VBoxVHWASurfaceBase *pDstSurf, VBoxVHWASurfaceBase *pSrcSurf, struct _VBOXVHWACMD_SURF_OVERLAY_UPDATE *pCmd); 1285 1315 #endif … … 1292 1322 * submit the operation to be performed 1293 1323 * @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 } 1295 1330 1296 1331 // /* posts op to UI thread */ … … 1380 1415 }; 1381 1416 1417 #ifdef VBOX_WITH_VIDEOHWACCEL 1418 class VBoxQGLOverlayFrameBuffer : public VBoxQImageFrameBuffer 1419 { 1420 public: 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); 1435 private: 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 1382 1449 1383 1450 #endif -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h
r22189 r22794 750 750 #ifdef VBOX_WITH_VIDEOHWACCEL 751 751 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 } 753 759 #endif 754 760 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp
r22703 r22794 825 825 case VBoxDefs::QGLMode: 826 826 mFrameBuf = new VBoxQGLFrameBuffer (this); 827 break; 828 case VBoxDefs::QGLOverlayMode: 829 mFrameBuf = new VBoxQGLOverlayFrameBuffer (this); 827 830 break; 828 831 #endif -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBQGL.cpp
r22793 r22794 1735 1735 } 1736 1736 1737 VBoxVHWASurfaceBase::VBoxVHWASurfaceBase(class VBoxGLWidget *aWidget, const QSize * aSize, const QSize * aTargSize, 1737 VBoxVHWASurfaceBase::VBoxVHWASurfaceBase(class VBoxGLWidget *aWidget, 1738 const QSize & aSize, 1739 const QRect & aTargRect, 1740 const QRect & aSrcRect, 1741 const QRect & aVisTargRect, 1738 1742 VBoxVHWAColorFormat & aColorFormat, 1739 1743 VBoxVHWAColorKey * pSrcBltCKey, VBoxVHWAColorKey * pDstBltCKey, 1740 1744 VBoxVHWAColorKey * pSrcOverlayCKey, VBoxVHWAColorKey * pDstOverlayCKey, 1741 1745 bool bVGA) : 1742 mRect(0,0,aSize ->width(),aSize->height()),1746 mRect(0,0,aSize.width(),aSize.height()), 1743 1747 mVisibleDisplayInitialized(false), 1744 1748 mAddress(NULL), … … 1770 1774 resetDefaultSrcOverlayCKey(); 1771 1775 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); 1773 1777 if(mColorFormat.fourcc() == FOURCC_YV12) 1774 1778 { 1775 QRect rect(0,0,aSize ->width()/2,aSize->height()/2);1779 QRect rect(0,0,aSize.width()/2,aSize.height()/2); 1776 1780 mpTex[1] = vboxVHWATextureCreate(rect, mColorFormat, bVGA); 1777 1781 mpTex[2] = vboxVHWATextureCreate(rect, mColorFormat, bVGA); 1778 1782 } 1779 1783 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()); 1783 1786 1784 1787 // mBytesPerPixel = calcBytesPerPixel(mColorFormat.format(), mColorFormat.type()); … … 2644 2647 } 2645 2648 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 ); 2649 void 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 2685 void 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 2701 void 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 2708 void VBoxVHWASurfaceBase::updateVisibleTargRect(VBoxVHWASurfaceBase *pPrimary, const QRect & aVisibleTargRect) 2709 { 2710 setRects(pPrimary, targRect(), srcRect(), aVisibleTargRect, false); 2667 2711 } 2668 2712 … … 2807 2851 } 2808 2852 2853 //void VBoxVHWASurfaceBase::setVisibleTargetRect(const QRect & aRect) 2854 //{ 2855 // Assert(mVisibleRect.contains(aRect)); 2856 // mVisibleRect = mSrcRect.intersected(aRect); 2857 //} 2858 2809 2859 void VBoxVHWASurfaceBase::performDisplay(VBoxVHWASurfaceBase *pPrimary) 2810 2860 { … … 2924 2974 void VBoxQGLFrameBuffer::paintEvent (QPaintEvent *pe) 2925 2975 { 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(); 2927 2988 } 2928 2989 … … 3173 3234 } while(pFirst); 3174 3235 3175 mDisplay.performDisplay();3236 // mDisplay.performDisplay(); 3176 3237 } 3177 3238 … … 3473 3534 pCmd->SurfInfo.PixelFormat.m3.rgbBBitMask); 3474 3535 QSize surfSize(pCmd->SurfInfo.width, pCmd->SurfInfo.height); 3475 Q Size primarySize = mDisplay.getPrimary()->rect().size();3476 surf = new VBoxVHWASurfaceBase(this, &surfSize,3536 QRect primaryRect = mDisplay.getPrimary()->rect(); 3537 surf = new VBoxVHWASurfaceBase(this, surfSize, 3477 3538 // ((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, 3479 3542 format, 3480 3543 pSrcBltCKey, pDstBltCKey, pSrcOverlayCKey, pDstOverlayCKey, … … 3484 3547 { 3485 3548 QSize surfSize(pCmd->SurfInfo.width, pCmd->SurfInfo.height); 3486 Q Size primarySize = mDisplay.getPrimary()->rect().size();3549 QRect primaryRect = mDisplay.getPrimary()->rect(); 3487 3550 3488 3551 VBoxVHWAColorFormat format(pCmd->SurfInfo.PixelFormat.fourCC); 3489 surf = new VBoxVHWASurfaceBase(this, &surfSize,3552 surf = new VBoxVHWASurfaceBase(this, surfSize, 3490 3553 // ((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, 3492 3557 format, 3493 3558 pSrcBltCKey, pDstBltCKey, pSrcOverlayCKey, pDstOverlayCKey, … … 3502 3567 3503 3568 uchar * addr = vboxVRAMAddressFromOffset(pCmd->SurfInfo.offSurface); 3504 surf->init(mDisplay.get VGA(), addr);3569 surf->init(mDisplay.getPrimary(), addr); 3505 3570 3506 3571 if(pCmd->SurfInfo.surfCaps & VBOXVHWA_SCAPS_OVERLAY) … … 3828 3893 } 3829 3894 3830 pSrcSurf->setRects(pDstSurf, &dstRect, &srcRect);3895 pSrcSurf->setRects(pDstSurf, dstRect, srcRect, mViewport, true); 3831 3896 } 3832 3897 } … … 3889 3954 { 3890 3955 VBoxVHWASurfaceBase *pCurSrcSurf = (*it); 3891 pCurSrcSurf->setTarg etRectPosition(pDstSurf, &pos);3956 pCurSrcSurf->setTargRectPosition(pDstSurf, pos, mViewport); 3892 3957 } 3893 3958 … … 4250 4315 int rc = SSMR3PutU32(pSSM, flags); AssertRC(rc); 4251 4316 4252 rc = SSMR3PutU32(pSSM, mDisplay.get VGA()->handle()); AssertRC(rc);4317 rc = SSMR3PutU32(pSSM, mDisplay.getPrimary()->handle()); AssertRC(rc); 4253 4318 rc = SSMR3PutU32(pSSM, pSurf->handle()); AssertRC(rc); 4254 4319 … … 4601 4666 #endif 4602 4667 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()); 4668 void 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 4698 bool VBoxGLWidget::hasSurfaces() const 4699 { 4700 return mDisplay.overlays().size() != 0; 4701 } 4702 4703 bool 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 4716 const 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); 4620 4738 //#endif 4621 mDisplay.performDisplay(); 4622 } 4739 ////#ifdef VBOXQGL_PROF_BASE 4740 //// vboxDoUpdateRect(&((QPaintEvent*)pe)->rect()); 4741 ////#endif 4742 //// mDisplay.performDisplay(); 4743 //} 4623 4744 4624 4745 void VBoxGLWidget::vboxDoUpdateRect(const QRect * pRect) 4625 4746 { 4626 mDisplay.get VGA()->updatedMem(pRect);4747 mDisplay.getPrimary()->updatedMem(pRect); 4627 4748 } 4628 4749 … … 4790 4911 VBoxVHWAColorFormat format(bitsPerPixel, r,g,b); 4791 4912 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 */ 4793 4919 format, 4794 4920 (VBoxVHWAColorKey*)NULL, (VBoxVHWAColorKey*)NULL, (VBoxVHWAColorKey*)NULL, (VBoxVHWAColorKey*)NULL, true); … … 4906 5032 4907 5033 4908 mDisplay.performDisplay();5034 // mDisplay.performDisplay(); 4909 5035 4910 5036 if (remind) … … 5136 5262 *b = mB.colorValNorm(pix); 5137 5263 } 5138 5139 #endif 5264 #ifdef VBOX_WITH_VIDEOHWACCEL 5265 VBoxQGLOverlayFrameBuffer::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 5274 STDMETHODIMP 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 5288 void VBoxQGLOverlayFrameBuffer::doProcessVHWACommand(QEvent * pEvent) 5289 { 5290 mpOverlayWidget->vboxProcessVHWACommands((VBoxVHWACommandProcessEvent*)pEvent); 5291 } 5292 5293 STDMETHODIMP VBoxQGLOverlayFrameBuffer::NotifyUpdate(ULONG aX, ULONG aY, 5294 ULONG aW, ULONG aH) 5295 { 5296 return VBoxQImageFrameBuffer::NotifyUpdate(aX, aY, aW, aH); 5297 } 5298 5299 void VBoxQGLOverlayFrameBuffer::paintEvent (QPaintEvent *pe) 5300 { 5301 VBoxQImageFrameBuffer::paintEvent (pe); 5302 } 5303 5304 void 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 5315 void 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 5329 void 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 5351 void VBoxQGLOverlayFrameBuffer::vboxShowOverlay(bool show) 5352 { 5353 /** @todo */ 5354 Assert(0); 5355 } 5356 5357 void VBoxQGLOverlayFrameBuffer::vboxUpdateOverlayPosition(const QPoint & pos) 5358 { 5359 /** @todo */ 5360 Assert(0); 5361 } 5362 5363 void VBoxQGLOverlayFrameBuffer::vboxUpdateOverlay(const QPoint & pos, const QRect & rect, bool show) 5364 { 5365 /** @todo */ 5366 Assert(0); 5367 } 5368 5369 void 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 549 549 mode = VBoxDefs::QGLMode; 550 550 #endif 551 #if defined (VBOX_GUI_USE_QGL) 552 else if (::strcmp (aModeStr, "qgloverlay") == 0) 553 mode = VBoxDefs::QGLOverlayMode; 554 #endif 555 551 556 } 552 557
Note:
See TracChangeset
for help on using the changeset viewer.